diff mbox

P2P: enable to set in the conf file the wmm params

Message ID 1341937938-7594-1-git-send-email-yoni.divinsky@ti.com
State Accepted
Headers show

Commit Message

Yoni Divinsky July 10, 2012, 4:32 p.m. UTC
In case of P2P GO, the wpa_supplicant uses the
default hostapd parameters. In the default parameters
the ACM bit for video and voice are set to 1, meaning,
P2P devices and stations which are connected to the
GO cannot pass voice or video data packets.

Signed-hostap: Yoni Divinsky <yoni.divinsky@ti.com>
---
 hostapd/config_file.c        |   74 +-----------------------------------------
 src/ap/ap_config.c           |    8 ++--
 src/ap/ap_config.h           |   10 +-----
 src/ap/wmm.c                 |    2 +-
 src/common/wpa_common.c      |   70 +++++++++++++++++++++++++++++++++++++++
 src/common/wpa_common.h      |    9 +++++
 wpa_supplicant/ap.c          |    4 ++
 wpa_supplicant/config.c      |   13 +++++++
 wpa_supplicant/config.h      |    2 +
 wpa_supplicant/config_file.c |   18 ++++++++++
 10 files changed, 123 insertions(+), 87 deletions(-)

Comments

Jouni Malinen Aug. 12, 2012, 8:41 a.m. UTC | #1
On Tue, Jul 10, 2012 at 07:32:18PM +0300, Yoni Divinsky wrote:
> In case of P2P GO, the wpa_supplicant uses the
> default hostapd parameters. In the default parameters
> the ACM bit for video and voice are set to 1, meaning,
> P2P devices and stations which are connected to the
> GO cannot pass voice or video data packets.

Thanks, applied. Though, I ended up changing the defaults to use ACM=0
for all ACs since I did not find any specific reason for the defaults to
use ACM=1 for AC_VO and AC_VI.
diff mbox

Patch

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index eebbaa6..03f82b2 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -909,78 +909,6 @@  static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
 }
 
 
-static int hostapd_config_wmm_ac(struct hostapd_config *conf, char *name,
-				 char *val)
-{
-	int num, v;
-	char *pos;
-	struct hostapd_wmm_ac_params *ac;
-
-	/* skip 'wme_ac_' or 'wmm_ac_' prefix */
-	pos = name + 7;
-	if (os_strncmp(pos, "be_", 3) == 0) {
-		num = 0;
-		pos += 3;
-	} else if (os_strncmp(pos, "bk_", 3) == 0) {
-		num = 1;
-		pos += 3;
-	} else if (os_strncmp(pos, "vi_", 3) == 0) {
-		num = 2;
-		pos += 3;
-	} else if (os_strncmp(pos, "vo_", 3) == 0) {
-		num = 3;
-		pos += 3;
-	} else {
-		wpa_printf(MSG_ERROR, "Unknown WMM name '%s'", pos);
-		return -1;
-	}
-
-	ac = &conf->wmm_ac_params[num];
-
-	if (os_strcmp(pos, "aifs") == 0) {
-		v = atoi(val);
-		if (v < 1 || v > 255) {
-			wpa_printf(MSG_ERROR, "Invalid AIFS value %d", v);
-			return -1;
-		}
-		ac->aifs = v;
-	} else if (os_strcmp(pos, "cwmin") == 0) {
-		v = atoi(val);
-		if (v < 0 || v > 12) {
-			wpa_printf(MSG_ERROR, "Invalid cwMin value %d", v);
-			return -1;
-		}
-		ac->cwmin = v;
-	} else if (os_strcmp(pos, "cwmax") == 0) {
-		v = atoi(val);
-		if (v < 0 || v > 12) {
-			wpa_printf(MSG_ERROR, "Invalid cwMax value %d", v);
-			return -1;
-		}
-		ac->cwmax = v;
-	} else if (os_strcmp(pos, "txop_limit") == 0) {
-		v = atoi(val);
-		if (v < 0 || v > 0xffff) {
-			wpa_printf(MSG_ERROR, "Invalid txop value %d", v);
-			return -1;
-		}
-		ac->txop_limit = v;
-	} else if (os_strcmp(pos, "acm") == 0) {
-		v = atoi(val);
-		if (v < 0 || v > 1) {
-			wpa_printf(MSG_ERROR, "Invalid acm value %d", v);
-			return -1;
-		}
-		ac->admission_control_mandatory = v;
-	} else {
-		wpa_printf(MSG_ERROR, "Unknown wmm_ac_ field '%s'", pos);
-		return -1;
-	}
-
-	return 0;
-}
-
-
 #ifdef CONFIG_IEEE80211R
 static int add_r0kh(struct hostapd_bss_config *bss, char *value)
 {
@@ -2142,7 +2070,7 @@  static int hostapd_config_fill(struct hostapd_config *conf,
 			bss->wmm_uapsd = atoi(pos);
 		} else if (os_strncmp(buf, "wme_ac_", 7) == 0 ||
 			   os_strncmp(buf, "wmm_ac_", 7) == 0) {
-			if (hostapd_config_wmm_ac(conf, buf, pos)) {
+			if (wpa_config_wmm_ac(conf->wmm_ac_params, buf, pos)) {
 				wpa_printf(MSG_ERROR, "Line %d: invalid WMM "
 					   "ac item", line);
 				errors++;
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index 2c633d9..ec9e17d 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -99,13 +99,13 @@  struct hostapd_config * hostapd_config_defaults(void)
 	struct hostapd_config *conf;
 	struct hostapd_bss_config *bss;
 	const int aCWmin = 4, aCWmax = 10;
-	const struct hostapd_wmm_ac_params ac_bk =
+	const struct wpa_wmm_ac_params ac_bk =
 		{ aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
-	const struct hostapd_wmm_ac_params ac_be =
+	const struct wpa_wmm_ac_params ac_be =
 		{ aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
-	const struct hostapd_wmm_ac_params ac_vi = /* video traffic */
+	const struct wpa_wmm_ac_params ac_vi = /* video traffic */
 		{ aCWmin - 1, aCWmin, 2, 3000 / 32, 1 };
-	const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
+	const struct wpa_wmm_ac_params ac_vo = /* voice traffic */
 		{ aCWmin - 2, aCWmin - 1, 2, 1500 / 32, 1 };
 	const struct hostapd_tx_queue_params txq_bk =
 		{ 7, ecw2cw(aCWmin), ecw2cw(aCWmax), 0 };
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index ca4fe58..a203599 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -132,14 +132,6 @@  struct hostapd_tx_queue_params {
 	int burst; /* maximum burst time in 0.1 ms, i.e., 10 = 1 ms */
 };
 
-struct hostapd_wmm_ac_params {
-	int cwmin;
-	int cwmax;
-	int aifs;
-	int txop_limit; /* in units of 32us */
-	int admission_control_mandatory;
-};
-
 
 #define MAX_ROAMING_CONSORTIUM_LEN 15
 
@@ -446,7 +438,7 @@  struct hostapd_config {
 	 * 2 = VI (video)
 	 * 3 = VO (voice)
 	 */
-	struct hostapd_wmm_ac_params wmm_ac_params[4];
+	struct wpa_wmm_ac_params wmm_ac_params[4];
 
 	int ht_op_mode_fixed;
 	u16 ht_capab;
diff --git a/src/ap/wmm.c b/src/ap/wmm.c
index d21c82f..751f9c4 100644
--- a/src/ap/wmm.c
+++ b/src/ap/wmm.c
@@ -81,7 +81,7 @@  u8 * hostapd_eid_wmm(struct hostapd_data *hapd, u8 *eid)
 	/* fill in a parameter set record for each AC */
 	for (e = 0; e < 4; e++) {
 		struct wmm_ac_parameter *ac = &wmm->ac[e];
-		struct hostapd_wmm_ac_params *acp =
+		struct wpa_wmm_ac_params *acp =
 			&hapd->iconf->wmm_ac_params[e];
 
 		ac->aci_aifsn = wmm_aci_aifsn(acp->aifs,
diff --git a/src/common/wpa_common.c b/src/common/wpa_common.c
index 7a013a8..b339e2e 100644
--- a/src/common/wpa_common.c
+++ b/src/common/wpa_common.c
@@ -989,6 +989,76 @@  int wpa_compare_rsn_ie(int ft_initial_assoc,
 	return -1;
 }
 
+int wpa_config_wmm_ac(struct wpa_wmm_ac_params wmm_ac_params[], char *name,
+				 char *val)
+{
+	int num, v;
+	char *pos;
+	struct wpa_wmm_ac_params *ac;
+
+	/* skip 'wme_ac_' or 'wmm_ac_' prefix */
+	pos = name + 7;
+	if (os_strncmp(pos, "be_", 3) == 0) {
+		num = 0;
+		pos += 3;
+	} else if (os_strncmp(pos, "bk_", 3) == 0) {
+		num = 1;
+		pos += 3;
+	} else if (os_strncmp(pos, "vi_", 3) == 0) {
+		num = 2;
+		pos += 3;
+	} else if (os_strncmp(pos, "vo_", 3) == 0) {
+		num = 3;
+		pos += 3;
+	} else {
+		wpa_printf(MSG_ERROR, "Unknown WMM name '%s'", pos);
+		return -1;
+	}
+
+	ac = &wmm_ac_params[num];
+
+	if (os_strcmp(pos, "aifs") == 0) {
+		v = atoi(val);
+		if (v < 1 || v > 255) {
+			wpa_printf(MSG_ERROR, "Invalid AIFS value %d", v);
+			return -1;
+		}
+		ac->aifs = v;
+	} else if (os_strcmp(pos, "cwmin") == 0) {
+		v = atoi(val);
+		if (v < 0 || v > 12) {
+			wpa_printf(MSG_ERROR, "Invalid cwMin value %d", v);
+			return -1;
+		}
+		ac->cwmin = v;
+	} else if (os_strcmp(pos, "cwmax") == 0) {
+		v = atoi(val);
+		if (v < 0 || v > 12) {
+			wpa_printf(MSG_ERROR, "Invalid cwMax value %d", v);
+			return -1;
+		}
+		ac->cwmax = v;
+	} else if (os_strcmp(pos, "txop_limit") == 0) {
+		v = atoi(val);
+		if (v < 0 || v > 0xffff) {
+			wpa_printf(MSG_ERROR, "Invalid txop value %d", v);
+			return -1;
+		}
+		ac->txop_limit = v;
+	} else if (os_strcmp(pos, "acm") == 0) {
+		v = atoi(val);
+		if (v < 0 || v > 1) {
+			wpa_printf(MSG_ERROR, "Invalid acm value %d", v);
+			return -1;
+		}
+		ac->admission_control_mandatory = v;
+	} else {
+		wpa_printf(MSG_ERROR, "Unknown wmm_ac_ field '%s'", pos);
+		return -1;
+	}
+
+	return 0;
+}
 
 #ifdef CONFIG_IEEE80211R
 int wpa_insert_pmkid(u8 *ies, size_t ies_len, const u8 *pmkid)
diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
index 6b50997..a553b2f 100644
--- a/src/common/wpa_common.h
+++ b/src/common/wpa_common.h
@@ -296,6 +296,13 @@  struct rsn_rdie {
 #pragma pack(pop)
 #endif /* _MSC_VER */
 
+struct wpa_wmm_ac_params {
+	int cwmin;
+	int cwmax;
+	int aifs;
+	int txop_limit; /* in units of 32us */
+	int admission_control_mandatory;
+};
 
 int wpa_eapol_key_mic(const u8 *key, int ver, const u8 *buf, size_t len,
 		      u8 *mic);
@@ -375,4 +382,6 @@  struct wpa_ft_ies {
 
 int wpa_ft_parse_ies(const u8 *ies, size_t ies_len, struct wpa_ft_ies *parse);
 
+int wpa_config_wmm_ac(struct wpa_wmm_ac_params wmm_ac_params[], char *name,
+				 char *val);
 #endif /* WPA_COMMON_H */
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index f9e0045..c4daf18 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -491,6 +491,10 @@  int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
 		return -1;
 	}
 
+	os_memcpy(wpa_s->ap_iface->conf->wmm_ac_params,
+		  wpa_s->conf->wmm_ac_params,
+		  sizeof(wpa_s->conf->wmm_ac_params));
+
 	if (params.uapsd > 0) {
 		conf->bss->wmm_enabled = 1;
 		conf->bss->wmm_uapsd = 1;
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index a68b31e..d7979ff 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2488,6 +2488,15 @@  struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
 					   const char *driver_param)
 {
 	struct wpa_config *config;
+	const int aCWmin = 4, aCWmax = 10;
+	const struct wpa_wmm_ac_params ac_bk =
+		{ aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
+	const struct wpa_wmm_ac_params ac_be =
+		{ aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
+	const struct wpa_wmm_ac_params ac_vi = /* video traffic */
+		{ aCWmin - 1, aCWmin, 2, 3000 / 32, 1 };
+	const struct wpa_wmm_ac_params ac_vo = /* voice traffic */
+		{ aCWmin - 2, aCWmin - 1, 2, 1500 / 32, 1 };
 
 	config = os_zalloc(sizeof(*config));
 	if (config == NULL)
@@ -2502,6 +2511,10 @@  struct wpa_config * wpa_config_alloc_empty(const char *ctrl_interface,
 	config->bss_expiration_scan_count = DEFAULT_BSS_EXPIRATION_SCAN_COUNT;
 	config->max_num_sta = DEFAULT_MAX_NUM_STA;
 	config->access_network_type = DEFAULT_ACCESS_NETWORK_TYPE;
+	config->wmm_ac_params[0] = ac_be;
+	config->wmm_ac_params[1] = ac_bk;
+	config->wmm_ac_params[2] = ac_vi;
+	config->wmm_ac_params[3] = ac_vo;
 
 	if (ctrl_interface)
 		config->ctrl_interface = os_strdup(ctrl_interface);
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index 46c4da2..19c0d2b 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -26,6 +26,7 @@ 
 
 #include "config_ssid.h"
 #include "wps/wps.h"
+#include "common/wpa_common.h"
 
 
 struct wpa_cred {
@@ -517,6 +518,7 @@  struct wpa_config {
 	struct p2p_channel *p2p_pref_chan;
 
 	struct wpabuf *wps_vendor_ext_m1;
+	struct wpa_wmm_ac_params wmm_ac_params[4];
 
 #define MAX_WPS_VENDOR_EXT 10
 	/**
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index 8badc7b..55cb5fd 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -382,6 +382,24 @@  struct wpa_config * wpa_config_read(const char *name)
 				continue;
 			}
 #endif /* CONFIG_NO_CONFIG_BLOBS */
+#ifdef CONFIG_P2P
+		} else if (os_strncmp(buf, "wme_ac_", 7) == 0 ||
+			   os_strncmp(buf, "wmm_ac_", 7) == 0) {
+			pos = os_strchr(buf, '=');
+			if (pos == NULL) {
+				wpa_printf(MSG_ERROR, "Line %d: invalid line '%s'",
+						line, buf);
+				errors++;
+				continue;
+			}
+			*pos = '\0';
+			pos++;
+			if (wpa_config_wmm_ac(config->wmm_ac_params, buf, pos)) {
+				wpa_printf(MSG_ERROR, "Line %d: invalid WMM "
+					   "ac item", line);
+				errors++;
+			}
+#endif /* CONFIG_P2P */
 		} else if (wpa_config_process_global(config, pos, line) < 0) {
 			wpa_printf(MSG_ERROR, "Line %d: Invalid configuration "
 				   "line '%s'.", line, pos);