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

login
register
mail settings
Submitter Sreenath
Date Oct. 4, 2013, 6:43 a.m.
Message ID <5F8A83CFE238064080EB46F88B8161C1013BD073@SJEXCHMB09.corp.ad.broadcom.com>
Download mbox | patch
Permalink /patch/280476/
State New
Headers show

Comments

Sreenath - Oct. 4, 2013, 6:43 a.m.
Hi Jouni,

Thanks for the update.

I will see how this patch can be reworked considering your suggestions.

Regards,
Sreenath

Patch

diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c
index 178a8f6..3480781 100644
--- a/src/p2p/p2p.c
+++ b/src/p2p/p2p.c
@@ -1175,7 +1175,7 @@  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, int *best_freq)
 {
        u8 op_class, op_channel;

@@ -1188,6 +1188,7 @@  static void p2p_prepare_channel_best(struct p2p_data *p2p)
                p2p_dbg(p2p, "Select best 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->best_freq_5, &op_class, &op_channel)
@@ -1195,6 +1196,7 @@  static void p2p_prepare_channel_best(struct p2p_data *p2p)
                p2p_dbg(p2p, "Select best 5 GHz 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->best_freq_24, &op_class,
@@ -1202,6 +1204,7 @@  static void p2p_prepare_channel_best(struct p2p_data *p2p)
                p2p_dbg(p2p, "Select best 2.4 GHz channel as operating channel preference");
                p2p->op_reg_class = op_class;
                p2p->op_channel = op_channel;
+               *best_freq = 1;
        } else if (p2p->cfg->num_pref_chan > 0 &&
                   p2p_channels_includes(&p2p->cfg->channels,
                                         p2p->cfg->pref_chan[0].op_class,
@@ -1209,10 +1212,12 @@  static void p2p_prepare_channel_best(struct p2p_data *p2p)
                p2p_dbg(p2p, "Select first pref_chan entry as operating channel preference");
                p2p->op_reg_class = p2p->cfg->pref_chan[0].op_class;
                p2p->op_channel = p2p->cfg->pref_chan[0].chan;
+               *best_freq = 0;
        } else {
                p2p_dbg(p2p, "Select pre-configured channel as operating channel preference");
                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,
@@ -1236,19 +1241,22 @@  static void p2p_prepare_channel_best(struct p2p_data *p2p)
 int p2p_prepare_channel(struct p2p_data *p2p, struct p2p_device *dev,
                        unsigned int force_freq, unsigned int pref_freq)
 {
+       int best_freq = 0;
+
        p2p_dbg(p2p, "Prepare channel - force_freq=%u pref_freq=%u",
                force_freq, pref_freq);
        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);
        }
        p2p_dbg(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;