]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Enhance determination of secondary offset to support 6 GHz channels
authorSreeramya Soratkal <ssramya@codeaurora.org>
Thu, 22 Jul 2021 12:37:47 +0000 (18:07 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 2 Sep 2021 15:19:33 +0000 (18:19 +0300)
Current definition of wpas_p2p_get_ht40_mode() determines secondary
offset in the 5 GHz band. Enhance the functionality of this function to
determine offset to support 6 GHz channels also.

Signed-off-by: Sreeramya Soratkal <ssramya@codeaurora.org>
src/common/ieee802_11_common.c
src/common/ieee802_11_common.h
wpa_supplicant/ap.c
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/p2p_supplicant.h

index 3e5cfb01d5651790a7e3ba4540e269e4718fad85..ef68abacd4354c7ea07628be57e7317654dee29c 100644 (file)
@@ -2293,6 +2293,30 @@ bool is_6ghz_psc_frequency(int freq)
 }
 
 
+/**
+ * get_6ghz_sec_channel - Get the relative position of the secondary channel
+ * to the primary channel in 6 GHz
+ * @channel: Primary channel to be checked for (in global op class 131)
+ * Returns: 1 = secondary channel above, -1 = secondary channel below
+ */
+
+int get_6ghz_sec_channel(int channel)
+{
+       /*
+        * In the 6 GHz band, primary channels are numbered as 1, 5, 9, 13.., so
+        * the 40 MHz channels are formed with the channel pairs as (1,5),
+        * (9,13), (17,21)..
+        * The secondary channel for a given primary channel is below the
+        * primary channel for the channels 5, 13, 21.. and it is above the
+        * primary channel for the channels 1, 9, 17..
+        */
+
+       if (((channel - 1) / 4) % 2)
+               return -1;
+       return 1;
+}
+
+
 int ieee802_11_parse_candidate_list(const char *pos, u8 *nei_rep,
                                    size_t nei_rep_len)
 {
index fe2b1bca601b8c3ab0e5ca44a87d53b311a49da0..e9d7293e791c381ec460328f55bcf1af5511cfa8 100644 (file)
@@ -264,6 +264,7 @@ int center_idx_to_bw_6ghz(u8 idx);
 bool is_6ghz_freq(int freq);
 bool is_6ghz_op_class(u8 op_class);
 bool is_6ghz_psc_frequency(int freq);
+int get_6ghz_sec_channel(int channel);
 
 int ieee802_11_parse_candidate_list(const char *pos, u8 *nei_rep,
                                    size_t nei_rep_len);
index 6c0f68ac10e827897f257f01fe2feb01e5a785ef..d3fb239c8a4c20361ea838d51d8ba7c7794d0825 100644 (file)
@@ -280,8 +280,8 @@ int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s,
                             HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET) &&
                            ssid->ht40) {
                                conf->secondary_channel =
-                                       wpas_p2p_get_ht40_mode(wpa_s, mode,
-                                                              conf->channel);
+                                       wpas_p2p_get_sec_channel_offset_40mhz(
+                                               wpa_s, mode, conf->channel);
                                wpa_printf(MSG_DEBUG,
                                           "HT secondary channel offset %d for P2P group",
                                           conf->secondary_channel);
index 92b696699eee3aa4d7a592646f66c1e0a9b158f8..51d351a482797fbcd2c6f7a4b4da9ff3a501ce9d 100644 (file)
@@ -3893,30 +3893,41 @@ static int wpas_p2p_setup_channels(struct wpa_supplicant *wpa_s,
 }
 
 
-int wpas_p2p_get_ht40_mode(struct wpa_supplicant *wpa_s,
-                          struct hostapd_hw_modes *mode, u8 channel)
+int wpas_p2p_get_sec_channel_offset_40mhz(struct wpa_supplicant *wpa_s,
+                                         struct hostapd_hw_modes *mode,
+                                         u8 channel)
 {
        int op;
        enum chan_allowed ret;
 
        for (op = 0; global_op_class[op].op_class; op++) {
                const struct oper_class_map *o = &global_op_class[op];
-               u8 ch;
+               u16 ch;
+               int chan = channel;
 
                if (o->p2p == NO_P2P_SUPP ||
                    (is_6ghz_op_class(o->op_class) &&
                     wpa_s->conf->p2p_6ghz_disable))
                        continue;
 
+               if (is_6ghz_op_class(o->op_class) && o->bw == BW40 &&
+                   get_6ghz_sec_channel(channel) < 0)
+                       chan = channel - 4;
+
                for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) {
                        if (o->mode != HOSTAPD_MODE_IEEE80211A ||
-                           (o->bw != BW40PLUS && o->bw != BW40MINUS) ||
-                           ch != channel)
+                           (o->bw != BW40PLUS && o->bw != BW40MINUS &&
+                            o->bw != BW40) ||
+                           ch != chan)
                                continue;
                        ret = wpas_p2p_verify_channel(wpa_s, mode, o->op_class,
                                                      ch, o->bw);
-                       if (ret == ALLOWED)
+                       if (ret == ALLOWED) {
+                               if (is_6ghz_op_class(o->op_class) &&
+                                   o->bw == BW40)
+                                       return get_6ghz_sec_channel(channel);
                                return (o->bw == BW40MINUS) ? -1 : 1;
+                       }
                }
        }
        return 0;
index dee9c1bcc1e1c0f47244a65f55a5a1b06fb16b7c..5a869e7309a3254ae7d2b91176932aa1cab2af14 100644 (file)
@@ -146,8 +146,9 @@ struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
 void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
                                       const u8 *addr);
 int wpas_p2p_scan_no_go_seen(struct wpa_supplicant *wpa_s);
-int wpas_p2p_get_ht40_mode(struct wpa_supplicant *wpa_s,
-                          struct hostapd_hw_modes *mode, u8 channel);
+int wpas_p2p_get_sec_channel_offset_40mhz(struct wpa_supplicant *wpa_s,
+                                         struct hostapd_hw_modes *mode,
+                                         u8 channel);
 int wpas_p2p_get_vht80_center(struct wpa_supplicant *wpa_s,
                              struct hostapd_hw_modes *mode, u8 channel,
                              u8 op_class);