Skip to contentSkip to conversation

mac80211: move radiotap removal code to right function

PATCH In review Michael Wu 2 participants 8 messages Apr 28, 2007 mac80211

lore
Share & tools
lore

Michael Wu

author
#0 lore raw

PATCH 1/7 mac80211: move radiotap removal code to right function

From: Michael Wu <[email protected]>

A chunk from the radiotap patch landed in the wrong function when the patch was being updated. This moves it to the right function.

---

 net/mac80211/ieee80211.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
net/mac80211/ieee80211.c +3 -3
index e4aa4aa..851400a 100644
@@ -3280,6 +3280,9 @@ ieee80211_rx_h_monitor(struct ieee80211_txrx_data *rx)
 		return TXRX_QUEUED;
 	}
 
+	if (rx->u.rx.status->flag & RX_FLAG_RADIOTAP)
+		skb_pull(rx->skb, ieee80211_get_radiotap_len(rx->skb));
+
 	return TXRX_CONTINUE;
 }
 
@@ -3472,9 +3475,6 @@ ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx)
 		return TXRX_QUEUED;
 	}
 
-	if (rx->u.rx.status->flag & RX_FLAG_RADIOTAP)
-		skb_pull(rx->skb, ieee80211_get_radiotap_len(rx->skb));
-
 	return TXRX_CONTINUE;
 }
 
author
#1 lore raw

PATCH 2/7 mac80211: kill ieee80211_set_mac_address

From: Michael Wu <[email protected]>

ieee80211_set_mac_address does exactly the same thing that eth_mac_addr does. This patch removes it.

---

 net/mac80211/ieee80211.c |   12 ------------
 1 files changed, 0 insertions(+), 12 deletions(-)
net/mac80211/ieee80211.c +0 -12
index 851400a..4d7c035 100644
@@ -2147,17 +2147,6 @@ static int ieee80211_change_mtu_apdev(struct net_device *dev, int new_mtu)
 }
 
 
-static int ieee80211_set_mac_address(struct net_device *dev, void *addr)
-{
-	struct sockaddr *a = addr;
-
-	if (netif_running(dev))
-		return -EBUSY;
-
-	memcpy(dev->dev_addr, a->sa_data, ETH_ALEN);
-	return 0;
-}
-
 static void ieee80211_set_multicast_list(struct net_device *dev)
 {
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
@@ -4555,7 +4544,6 @@ void ieee80211_if_setup(struct net_device *dev)
 	dev->hard_start_xmit = ieee80211_subif_start_xmit;
 	dev->wireless_handlers = &ieee80211_iw_handler_def;
 	dev->do_ioctl = ieee80211_ioctl;
-	dev->set_mac_address = ieee80211_set_mac_address;
 	dev->set_multicast_list = ieee80211_set_multicast_list;
 	dev->change_mtu = ieee80211_change_mtu;
 	dev->get_stats = ieee80211_get_stats;
author
#2 lore raw

PATCH 3/7 mac80211: kill ceiling_div

In reply to Michael Wu

From: Michael Wu <[email protected]>

kernel.h provides a macro which does the same thing as ceiling_div.

---

 net/mac80211/ieee80211.c |   14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)
net/mac80211/ieee80211.c +4 -10
index 4d7c035..66fb4db 100644
@@ -612,12 +612,6 @@ ieee80211_tx_h_wep_encrypt(struct ieee80211_txrx_data *tx)
 }
 
 
-static inline int ceiling_div(int dividend, int divisor)
-{
-	return ((dividend + divisor - 1) / divisor);
-}
-
-
 static int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
 				    int rate, int erp, int short_preamble)
 {
@@ -629,7 +623,7 @@ static int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
 	 * also include SIFS.
 	 *
 	 * rate is in 100 kbps, so divident is multiplied by 10 in the
-	 * ceiling_div() operations.
+	 * DIV_ROUND_UP() operations.
 	 */
 
 	if (local->hw.conf.phymode == MODE_IEEE80211A || erp ||
@@ -651,8 +645,8 @@ static int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
 		dur = 16; /* SIFS + signal ext */
 		dur += 16; /* 17.3.2.3: T_PREAMBLE = 16 usec */
 		dur += 4; /* 17.3.2.3: T_SIGNAL = 4 usec */
-		dur += 4 * ceiling_div((16 + 8 * (len + 4) + 6) * 10,
-				       4 * rate); /* T_SYM x N_SYM */
+		dur += 4 * DIV_ROUND_UP((16 + 8 * (len + 4) + 6) * 10,
+					4 * rate); /* T_SYM x N_SYM */
 	} else {
 		/*
 		 * 802.11b or 802.11g with 802.11b compatibility:
@@ -667,7 +661,7 @@ static int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
 		dur = 10; /* aSIFSTime = 10 usec */
 		dur += short_preamble ? (72 + 24) : (144 + 48);
 
-		dur += ceiling_div(8 * (len + 4) * 10, rate);
+		dur += DIV_ROUND_UP(8 * (len + 4) * 10, rate);
 	}
 
 	return dur;
author
#3 lore raw

PATCH 4/7 mac80211: eliminate forward declarations in ieee80211.c

In reply to Michael Wu

From: Michael Wu <[email protected]>

ieee80211_get_bssid can be moved up in ieee80211 to avoid declaring it at the top of the file. ieee80211_mgmt_start_xmit is used after it's defined so it doesn't need to be declared at the top.

---

 net/mac80211/ieee80211.c |   73 +++++++++++++++++++++-------------------------
 1 files changed, 34 insertions(+), 39 deletions(-)
net/mac80211/ieee80211.c +34 -39
index 66fb4db..4fd2300 100644
@@ -55,11 +55,6 @@ static const unsigned char eapol_header[] =
 	{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e };
 
 
-static u8 * ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
-
-static int ieee80211_mgmt_start_xmit(struct sk_buff *skb,
-				     struct net_device *dev);
-
 static inline void ieee80211_include_sequence(struct ieee80211_sub_if_data *sdata,
 					      struct ieee80211_hdr *hdr)
 {
@@ -250,6 +245,40 @@ static void ieee80211_key_threshold_notify(struct net_device *dev,
 }
 
 
+static u8 * ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
+{
+	u16 fc;
+
+	if (len < 24)
+		return NULL;
+
+	fc = le16_to_cpu(hdr->frame_control);
+
+	switch (fc & IEEE80211_FCTL_FTYPE) {
+	case IEEE80211_FTYPE_DATA:
+		switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
+		case IEEE80211_FCTL_TODS:
+			return hdr->addr1;
+		case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
+			return NULL;
+		case IEEE80211_FCTL_FROMDS:
+			return hdr->addr2;
+		case 0:
+			return hdr->addr3;
+		}
+		break;
+	case IEEE80211_FTYPE_MGMT:
+		return hdr->addr3;
+	case IEEE80211_FTYPE_CTL:
+		if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)
+			return hdr->addr1;
+		else
+			return NULL;
+	}
+
+	return NULL;
+}
+
 int ieee80211_get_hdrlen(u16 fc)
 {
 	int hdrlen = 24;
@@ -3654,40 +3683,6 @@ ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx)
 }
 
 
-static u8 * ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len)
-{
-	u16 fc;
-
-	if (len < 24)
-		return NULL;
-
-	fc = le16_to_cpu(hdr->frame_control);
-
-	switch (fc & IEEE80211_FCTL_FTYPE) {
-	case IEEE80211_FTYPE_DATA:
-		switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
-		case IEEE80211_FCTL_TODS:
-			return hdr->addr1;
-		case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
-			return NULL;
-		case IEEE80211_FCTL_FROMDS:
-			return hdr->addr2;
-		case 0:
-			return hdr->addr3;
-		}
-		break;
-	case IEEE80211_FTYPE_MGMT:
-		return hdr->addr3;
-	case IEEE80211_FTYPE_CTL:
-		if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)
-			return hdr->addr1;
-		else
-			return NULL;
-	}
-
-	return NULL;
-}
-
 static void ieee80211_rx_michael_mic_report(struct net_device *dev,
 					    struct ieee80211_hdr *hdr,
 					    struct sta_info *sta,
author
#4 lore raw

PATCH 5/7 mac80211: set event_capa in iw_range

In reply to Michael Wu

From: Michael Wu <[email protected]>

This fills in the event capability bitfield in struct iw_range.

---

 net/mac80211/ieee80211_ioctl.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
net/mac80211/ieee80211_ioctl.c +5 -0
index 91bc633..9f4bde6 100644
@@ -1599,6 +1599,11 @@ static int ieee80211_ioctl_giwrange(struct net_device *dev,
 	range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
 			  IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
 
+	IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
+	IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY);
+	IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
+	IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
+
 	return 0;
 }
 
author
#5 lore raw

PATCH 6/7 mac80211: suppress warnings

In reply to Michael Wu

From: Michael Wu <[email protected]>

This eliminates warnings from gcc and sparse.

---

 net/mac80211/ieee80211.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
net/mac80211/ieee80211.c +3 -5
index 4fd2300..2b6cb06 100644
@@ -952,8 +952,6 @@ ieee80211_tx_h_check_assoc(struct ieee80211_txrx_data *tx)
 	if (unlikely(!tx->u.tx.mgmt_interface && tx->sdata->ieee802_1x &&
 		     !(sta_flags & WLAN_STA_AUTHORIZED))) {
 #ifdef CONFIG_MAC80211_DEBUG
-		struct ieee80211_hdr *hdr =
-			(struct ieee80211_hdr *) tx->skb->data;
 		printk(KERN_DEBUG "%s: dropped frame to " MAC_FMT
 		       " (unauthorized port)\n", tx->dev->name,
 		       MAC_ARG(hdr->addr1));
@@ -2049,7 +2047,7 @@ static int __ieee80211_if_config(struct net_device *dev,
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
 	struct ieee80211_if_conf conf;
-	static const u8 scan_bssid[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+	static u8 scan_bssid[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
 
 	if (!local->ops->config_interface || !netif_running(dev))
 		return 0;
@@ -2758,7 +2756,7 @@ ieee80211_fill_frame_info(struct ieee80211_local *local,
 				htonl(ieee80211_phytype_dsss_dot11_turbo);
 			break;
 		default:
-			fi->phytype = 0xAAAAAAAA;
+			fi->phytype = htonl(0xAAAAAAAA);
 			break;
 		}
 		fi->channel = htonl(status->channel);
@@ -2779,7 +2777,7 @@ ieee80211_fill_frame_info(struct ieee80211_local *local,
 		}
 
 		fi->antenna = htonl(status->antenna);
-		fi->priority = 0xffffffff; /* no clue */
+		fi->priority = htonl(0xffffffff); /* no clue */
 		fi->ssi_type = htonl(ieee80211_ssi_raw);
 		fi->ssi_signal = htonl(status->ssi);
 		fi->ssi_noise = 0x00000000;
author
#6 lore raw

PATCH 7/7 mac80211: Allow drivers to configure default regulatory domain

In reply to Michael Wu

From: Michael Wu <[email protected]>

This patch allows drivers to configure the default set of channels if the device reports its default regulatory domain.

---

 include/net/mac80211.h   |    8 ++++++--
 net/mac80211/ieee80211.c |    3 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)
include/net/mac80211.h +6 -2
index f0cfe88..96321be 100644
@@ -52,7 +52,9 @@
  * freq, and val fields. Other fields will be filled in by 80211.o based on
  * hostapd information and low-level driver does not need to use them. The
  * limits for each channel will be provided in 'struct ieee80211_conf' when
- * configuring the low-level driver with hw->config callback. */
+ * configuring the low-level driver with hw->config callback. If a device has
+ * a default regulatory domain, IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED
+ * can be set to let the driver configure all fields */
 struct ieee80211_channel {
 	short chan; /* channel number (IEEE 802.11) */
 	short freq; /* frequency in MHz */
@@ -528,7 +530,9 @@ struct ieee80211_hw {
 	 * receive all probe responses while scanning */
 #define IEEE80211_HW_NO_PROBE_FILTERING (1<<10)
 
-	/* please fill this gap when adding new flags */
+	/* Channels are already configured to the default regulatory domain
+	 * specified in the device's EEPROM */
+#define IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED (1<<11)
 
 	/* calculate Michael MIC for an MSDU when doing hwcrypto */
 #define IEEE80211_HW_TKIP_INCLUDE_MMIC (1<<12)
net/mac80211/ieee80211.c +2 -1
index 2b6cb06..f609e6c 100644
@@ -4837,7 +4837,8 @@ int ieee80211_register_hwmode(struct ieee80211_hw *hw,
 		local->hw.conf.chan = local->oper_channel;
 	}
 
-	ieee80211_init_client(local->mdev);
+	if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED))
+		ieee80211_init_client(local->mdev);
 
 	return 0;
 }
#7 lore raw
In reply to Michael Wu
Quoted 2 lines · Michael Wu

A chunk from the radiotap patch landed in the wrong function when the patch was being updated. This moves it to the right function.

Oops. Too narrow context, I guess. Thanks for noticing it.

All seven patches applied.

Thanks!

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs