Patchwork Avoid channel reselection, if any of the best channel is selected as operating channel

login
register
mail settings
Submitter Sreenath
Date Jan. 22, 2013, 2:13 p.m.
Message ID <50FE9E9F.8040900@broadcom.com>
Download mbox | patch
Permalink /patch/214559/
State Superseded
Headers show

Comments

Sreenath - Jan. 22, 2013, 2:13 p.m.
Set P2P_DEV_FORCE_FREQ flag if any of the best channel is selected as 
the operating channel, to prevent channel reselection in GO channel 
selection.

Signed-hostap: Sreenath Sharma <sreenats@broadcom.com>

---
  src/p2p/p2p.c |   16 ++++++++++++----
  1 file changed, 12 insertions(+), 4 deletions(-)


@@ -1172,6 +1173,7 @@ static void p2p_prepare_channel_best(struct 
p2p_data *p2p)
              "overall channel as operating channel preference");
          p2p->op_reg_class = op_class;
          p2p->op_channel = op_channel;
+        *best_freq = 1;
      } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_5 > 0 &&
             p2p_supported_freq(p2p, p2p->best_freq_5) &&
             p2p_freq_to_channel(p2p->cfg->country, p2p->best_freq_5,
@@ -1180,6 +1182,7 @@ static void p2p_prepare_channel_best(struct 
p2p_data *p2p)
              "channel as operating channel preference");
          p2p->op_reg_class = op_class;
          p2p->op_channel = op_channel;
+        *best_freq = 1;
      } else if (!p2p->cfg->cfg_op_channel && p2p->best_freq_24 > 0 &&
             p2p_supported_freq(p2p, p2p->best_freq_24) &&
             p2p_freq_to_channel(p2p->cfg->country, p2p->best_freq_24,
@@ -1188,9 +1191,11 @@ static void p2p_prepare_channel_best(struct 
p2p_data *p2p)
              "GHz channel as operating channel preference");
          p2p->op_reg_class = op_class;
          p2p->op_channel = op_channel;
+        *best_freq = 1;
      } else {
          p2p->op_reg_class = p2p->cfg->op_reg_class;
          p2p->op_channel = p2p->cfg->op_channel;
+        *best_freq = 0;
      }

      os_memcpy(&p2p->channels, &p2p->cfg->channels,
@@ -1214,19 +1219,22 @@ static void p2p_prepare_channel_best(struct 
p2p_data *p2p)
  static int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device 
*dev,
                     unsigned int force_freq, unsigned int pref_freq)
  {
+    unsigned int best_freq = 0;
+
      if (force_freq || pref_freq) {
          if (p2p_prepare_channel_pref(p2p, force_freq, pref_freq) < 0)
              return -1;
      } else {
-        p2p_prepare_channel_best(p2p);
+        p2p_prepare_channel_best(p2p, &best_freq);
      }
      wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
          "P2P: Own preference for operation channel: "
          "Operating Class %u Channel %u%s",
          p2p->op_reg_class, p2p->op_channel,
-        force_freq ? " (forced)" : "");
+        force_freq ? " (forced)" :
+        best_freq ? " (best)" : "");

-    if (force_freq)
+    if (force_freq || best_freq)
          dev->flags |= P2P_DEV_FORCE_FREQ;
      else
          dev->flags &= ~P2P_DEV_FORCE_FREQ;

Patch

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 43f8673..c616112 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1160,7 +1160,8 @@  static int p2p_prepare_channel_pref(struct 
p2p_data *p2p,
  }


-static void p2p_prepare_channel_best(struct p2p_data *p2p)
+static void p2p_prepare_channel_best(struct p2p_data *p2p,
+                    unsigned int *best_freq)
  {
      u8 op_class, op_channel;