Skip to contentSkip to conversation

rt2x00: Remove duplicate code in MAC & BSSID handling

PATCH New Ivo van Doorn 1 participant 16 messages Oct 6, 2007 1 message not in the archive Networking drivers (wireless)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/16 rt2x00: Remove duplicate code in MAC & BSSID handling

The various drivers contained duplicate code to handle the MAC and BSSID initialization correctly. This moves the address copy to little endian variables to rt2x00config.

---
 drivers/net/wireless/rt2x00/rt2400pci.c    |   30 ++++++------------------
 drivers/net/wireless/rt2x00/rt2500pci.c    |   30 ++++++------------------
 drivers/net/wireless/rt2x00/rt2500usb.c    |   30 ++++++------------------
 drivers/net/wireless/rt2x00/rt2x00.h       |    4 +-
 drivers/net/wireless/rt2x00/rt2x00config.c |   32 ++++++++++++++++++++++++-
 drivers/net/wireless/rt2x00/rt61pci.c      |   34 ++++++++-------------------
 drivers/net/wireless/rt2x00/rt73usb.c      |   34 ++++++++-------------------
 7 files changed, 76 insertions(+), 118 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +8 -22
index 4f28662..84f807d 100644
@@ -249,32 +249,18 @@ static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 /*
  * Configuration handlers.
  */
-static void rt2400pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr)
+static void rt2400pci_config_mac_addr(struct rt2x00_dev *rt2x00dev,
+				      __le32 *mac)
 {
-	__le32 reg[2];
-
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, addr, ETH_ALEN);
-
-	/*
-	 * The MAC address is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt2x00pci_register_multiwrite(rt2x00dev, CSR3, &reg, sizeof(reg));
+	rt2x00pci_register_multiwrite(rt2x00dev, CSR3, mac,
+				      (2 * sizeof(__le32)));
 }
 
-static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
+static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev,
+				   __le32 *bssid)
 {
-	__le32 reg[2];
-
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, bssid, ETH_ALEN);
-
-	/*
-	 * The BSSID is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg));
+	rt2x00pci_register_multiwrite(rt2x00dev, CSR5, bssid,
+				      (2 * sizeof(__le32)));
 }
 
 static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
drivers/net/wireless/rt2x00/rt2500pci.c +8 -22
index c0cd60a..87a0988 100644
@@ -249,32 +249,18 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 /*
  * Configuration handlers.
  */
-static void rt2500pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr)
+static void rt2500pci_config_mac_addr(struct rt2x00_dev *rt2x00dev,
+				      __le32 *mac)
 {
-	__le32 reg[2];
-
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, addr, ETH_ALEN);
-
-	/*
-	 * The MAC address is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt2x00pci_register_multiwrite(rt2x00dev, CSR3, &reg, sizeof(reg));
+	rt2x00pci_register_multiwrite(rt2x00dev, CSR3, mac,
+				      (2 * sizeof(__le32)));
 }
 
-static void rt2500pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
+static void rt2500pci_config_bssid(struct rt2x00_dev *rt2x00dev,
+				   __le32 *bssid)
 {
-	__le32 reg[2];
-
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, bssid, ETH_ALEN);
-
-	/*
-	 * The BSSID is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt2x00pci_register_multiwrite(rt2x00dev, CSR5, &reg, sizeof(reg));
+	rt2x00pci_register_multiwrite(rt2x00dev, CSR5, bssid,
+				      (2 * sizeof(__le32)));
 }
 
 static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
drivers/net/wireless/rt2x00/rt2500usb.c +8 -22
index e082961..e24ffe6 100644
@@ -254,32 +254,18 @@ static const struct rt2x00debug rt2500usb_rt2x00debug = {
 /*
  * Configuration handlers.
  */
-static void rt2500usb_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr)
+static void rt2500usb_config_mac_addr(struct rt2x00_dev *rt2x00dev,
+				      __le32 *mac)
 {
-	__le16 reg[3];
-
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, addr, ETH_ALEN);
-
-	/*
-	 * The MAC address is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR2, &reg, sizeof(reg));
+	rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR2, &mac,
+				      (3 * sizeof(__le16)));
 }
 
-static void rt2500usb_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
+static void rt2500usb_config_bssid(struct rt2x00_dev *rt2x00dev,
+				   __le32 *bssid)
 {
-	__le16 reg[3];
-
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, bssid, ETH_ALEN);
-
-	/*
-	 * The BSSID is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR5, &reg, sizeof(reg));
+	rt2500usb_register_multiwrite(rt2x00dev, MAC_CSR5, bssid,
+				      (3 * sizeof(__le16)));
 }
 
 static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
drivers/net/wireless/rt2x00/rt2x00.h +2 -2
index 6262d4e..5d30ca6 100644
@@ -408,8 +408,8 @@ struct rt2x00lib_ops {
 	/*
 	 * Configuration handlers.
 	 */
-	void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, u8 *mac);
-	void (*config_bssid) (struct rt2x00_dev *rt2x00dev, u8 *bssid);
+	void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, __le32 *mac);
+	void (*config_bssid) (struct rt2x00_dev *rt2x00dev, __le32 *bssid);
 	void (*config_packet_filter) (struct rt2x00_dev *rt2x00dev,
 				      const unsigned int filter);
 	void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type);
drivers/net/wireless/rt2x00/rt2x00config.c +30 -2
index 13b5106..aeeaa0c 100644
@@ -34,16 +34,44 @@
 #include "rt2x00.h"
 #include "rt2x00lib.h"
 
+
+/*
+ * The MAC and BSSID addressess are simple array of bytes,
+ * these arrays are little endian, so when sending the addressess
+ * to the drivers, copy the it into a endian-signed variable.
+ *
+ * Note that all devices (except rt2500usb) have 32 bits
+ * register word sizes. This means that whatever variable we
+ * pass _must_ be a multiple of 32 bits. Otherwise the device
+ * might not accept what we are sending to it.
+ * This will also make it easier for the driver to write
+ * the data to the device.
+ *
+ * Also note that when NULL is passed as address the
+ * we will send 00:00:00:00:00 to the device to clear the address.
+ * This will prevent the device being confused when it wants
+ * to ACK frames or consideres itself associated.
+ */
 void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac)
 {
+	__le32 reg[2];
+
+	memset(&reg, 0, sizeof(reg));
 	if (mac)
-		rt2x00dev->ops->lib->config_mac_addr(rt2x00dev, mac);
+		memcpy(&reg, mac, ETH_ALEN);
+
+	rt2x00dev->ops->lib->config_mac_addr(rt2x00dev, &reg[0]);
 }
 
 void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
 {
+	__le32 reg[2];
+
+	memset(&reg, 0, sizeof(reg));
 	if (bssid)
-		rt2x00dev->ops->lib->config_bssid(rt2x00dev, bssid);
+		memcpy(&reg, bssid, ETH_ALEN);
+
+	rt2x00dev->ops->lib->config_bssid(rt2x00dev, &reg[0]);
 }
 
 void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type)
drivers/net/wireless/rt2x00/rt61pci.c +10 -24
index 960af18..2157764 100644
@@ -274,42 +274,28 @@ static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 /*
  * Configuration handlers.
  */
-static void rt61pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr)
+static void rt61pci_config_mac_addr(struct rt2x00_dev *rt2x00dev, __le32 *mac)
 {
-	__le32 reg[2];
 	u32 tmp;
 
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, addr, ETH_ALEN);
-
-	tmp = le32_to_cpu(reg[1]);
+	tmp = le32_to_cpu(mac[1]);
 	rt2x00_set_field32(&tmp, MAC_CSR3_UNICAST_TO_ME_MASK, 0xff);
-	reg[1] = cpu_to_le32(tmp);
+	mac[1] = cpu_to_le32(tmp);
 
-	/*
-	 * The MAC address is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR2, &reg, sizeof(reg));
+	rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR2, mac,
+				      (2 * sizeof(__le32)));
 }
 
-static void rt61pci_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
+static void rt61pci_config_bssid(struct rt2x00_dev *rt2x00dev, __le32 *bssid)
 {
-	__le32 reg[2];
 	u32 tmp;
 
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, bssid, ETH_ALEN);
-
-	tmp = le32_to_cpu(reg[1]);
+	tmp = le32_to_cpu(bssid[1]);
 	rt2x00_set_field32(&tmp, MAC_CSR5_BSS_ID_MASK, 3);
-	reg[1] = cpu_to_le32(tmp);
+	bssid[1] = cpu_to_le32(tmp);
 
-	/*
-	 * The BSSID is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR4, &reg, sizeof(reg));
+	rt2x00pci_register_multiwrite(rt2x00dev, MAC_CSR4, bssid,
+				      (2 * sizeof(__le32)));
 }
 
 static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
drivers/net/wireless/rt2x00/rt73usb.c +10 -24
index 7640136..b81ba3d 100644
@@ -255,42 +255,28 @@ static const struct rt2x00debug rt73usb_rt2x00debug = {
 /*
  * Configuration handlers.
  */
-static void rt73usb_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *addr)
+static void rt73usb_config_mac_addr(struct rt2x00_dev *rt2x00dev, __le32 *mac)
 {
-	__le32 reg[2];
 	u32 tmp;
 
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, addr, ETH_ALEN);
-
-	tmp = le32_to_cpu(reg[1]);
+	tmp = le32_to_cpu(mac[1]);
 	rt2x00_set_field32(&tmp, MAC_CSR3_UNICAST_TO_ME_MASK, 0xff);
-	reg[1] = cpu_to_le32(tmp);
+	mac[1] = cpu_to_le32(tmp);
 
-	/*
-	 * The MAC address is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt73usb_register_multiwrite(rt2x00dev, MAC_CSR2, &reg, sizeof(reg));
+	rt73usb_register_multiwrite(rt2x00dev, MAC_CSR2, mac,
+				    (2 * sizeof(__le32)));
 }
 
-static void rt73usb_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
+static void rt73usb_config_bssid(struct rt2x00_dev *rt2x00dev, __le32 *bssid)
 {
-	__le32 reg[2];
 	u32 tmp;
 
-	memset(&reg, 0, sizeof(reg));
-	memcpy(&reg, bssid, ETH_ALEN);
-
-	tmp = le32_to_cpu(reg[1]);
+	tmp = le32_to_cpu(bssid[1]);
 	rt2x00_set_field32(&tmp, MAC_CSR5_BSS_ID_MASK, 3);
-	reg[1] = cpu_to_le32(tmp);
+	bssid[1] = cpu_to_le32(tmp);
 
-	/*
-	 * The BSSID is passed to us as an array of bytes,
-	 * that array is little endian, so no need for byte ordering.
-	 */
-	rt73usb_register_multiwrite(rt2x00dev, MAC_CSR4, &reg, sizeof(reg));
+	rt73usb_register_multiwrite(rt2x00dev, MAC_CSR4, bssid,
+				    (2 * sizeof(__le32)));
 }
 
 static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
Signature · 1 line
1.5.3.4
#2 lore raw

PATCH 2/16 rt2x00: Remove radio check from rt2x00lib_toggle_rx

In reply to a message not in the archive

Don't check if the radio is enabled in rt2x00lib_toggle_rx, this is required since the link tuner should be disabled when shutting down the device. The remaining calls inside the rt2x00lib_toggle_rx handler should deliver no problems when called while the radio is done.

---
 drivers/net/wireless/rt2x00/rt2x00dev.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/net/wireless/rt2x00/rt2x00dev.c +0 -3
index 0216096..b6a5c34 100644
@@ -164,9 +164,6 @@ void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, int enable)
 {
 	enum dev_state state = enable ? STATE_RADIO_RX_ON : STATE_RADIO_RX_OFF;
 
-	if (!test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
-		return;
-
 	/*
 	 * When we are disabling the RX, we should also stop the link tuner.
 	 */
Signature · 1 line
1.5.3.4
#3 lore raw

PATCH 3/16 rt2x00: Store "STARTED" state during suspend

In reply to a message not in the archive

Store the started state into a new flag DEVICE_STARTED_SUSPEND and set this when suspending while the device was started. We can't check for is_interface_present() since only mac80211 knows if there are monitor interfaces present.

---
 drivers/net/wireless/rt2x00/rt2x00.h    |    1 +
 drivers/net/wireless/rt2x00/rt2x00dev.c |    7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/wireless/rt2x00/rt2x00.h +1 -0
index 5d30ca6..d280d0e 100644
@@ -508,6 +508,7 @@ struct rt2x00_dev {
 #define CONFIG_EXTERNAL_LNA_BG		13
 #define CONFIG_DOUBLE_ANTENNA		14
 #define CONFIG_DISABLE_LINK_TUNING	15
+#define DEVICE_STARTED_SUSPEND		16
 
 	/*
 	 * Chipset identification.
drivers/net/wireless/rt2x00/rt2x00dev.c +4 -3
index b6a5c34..f254753 100644
@@ -1088,12 +1088,13 @@ int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state)
 	 */
 	if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags))
 		goto exit;
+	__set_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags);
 
 	/*
 	 * Disable radio and unitialize all items
 	 * that must be recreated on resume.
 	 */
-	rt2x00lib_disable_radio(rt2x00dev);
+	rt2x00mac_stop(rt2x00dev->hw);
 	rt2x00lib_uninitialize(rt2x00dev);
 	rt2x00debug_deregister(rt2x00dev);
 
@@ -1123,9 +1124,9 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
 	rt2x00debug_register(rt2x00dev);
 
 	/*
-	 * Only continue if mac80211 has open interfaces.
+	 * Only continue if mac80211 had open interfaces.
 	 */
-	if (!test_bit(DEVICE_STARTED, &rt2x00dev->flags))
+	if (!__test_and_clear_bit(DEVICE_STARTED_SUSPEND, &rt2x00dev->flags))
 		return 0;
 
 	/*
Signature · 1 line
1.5.3.4
#4 lore raw

PATCH 4/16 rt2x00: Move rt2x00dev flags into enumeration

In reply to a message not in the archive

By putting the flags into a enumeration we can make it easier maintable since we don't have to assign numbers for each flag. This makes it easier to insert and remove flags.

---
 drivers/net/wireless/rt2x00/rt2x00.h |   49 +++++++++++++++++++++++-----------
 1 files changed, 33 insertions(+), 16 deletions(-)
drivers/net/wireless/rt2x00/rt2x00.h +33 -16
index d280d0e..82dfcd9 100644
@@ -441,6 +441,39 @@ struct rt2x00_ops {
 };
 
 /*
+ * rt2x00 device flags
+ */
+enum rt2x00_flags {
+	/*
+	 * Device state flags
+	 */
+	DEVICE_PRESENT,
+	DEVICE_REGISTERED_HW,
+	DEVICE_INITIALIZED,
+	DEVICE_STARTED,
+	DEVICE_STARTED_SUSPEND,
+	DEVICE_ENABLED_RADIO,
+	DEVICE_ENABLED_RADIO_HW,
+
+	/*
+	 * Driver features
+	 */
+	DRIVER_REQUIRE_FIRMWARE,
+	DRIVER_REQUIRE_BEACON_RING,
+
+	/*
+	 * Driver configuration
+	 */
+	CONFIG_SUPPORT_HW_BUTTON,
+	CONFIG_FRAME_TYPE,
+	CONFIG_RF_SEQUENCE,
+	CONFIG_EXTERNAL_LNA_A,
+	CONFIG_EXTERNAL_LNA_BG,
+	CONFIG_DOUBLE_ANTENNA,
+	CONFIG_DISABLE_LINK_TUNING,
+};
+
+/*
  * rt2x00 device structure.
  */
 struct rt2x00_dev {
@@ -493,22 +526,6 @@ struct rt2x00_dev {
 	 * of the device capabilities are stored.
 	 */
 	unsigned long flags;
-#define DEVICE_PRESENT			1
-#define DEVICE_REGISTERED_HW		2
-#define DEVICE_INITIALIZED		3
-#define DEVICE_STARTED			4
-#define DEVICE_ENABLED_RADIO		5
-#define DEVICE_ENABLED_RADIO_HW		6
-#define DRIVER_REQUIRE_FIRMWARE		7
-#define DRIVER_REQUIRE_BEACON_RING	8
-#define CONFIG_SUPPORT_HW_BUTTON	9
-#define CONFIG_FRAME_TYPE		10
-#define CONFIG_RF_SEQUENCE		11
-#define CONFIG_EXTERNAL_LNA_A		12
-#define CONFIG_EXTERNAL_LNA_BG		13
-#define CONFIG_DOUBLE_ANTENNA		14
-#define CONFIG_DISABLE_LINK_TUNING	15
-#define DEVICE_STARTED_SUSPEND		16
 
 	/*
 	 * Chipset identification.
Signature · 1 line
1.5.3.4
#5 lore raw

PATCH 5/16 rt2x00: Don't use changed_flags inside configure_packet_filter

In reply to a message not in the archive

We shouldn't use changed_flags when configuring the packet filter, we work directly with the total_flags which is safe enough since we already check if something has changed after we applied our packet filtering flag rules.
Also make sure that when the packet filter is scheduled, the rt2x00dev->interface.filter is cleared to make sure the drivers will update the packet filter instead of failing at the check:
*total_flags == rt2x00dev->interface.filter

---
 drivers/net/wireless/rt2x00/rt2400pci.c |    4 ++--
 drivers/net/wireless/rt2x00/rt2500pci.c |    4 ++--
 drivers/net/wireless/rt2x00/rt2500usb.c |    4 ++--
 drivers/net/wireless/rt2x00/rt2x00.h    |    2 --
 drivers/net/wireless/rt2x00/rt2x00dev.c |   13 ++++++++++---
 drivers/net/wireless/rt2x00/rt61pci.c   |    4 ++--
 drivers/net/wireless/rt2x00/rt73usb.c   |    4 ++--
 7 files changed, 20 insertions(+), 15 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +2 -2
index 84f807d..ee62daa 100644
@@ -1495,8 +1495,8 @@ static void rt2400pci_configure_filter(struct ieee80211_hw *hw,
 	 * - Some filters are set based on interface type.
 	 */
 	*total_flags |= FIF_ALLMULTI;
-	if (changed_flags & FIF_OTHER_BSS ||
-	    changed_flags & FIF_PROMISC_IN_BSS)
+	if (*total_flags & FIF_OTHER_BSS ||
+	    *total_flags & FIF_PROMISC_IN_BSS)
 		*total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
 	if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
 		*total_flags |= FIF_PROMISC_IN_BSS;
drivers/net/wireless/rt2x00/rt2500pci.c +2 -2
index 87a0988..1137c26 100644
@@ -1827,8 +1827,8 @@ static void rt2500pci_configure_filter(struct ieee80211_hw *hw,
 	 */
 	if (mc_count)
 		*total_flags |= FIF_ALLMULTI;
-	if (changed_flags & FIF_OTHER_BSS ||
-	    changed_flags & FIF_PROMISC_IN_BSS)
+	if (*total_flags & FIF_OTHER_BSS ||
+	    *total_flags & FIF_PROMISC_IN_BSS)
 		*total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
 	if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
 		*total_flags |= FIF_PROMISC_IN_BSS;
drivers/net/wireless/rt2x00/rt2500usb.c +2 -2
index e24ffe6..e7530ae 100644
@@ -1600,8 +1600,8 @@ static void rt2500usb_configure_filter(struct ieee80211_hw *hw,
 	 */
 	if (mc_count)
 		*total_flags |= FIF_ALLMULTI;
-	if (changed_flags & FIF_OTHER_BSS ||
-	    changed_flags & FIF_PROMISC_IN_BSS)
+	if (*total_flags & FIF_OTHER_BSS ||
+	    *total_flags & FIF_PROMISC_IN_BSS)
 		*total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
 	if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
 		*total_flags |= FIF_PROMISC_IN_BSS;
drivers/net/wireless/rt2x00/rt2x00.h +0 -2
index 82dfcd9..9bb5fb9 100644
@@ -410,8 +410,6 @@ struct rt2x00lib_ops {
 	 */
 	void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, __le32 *mac);
 	void (*config_bssid) (struct rt2x00_dev *rt2x00dev, __le32 *bssid);
-	void (*config_packet_filter) (struct rt2x00_dev *rt2x00dev,
-				      const unsigned int filter);
 	void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type);
 	void (*config) (struct rt2x00_dev *rt2x00dev, const unsigned int flags,
 			struct ieee80211_conf *conf);
drivers/net/wireless/rt2x00/rt2x00dev.c +10 -3
index f254753..1e07c39 100644
@@ -276,11 +276,18 @@ static void rt2x00lib_packetfilter_scheduled(struct work_struct *work)
 {
 	struct rt2x00_dev *rt2x00dev =
 	    container_of(work, struct rt2x00_dev, filter_work);
+	unsigned int filter = rt2x00dev->interface.filter;
+
+	/*
+	 * Since we had stored the filter inside interface.filter,
+	 * we should now clear that field. Otherwise the driver will
+	 * assume nothing has changed (*total_flags will be compared
+	 * to interface.filter to determine if any action is required).
+	 */
+	rt2x00dev->interface.filter = 0;
 
 	rt2x00dev->ops->hw->configure_filter(rt2x00dev->hw,
-					     rt2x00dev->interface.filter,
-					     &rt2x00dev->interface.filter,
-					     0, NULL);
+					     filter, &filter, 0, NULL);
 }
 
 /*
drivers/net/wireless/rt2x00/rt61pci.c +2 -2
index 2157764..5ae09e3 100644
@@ -2387,8 +2387,8 @@ static void rt61pci_configure_filter(struct ieee80211_hw *hw,
 	 */
 	if (mc_count)
 		*total_flags |= FIF_ALLMULTI;
-	if (changed_flags & FIF_OTHER_BSS ||
-	    changed_flags & FIF_PROMISC_IN_BSS)
+	if (*total_flags & FIF_OTHER_BSS ||
+	    *total_flags & FIF_PROMISC_IN_BSS)
 		*total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
 	if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
 		*total_flags |= FIF_PROMISC_IN_BSS;
drivers/net/wireless/rt2x00/rt73usb.c +2 -2
index b81ba3d..f48e5fb 100644
@@ -1854,8 +1854,8 @@ static void rt73usb_configure_filter(struct ieee80211_hw *hw,
 	 */
 	if (mc_count)
 		*total_flags |= FIF_ALLMULTI;
-	if (changed_flags & FIF_OTHER_BSS ||
-	    changed_flags & FIF_PROMISC_IN_BSS)
+	if (*total_flags & FIF_OTHER_BSS ||
+	    *total_flags & FIF_PROMISC_IN_BSS)
 		*total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
 	if (is_interface_type(intf, IEEE80211_IF_TYPE_AP))
 		*total_flags |= FIF_PROMISC_IN_BSS;
Signature · 1 line
1.5.3.4
#6 lore raw

PATCH 6/16 rt2x00: Fix rfkill handling

In reply to a message not in the archive

As reported by Modestas Vainius, enabling rkfill in 1 driver and disabling it in a second could cause a NULL pointer exception when the rfkill-disabled driver still sets the CONFIG_SUPPORT_HW_BUTTON flag.

Furthermore, rfkill expects the timeout as a value in milliseconds instead of jiffies. Also increase the timeout to a second, since this 250ms would be overkill.

Also the flag DEVICE_ENABLED_RADIO_HW is causing problems for devices which do not support the hardware button while rfkill is enabled in the driver.

To remidy this we should inverse the flag and its meaning, rename the flag to DEVICE_DISABLED_RADIO_HW this means that by default the radio is enabled by the hardware button (if present) and can only be disabled explicitely.

---
 drivers/net/wireless/rt2x00/rt2400pci.c    |    6 ++++--
 drivers/net/wireless/rt2x00/rt2500pci.c    |    6 ++++--
 drivers/net/wireless/rt2x00/rt2x00.h       |    2 +-
 drivers/net/wireless/rt2x00/rt2x00dev.c    |    3 +--
 drivers/net/wireless/rt2x00/rt2x00lib.h    |   10 ++--------
 drivers/net/wireless/rt2x00/rt2x00rfkill.c |    4 ++--
 drivers/net/wireless/rt2x00/rt61pci.c      |    6 ++++--
 7 files changed, 18 insertions(+), 19 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +4 -2
index ee62daa..7f2db6d 100644
@@ -244,6 +244,8 @@ static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 	rt2x00pci_register_read(rt2x00dev, GPIOCSR, &reg);
 	return rt2x00_get_field32(reg, GPIOCSR_BIT0);
 }
+#else
+#define rt2400pci_rfkill_poll	NULL
 #endif /* CONFIG_RT2400PCI_RFKILL */
 
 /*
@@ -1357,8 +1359,10 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Detect if this device has an hardware controlled radio.
 	 */
+#ifdef CONFIG_RT2400PCI_RFKILL
 	if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
 		__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
+#endif /* CONFIG_RT2400PCI_RFKILL */
 
 	/*
 	 * Check if the BBP tuning should be enabled.
@@ -1623,9 +1627,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
 	.initialize		= rt2x00pci_initialize,
 	.uninitialize		= rt2x00pci_uninitialize,
 	.set_device_state	= rt2400pci_set_device_state,
-#ifdef CONFIG_RT2400PCI_RFKILL
 	.rfkill_poll		= rt2400pci_rfkill_poll,
-#endif /* CONFIG_RT2400PCI_RFKILL */
 	.link_stats		= rt2400pci_link_stats,
 	.reset_tuner		= rt2400pci_reset_tuner,
 	.link_tuner		= rt2400pci_link_tuner,
drivers/net/wireless/rt2x00/rt2500pci.c +4 -2
index 1137c26..1f70917 100644
@@ -244,6 +244,8 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 	rt2x00pci_register_read(rt2x00dev, GPIOCSR, &reg);
 	return rt2x00_get_field32(reg, GPIOCSR_BIT0);
 }
+#else
+#define rt2500pci_rfkill_poll	NULL
 #endif /* CONFIG_RT2500PCI_RFKILL */
 
 /*
@@ -1527,8 +1529,10 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Detect if this device has an hardware controlled radio.
 	 */
+#ifdef CONFIG_RT2500PCI_RFKILL
 	if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
 		__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
+#endif /* CONFIG_RT2500PCI_RFKILL */
 
 	/*
 	 * Check if the BBP tuning should be enabled.
@@ -1934,9 +1938,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
 	.initialize		= rt2x00pci_initialize,
 	.uninitialize		= rt2x00pci_uninitialize,
 	.set_device_state	= rt2500pci_set_device_state,
-#ifdef CONFIG_RT2500PCI_RFKILL
 	.rfkill_poll		= rt2500pci_rfkill_poll,
-#endif /* CONFIG_RT2500PCI_RFKILL */
 	.link_stats		= rt2500pci_link_stats,
 	.reset_tuner		= rt2500pci_reset_tuner,
 	.link_tuner		= rt2500pci_link_tuner,
drivers/net/wireless/rt2x00/rt2x00.h +1 -1
index 9bb5fb9..235e5ad 100644
@@ -451,7 +451,7 @@ enum rt2x00_flags {
 	DEVICE_STARTED,
 	DEVICE_STARTED_SUSPEND,
 	DEVICE_ENABLED_RADIO,
-	DEVICE_ENABLED_RADIO_HW,
+	DEVICE_DISABLED_RADIO_HW,
 
 	/*
 	 * Driver features
drivers/net/wireless/rt2x00/rt2x00dev.c +1 -2
index 1e07c39..6dc4f63 100644
@@ -104,8 +104,7 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
 	 * And check if the hardware button has been disabled.
 	 */
 	if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags) ||
-	    (test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) &&
-	     !test_bit(DEVICE_ENABLED_RADIO_HW, &rt2x00dev->flags)))
+	    test_bit(DEVICE_DISABLED_RADIO_HW, &rt2x00dev->flags))
 		return 0;
 
 	/*
drivers/net/wireless/rt2x00/rt2x00lib.h +2 -8
index 6dd92eb..0ab39ca 100644
@@ -28,9 +28,10 @@
 
 /*
  * Interval defines
+ * Both the link tuner as the rfkill will be called once per second.
  */
 #define LINK_TUNE_INTERVAL	( round_jiffies(HZ) )
-#define RFKILL_POLL_INTERVAL	( HZ / 4 )
+#define RFKILL_POLL_INTERVAL	( 1000 )
 
 /*
  * Radio control handlers.
@@ -98,13 +99,6 @@ void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev);
 #else
 static inline int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
 {
-	/*
-	 * Force enable this flag, this will assure that
-	 * devices with a hardware button but without rfkill support
-	 * can still use their hardware.
-	 */
-	__set_bit(DEVICE_ENABLED_RADIO_HW, &rt2x00dev->flags);
-
 	return 0;
 }
 
drivers/net/wireless/rt2x00/rt2x00rfkill.c +2 -2
index 06af014..a0f8b8e 100644
@@ -52,11 +52,11 @@ static int rt2x00rfkill_toggle_radio(void *data, enum rfkill_state state)
 
 	if (state == RFKILL_STATE_ON) {
 		INFO(rt2x00dev, "Hardware button pressed, enabling radio.\n");
-		__set_bit(DEVICE_ENABLED_RADIO_HW, &rt2x00dev->flags);
+		__clear_bit(DEVICE_DISABLED_RADIO_HW, &rt2x00dev->flags);
 		retval = rt2x00lib_enable_radio(rt2x00dev);
 	} else if (state == RFKILL_STATE_OFF) {
 		INFO(rt2x00dev, "Hardware button pressed, disabling radio.\n");
-		__clear_bit(DEVICE_ENABLED_RADIO_HW, &rt2x00dev->flags);
+		__set_bit(DEVICE_DISABLED_RADIO_HW, &rt2x00dev->flags);
 		rt2x00lib_disable_radio(rt2x00dev);
 	}
 
drivers/net/wireless/rt2x00/rt61pci.c +4 -2
index 5ae09e3..ba6153a 100644
@@ -269,6 +269,8 @@ static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
 	rt2x00pci_register_read(rt2x00dev, MAC_CSR13, &reg);
 	return rt2x00_get_field32(reg, MAC_CSR13_BIT5);;
 }
+#else
+#define rt61pci_rfkill_poll	NULL
 #endif /* CONFIG_RT61PCI_RFKILL */
 
 /*
@@ -2088,8 +2090,10 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Detect if this device has an hardware controlled radio.
 	 */
+#ifdef CONFIG_RT61PCI_RFKILL
 	if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
 		__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
+#endif /* CONFIG_RT61PCI_RFKILL */
 
 	/*
 	 * Read frequency offset and RF programming sequence.
@@ -2529,9 +2533,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
 	.initialize		= rt2x00pci_initialize,
 	.uninitialize		= rt2x00pci_uninitialize,
 	.set_device_state	= rt61pci_set_device_state,
-#ifdef CONFIG_RT61PCI_RFKILL
 	.rfkill_poll		= rt61pci_rfkill_poll,
-#endif /* CONFIG_RT61PCI_RFKILL */
 	.link_stats		= rt61pci_link_stats,
 	.reset_tuner		= rt61pci_reset_tuner,
 	.link_tuner		= rt61pci_link_tuner,
Signature · 1 line
1.5.3.4
#7 lore raw

PATCH 7/16 rt2x00: Move TSF sync values into rt2x00config

In reply to a message not in the archive

All drivers use the same values for TSF sync,
this will move the value determination into rt2x00config.c, and the definition for the values to rt2x00reg.h

---
 drivers/net/wireless/rt2x00/rt2400pci.c    |   12 +++---------
 drivers/net/wireless/rt2x00/rt2500pci.c    |   12 +++---------
 drivers/net/wireless/rt2x00/rt2500usb.c    |   14 ++++----------
 drivers/net/wireless/rt2x00/rt2x00.h       |    3 ++-
 drivers/net/wireless/rt2x00/rt2x00config.c |   20 +++++++++++++++++---
 drivers/net/wireless/rt2x00/rt2x00lib.h    |    2 +-
 drivers/net/wireless/rt2x00/rt2x00reg.h    |    9 +++++++++
 drivers/net/wireless/rt2x00/rt61pci.c      |   12 +++---------
 drivers/net/wireless/rt2x00/rt73usb.c      |   12 +++---------
 9 files changed, 45 insertions(+), 51 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +3 -9
index 7f2db6d..5f8df7a 100644
@@ -265,9 +265,9 @@ static void rt2400pci_config_bssid(struct rt2x00_dev *rt2x00dev,
 				      (2 * sizeof(__le32)));
 }
 
-static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
+static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+				  const int tsf_sync)
 {
-	struct interface *intf = &rt2x00dev->interface;
 	u32 reg;
 
 	rt2x00pci_register_write(rt2x00dev, CSR14, 0);
@@ -287,13 +287,7 @@ static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, int type)
 	rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
 	rt2x00_set_field32(&reg, CSR14_TBCN, 1);
 	rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
-	if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-	    is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
-	else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
-	else
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
+	rt2x00_set_field32(&reg, CSR14_TSF_SYNC, tsf_sync);
 	rt2x00pci_register_write(rt2x00dev, CSR14, reg);
 }
 
drivers/net/wireless/rt2x00/rt2500pci.c +3 -9
index 1f70917..cac9430 100644
@@ -265,9 +265,9 @@ static void rt2500pci_config_bssid(struct rt2x00_dev *rt2x00dev,
 				      (2 * sizeof(__le32)));
 }
 
-static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
+static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+				  const int tsf_sync)
 {
-	struct interface *intf = &rt2x00dev->interface;
 	u32 reg;
 
 	rt2x00pci_register_write(rt2x00dev, CSR14, 0);
@@ -291,13 +291,7 @@ static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
 	rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
 	rt2x00_set_field32(&reg, CSR14_TBCN, 1);
 	rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
-	if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-	    is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 2);
-	else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 1);
-	else
-		rt2x00_set_field32(&reg, CSR14_TSF_SYNC, 0);
+	rt2x00_set_field32(&reg, CSR14_TSF_SYNC, tsf_sync);
 	rt2x00pci_register_write(rt2x00dev, CSR14, reg);
 }
 
drivers/net/wireless/rt2x00/rt2500usb.c +4 -10
index e7530ae..234b34e 100644
@@ -268,9 +268,9 @@ static void rt2500usb_config_bssid(struct rt2x00_dev *rt2x00dev,
 				      (3 * sizeof(__le16)));
 }
 
-static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
+static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+				  const int tsf_sync)
 {
-	struct interface *intf = &rt2x00dev->interface;
 	u16 reg;
 
 	rt2500usb_register_write(rt2x00dev, TXRX_CSR19, 0);
@@ -281,7 +281,7 @@ static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
 	rt2500usb_register_read(rt2x00dev, TXRX_CSR20, &reg);
 	rt2x00_set_field16(&reg, TXRX_CSR20_OFFSET,
 			   (PREAMBLE + get_duration(IEEE80211_HEADER, 2)) >> 6);
-	if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
+	if (type == IEEE80211_IF_TYPE_STA)
 		rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 0);
 	else
 		rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 2);
@@ -298,13 +298,7 @@ static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
 	rt2x00_set_field16(&reg, TXRX_CSR19_TSF_COUNT, 1);
 	rt2x00_set_field16(&reg, TXRX_CSR19_TBCN, 1);
 	rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
-	if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-	    is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-		rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 2);
-	else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-		rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 1);
-	else
-		rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, 0);
+	rt2x00_set_field16(&reg, TXRX_CSR19_TSF_SYNC, tsf_sync);
 	rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);
 }
 
drivers/net/wireless/rt2x00/rt2x00.h +2 -1
index 235e5ad..27bec6e 100644
@@ -410,7 +410,8 @@ struct rt2x00lib_ops {
 	 */
 	void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, __le32 *mac);
 	void (*config_bssid) (struct rt2x00_dev *rt2x00dev, __le32 *bssid);
-	void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type);
+	void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type,
+							   const int tsf_sync);
 	void (*config) (struct rt2x00_dev *rt2x00dev, const unsigned int flags,
 			struct ieee80211_conf *conf);
 #define CONFIG_UPDATE_PHYMODE		( 1 << 1 )
drivers/net/wireless/rt2x00/rt2x00config.c +17 -3
index aeeaa0c..f8e87aa 100644
@@ -74,10 +74,24 @@ void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
 	rt2x00dev->ops->lib->config_bssid(rt2x00dev, &reg[0]);
 }
 
-void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type)
+void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, const int type)
 {
-	if (type != INVALID_INTERFACE)
-		rt2x00dev->ops->lib->config_type(rt2x00dev, type);
+	int tsf_sync;
+
+	switch (type) {
+	case IEEE80211_IF_TYPE_IBSS:
+	case IEEE80211_IF_TYPE_AP:
+		tsf_sync = TSF_SYNC_BEACON;
+		break;
+	case IEEE80211_IF_TYPE_STA:
+		tsf_sync = TSF_SYNC_INFRA;
+		break;
+	default:
+		tsf_sync = TSF_SYNC_NONE;
+		break;
+	}
+
+	rt2x00dev->ops->lib->config_type(rt2x00dev, type, tsf_sync);
 }
 
 void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
drivers/net/wireless/rt2x00/rt2x00lib.h +1 -1
index 0ab39ca..29ca932 100644
@@ -52,7 +52,7 @@ void rt2x00lib_uninitialize(struct rt2x00_dev *rt2x00dev);
  */
 void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac);
 void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid);
-void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, int type);
+void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, const int type);
 void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
 		      struct ieee80211_conf *conf, const int force_config);
 
drivers/net/wireless/rt2x00/rt2x00reg.h +9 -0
index 7927d5f..8384212 100644
@@ -59,6 +59,15 @@ enum led_mode {
 };
 
 /*
+ * TSF sync values
+ */
+enum tsf_sync {
+	TSF_SYNC_NONE = 0,
+	TSF_SYNC_INFRA = 1,
+	TSF_SYNC_BEACON = 2,
+};
+
+/*
  * Device states
  */
 enum dev_state {
drivers/net/wireless/rt2x00/rt61pci.c +3 -9
index ba6153a..62f1297 100644
@@ -300,9 +300,9 @@ static void rt61pci_config_bssid(struct rt2x00_dev *rt2x00dev, __le32 *bssid)
 				      (2 * sizeof(__le32)));
 }
 
-static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
+static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+				const int tsf_sync)
 {
-	struct interface *intf = &rt2x00dev->interface;
 	u32 reg;
 
 	/*
@@ -324,13 +324,7 @@ static void rt61pci_config_type(struct rt2x00_dev *rt2x00dev, const int type)
 	rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1);
 	rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
 	rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
-	if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-	    is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-		rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 2);
-	else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-		rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 1);
-	else
-		rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0);
+	rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, tsf_sync);
 	rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
 }
 
drivers/net/wireless/rt2x00/rt73usb.c +3 -9
index f48e5fb..e7887c3 100644
@@ -279,9 +279,9 @@ static void rt73usb_config_bssid(struct rt2x00_dev *rt2x00dev, __le32 *bssid)
 				    (2 * sizeof(__le32)));
 }
 
-static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
+static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type,
+				const int tsf_sync)
 {
-	struct interface *intf = &rt2x00dev->interface;
 	u32 reg;
 
 	/*
@@ -303,13 +303,7 @@ static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type)
 	rt2x00_set_field32(&reg, TXRX_CSR9_TSF_TICKING, 1);
 	rt2x00_set_field32(&reg, TXRX_CSR9_TBTT_ENABLE, 1);
 	rt2x00_set_field32(&reg, TXRX_CSR9_BEACON_GEN, 0);
-	if (is_interface_type(intf, IEEE80211_IF_TYPE_IBSS) ||
-	    is_interface_type(intf, IEEE80211_IF_TYPE_AP))
-		rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 2);
-	else if (is_interface_type(intf, IEEE80211_IF_TYPE_STA))
-		rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 1);
-	else
-		rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, 0);
+	rt2x00_set_field32(&reg, TXRX_CSR9_TSF_SYNC, tsf_sync);
 	rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg);
 }
 
Signature · 1 line
1.5.3.4
#8 lore raw

PATCH 8/16 rt2x00: get_duration expects values in 100kbs

In reply to a message not in the archive

get_duration expects all speeds to be passed in 100kbs, this means that passing 2 is incorrect and should be raised to 20

---
 drivers/net/wireless/rt2x00/rt2400pci.c |    2 +-
 drivers/net/wireless/rt2x00/rt2500pci.c |    2 +-
 drivers/net/wireless/rt2x00/rt2500usb.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/rt2x00/rt2400pci.c +1 -1
index 5f8df7a..edb5bd1 100644
@@ -277,7 +277,7 @@ static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
 	 */
 	rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg);
 	rt2x00_set_field32(&reg, BCNCSR1_PRELOAD,
-			   PREAMBLE + get_duration(IEEE80211_HEADER, 2));
+			   PREAMBLE + get_duration(IEEE80211_HEADER, 20));
 	rt2x00pci_register_write(rt2x00dev, BCNCSR1, reg);
 
 	/*
drivers/net/wireless/rt2x00/rt2500pci.c +1 -1
index cac9430..68baccc 100644
@@ -277,7 +277,7 @@ static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
 	 */
 	rt2x00pci_register_read(rt2x00dev, BCNCSR1, &reg);
 	rt2x00_set_field32(&reg, BCNCSR1_PRELOAD,
-			   PREAMBLE + get_duration(IEEE80211_HEADER, 2));
+			   PREAMBLE + get_duration(IEEE80211_HEADER, 20));
 	rt2x00_set_field32(&reg, BCNCSR1_BEACON_CWMIN,
 			   rt2x00lib_get_ring(rt2x00dev,
 					      IEEE80211_TX_QUEUE_BEACON)
drivers/net/wireless/rt2x00/rt2500usb.c +1 -1
index 234b34e..c1f217b 100644
@@ -280,7 +280,7 @@ static void rt2500usb_config_type(struct rt2x00_dev *rt2x00dev, const int type,
 	 */
 	rt2500usb_register_read(rt2x00dev, TXRX_CSR20, &reg);
 	rt2x00_set_field16(&reg, TXRX_CSR20_OFFSET,
-			   (PREAMBLE + get_duration(IEEE80211_HEADER, 2)) >> 6);
+			   (PREAMBLE + get_duration(IEEE80211_HEADER, 20)) >> 6);
 	if (type == IEEE80211_IF_TYPE_STA)
 		rt2x00_set_field16(&reg, TXRX_CSR20_BCN_EXPECT_WINDOW, 0);
 	else
Signature · 1 line
1.5.3.4
#9 lore raw

PATCH 9/16 rt2x00: Cut lines down to 80 characters

In reply to a message not in the archive

rt61pci contained 1 line of 88 characters width,
this needs to be cut down.

---
 drivers/net/wireless/rt2x00/rt61pci.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/rt2x00/rt61pci.c +2 -1
index 62f1297..b9051a1 100644
@@ -2495,7 +2495,8 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
 	 * Write entire beacon with descriptor to register,
 	 * and kick the beacon generator.
 	 */
-	rt2x00pci_register_multiwrite(rt2x00dev, HW_BEACON_BASE0, skb->data, skb->len);
+	rt2x00pci_register_multiwrite(rt2x00dev, HW_BEACON_BASE0,
+				      skb->data, skb->len);
 	rt61pci_kick_tx_queue(rt2x00dev, IEEE80211_TX_QUEUE_BEACON);
 
 	return 0;
Signature · 1 line
1.5.3.4
#10 lore raw

PATCH 10/16 rt2x00: Add get_tx_data_len callback function

In reply to a message not in the archive

The TX datalen must always be converted to a value rt73 and rt2500usb understand. Both require to use a different size then skb->len. First off this is required because the descriptor must be added, but the second is because the value must be a multiple of either 2 or 4, and it should not be a multiple of the USB packetmax

---
 drivers/net/wireless/rt2x00/rt2500usb.c |   32 ++++++++++++++++++++----------
 drivers/net/wireless/rt2x00/rt2x00.h    |    2 +
 drivers/net/wireless/rt2x00/rt2x00usb.c |   29 ++++++++++++++++-----------
 drivers/net/wireless/rt2x00/rt73usb.c   |   16 +++++++++++++++
 4 files changed, 56 insertions(+), 23 deletions(-)
drivers/net/wireless/rt2x00/rt2500usb.c +21 -11
index c1f217b..c4aa466 100644
@@ -1057,6 +1057,21 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
 	rt2x00_desc_write(txd, 0, word);
 }
 
+static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
+				     int maxpacket, struct sk_buff *skb)
+{
+	int length;
+
+	/*
+	 * The length _must_ be a multiple of 2,
+	 * but it must _not_ be a multiple of the USB packet size.
+	 */
+	length = roundup(skb->len, 2);
+	length += (2 * !(length % maxpacket));
+
+	return length;
+}
+
 /*
  * TX data initialization
  */
@@ -1651,6 +1666,8 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
 	    rt2x00lib_get_ring(rt2x00dev, IEEE80211_TX_QUEUE_BEACON);
 	struct data_entry *beacon;
 	struct data_entry *guardian;
+	int pipe = usb_sndbulkpipe(usb_dev, 1);
+	int max_packet = usb_maxpacket(usb_dev, pipe, 1);
 	int length;
 
 	/*
@@ -1677,16 +1694,9 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
 							 ring->desc_size),
 				skb->len - ring->desc_size, control);
 
-	/*
-	 * Length passed to usb_fill_urb cannot be an odd number,
-	 * so add 1 byte to make it even.
-	 */
-	length = skb->len;
-	if (length % 2)
-		length++;
+	length = rt2500usb_get_tx_data_len(rt2x00dev, max_packet, skb);
 
-	usb_fill_bulk_urb(beacon->priv, usb_dev,
-			  usb_sndbulkpipe(usb_dev, 1),
+	usb_fill_bulk_urb(beacon->priv, usb_dev, pipe,
 			  skb->data, length, rt2500usb_beacondone, beacon);
 
 	beacon->skb = skb;
@@ -1697,8 +1707,7 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
 	 * the 'flags' field we are not using for beacons.
 	 */
 	guardian->flags = 0;
-	usb_fill_bulk_urb(guardian->priv, usb_dev,
-			  usb_sndbulkpipe(usb_dev, 1),
+	usb_fill_bulk_urb(guardian->priv, usb_dev, pipe,
 			  &guardian->flags, 1, rt2500usb_beacondone, guardian);
 
 	/*
@@ -1739,6 +1748,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
 	.link_tuner		= rt2500usb_link_tuner,
 	.write_tx_desc		= rt2500usb_write_tx_desc,
 	.write_tx_data		= rt2x00usb_write_tx_data,
+	.get_tx_data_len	= rt2500usb_get_tx_data_len,
 	.kick_tx_queue		= rt2500usb_kick_tx_queue,
 	.fill_rxdone		= rt2500usb_fill_rxdone,
 	.config_mac_addr	= rt2500usb_config_mac_addr,
drivers/net/wireless/rt2x00/rt2x00.h +2 -0
index 27bec6e..a392e2a 100644
@@ -396,6 +396,8 @@ struct rt2x00lib_ops {
 	int (*write_tx_data) (struct rt2x00_dev *rt2x00dev,
 			      struct data_ring *ring, struct sk_buff *skb,
 			      struct ieee80211_tx_control *control);
+	int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, int maxpacket,
+				struct sk_buff *skb);
 	void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
 			       unsigned int queue);
 
drivers/net/wireless/rt2x00/rt2x00usb.c +17 -12
index 66e4761..73cc726 100644
@@ -157,9 +157,10 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
 {
 	struct usb_device *usb_dev =
 	    interface_to_usbdev(rt2x00dev_usb(rt2x00dev));
-	struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data;
 	struct data_entry *entry = rt2x00_get_data_entry(ring);
-	u32 length = skb->len;
+	int pipe = usb_sndbulkpipe(usb_dev, 1);
+	int max_packet = usb_maxpacket(usb_dev, pipe, 1);
+	u32 length;
 
 	if (rt2x00_ring_full(ring)) {
 		ieee80211_stop_queue(rt2x00dev->hw, control->queue);
@@ -178,25 +179,29 @@ int rt2x00usb_write_tx_data(struct rt2x00_dev *rt2x00dev,
 	/*
 	 * Add the descriptor in front of the skb.
 	 */
-	skb_push(skb, rt2x00dev->hw->extra_tx_headroom);
-	memset(skb->data, 0x00, rt2x00dev->hw->extra_tx_headroom);
+	skb_push(skb, ring->desc_size);
+	memset(skb->data, 0, ring->desc_size);
 
 	rt2x00lib_write_tx_desc(rt2x00dev, (struct data_desc *)skb->data,
-				ieee80211hdr, length, control);
+				(struct ieee80211_hdr *)(skb->data +
+							 ring->desc_size),
+				skb->len - ring->desc_size, control);
 	memcpy(&entry->tx_status.control, control, sizeof(*control));
 	entry->skb = skb;
 
 	/*
-	 * Length passed to usb_fill_urb cannot be an odd number,
-	 * so add 1 byte to make it even.
+	 * USB devices cannot blindly pass the skb->len as the
+	 * length of the data to usb_fill_bulk_urb. Pass the skb
+	 * to the driver to determine what the length should be.
 	 */
-	length += rt2x00dev->hw->extra_tx_headroom;
-	if (length % 2)
-		length++;
+	length = rt2x00dev->ops->lib->get_tx_data_len(rt2x00dev,
+						      max_packet, skb);
 
+	/*
+	 * Initialize URB and send the frame to the device.
+	 */
 	__set_bit(ENTRY_OWNER_NIC, &entry->flags);
-	usb_fill_bulk_urb(entry->priv, usb_dev,
-			  usb_sndbulkpipe(usb_dev, 1),
+	usb_fill_bulk_urb(entry->priv, usb_dev, pipe,
 			  skb->data, length, rt2x00usb_interrupt_txdone, entry);
 	usb_submit_urb(entry->priv, GFP_ATOMIC);
 
drivers/net/wireless/rt2x00/rt73usb.c +16 -0
index e7887c3..7cfdf65 100644
@@ -1286,6 +1286,21 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev,
 	rt2x00_desc_write(txd, 0, word);
 }
 
+static int rt73usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
+				   int maxpacket, struct sk_buff *skb)
+{
+	int length;
+
+	/*
+	 * The length _must_ be a multiple of 4,
+	 * but it must _not_ be a multiple of the USB packet size.
+	 */
+	length = roundup(skb->len, 4);
+	length += (4 * !(length % maxpacket));
+
+	return length;
+}
+
 /*
  * TX data initialization
  */
@@ -2010,6 +2025,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
 	.link_tuner		= rt73usb_link_tuner,
 	.write_tx_desc		= rt73usb_write_tx_desc,
 	.write_tx_data		= rt2x00usb_write_tx_data,
+	.get_tx_data_len	= rt73usb_get_tx_data_len,
 	.kick_tx_queue		= rt73usb_kick_tx_queue,
 	.fill_rxdone		= rt73usb_fill_rxdone,
 	.config_mac_addr	= rt73usb_config_mac_addr,
Signature · 1 line
1.5.3.4
#11 lore raw

PATCH 11/16 rt2x00: Pass dev_state to rt2x00lib_toggle_rx

In reply to a message not in the archive

Directly pass a value from the enum dev_state with rt2x00lib_toggle_rx, this will save us a ? : statement, and it is clearer then passing a 1 0 argument.

---
 drivers/net/wireless/rt2x00/rt2x00dev.c |   13 ++++++-------
 drivers/net/wireless/rt2x00/rt2x00lib.h |    2 +-
 drivers/net/wireless/rt2x00/rt2x00mac.c |    4 ++--
 3 files changed, 9 insertions(+), 10 deletions(-)
drivers/net/wireless/rt2x00/rt2x00dev.c +6 -7
index 6dc4f63..e141048 100644
@@ -120,7 +120,7 @@ int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Enable RX.
 	 */
-	rt2x00lib_toggle_rx(rt2x00dev, 1);
+	rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
 
 	/*
 	 * Start the TX queues.
@@ -151,7 +151,7 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Disable RX.
 	 */
-	rt2x00lib_toggle_rx(rt2x00dev, 0);
+	rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
 
 	/*
 	 * Disable radio.
@@ -159,14 +159,12 @@ void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev)
 	rt2x00dev->ops->lib->set_device_state(rt2x00dev, STATE_RADIO_OFF);
 }
 
-void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, int enable)
+void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state)
 {
-	enum dev_state state = enable ? STATE_RADIO_RX_ON : STATE_RADIO_RX_OFF;
-
 	/*
 	 * When we are disabling the RX, we should also stop the link tuner.
 	 */
-	if (!enable)
+	if (state == STATE_RADIO_RX_OFF)
 		rt2x00lib_stop_link_tuner(rt2x00dev);
 
 	rt2x00dev->ops->lib->set_device_state(rt2x00dev, state);
@@ -174,7 +172,8 @@ void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, int enable)
 	/*
 	 * When we are enabling the RX, we should also start the link tuner.
 	 */
-	if (enable && is_interface_present(&rt2x00dev->interface))
+	if (state == STATE_RADIO_RX_ON &&
+	    is_interface_present(&rt2x00dev->interface))
 		rt2x00lib_start_link_tuner(rt2x00dev);
 }
 
drivers/net/wireless/rt2x00/rt2x00lib.h +1 -1
index 29ca932..298faa9 100644
@@ -38,7 +38,7 @@
  */
 int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev);
 void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev);
-void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, int enable);
+void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state);
 void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev);
 
 /*
drivers/net/wireless/rt2x00/rt2x00mac.c +2 -2
index e98d013..f519d73 100644
@@ -272,7 +272,7 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
 		if (!conf->radio_enabled)
 			rt2x00lib_disable_radio(rt2x00dev);
 		else
-			rt2x00lib_toggle_rx(rt2x00dev, 0);
+			rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF);
 	}
 
 	rt2x00lib_config(rt2x00dev, conf, 0);
@@ -281,7 +281,7 @@ int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
 	 * Reenable RX only if the radio should be on.
 	 */
 	if (test_bit(DEVICE_ENABLED_RADIO, &rt2x00dev->flags))
-		rt2x00lib_toggle_rx(rt2x00dev, 1);
+		rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON);
 	else if (conf->radio_enabled)
 		return rt2x00lib_enable_radio(rt2x00dev);
 
Signature · 1 line
1.5.3.4
#12 lore raw

PATCH 12/16 rt2x00: Small optimizations

In reply to a message not in the archive

Make some small optimizations by removing
some simple if-statements.

---
 drivers/net/wireless/rt2x00/rt2500usb.c |    6 ++----
 drivers/net/wireless/rt2x00/rt61pci.c   |    6 ++----
 drivers/net/wireless/rt2x00/rt73usb.c   |   19 +++++++++----------
 3 files changed, 13 insertions(+), 18 deletions(-)
drivers/net/wireless/rt2x00/rt2500usb.c +2 -4
index c4aa466..480527f 100644
@@ -326,10 +326,8 @@ static void rt2500usb_config_rate(struct rt2x00_dev *rt2x00dev, const int rate)
 	rt2500usb_register_write(rt2x00dev, TXRX_CSR1, reg);
 
 	rt2500usb_register_read(rt2x00dev, TXRX_CSR10, &reg);
-	if (preamble == SHORT_PREAMBLE)
-		rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE, 1);
-	else
-		rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE, 0);
+	rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE,
+			   (preamble == SHORT_PREAMBLE));
 	rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg);
 }
 
drivers/net/wireless/rt2x00/rt61pci.c +2 -4
index b9051a1..e250f0a 100644
@@ -357,10 +357,8 @@ static void rt61pci_config_rate(struct rt2x00_dev *rt2x00dev, const int rate)
 	rt2x00pci_register_write(rt2x00dev, TXRX_CSR0, reg);
 
 	rt2x00pci_register_read(rt2x00dev, TXRX_CSR4, &reg);
-	if (preamble == SHORT_PREAMBLE)
-		rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 1);
-	else
-		rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 0);
+	rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
+			   (preamble == SHORT_PREAMBLE));
 	rt2x00pci_register_write(rt2x00dev, TXRX_CSR4, reg);
 }
 
drivers/net/wireless/rt2x00/rt73usb.c +9 -10
index 7cfdf65..d3c57a4 100644
@@ -195,12 +195,13 @@ rf_write:
 	reg = 0;
 	rt2x00_set_field32(&reg, PHY_CSR4_VALUE, value);
 
-	if (rt2x00_rf(&rt2x00dev->chip, RF5225) ||
-	    rt2x00_rf(&rt2x00dev->chip, RF2527))
-		rt2x00_set_field32(&reg, PHY_CSR4_NUMBER_OF_BITS, 21);
-	else
-		rt2x00_set_field32(&reg, PHY_CSR4_NUMBER_OF_BITS, 20);
-
+	/*
+	 * RF5225 and RF2527 contain 21 bits per RF register value,
+	 * all others contain 20 bits.
+	 */
+	rt2x00_set_field32(&reg, PHY_CSR4_NUMBER_OF_BITS,
+			   20 + !!(rt2x00_rf(&rt2x00dev->chip, RF5225) ||
+				   rt2x00_rf(&rt2x00dev->chip, RF2527)));
 	rt2x00_set_field32(&reg, PHY_CSR4_IF_SELECT, 0);
 	rt2x00_set_field32(&reg, PHY_CSR4_BUSY, 1);
 
@@ -331,10 +332,8 @@ static void rt73usb_config_rate(struct rt2x00_dev *rt2x00dev, const int rate)
 	rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg);
 
 	rt73usb_register_read(rt2x00dev, TXRX_CSR4, &reg);
-	if (preamble == SHORT_PREAMBLE)
-		rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 1);
-	else
-		rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE, 0);
+	rt2x00_set_field32(&reg, TXRX_CSR4_AUTORESPOND_PREAMBLE,
+			   (preamble == SHORT_PREAMBLE));
 	rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg);
 }
 
Signature · 1 line
1.5.3.4
#13 lore raw

PATCH 13/16 rt2x00: Reorganize configuration handler

In reply to a message not in the archive

Reorganize configuration handling by creating a extra structure which contains precalculated values based on the mac80211 values which are usefull for all individual drivers.

This also fixes the preamble configuration problem, up untill now preamble was never configured since by default the rate->val value was used when changing the mode.
Now rate->val will only be used to set the basic rate mask. The preamble configuration will now be done correctly through the erp_ie_changed callback function.

---

http://kernel.org//pub/linux/kernel/people/ivd/rt2x00-2.0.10/0013-rt2x00-Reorganize-configuration-handler.patch

#14 lore raw

PATCH 14/16 rt2x00: Clean disabling of rt73usb_get_tsf

In reply to a message not in the archive

By defining rt73usb_get_tsf to NULL we only have 1 location that needs to be edited when rt73usb_get_tsf can be enabled again. This also reduces the number of #ifdefs in the code which is also a "good thing"

---
 drivers/net/wireless/rt2x00/rt73usb.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/rt2x00/rt73usb.c +2 -5
index a3555e5..71699a7 100644
@@ -1908,6 +1908,8 @@ static u64 rt73usb_get_tsf(struct ieee80211_hw *hw)
 
 	return tsf;
 }
+#else
+#define rt73usb_get_tsf	NULL
 #endif
 
 static void rt73usb_reset_tsf(struct ieee80211_hw *hw)
@@ -1968,12 +1970,7 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
 	.erp_ie_changed		= rt2x00mac_erp_ie_changed,
 	.conf_tx		= rt2x00mac_conf_tx,
 	.get_tx_stats		= rt2x00mac_get_tx_stats,
-#if 0
-/*
- * See comment at the rt73usb_get_tsf function.
- */
 	.get_tsf		= rt73usb_get_tsf,
-#endif
 	.reset_tsf		= rt73usb_reset_tsf,
 	.beacon_update		= rt73usb_beacon_update,
 };
Signature · 1 line
1.5.3.4
#15 lore raw

PATCH 15/16 rt2x00: Allways memset memory obtained from skb_push()

In reply to a message not in the archive

When skb_push() is used we should memset the memory before usage. This will prevent bugs which could occur when the data is treated as TX descriptor.

---
 drivers/net/wireless/rt2x00/rt2500usb.c |    2 ++
 drivers/net/wireless/rt2x00/rt61pci.c   |    2 ++
 drivers/net/wireless/rt2x00/rt73usb.c   |    2 ++
 3 files changed, 6 insertions(+), 0 deletions(-)
drivers/net/wireless/rt2x00/rt2500usb.c +2 -0
index dff051e..fc1c60a 100644
@@ -1663,6 +1663,8 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
 	 * First we create the beacon.
 	 */
 	skb_push(skb, ring->desc_size);
+	memset(skb->data, 0, ring->desc_size);
+
 	rt2x00lib_write_tx_desc(rt2x00dev, (struct data_desc *)skb->data,
 				(struct ieee80211_hdr *)(skb->data +
 							 ring->desc_size),
drivers/net/wireless/rt2x00/rt61pci.c +2 -0
index 92ca51c..b6fb1ce 100644
@@ -2435,6 +2435,8 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
 	 * First we create the beacon.
 	 */
 	skb_push(skb, TXD_DESC_SIZE);
+	memset(skb->data, 0, TXD_DESC_SIZE);
+
 	rt2x00lib_write_tx_desc(rt2x00dev, (struct data_desc *)skb->data,
 				(struct ieee80211_hdr *)(skb->data +
 							 TXD_DESC_SIZE),
drivers/net/wireless/rt2x00/rt73usb.c +2 -0
index 71699a7..091a37f 100644
@@ -1937,6 +1937,8 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
 	 * First we create the beacon.
 	 */
 	skb_push(skb, TXD_DESC_SIZE);
+	memset(skb->data, 0, TXD_DESC_SIZE);
+
 	rt2x00lib_write_tx_desc(rt2x00dev, (struct data_desc *)skb->data,
 				(struct ieee80211_hdr *)(skb->data +
 							 TXD_DESC_SIZE),
Signature · 1 line
1.5.3.4
#16 lore raw

PATCH 16/16 rt2x00: Release 2.0.10

In reply to a message not in the archive

Version bump

---
 drivers/net/wireless/rt2x00/rt2x00.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/rt2x00/rt2x00.h +1 -1
index aabbe42..9845e58 100644
@@ -42,7 +42,7 @@
  * Module information.
  * DRV_NAME should be set within the individual module source files.
  */
-#define DRV_VERSION	"2.0.9"
+#define DRV_VERSION	"2.0.10"
 #define DRV_PROJECT	"http://rt2x00.serialmonkey.com"
 
 /*
Signature · 1 line
1.5.3.4