[RFC] p2p: disable 11b rates on p2p interface creation

Rajkumar Manoharan rmanohar at qca.qualcomm.com
Tue Aug 16 15:29:20 EDT 2011


11b rates are disabled blindly during p2p init based on driver
capability. This prevents use of CCK rates when no p2p vif
is present. This patch disables 11b rates while creating p2p
interface.

Signed-off-by: Rajkumar Manoharan <rmanohar at qca.qualcomm.com>
---
 src/drivers/driver.h            |    4 ++--
 src/drivers/driver_nl80211.c    |   17 ++++++++++++-----
 wpa_supplicant/driver_i.h       |    6 ++----
 wpa_supplicant/p2p_supplicant.c |    5 +----
 4 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index e2d0f8b..6812b0c 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1911,14 +1911,14 @@ struct wpa_driver_ops {
 	 * disable_11b_rates - Set whether IEEE 802.11b rates are used for TX
 	 * @priv: Private driver interface data
 	 * @disabled: Whether IEEE 802.11b rates are disabled
-	 * Returns: 0 on success, -1 on failure (or if not supported)
+	 * Returns: None
 	 *
 	 * This command is used to disable IEEE 802.11b rates (1, 2, 5.5, and
 	 * 11 Mbps) as TX rates for data and management frames. This can be
 	 * used to optimize channel use when there is no need to support IEEE
 	 * 802.11b-only devices.
 	 */
-	int (*disable_11b_rates)(void *priv, int disabled);
+	void (*disable_11b_rates)(void *priv, int disabled);
 
 	/**
 	 * deinit_ap - Deinitialize AP mode
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 1cb2196..350898b 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4134,7 +4134,9 @@ static int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
 						wds);
 	}
 
-	if (ret >= 0 && drv->disable_11b_rates)
+	if (ret >= 0 && drv->disable_11b_rates &&
+	    (iftype == NL80211_IFTYPE_P2P_CLIENT ||
+	     iftype == NL80211_IFTYPE_P2P_GO))
 		nl80211_disable_11b_rates(drv, ret, 1);
 
 	return ret;
@@ -5101,7 +5103,10 @@ static int nl80211_set_mode(struct wpa_driver_nl80211_data *drv,
 	NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, mode);
 
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
-	if (!ret)
+	if (!ret && drv->disable_11b_rates &&
+	    (mode == NL80211_IFTYPE_P2P_CLIENT ||
+	     mode == NL80211_IFTYPE_P2P_GO))
+		nl80211_disable_11b_rates(drv, ifindex, 1);
 		return 0;
 nla_put_failure:
 	wpa_printf(MSG_DEBUG, "nl80211: Failed to set interface %d to mode %d:"
@@ -6500,6 +6505,9 @@ static int nl80211_disable_11b_rates(struct wpa_driver_nl80211_data *drv,
 		    NL80211_CMD_SET_TX_BITRATE_MASK, 0);
 	NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);
 
+	if (!disabled)
+		goto nla_send;
+
 	bands = nla_nest_start(msg, NL80211_ATTR_TX_RATES);
 	if (!bands)
 		goto nla_put_failure;
@@ -6517,7 +6525,7 @@ static int nl80211_disable_11b_rates(struct wpa_driver_nl80211_data *drv,
 	nla_nest_end(msg, band);
 
 	nla_nest_end(msg, bands);
-
+nla_send:
 	ret = send_and_recv_msgs(drv, msg, NULL, NULL);
 	msg = NULL;
 	if (ret) {
@@ -6533,12 +6541,11 @@ nla_put_failure:
 }
 
 
-static int wpa_driver_nl80211_disable_11b_rates(void *priv, int disabled)
+static void wpa_driver_nl80211_disable_11b_rates(void *priv, int disabled)
 {
 	struct i802_bss *bss = priv;
 	struct wpa_driver_nl80211_data *drv = bss->drv;
 	drv->disable_11b_rates = disabled;
-	return nl80211_disable_11b_rates(drv, drv->ifindex, disabled);
 }
 
 
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
index 79fdddd..f42e58b 100644
--- a/wpa_supplicant/driver_i.h
+++ b/wpa_supplicant/driver_i.h
@@ -463,13 +463,11 @@ static inline int wpa_drv_probe_req_report(struct wpa_supplicant *wpa_s,
 	return -1;
 }
 
-static inline int wpa_drv_disable_11b_rates(struct wpa_supplicant *wpa_s,
+static inline void wpa_drv_disable_11b_rates(struct wpa_supplicant *wpa_s,
 					    int disabled)
 {
 	if (wpa_s->driver->disable_11b_rates)
-		return wpa_s->driver->disable_11b_rates(wpa_s->drv_priv,
-							disabled);
-	return -1;
+		wpa_s->driver->disable_11b_rates(wpa_s->drv_priv, disabled);
 }
 
 static inline int wpa_drv_deinit_ap(struct wpa_supplicant *wpa_s)
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 400b6cc..2c730dc 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -2364,10 +2364,7 @@ int wpas_p2p_init(struct wpa_global *global, struct wpa_supplicant *wpa_s)
 	}
 #endif /* CONFIG_CLIENT_MLME */
 
-	if (wpa_drv_disable_11b_rates(wpa_s, 1) < 0) {
-		wpa_printf(MSG_DEBUG, "P2P: Failed to disable 11b rates");
-		/* Continue anyway; this is not really a fatal error */
-	}
+	wpa_drv_disable_11b_rates(wpa_s, 1);
 
 	if (global->p2p)
 		return 0;
-- 
1.7.6



More information about the HostAP mailing list