Johannes Berg wrote:
Couldn't we just initialise the softmac txrates substructure to
something useful when associating, and have drivers look into that
instead?
How about this?
It also addresses the fact that multicast data must be transmitted at a
basic rate.
--- linux/include/net/ieee80211softmac.h.orig 2006-04-16 23:37:32.0
+0100
+++ linux/include/net/ieee80211softmac.h2006-04-17 18:40:04.0
+0100
@@ -86,6 +86,9 @@ struct ieee80211softmac_assoc_info {
/* BSSID we're trying to associate to */
char bssid[ETH_ALEN];
+
+ /* Rates supported by the network */
+ struct ieee80211softmac_ratesinfo supported_rates;
/* some flags.
* static_essid is valid if the essid is constant,
@@ -133,12 +136,23 @@ struct ieee80211softmac_txrates {
* (If the device supports fallback and hardware-retry)
*/
u8 mcast_fallback;
+
+ /* The Bit-Rate to be used for multicast management frames. */
+ u8 mgt_mcast_rate;
+ /* The Bit-Rate to be used for multicast management fallback
+* (If the device supports fallback and hardware-retry)
+*/
+ u8 mgt_mcast_fallback;
+
/* The Bit-Rate to be used for any other (normal) data packet. */
u8 default_rate;
/* The Bit-Rate to be used for default fallback
* (If the device supports fallback and hardware-retry)
*/
u8 default_fallback;
+
+ /* This is the rate that the user asked for */
+ u8 user_rate;
};
/* Bits for txrates_change callback. */
@@ -146,6 +160,8 @@ struct ieee80211softmac_txrates {
#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /*
default_fallback */
#define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate
*/
#define IEEE80211SOFTMAC_TXRATECHG_MCAST_FBACK (1 << 3) /*
mcast_fallback */
+#define IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST (1 << 4) /*
mgt_mcast_rate */
+#define IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST_FBACK (1 << 5) /*
mgt_mcast_fallback */
struct ieee80211softmac_device {
/* 802.11 structure for data stuff */
@@ -246,6 +262,28 @@ extern void ieee80211softmac_fragment_lo
* Note that the rates need to be sorted. */
extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8
*rates);
+/* Helper function which advises you the rate at which a frame should be
+ * transmitted at. */
+static inline u8 ieee80211softmac_suggest_txrate(struct
ieee80211softmac_device *mac,
+int is_multicast,
+int is_mgt)
+{
+ struct ieee80211softmac_txrates *txrates = &mac->txrates;
+
+ if (!mac->associated)
+ return txrates->mgt_mcast_rate;
+
+ /* We are associated, sending unicast frame */
+ if (!is_multicast)
+ return txrates->default_rate;
+
+ /* We are associated, sending multicast frame */
+ if (is_mgt)
+ return txrates->mgt_mcast_rate;
+ else
+ return txrates->mcast_rate;
+}
+
/* Start the SoftMAC. Call this after you initialized the device
* and it is ready to run.
*/
--- linux/net/ieee80211/softmac/ieee80211softmac_module.c.orig 2006-04-17
01:04:42.0 +0100
+++ linux/net/ieee80211/softmac/ieee80211softmac_module.c 2006-04-17
18:30:04.0 +0100
@@ -26,6 +26,7 @@
#include "ieee80211softmac_priv.h"
#include
+#include
struct net_device *alloc_ieee80211softmac(int sizeof_priv)
{
@@ -166,15 +167,85 @@ static void ieee80211softmac_start_check
}
}
-void ieee80211softmac_start(struct net_device *dev)
+int ieee80211softmac_ratesinfo_rate_supported(struct
ieee80211softmac_ratesinfo *ri, u8 rate)
+{
+ int search;
+ u8 search_rate;
+
+ for (search = 0; search < ri->count; search++) {
+ search_rate = ri->rates[search];
+ search_rate &= ~IEEE80211_BASIC_RATE_MASK;
+ if (rate == search_rate)
+ return 1;
+ }
+
+ return 0;
+}
+
+/* Finds the highest rate which is:
+ * 1. Present in ri (optionally a basic rate)
+ * 2. Supported by the device
+ * 3. Less than or equal to the user-defined rate
+ */
+static u8 highest_supported_rate(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_ratesinfo *ri, int basic_only)
+{
+ u8 user_rate = mac->txrates.user_rate;
+ int i;
+
+ if (ri->count == 0) {
+ dprintk(KERN_ERROR PFX "empty ratesinfo?\n");
+ return IEEE80211_CCK_RATE_1MB;
+ }
+
+ for (i = ri->count - 1; i >= 0; i--) {
+ u8 rate = ri->rates[i];
+ if (basic_only && !(rate & IEEE80211_BASIC_RATE_MASK))
+ continue;
+ rate &= ~IEEE80211_BASIC_RATE_MASK;
+ if (rate > user_rate)
+ continue;
+