Skip to contentSkip to conversation

Please pull 'upstream-davem' branch of wireless-2.6

PATCH Superseded John W. Linville 8 participants 13 messages Jul 12, 2007 – Jul 18, 2007 8 messages not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Dave,

This request is based off net-2.6, as it requires a patch that is in net-2.6 but not yet in Linus' tree (b3d88ad49a0623d09efcf998beb26288c8029f75).

Individual patches available here:

http://www.kernel.org/pub/linux/kernel/people/linville/wireless-2.6/upstream-davem/

Let me know if you want individual patches by email -- hopefully the URL above is sufficient?

John

---

The following changes since commit 15028aad00ddf241581fbe74a02ec89cbb28d35d:
Michael Chan (1):

        [TG3]: Update version to 3.78.

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git upstream-davem

Andy Green (3):
mac80211: Monitor mode radiotap injection docs
cfg80211: Radiotap parser
mac80211: Monitor mode radiotap-based packet injection

Daniel Drake (2):
mac80211: ERP IE handling improvements
mac80211: improved 802.11g CTS protection

Hong Liu (1):
mac80211: add support for iwlist channel

Johannes Berg (10):
mac80211: show transmitted frames on monitor interfaces
mac80211: remove ieee80211_msg_passive_scan
mac80211: remove ieee80211_set_aid_for_sta
mac80211: separate monitor/subif_start_xmit
mac80211: kill rate control ioctls
mac80211: kill antenna select ioctls
mac80211: remove PRISM2_PARAM_DROP_UNENCRYPTED ioctl
mac80211: kill PRISM2_PARAM_CLEAR_KEYS
mac80211: conserve stack space due to padding
mac80211: clarify some mac80211 things

Larry Finger (1):
mac80211: Implementation of SIOCSIWRATE

 Documentation/networking/mac80211-injection.txt |   59 +++
 Documentation/networking/radiotap-headers.txt   |  152 ++++++++
 include/linux/ieee80211.h                       |   11 +
 include/net/cfg80211.h                          |   38 ++
 include/net/mac80211.h                          |   22 +-
 net/mac80211/debugfs_netdev.c                   |    2 +-
 net/mac80211/hostapd_ioctl.h                    |    8 -
 net/mac80211/ieee80211.c                        |  449 ++++++++++++++++++-----
 net/mac80211/ieee80211_common.h                 |    9 +-
 net/mac80211/ieee80211_i.h                      |   14 +-
 net/mac80211/ieee80211_iface.c                  |    3 +
 net/mac80211/ieee80211_ioctl.c                  |  240 ++++---------
 net/mac80211/ieee80211_sta.c                    |   98 ++++--
 net/mac80211/rc80211_simple.c                   |    8 +-
 net/wireless/Makefile                           |    2 +-
 net/wireless/radiotap.c                         |  257 +++++++++++++
 16 files changed, 1050 insertions(+), 322 deletions(-)
 create mode 100644 Documentation/networking/mac80211-injection.txt
 create mode 100644 Documentation/networking/radiotap-headers.txt
 create mode 100644 net/wireless/radiotap.c
Documentation/networking/mac80211-injection.txt new file +59 -0
new file mode 100644
index 0000000..53ef7a0
@@ -0,0 +1,59 @@
+How to use packet injection with mac80211
+=========================================
+
+mac80211 now allows arbitrary packets to be injected down any Monitor Mode
+interface from userland.  The packet you inject needs to be composed in the
+following format:
+
+ [ radiotap header  ]
+ [ ieee80211 header ]
+ [ payload ]
+
+The radiotap format is discussed in
+./Documentation/networking/radiotap-headers.txt.
+
+Despite 13 radiotap argument types are currently defined, most only make sense
+to appear on received packets.  Currently three kinds of argument are used by
+the injection code, although it knows to skip any other arguments that are
+present (facilitating replay of captured radiotap headers directly):
+
+ - IEEE80211_RADIOTAP_RATE - u8 arg in 500kbps units (0x02 --> 1Mbps)
+
+ - IEEE80211_RADIOTAP_ANTENNA - u8 arg, 0x00 = ant1, 0x01 = ant2
+
+ - IEEE80211_RADIOTAP_DBM_TX_POWER - u8 arg, dBm
+
+Here is an example valid radiotap header defining these three parameters
+
+	0x00, 0x00, // <-- radiotap version
+	0x0b, 0x00, // <- radiotap header length
+	0x04, 0x0c, 0x00, 0x00, // <-- bitmap
+	0x6c, // <-- rate
+	0x0c, //<-- tx power
+	0x01 //<-- antenna
+
+The ieee80211 header follows immediately afterwards, looking for example like
+this:
+
+	0x08, 0x01, 0x00, 0x00,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0x13, 0x22, 0x33, 0x44, 0x55, 0x66,
+	0x13, 0x22, 0x33, 0x44, 0x55, 0x66,
+	0x10, 0x86
+
+Then lastly there is the payload.
+
+After composing the packet contents, it is sent by send()-ing it to a logical
+mac80211 interface that is in Monitor mode.  Libpcap can also be used,
+(which is easier than doing the work to bind the socket to the right
+interface), along the following lines:
+
+	ppcap = pcap_open_live(szInterfaceName, 800, 1, 20, szErrbuf);
+...
+	r = pcap_inject(ppcap, u8aSendBuffer, nLength);
+
+You can also find sources for a complete inject test applet here:
+
+http://penumbra.warmcat.com/_twk/tiki-index.php?page=packetspammer
+
+Andy Green <andy-/[email protected]>
Documentation/networking/radiotap-headers.txt new file +152 -0

152 lines not on this page · raw message

include/linux/ieee80211.h +11 -0
index ecd61e8..272f8c8 100644
@@ -227,6 +227,17 @@ struct ieee80211_cts {
 #define WLAN_CAPABILITY_SHORT_SLOT_TIME	(1<<10)
 #define WLAN_CAPABILITY_DSSS_OFDM	(1<<13)
 
+/* 802.11g ERP information element */
+#define WLAN_ERP_NON_ERP_PRESENT (1<<0)
+#define WLAN_ERP_USE_PROTECTION (1<<1)
+#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
+
+/* WLAN_ERP_BARKER_PREAMBLE values */
+enum {
+	WLAN_ERP_PREAMBLE_SHORT = 0,
+	WLAN_ERP_PREAMBLE_LONG = 1,
+};
+
 /* Status codes */
 enum ieee80211_statuscode {
 	WLAN_STATUS_SUCCESS = 0,
include/net/cfg80211.h +38 -0
index 88171f8..7edaef6 100644
@@ -11,6 +11,44 @@
  * Copyright 2006 Johannes Berg <[email protected]>
  */
 
+
+/* Radiotap header iteration
+ *   implemented in net/wireless/radiotap.c
+ *   docs in Documentation/networking/radiotap-headers.txt
+ */
+/**
+ * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
+ * @rtheader: pointer to the radiotap header we are walking through
+ * @max_length: length of radiotap header in cpu byte ordering
+ * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
+ * @this_arg: pointer to current radiotap arg
+ * @arg_index: internal next argument index
+ * @arg: internal next argument pointer
+ * @next_bitmap: internal pointer to next present u32
+ * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
+ */
+
+struct ieee80211_radiotap_iterator {
+	struct ieee80211_radiotap_header *rtheader;
+	int max_length;
+	int this_arg_index;
+	u8 *this_arg;
+
+	int arg_index;
+	u8 *arg;
+	__le32 *next_bitmap;
+	u32 bitmap_shifter;
+};
+
+extern int ieee80211_radiotap_iterator_init(
+   struct ieee80211_radiotap_iterator *iterator,
+   struct ieee80211_radiotap_header *radiotap_header,
+   int max_length);
+
+extern int ieee80211_radiotap_iterator_next(
+   struct ieee80211_radiotap_iterator *iterator);
+
+
 /* from net/wireless.h */
 struct wiphy;
 
include/net/mac80211.h +12 -10
index a7f122b..c34fd9a 100644
@@ -347,9 +347,16 @@ enum ieee80211_if_types {
  * @mac_addr: pointer to MAC address of the interface. This pointer is valid
  *	until the interface is removed (i.e. it cannot be used after
  *	remove_interface() callback was called for this interface).
+ *	This pointer will be %NULL for monitor interfaces, be careful.
  *
  * This structure is used in add_interface() and remove_interface()
  * callbacks of &struct ieee80211_hw.
+ *
+ * When you allow multiple interfaces to be added to your PHY, take care
+ * that the hardware can actually handle multiple MAC addresses. However,
+ * also take care that when there's no interface left with mac_addr != %NULL
+ * you remove the MAC address from the device to avoid acknowledging packets
+ * in pure monitor mode.
  */
 struct ieee80211_if_init_conf {
 	int if_id;
@@ -574,10 +581,11 @@ struct ieee80211_ops {
 	 * to returning zero. By returning non-zero addition of the interface
 	 * is inhibited. Unless monitor_during_oper is set, it is guaranteed
 	 * that monitor interfaces and normal interfaces are mutually
-	 * exclusive. The open() handler is called after add_interface()
-	 * if this is the first device added. At least one of the open()
-	 * open() and add_interface() callbacks has to be assigned. If
-	 * add_interface() is NULL, one STA interface is permitted only. */
+	 * exclusive. If assigned, the open() handler is called after
+	 * add_interface() if this is the first device added. The
+	 * add_interface() callback has to be assigned because it is the only
+	 * way to obtain the requested MAC address for any interface.
+	 */
 	int (*add_interface)(struct ieee80211_hw *hw,
 			     struct ieee80211_if_init_conf *conf);
 
@@ -921,12 +929,6 @@ struct sk_buff *
 ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
 			  struct ieee80211_tx_control *control);
 
-/* Low level drivers that have their own MLME and MAC indicate
- * the aid for an associating station with this call */
-int ieee80211_set_aid_for_sta(struct ieee80211_hw *hw,
-			      u8 *peer_address, u16 aid);
-
-
 /* Given an sk_buff with a raw 802.11 header at the data pointer this function
  * returns the 802.11 header length in bytes (not including encryption
  * headers). If the data in the sk_buff is too short to contain a valid 802.11
net/mac80211/debugfs_netdev.c +1 -1
index 9e39646..a3e01d7 100644
@@ -118,7 +118,7 @@ static ssize_t ieee80211_if_fmt_flags(
 			 sdata->u.sta.authenticated ? "AUTH\n" : "",
 			 sdata->u.sta.associated ? "ASSOC\n" : "",
 			 sdata->u.sta.probereq_poll ? "PROBEREQ POLL\n" : "",
-			 sdata->u.sta.use_protection ? "CTS prot\n" : "");
+			 sdata->use_protection ? "CTS prot\n" : "");
 }
 __IEEE80211_IF_FILE(flags);
 
net/mac80211/hostapd_ioctl.h +0 -8
index 34fa128..52da513 100644
@@ -26,24 +26,16 @@
  * mess shall be deleted completely. */
 enum {
 	PRISM2_PARAM_IEEE_802_1X = 23,
-	PRISM2_PARAM_ANTSEL_TX = 24,
-	PRISM2_PARAM_ANTSEL_RX = 25,
 
 	/* Instant802 additions */
 	PRISM2_PARAM_CTS_PROTECT_ERP_FRAMES = 1001,
-	PRISM2_PARAM_DROP_UNENCRYPTED = 1002,
 	PRISM2_PARAM_PREAMBLE = 1003,
 	PRISM2_PARAM_SHORT_SLOT_TIME = 1006,
 	PRISM2_PARAM_NEXT_MODE = 1008,
-	PRISM2_PARAM_CLEAR_KEYS = 1009,
 	PRISM2_PARAM_RADIO_ENABLED = 1010,
 	PRISM2_PARAM_ANTENNA_MODE = 1013,
 	PRISM2_PARAM_STAT_TIME = 1016,
 	PRISM2_PARAM_STA_ANTENNA_SEL = 1017,
-	PRISM2_PARAM_FORCE_UNICAST_RATE = 1018,
-	PRISM2_PARAM_RATE_CTRL_NUM_UP = 1019,
-	PRISM2_PARAM_RATE_CTRL_NUM_DOWN = 1020,
-	PRISM2_PARAM_MAX_RATECTRL_RATE = 1021,
 	PRISM2_PARAM_TX_POWER_REDUCTION = 1022,
 	PRISM2_PARAM_KEY_TX_RX_THRESHOLD = 1024,
 	PRISM2_PARAM_DEFAULT_WEP_ONLY = 1026,
net/mac80211/ieee80211.c +363 -86

635 lines not on this page · raw message

net/mac80211/ieee80211_common.h +2 -7
index b9a73e7..77c6afb 100644
@@ -47,21 +47,16 @@ enum ieee80211_msg_type {
 	ieee80211_msg_normal = 0,
 	ieee80211_msg_tx_callback_ack = 1,
 	ieee80211_msg_tx_callback_fail = 2,
-	ieee80211_msg_passive_scan = 3,
+	/* hole at 3, was ieee80211_msg_passive_scan but unused */
 	ieee80211_msg_wep_frame_unknown_key = 4,
 	ieee80211_msg_michael_mic_failure = 5,
 	/* hole at 6, was monitor but never sent to userspace */
 	ieee80211_msg_sta_not_assoc = 7,
-	ieee80211_msg_set_aid_for_sta = 8 /* used by Intersil MVC driver */,
+	/* 8 was ieee80211_msg_set_aid_for_sta */
 	ieee80211_msg_key_threshold_notification = 9,
 	ieee80211_msg_radar = 11,
 };
 
-struct ieee80211_msg_set_aid_for_sta {
-	char	sta_address[ETH_ALEN];
-	u16	aid;
-};
-
 struct ieee80211_msg_key_notification {
 	int tx_rx_count;
 	char ifname[IFNAMSIZ];
net/mac80211/ieee80211_i.h +10 -4
index af4d14d..055a2a9 100644
@@ -99,6 +99,12 @@ struct ieee80211_sta_bss {
 	int probe_resp;
 	unsigned long last_update;
 
+	/* during assocation, we save an ERP value from a probe response so
+	 * that we can feed ERP info to the driver when handling the
+	 * association completes. these fields probably won't be up-to-date
+	 * otherwise, you probably don't want to use them. */
+	int has_erp_value;
+	u8 erp_value;
 };
 
 
@@ -235,7 +241,6 @@ struct ieee80211_if_sta {
 	unsigned int authenticated:1;
 	unsigned int associated:1;
 	unsigned int probereq_poll:1;
-	unsigned int use_protection:1;
 	unsigned int create_ibss:1;
 	unsigned int mixed_cell:1;
 	unsigned int wmm_enabled:1;
@@ -278,6 +283,7 @@ struct ieee80211_sub_if_data {
 	int mc_count;
 	unsigned int allmulti:1;
 	unsigned int promisc:1;
+	unsigned int use_protection:1; /* CTS protect ERP frames */
 
 	struct net_device_stats stats;
 	int drop_unencrypted;
@@ -392,6 +398,7 @@ struct ieee80211_local {
 	int monitors;
 	struct iw_statistics wstats;
 	u8 wstats_flags;
+	int tx_headroom; /* required headroom for hardware/radiotap */
 
 	enum {
 		IEEE80211_DEV_UNINITIALIZED = 0,
@@ -437,7 +444,6 @@ struct ieee80211_local {
 	int *basic_rates[NUM_IEEE80211_MODES];
 
 	int rts_threshold;
-	int cts_protect_erp_frames;
 	int fragmentation_threshold;
 	int short_retry_limit; /* dot11ShortRetryLimit */
 	int long_retry_limit; /* dot11LongRetryLimit */
@@ -513,8 +519,6 @@ struct ieee80211_local {
 		STA_ANTENNA_SEL_SW_CTRL_DEBUG = 2
 	} sta_antenna_sel;
 
-	int rate_ctrl_num_up, rate_ctrl_num_down;
-
 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
 	/* TX/RX handler statistics */
 	unsigned int tx_handlers_drop;
@@ -719,6 +723,8 @@ void ieee80211_prepare_rates(struct ieee80211_local *local,
 			     struct ieee80211_hw_mode *mode);
 void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
 int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
+int ieee80211_monitor_start_xmit(struct sk_buff *skb, struct net_device *dev);
+int ieee80211_subif_start_xmit(struct sk_buff *skb, struct net_device *dev);
 void ieee80211_if_setup(struct net_device *dev);
 void ieee80211_if_mgmt_setup(struct net_device *dev);
 int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
net/mac80211/ieee80211_iface.c +3 -0
index cf0f32e..8532a5c 100644
@@ -157,6 +157,8 @@ void ieee80211_if_set_type(struct net_device *dev, int type)
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
 	int oldtype = sdata->type;
 
+	dev->hard_start_xmit = ieee80211_subif_start_xmit;
+
 	sdata->type = type;
 	switch (type) {
 	case IEEE80211_IF_TYPE_WDS:
@@ -196,6 +198,7 @@ void ieee80211_if_set_type(struct net_device *dev, int type)
 	}
 	case IEEE80211_IF_TYPE_MNTR:
 		dev->type = ARPHRD_IEEE80211_RADIOTAP;
+		dev->hard_start_xmit = ieee80211_monitor_start_xmit;
 		break;
 	default:
 		printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x",
net/mac80211/ieee80211_ioctl.c +69 -171

302 lines not on this page · raw message

net/mac80211/ieee80211_sta.c +66 -32

171 lines not on this page · raw message

net/mac80211/rc80211_simple.c +6 -2
index 5ae7fc4..f6780d6 100644
@@ -187,9 +187,13 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev,
 		}
 #endif
 
-		if (per_failed > local->rate_ctrl_num_down) {
+		/*
+		 * XXX: Make these configurable once we have an
+		 * interface to the rate control algorithms
+		 */
+		if (per_failed > RATE_CONTROL_NUM_DOWN) {
 			rate_control_rate_dec(local, sta);
-		} else if (per_failed < local->rate_ctrl_num_up) {
+		} else if (per_failed < RATE_CONTROL_NUM_UP) {
 			rate_control_rate_inc(local, sta);
 		}
 		srctrl->tx_avg_rate_sum += status->control.rate->rate;
net/wireless/Makefile +1 -1
index 3a96ae6..092116e 100644
@@ -1,4 +1,4 @@
 obj-$(CONFIG_WIRELESS_EXT) += wext.o
 obj-$(CONFIG_CFG80211) += cfg80211.o
 
-cfg80211-y += core.o sysfs.o
+cfg80211-y += core.o sysfs.o radiotap.o
net/wireless/radiotap.c new file +257 -0

257 lines not on this page · raw message

Signature · 2 lines
John W. Linville
[email protected]
#2 lore raw
In reply to a message not in the archive

From: "John W. Linville" <[email protected]>
Date: Thu, 12 Jul 2007 16:41:38 -0400

Quoted 2 lines

This request is based off net-2.6, as it requires a patch that is in net-2.6 but not yet in Linus' tree (b3d88ad49a0623d09efcf998beb26288c8029f75).

...

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git upstream-davem

Pulled, thanks John!

#4 lore raw
In reply to a message not in the archive

From: David Miller <[email protected]>
Date: Sat, 14 Jul 2007 18:59:35 -0700 (PDT)

Quoted 9 lines

From: "John W. Linville" <[email protected]>
Date: Thu, 12 Jul 2007 16:41:38 -0400

Quoted 2 lines

This request is based off net-2.6, as it requires a patch that is in net-2.6 but not yet in Linus' tree (b3d88ad49a0623d09efcf998beb26288c8029f75).

...

Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git upstream-davem

Pulled, thanks John!

A warning to look into:

net/mac80211/ieee80211.c: In function $,1rx(Bieee80211_register_hw$,1ry(B:
net/mac80211/ieee80211.c:4989: warning: comparison of distinct pointer types lacks a cast

#19 lore raw
In reply to John W. Linville
Quoted 5 lines

Dave,

This request is based off net-2.6, as it requires a patch that is in net-2.6 but not yet in Linus' tree (b3d88ad49a0623d09efcf998beb26288c8029f75).

Thanks John and everyone who helped... the injection patches are in the Linus git tree now :-D

-Andy

#6 lore raw

PATCH 1/1 mac80211: fix GCC warning on 64bit platforms

In reply to a message not in the archive

net/mac80211/ieee80211.c: In function ieee80211_register_hw:
net/mac80211/ieee80211.c:4989: warning: comparison of distinct pointer types lacks a cast

Fix by casting from size_t to unsigned as size of ieee80211_tx_status_rtap_hdr structure will never be greater than that.

---

Quoted 9 lines · David Miller

From: David Miller <[email protected]>
Date: Sat, 14 Jul 2007 18:59:35 -0700 (PDT)

Quoted 6 lines

From: "John W. Linville" <[email protected]>
Date: Thu, 12 Jul 2007 16:41:38 -0400

Quoted 2 lines

This request is based off net-2.6, as it requires a patch that is in net-2.6 but not yet in Linus' tree (b3d88ad49a0623d09efcf998beb26288c8029f75).

...

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git upstream-davem

Pulled, thanks John!

A warning to look into:

net/mac80211/ieee80211.c: In function $,1rxieee80211_register_hw$,1ry:
net/mac80211/ieee80211.c:4989: warning: comparison of distinct pointer types lacks a cast

---
 net/mac80211/ieee80211.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/ieee80211.c +1 -1
@@ -4987,7 +4987,7 @@ int ieee80211_register_hw(struct ieee802
 	 * interfaces, but never both at the same time.
 	 */
 	local->tx_headroom = max(local->hw.extra_tx_headroom,
-				 sizeof(struct ieee80211_tx_status_rtap_hdr));
+				 (unsigned)sizeof(struct ieee80211_tx_status_rtap_hdr));
 
 	debugfs_hw_add(local);
 
Signature · 2 lines
Jiri Benc
SUSE Labs
#20 lore raw
In reply to Andy Green
Quoted 2 lines · Andy Green

Thanks John and everyone who helped... the injection patches are in the Linus git tree now :-D

Sorry that it took so long.

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs
#8 lore raw

Re: [PATCH] mac80211: fix GCC warning on 64bit platforms

In reply to a message not in the archive

From: Jiri Benc <[email protected]>
Date: Mon, 16 Jul 2007 18:46:53 +0200

Quoted 7 lines

net/mac80211/ieee80211.c: In function ieee80211_register_hw:
net/mac80211/ieee80211.c:4989: warning: comparison of distinct pointer types lacks a cast

Fix by casting from size_t to unsigned as size of ieee80211_tx_status_rtap_hdr structure will never be greater than that.

The macro "max_t" exists for these kinds of situations, please use it. :-)

#10 lore raw

PATCH v2 1/1 mac80211: fix GCC warning on 64bit platforms

In reply to a message not in the archive

net/mac80211/ieee80211.c: In function ieee80211_register_hw:
net/mac80211/ieee80211.c:4989: warning: comparison of distinct pointer types lacks a cast

Size of ieee80211_tx_status_rtap_hdr structure will never be greater than unsigned int.

---

Quoted 2 lines · David Miller

The macro "max_t" exists for these kinds of situations, please use it. :-)

Ok.

---
 net/mac80211/ieee80211.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/mac80211/ieee80211.c +2 -2
@@ -4986,8 +4986,8 @@ int ieee80211_register_hw(struct ieee802
 	 * and we need some headroom for passing the frame to monitor
 	 * interfaces, but never both at the same time.
 	 */
-	local->tx_headroom = max(local->hw.extra_tx_headroom,
-				 sizeof(struct ieee80211_tx_status_rtap_hdr));
+	local->tx_headroom = max_t(unsigned, local->hw.extra_tx_headroom,
+				   sizeof(struct ieee80211_tx_status_rtap_hdr));
 
 	debugfs_hw_add(local);
 
Signature · 2 lines
Jiri Benc
SUSE Labs
#12 lore raw

Re: [PATCH v2] mac80211: fix GCC warning on 64bit platforms

In reply to a message not in the archive
Quoted 23 lines · Jiri Benc

net/mac80211/ieee80211.c: In function ieee80211_register_hw:
net/mac80211/ieee80211.c:4989: warning: comparison of distinct pointer types lacks a cast

Size of ieee80211_tx_status_rtap_hdr structure will never be greater than unsigned int.

---

Quoted 2 lines · David Miller

The macro "max_t" exists for these kinds of situations, please use it. :-)

Ok.

---
 net/mac80211/ieee80211.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

net/mac80211/ieee80211.c int ieee80211_register_hw(struct ieee802 · line 4992

Quoted 9 lines
net/mac80211/ieee80211.c +2 -2
@@ -4986,8 +4986,8 @@ int ieee80211_register_hw(struct ieee802
 	 * and we need some headroom for passing the frame to monitor
 	 * interfaces, but never both at the same time.
 	 */
-	local->tx_headroom = max(local->hw.extra_tx_headroom,
-				 sizeof(struct ieee80211_tx_status_rtap_hdr));
+	local->tx_headroom = max_t(unsigned, local->hw.extra_tx_headroom,
+				   sizeof(struct ieee80211_tx_status_rtap_hdr));
 
 	debugfs_hw_add(local);

For my info on how to use max_t, not as a critique of this patch. (1) Is 'unsigned' enough or should it be 'unsigned int'? (2) Because tx_headroom is an int, why use unsigned at all?

Larry

#14 lore raw

Re: [PATCH v2] mac80211: fix GCC warning on 64bit platforms

In reply to a message not in the archive
Quoted 9 lines · Larry Finger

net/mac80211/ieee80211.c int ieee80211_register_hw(struct ieee802 · line 4992

Quoted 6 lines
net/mac80211/ieee80211.c +2 -2
-	local->tx_headroom = max(local->hw.extra_tx_headroom,
-				 sizeof(struct ieee80211_tx_status_rtap_hdr));
+	local->tx_headroom = max_t(unsigned, local->hw.extra_tx_headroom,
+				   sizeof(struct ieee80211_tx_status_rtap_hdr));
 
 	debugfs_hw_add(local);

For my info on how to use max_t, not as a critique of this patch.
(1) Is 'unsigned' enough or should it be 'unsigned int'?

Don't know. For a C compiler, it doesn't matter, but it's fact that most of the code in the kernel uses "unsigned int".

Quoted 1 line

(2) Because tx_headroom is an int, why use unsigned at all?

Because hw.extra_tx_headroom is unsigned. tx_headroom should be IMO unsigned too but that's not just a matter of changing its type as it would mean a lot of new warnings. We're talking about numbers several orders less than int, so it's not an issue here anyway.

If you think "int" is more appropriate, fine with me, I don't really care.

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs
maintainer
#17 lore raw

Re: [PATCH v2] mac80211: fix GCC warning on 64bit platforms

In reply to Jiri Benc
Quoted 5 lines · Jiri Benc

net/mac80211/ieee80211.c: In function ieee80211_register_hw:
net/mac80211/ieee80211.c:4989: warning: comparison of distinct pointer types lacks a cast

Size of ieee80211_tx_status_rtap_hdr structure will never be greater than unsigned int.

Thanks Jiri, just noticed that it was actually my bug.

johannes

maintainer
#18 lore raw

Re: [PATCH v2] mac80211: fix GCC warning on 64bit platforms

In reply to Jiri Benc

From: Jiri Benc <[email protected]>
Date: Wed, 18 Jul 2007 17:10:44 +0200

net/mac80211/ieee80211.c int ieee80211_register_hw(struct ieee802 · line 4990

Quoted 4 lines
net/mac80211/ieee80211.c +2 -2
-	local->tx_headroom = max(local->hw.extra_tx_headroom,
-				 sizeof(struct ieee80211_tx_status_rtap_hdr));
+	local->tx_headroom = max_t(unsigned, local->hw.extra_tx_headroom,
+				   sizeof(struct ieee80211_tx_status_rtap_hdr));

Please spell out the complete type, "unsigned int".