OSDN Git Service

Merge tag 'wireless-next-2022-03-11' of git://git.kernel.org/pub/scm/linux/kernel...
[uclinux-h8/linux.git] / drivers / net / wireless / mac80211_hwsim.c
index fc5725f..28bfa7b 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
  * Copyright (c) 2011, Javier Lopez <jlopex@gmail.com>
  * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright (C) 2018 - 2020 Intel Corporation
+ * Copyright (C) 2018 - 2022 Intel Corporation
  */
 
 /*
@@ -173,9 +173,23 @@ static const struct ieee80211_regdomain hwsim_world_regdom_custom_02 = {
        }
 };
 
+static const struct ieee80211_regdomain hwsim_world_regdom_custom_03 = {
+       .n_reg_rules = 6,
+       .alpha2 =  "99",
+       .reg_rules = {
+               REG_RULE(2412 - 10, 2462 + 10, 40, 0, 20, 0),
+               REG_RULE(2484 - 10, 2484 + 10, 40, 0, 20, 0),
+               REG_RULE(5150 - 10, 5240 + 10, 40, 0, 30, 0),
+               REG_RULE(5745 - 10, 5825 + 10, 40, 0, 30, 0),
+               REG_RULE(5855 - 10, 5925 + 10, 40, 0, 33, 0),
+               REG_RULE(5955 - 10, 7125 + 10, 320, 0, 33, 0),
+       }
+};
+
 static const struct ieee80211_regdomain *hwsim_world_regdom_custom[] = {
        &hwsim_world_regdom_custom_01,
        &hwsim_world_regdom_custom_02,
+       &hwsim_world_regdom_custom_03,
 };
 
 struct hwsim_vif_priv {
@@ -475,16 +489,16 @@ static const struct ieee80211_sta_s1g_cap hwsim_s1g_cap = {
                     0 },
 };
 
-static void hwsim_init_s1g_channels(struct ieee80211_channel *channels)
+static void hwsim_init_s1g_channels(struct ieee80211_channel *chans)
 {
        int ch, freq;
 
        for (ch = 0; ch < NUM_S1G_CHANS_US; ch++) {
                freq = 902000 + (ch + 1) * 500;
-               channels[ch].band = NL80211_BAND_S1GHZ;
-               channels[ch].center_freq = KHZ_TO_MHZ(freq);
-               channels[ch].freq_offset = freq % 1000;
-               channels[ch].hw_value = ch + 1;
+               chans[ch].band = NL80211_BAND_S1GHZ;
+               chans[ch].center_freq = KHZ_TO_MHZ(freq);
+               chans[ch].freq_offset = freq % 1000;
+               chans[ch].hw_value = ch + 1;
        }
 }
 
@@ -503,6 +517,8 @@ static const struct ieee80211_rate hwsim_rates[] = {
        { .bitrate = 540 }
 };
 
+#define DEFAULT_RX_RSSI -50
+
 static const u32 hwsim_ciphers[] = {
        WLAN_CIPHER_SUITE_WEP40,
        WLAN_CIPHER_SUITE_WEP104,
@@ -652,6 +668,7 @@ struct mac80211_hwsim_data {
                      ARRAY_SIZE(hwsim_channels_6ghz)];
 
        struct ieee80211_channel *channel;
+       enum nl80211_chan_width bw;
        u64 beacon_int  /* beacon interval in us */;
        unsigned int rx_filter;
        bool started, idle, scanning;
@@ -690,6 +707,9 @@ struct mac80211_hwsim_data {
        u64 rx_bytes;
        u64 tx_dropped;
        u64 tx_failed;
+
+       /* RSSI in rx status of the receiver */
+       int rx_rssi;
 };
 
 static const struct rhashtable_params hwsim_rht_params = {
@@ -803,6 +823,40 @@ extern int hwsim_tx_virtio(struct mac80211_hwsim_data *data,
 #define hwsim_virtio_enabled false
 #endif
 
+static int hwsim_get_chanwidth(enum nl80211_chan_width bw)
+{
+       switch (bw) {
+       case NL80211_CHAN_WIDTH_20_NOHT:
+       case NL80211_CHAN_WIDTH_20:
+               return 20;
+       case NL80211_CHAN_WIDTH_40:
+               return 40;
+       case NL80211_CHAN_WIDTH_80:
+               return 80;
+       case NL80211_CHAN_WIDTH_80P80:
+       case NL80211_CHAN_WIDTH_160:
+               return 160;
+       case NL80211_CHAN_WIDTH_320:
+               return 320;
+       case NL80211_CHAN_WIDTH_5:
+               return 5;
+       case NL80211_CHAN_WIDTH_10:
+               return 10;
+       case NL80211_CHAN_WIDTH_1:
+               return 1;
+       case NL80211_CHAN_WIDTH_2:
+               return 2;
+       case NL80211_CHAN_WIDTH_4:
+               return 4;
+       case NL80211_CHAN_WIDTH_8:
+               return 8;
+       case NL80211_CHAN_WIDTH_16:
+               return 16;
+       }
+
+       return INT_MAX;
+}
+
 static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
                                    struct sk_buff *skb,
                                    struct ieee80211_channel *chan);
@@ -964,6 +1018,29 @@ DEFINE_DEBUGFS_ATTRIBUTE(hwsim_fops_group,
                         hwsim_fops_group_read, hwsim_fops_group_write,
                         "%llx\n");
 
+static int hwsim_fops_rx_rssi_read(void *dat, u64 *val)
+{
+       struct mac80211_hwsim_data *data = dat;
+       *val = data->rx_rssi;
+       return 0;
+}
+
+static int hwsim_fops_rx_rssi_write(void *dat, u64 val)
+{
+       struct mac80211_hwsim_data *data = dat;
+       int rssi = (int)val;
+
+       if (rssi >= 0 || rssi < -100)
+               return -EINVAL;
+
+       data->rx_rssi = rssi;
+       return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(hwsim_fops_rx_rssi,
+                        hwsim_fops_rx_rssi_read, hwsim_fops_rx_rssi_write,
+                        "%lld\n");
+
 static netdev_tx_t hwsim_mon_xmit(struct sk_buff *skb,
                                        struct net_device *dev)
 {
@@ -1482,8 +1559,8 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
                rx_status.bw = RATE_INFO_BW_20;
        if (info->control.rates[0].flags & IEEE80211_TX_RC_SHORT_GI)
                rx_status.enc_flags |= RX_ENC_FLAG_SHORT_GI;
-       /* TODO: simulate real signal strength (and optional packet loss) */
-       rx_status.signal = -50;
+       /* TODO: simulate optional packet loss */
+       rx_status.signal = data->rx_rssi;
        if (info->control.vif)
                rx_status.signal += info->control.vif->bss_conf.txpower;
 
@@ -1595,7 +1672,8 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
        struct ieee80211_chanctx_conf *chanctx_conf;
        struct ieee80211_channel *channel;
        bool ack;
-       u32 _portid;
+       enum nl80211_chan_width confbw = NL80211_CHAN_WIDTH_20_NOHT;
+       u32 _portid, i;
 
        if (WARN_ON(skb->len < 10)) {
                /* Should not happen; just a sanity check for addr1 use */
@@ -1605,14 +1683,17 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
 
        if (!data->use_chanctx) {
                channel = data->channel;
+               confbw = data->bw;
        } else if (txi->hw_queue == 4) {
                channel = data->tmp_chan;
        } else {
                chanctx_conf = rcu_dereference(txi->control.vif->chanctx_conf);
-               if (chanctx_conf)
+               if (chanctx_conf) {
                        channel = chanctx_conf->def.chan;
-               else
+                       confbw = chanctx_conf->def.width;
+               } else {
                        channel = NULL;
+               }
        }
 
        if (WARN(!channel, "TX w/o channel - queue = %d\n", txi->hw_queue)) {
@@ -1636,6 +1717,25 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
                                       txi->control.rates,
                                       ARRAY_SIZE(txi->control.rates));
 
+       for (i = 0; i < ARRAY_SIZE(txi->control.rates); i++) {
+               u16 rflags = txi->control.rates[i].flags;
+               /* initialize to data->bw for 5/10 MHz handling */
+               enum nl80211_chan_width bw = data->bw;
+
+               if (txi->control.rates[i].idx == -1)
+                       break;
+
+               if (rflags & IEEE80211_TX_RC_40_MHZ_WIDTH)
+                       bw = NL80211_CHAN_WIDTH_40;
+               else if (rflags & IEEE80211_TX_RC_80_MHZ_WIDTH)
+                       bw = NL80211_CHAN_WIDTH_80;
+               else if (rflags & IEEE80211_TX_RC_160_MHZ_WIDTH)
+                       bw = NL80211_CHAN_WIDTH_160;
+
+               if (WARN_ON(hwsim_get_chanwidth(bw) > hwsim_get_chanwidth(confbw)))
+                       return;
+       }
+
        if (skb->len >= 24 + 8 &&
            ieee80211_is_probe_resp(hdr->frame_control)) {
                /* fake header transmission time */
@@ -1935,6 +2035,7 @@ static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
                }
 
                data->channel = conf->chandef.chan;
+               data->bw = conf->chandef.width;
 
                for (idx = 0; idx < ARRAY_SIZE(data->survey_data); idx++) {
                        if (data->survey_data[idx].channel &&
@@ -1946,6 +2047,7 @@ static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
                }
        } else {
                data->channel = conf->chandef.chan;
+               data->bw = conf->chandef.width;
        }
        mutex_unlock(&data->mutex);
 
@@ -2077,12 +2179,49 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
                wiphy_dbg(hw->wiphy, "  TX Power: %d dBm\n", info->txpower);
 }
 
+static void
+mac80211_hwsim_sta_rc_update(struct ieee80211_hw *hw,
+                            struct ieee80211_vif *vif,
+                            struct ieee80211_sta *sta,
+                            u32 changed)
+{
+       struct mac80211_hwsim_data *data = hw->priv;
+       u32 bw = U32_MAX;
+       enum nl80211_chan_width confbw = NL80211_CHAN_WIDTH_20_NOHT;
+
+       switch (sta->bandwidth) {
+#define C(_bw) case IEEE80211_STA_RX_BW_##_bw: bw = _bw; break
+       C(20);
+       C(40);
+       C(80);
+       C(160);
+       C(320);
+#undef C
+       }
+
+       if (!data->use_chanctx) {
+               confbw = data->bw;
+       } else {
+               struct ieee80211_chanctx_conf *chanctx_conf =
+                       rcu_dereference(vif->chanctx_conf);
+
+               if (!WARN_ON(!chanctx_conf))
+                       confbw = chanctx_conf->def.width;
+       }
+
+       WARN(bw > hwsim_get_chanwidth(confbw),
+            "intf %pM: bad STA %pM bandwidth %d MHz (%d) > channel config %d MHz (%d)\n",
+            vif->addr, sta->addr, bw, sta->bandwidth,
+            hwsim_get_chanwidth(data->bw), data->bw);
+}
+
 static int mac80211_hwsim_sta_add(struct ieee80211_hw *hw,
                                  struct ieee80211_vif *vif,
                                  struct ieee80211_sta *sta)
 {
        hwsim_check_magic(vif);
        hwsim_set_sta_magic(sta);
+       mac80211_hwsim_sta_rc_update(hw, vif, sta, 0);
 
        return 0;
 }
@@ -2658,6 +2797,7 @@ static int mac80211_hwsim_tx_last_beacon(struct ieee80211_hw *hw)
        .sta_add = mac80211_hwsim_sta_add,                      \
        .sta_remove = mac80211_hwsim_sta_remove,                \
        .sta_notify = mac80211_hwsim_sta_notify,                \
+       .sta_rc_update = mac80211_hwsim_sta_rc_update,          \
        .set_tim = mac80211_hwsim_set_tim,                      \
        .conf_tx = mac80211_hwsim_conf_tx,                      \
        .get_survey = mac80211_hwsim_get_survey,                \
@@ -2809,7 +2949,7 @@ out_err:
        nlmsg_free(mcast_skb);
 }
 
-static const struct ieee80211_sband_iftype_data he_capa_2ghz[] = {
+static const struct ieee80211_sband_iftype_data sband_capa_2ghz[] = {
        {
                .types_mask = BIT(NL80211_IFTYPE_STATION) |
                              BIT(NL80211_IFTYPE_AP),
@@ -2855,6 +2995,66 @@ static const struct ieee80211_sband_iftype_data he_capa_2ghz[] = {
                                .tx_mcs_80p80 = cpu_to_le16(0xffff),
                        },
                },
+               .eht_cap = {
+                       .has_eht = true,
+                       .eht_cap_elem = {
+                               .mac_cap_info[0] =
+                                       IEEE80211_EHT_MAC_CAP0_NSEP_PRIO_ACCESS |
+                                       IEEE80211_EHT_MAC_CAP0_OM_CONTROL |
+                                       IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE1,
+                               .phy_cap_info[0] =
+                                       IEEE80211_EHT_PHY_CAP0_242_TONE_RU_GT20MHZ |
+                                       IEEE80211_EHT_PHY_CAP0_NDP_4_EHT_LFT_32_GI |
+                                       IEEE80211_EHT_PHY_CAP0_PARTIAL_BW_UL_MU_MIMO |
+                                       IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER |
+                                       IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE,
+                               .phy_cap_info[3] =
+                                       IEEE80211_EHT_PHY_CAP3_NG_16_SU_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP3_NG_16_MU_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP3_CODEBOOK_4_2_SU_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_CODEBOOK_7_5_MU_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_SU_BF_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_MU_BF_PART_BW_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_CQI_FDBK,
+                               .phy_cap_info[4] =
+                                       IEEE80211_EHT_PHY_CAP4_PART_BW_DL_MU_MIMO |
+                                       IEEE80211_EHT_PHY_CAP4_PSR_SR_SUPP |
+                                       IEEE80211_EHT_PHY_CAP4_POWER_BOOST_FACT_SUPP |
+                                       IEEE80211_EHT_PHY_CAP4_EHT_MU_PPDU_4_EHT_LTF_08_GI |
+                                       IEEE80211_EHT_PHY_CAP4_MAX_NC_MASK,
+                               .phy_cap_info[5] =
+                                       IEEE80211_EHT_PHY_CAP5_NON_TRIG_CQI_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP5_TX_LESS_242_TONE_RU_SUPP |
+                                       IEEE80211_EHT_PHY_CAP5_RX_LESS_242_TONE_RU_SUPP |
+                                       IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT |
+                                       IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK |
+                                       IEEE80211_EHT_PHY_CAP5_MAX_NUM_SUPP_EHT_LTF_MASK,
+                               .phy_cap_info[6] =
+                                       IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK |
+                                       IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK,
+                               .phy_cap_info[7] =
+                                       IEEE80211_EHT_PHY_CAP7_20MHZ_STA_RX_NDP_WIDER_BW,
+                       },
+
+                       /* For all MCS and bandwidth, set 8 NSS for both Tx and
+                        * Rx
+                        */
+                       .eht_mcs_nss_supp = {
+                               /*
+                                * Since B0, B1, B2 and B3 are not set in
+                                * the supported channel width set field in the
+                                * HE PHY capabilities information field the
+                                * device is a 20MHz only device on 2.4GHz band.
+                                */
+                               .only_20mhz = {
+                                       .rx_tx_mcs7_max_nss = 0x88,
+                                       .rx_tx_mcs9_max_nss = 0x88,
+                                       .rx_tx_mcs11_max_nss = 0x88,
+                                       .rx_tx_mcs13_max_nss = 0x88,
+                               },
+                       },
+                       /* PPE threshold information is not supported */
+               },
        },
 #ifdef CONFIG_MAC80211_MESH
        {
@@ -2897,7 +3097,7 @@ static const struct ieee80211_sband_iftype_data he_capa_2ghz[] = {
 #endif
 };
 
-static const struct ieee80211_sband_iftype_data he_capa_5ghz[] = {
+static const struct ieee80211_sband_iftype_data sband_capa_5ghz[] = {
        {
                /* TODO: should we support other types, e.g., P2P?*/
                .types_mask = BIT(NL80211_IFTYPE_STATION) |
@@ -2948,6 +3148,81 @@ static const struct ieee80211_sband_iftype_data he_capa_5ghz[] = {
                                .tx_mcs_80p80 = cpu_to_le16(0xfffa),
                        },
                },
+               .eht_cap = {
+                       .has_eht = true,
+                       .eht_cap_elem = {
+                               .mac_cap_info[0] =
+                                       IEEE80211_EHT_MAC_CAP0_NSEP_PRIO_ACCESS |
+                                       IEEE80211_EHT_MAC_CAP0_OM_CONTROL |
+                                       IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE1,
+                               .phy_cap_info[0] =
+                                       IEEE80211_EHT_PHY_CAP0_242_TONE_RU_GT20MHZ |
+                                       IEEE80211_EHT_PHY_CAP0_NDP_4_EHT_LFT_32_GI |
+                                       IEEE80211_EHT_PHY_CAP0_PARTIAL_BW_UL_MU_MIMO |
+                                       IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER |
+                                       IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE |
+                                       IEEE80211_EHT_PHY_CAP0_BEAMFORMEE_SS_80MHZ_MASK,
+                               .phy_cap_info[1] =
+                                       IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK |
+                                       IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK,
+                               .phy_cap_info[2] =
+                                       IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK |
+                                       IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK,
+                               .phy_cap_info[3] =
+                                       IEEE80211_EHT_PHY_CAP3_NG_16_SU_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP3_NG_16_MU_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP3_CODEBOOK_4_2_SU_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_CODEBOOK_7_5_MU_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_SU_BF_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_MU_BF_PART_BW_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_CQI_FDBK,
+                               .phy_cap_info[4] =
+                                       IEEE80211_EHT_PHY_CAP4_PART_BW_DL_MU_MIMO |
+                                       IEEE80211_EHT_PHY_CAP4_PSR_SR_SUPP |
+                                       IEEE80211_EHT_PHY_CAP4_POWER_BOOST_FACT_SUPP |
+                                       IEEE80211_EHT_PHY_CAP4_EHT_MU_PPDU_4_EHT_LTF_08_GI |
+                                       IEEE80211_EHT_PHY_CAP4_MAX_NC_MASK,
+                               .phy_cap_info[5] =
+                                       IEEE80211_EHT_PHY_CAP5_NON_TRIG_CQI_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP5_TX_LESS_242_TONE_RU_SUPP |
+                                       IEEE80211_EHT_PHY_CAP5_RX_LESS_242_TONE_RU_SUPP |
+                                       IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT |
+                                       IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK |
+                                       IEEE80211_EHT_PHY_CAP5_MAX_NUM_SUPP_EHT_LTF_MASK,
+                               .phy_cap_info[6] =
+                                       IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK |
+                                       IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK,
+                               .phy_cap_info[7] =
+                                       IEEE80211_EHT_PHY_CAP7_20MHZ_STA_RX_NDP_WIDER_BW |
+                                       IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ |
+                                       IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ |
+                                       IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
+                                       IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ,
+                       },
+
+                       /* For all MCS and bandwidth, set 8 NSS for both Tx and
+                        * Rx
+                        */
+                       .eht_mcs_nss_supp = {
+                               /*
+                                * As B1 and B2 are set in the supported
+                                * channel width set field in the HE PHY
+                                * capabilities information field include all
+                                * the following MCS/NSS.
+                                */
+                               .bw._80 = {
+                                       .rx_tx_mcs9_max_nss = 0x88,
+                                       .rx_tx_mcs11_max_nss = 0x88,
+                                       .rx_tx_mcs13_max_nss = 0x88,
+                               },
+                               .bw._160 = {
+                                       .rx_tx_mcs9_max_nss = 0x88,
+                                       .rx_tx_mcs11_max_nss = 0x88,
+                                       .rx_tx_mcs13_max_nss = 0x88,
+                               },
+                       },
+                       /* PPE threshold information is not supported */
+               },
        },
 #ifdef CONFIG_MAC80211_MESH
        {
@@ -2995,7 +3270,7 @@ static const struct ieee80211_sband_iftype_data he_capa_5ghz[] = {
 #endif
 };
 
-static const struct ieee80211_sband_iftype_data he_capa_6ghz[] = {
+static const struct ieee80211_sband_iftype_data sband_capa_6ghz[] = {
        {
                /* TODO: should we support other types, e.g., P2P?*/
                .types_mask = BIT(NL80211_IFTYPE_STATION) |
@@ -3055,6 +3330,93 @@ static const struct ieee80211_sband_iftype_data he_capa_6ghz[] = {
                                .tx_mcs_80p80 = cpu_to_le16(0xfffa),
                        },
                },
+               .eht_cap = {
+                       .has_eht = true,
+                       .eht_cap_elem = {
+                               .mac_cap_info[0] =
+                                       IEEE80211_EHT_MAC_CAP0_NSEP_PRIO_ACCESS |
+                                       IEEE80211_EHT_MAC_CAP0_OM_CONTROL |
+                                       IEEE80211_EHT_MAC_CAP0_TRIG_TXOP_SHARING_MODE1,
+                               .phy_cap_info[0] =
+                                       IEEE80211_EHT_PHY_CAP0_320MHZ_IN_6GHZ |
+                                       IEEE80211_EHT_PHY_CAP0_242_TONE_RU_GT20MHZ |
+                                       IEEE80211_EHT_PHY_CAP0_NDP_4_EHT_LFT_32_GI |
+                                       IEEE80211_EHT_PHY_CAP0_PARTIAL_BW_UL_MU_MIMO |
+                                       IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMER |
+                                       IEEE80211_EHT_PHY_CAP0_SU_BEAMFORMEE |
+                                       IEEE80211_EHT_PHY_CAP0_BEAMFORMEE_SS_80MHZ_MASK,
+                               .phy_cap_info[1] =
+                                       IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_80MHZ_MASK |
+                                       IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_160MHZ_MASK |
+                                       IEEE80211_EHT_PHY_CAP1_BEAMFORMEE_SS_320MHZ_MASK,
+                               .phy_cap_info[2] =
+                                       IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_80MHZ_MASK |
+                                       IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_160MHZ_MASK |
+                                       IEEE80211_EHT_PHY_CAP2_SOUNDING_DIM_320MHZ_MASK,
+                               .phy_cap_info[3] =
+                                       IEEE80211_EHT_PHY_CAP3_NG_16_SU_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP3_NG_16_MU_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP3_CODEBOOK_4_2_SU_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_CODEBOOK_7_5_MU_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_SU_BF_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_MU_BF_PART_BW_FDBK |
+                                       IEEE80211_EHT_PHY_CAP3_TRIG_CQI_FDBK,
+                               .phy_cap_info[4] =
+                                       IEEE80211_EHT_PHY_CAP4_PART_BW_DL_MU_MIMO |
+                                       IEEE80211_EHT_PHY_CAP4_PSR_SR_SUPP |
+                                       IEEE80211_EHT_PHY_CAP4_POWER_BOOST_FACT_SUPP |
+                                       IEEE80211_EHT_PHY_CAP4_EHT_MU_PPDU_4_EHT_LTF_08_GI |
+                                       IEEE80211_EHT_PHY_CAP4_MAX_NC_MASK,
+                               .phy_cap_info[5] =
+                                       IEEE80211_EHT_PHY_CAP5_NON_TRIG_CQI_FEEDBACK |
+                                       IEEE80211_EHT_PHY_CAP5_TX_LESS_242_TONE_RU_SUPP |
+                                       IEEE80211_EHT_PHY_CAP5_RX_LESS_242_TONE_RU_SUPP |
+                                       IEEE80211_EHT_PHY_CAP5_PPE_THRESHOLD_PRESENT |
+                                       IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK |
+                                       IEEE80211_EHT_PHY_CAP5_MAX_NUM_SUPP_EHT_LTF_MASK,
+                               .phy_cap_info[6] =
+                                       IEEE80211_EHT_PHY_CAP6_MAX_NUM_SUPP_EHT_LTF_MASK |
+                                       IEEE80211_EHT_PHY_CAP6_MCS15_SUPP_MASK |
+                                       IEEE80211_EHT_PHY_CAP6_EHT_DUP_6GHZ_SUPP,
+                               .phy_cap_info[7] =
+                                       IEEE80211_EHT_PHY_CAP7_20MHZ_STA_RX_NDP_WIDER_BW |
+                                       IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_80MHZ |
+                                       IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_160MHZ |
+                                       IEEE80211_EHT_PHY_CAP7_NON_OFDMA_UL_MU_MIMO_320MHZ |
+                                       IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_80MHZ |
+                                       IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_160MHZ |
+                                       IEEE80211_EHT_PHY_CAP7_MU_BEAMFORMER_320MHZ,
+                       },
+
+                       /* For all MCS and bandwidth, set 8 NSS for both Tx and
+                        * Rx
+                        */
+                       .eht_mcs_nss_supp = {
+                               /*
+                                * As B1 and B2 are set in the supported
+                                * channel width set field in the HE PHY
+                                * capabilities information field and 320MHz in
+                                * 6GHz is supported include all the following
+                                * MCS/NSS.
+                                */
+                               .bw._80 = {
+                                       .rx_tx_mcs9_max_nss = 0x88,
+                                       .rx_tx_mcs11_max_nss = 0x88,
+                                       .rx_tx_mcs13_max_nss = 0x88,
+                               },
+                               .bw._160 = {
+                                       .rx_tx_mcs9_max_nss = 0x88,
+                                       .rx_tx_mcs11_max_nss = 0x88,
+                                       .rx_tx_mcs13_max_nss = 0x88,
+                               },
+                               .bw._320 = {
+                                       .rx_tx_mcs9_max_nss = 0x88,
+                                       .rx_tx_mcs11_max_nss = 0x88,
+                                       .rx_tx_mcs13_max_nss = 0x88,
+                               },
+                       },
+                       /* PPE threshold information is not supported */
+               },
        },
 #ifdef CONFIG_MAC80211_MESH
        {
@@ -3111,22 +3473,22 @@ static const struct ieee80211_sband_iftype_data he_capa_6ghz[] = {
 #endif
 };
 
-static void mac80211_hwsim_he_capab(struct ieee80211_supported_band *sband)
+static void mac80211_hwsim_sband_capab(struct ieee80211_supported_band *sband)
 {
        u16 n_iftype_data;
 
        if (sband->band == NL80211_BAND_2GHZ) {
-               n_iftype_data = ARRAY_SIZE(he_capa_2ghz);
+               n_iftype_data = ARRAY_SIZE(sband_capa_2ghz);
                sband->iftype_data =
-                       (struct ieee80211_sband_iftype_data *)he_capa_2ghz;
+                       (struct ieee80211_sband_iftype_data *)sband_capa_2ghz;
        } else if (sband->band == NL80211_BAND_5GHZ) {
-               n_iftype_data = ARRAY_SIZE(he_capa_5ghz);
+               n_iftype_data = ARRAY_SIZE(sband_capa_5ghz);
                sband->iftype_data =
-                       (struct ieee80211_sband_iftype_data *)he_capa_5ghz;
+                       (struct ieee80211_sband_iftype_data *)sband_capa_5ghz;
        } else if (sband->band == NL80211_BAND_6GHZ) {
-               n_iftype_data = ARRAY_SIZE(he_capa_6ghz);
+               n_iftype_data = ARRAY_SIZE(sband_capa_6ghz);
                sband->iftype_data =
-                       (struct ieee80211_sband_iftype_data *)he_capa_6ghz;
+                       (struct ieee80211_sband_iftype_data *)sband_capa_6ghz;
        } else {
                return;
        }
@@ -3318,6 +3680,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
                hw->wiphy->n_cipher_suites = param->n_ciphers;
        }
 
+       data->rx_rssi = DEFAULT_RX_RSSI;
+
        INIT_DELAYED_WORK(&data->roc_start, hw_roc_start);
        INIT_DELAYED_WORK(&data->roc_done, hw_roc_done);
        INIT_DELAYED_WORK(&data->hw_scan, hw_scan_work);
@@ -3449,7 +3813,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
                        sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED;
                }
 
-               mac80211_hwsim_he_capab(sband);
+               mac80211_hwsim_sband_capab(sband);
 
                hw->wiphy->bands[band] = sband;
        }
@@ -3509,6 +3873,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
        debugfs_create_file("ps", 0666, data->debugfs, data, &hwsim_fops_ps);
        debugfs_create_file("group", 0666, data->debugfs, data,
                            &hwsim_fops_group);
+       debugfs_create_file("rx_rssi", 0666, data->debugfs, data,
+                           &hwsim_fops_rx_rssi);
        if (!data->use_chanctx)
                debugfs_create_file("dfs_simulate_radar", 0222,
                                    data->debugfs,