OSDN Git Service

wifi: mt76: connac: add mt76_connac_mcu_uni_set_chctx
authorSean Wang <sean.wang@mediatek.com>
Thu, 10 Nov 2022 21:23:43 +0000 (05:23 +0800)
committerFelix Fietkau <nbd@nbd.name>
Thu, 1 Dec 2022 16:29:13 +0000 (17:29 +0100)
add mt76_connac_mcu_uni_set_chctx to set up the channel context per BSS
in the firmware

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h

index 9bba18d..aa1e2fa 100644 (file)
@@ -1347,13 +1347,10 @@ mt76_connac_mcu_uni_bss_he_tlv(struct mt76_phy *phy, struct ieee80211_vif *vif,
        he->max_nss_mcs[CMD_HE_MCS_BW8080] = cap->he_mcs_nss_supp.tx_mcs_80p80;
 }
 
-int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
-                               struct ieee80211_vif *vif,
-                               struct mt76_wcid *wcid,
-                               bool enable)
+int mt76_connac_mcu_uni_set_chctx(struct mt76_phy *phy, struct mt76_vif *mvif,
+                                 struct ieee80211_chanctx_conf *ctx)
 {
-       struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
-       struct cfg80211_chan_def *chandef = &phy->chandef;
+       struct cfg80211_chan_def *chandef = ctx ? &ctx->def : &phy->chandef;
        int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2;
        enum nl80211_band band = chandef->chan->band;
        struct mt76_dev *mdev = phy->dev;
@@ -1362,34 +1359,6 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
                        u8 bss_idx;
                        u8 pad[3];
                } __packed hdr;
-               struct mt76_connac_bss_basic_tlv basic;
-               struct mt76_connac_bss_qos_tlv qos;
-       } basic_req = {
-               .hdr = {
-                       .bss_idx = mvif->idx,
-               },
-               .basic = {
-                       .tag = cpu_to_le16(UNI_BSS_INFO_BASIC),
-                       .len = cpu_to_le16(sizeof(struct mt76_connac_bss_basic_tlv)),
-                       .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int),
-                       .dtim_period = vif->bss_conf.dtim_period,
-                       .omac_idx = mvif->omac_idx,
-                       .band_idx = mvif->band_idx,
-                       .wmm_idx = mvif->wmm_idx,
-                       .active = true, /* keep bss deactivated */
-                       .phymode = mt76_connac_get_phy_mode(phy, vif, band, NULL),
-               },
-               .qos = {
-                       .tag = cpu_to_le16(UNI_BSS_INFO_QBSS),
-                       .len = cpu_to_le16(sizeof(struct mt76_connac_bss_qos_tlv)),
-                       .qos = vif->bss_conf.qos,
-               },
-       };
-       struct {
-               struct {
-                       u8 bss_idx;
-                       u8 pad[3];
-               } __packed hdr;
                struct rlm_tlv {
                        __le16 tag;
                        __le16 len;
@@ -1422,6 +1391,81 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
                        .band = band,
                },
        };
+
+       switch (chandef->width) {
+       case NL80211_CHAN_WIDTH_40:
+               rlm_req.rlm.bw = CMD_CBW_40MHZ;
+               break;
+       case NL80211_CHAN_WIDTH_80:
+               rlm_req.rlm.bw = CMD_CBW_80MHZ;
+               break;
+       case NL80211_CHAN_WIDTH_80P80:
+               rlm_req.rlm.bw = CMD_CBW_8080MHZ;
+               break;
+       case NL80211_CHAN_WIDTH_160:
+               rlm_req.rlm.bw = CMD_CBW_160MHZ;
+               break;
+       case NL80211_CHAN_WIDTH_5:
+               rlm_req.rlm.bw = CMD_CBW_5MHZ;
+               break;
+       case NL80211_CHAN_WIDTH_10:
+               rlm_req.rlm.bw = CMD_CBW_10MHZ;
+               break;
+       case NL80211_CHAN_WIDTH_20_NOHT:
+       case NL80211_CHAN_WIDTH_20:
+       default:
+               rlm_req.rlm.bw = CMD_CBW_20MHZ;
+               rlm_req.rlm.ht_op_info = 0;
+               break;
+       }
+
+       if (rlm_req.rlm.control_channel < rlm_req.rlm.center_chan)
+               rlm_req.rlm.sco = 1; /* SCA */
+       else if (rlm_req.rlm.control_channel > rlm_req.rlm.center_chan)
+               rlm_req.rlm.sco = 3; /* SCB */
+
+       return mt76_mcu_send_msg(mdev, MCU_UNI_CMD(BSS_INFO_UPDATE), &rlm_req,
+                                sizeof(rlm_req), true);
+}
+EXPORT_SYMBOL_GPL(mt76_connac_mcu_uni_set_chctx);
+
+int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
+                               struct ieee80211_vif *vif,
+                               struct mt76_wcid *wcid,
+                               bool enable)
+{
+       struct mt76_vif *mvif = (struct mt76_vif *)vif->drv_priv;
+       struct cfg80211_chan_def *chandef = &phy->chandef;
+       enum nl80211_band band = chandef->chan->band;
+       struct mt76_dev *mdev = phy->dev;
+       struct {
+               struct {
+                       u8 bss_idx;
+                       u8 pad[3];
+               } __packed hdr;
+               struct mt76_connac_bss_basic_tlv basic;
+               struct mt76_connac_bss_qos_tlv qos;
+       } basic_req = {
+               .hdr = {
+                       .bss_idx = mvif->idx,
+               },
+               .basic = {
+                       .tag = cpu_to_le16(UNI_BSS_INFO_BASIC),
+                       .len = cpu_to_le16(sizeof(struct mt76_connac_bss_basic_tlv)),
+                       .bcn_interval = cpu_to_le16(vif->bss_conf.beacon_int),
+                       .dtim_period = vif->bss_conf.dtim_period,
+                       .omac_idx = mvif->omac_idx,
+                       .band_idx = mvif->band_idx,
+                       .wmm_idx = mvif->wmm_idx,
+                       .active = true, /* keep bss deactivated */
+                       .phymode = mt76_connac_get_phy_mode(phy, vif, band, NULL),
+               },
+               .qos = {
+                       .tag = cpu_to_le16(UNI_BSS_INFO_QBSS),
+                       .len = cpu_to_le16(sizeof(struct mt76_connac_bss_qos_tlv)),
+                       .qos = vif->bss_conf.qos,
+               },
+       };
        int err, conn_type;
        u8 idx, basic_phy;
 
@@ -1508,40 +1552,7 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
                        return err;
        }
 
-       switch (chandef->width) {
-       case NL80211_CHAN_WIDTH_40:
-               rlm_req.rlm.bw = CMD_CBW_40MHZ;
-               break;
-       case NL80211_CHAN_WIDTH_80:
-               rlm_req.rlm.bw = CMD_CBW_80MHZ;
-               break;
-       case NL80211_CHAN_WIDTH_80P80:
-               rlm_req.rlm.bw = CMD_CBW_8080MHZ;
-               break;
-       case NL80211_CHAN_WIDTH_160:
-               rlm_req.rlm.bw = CMD_CBW_160MHZ;
-               break;
-       case NL80211_CHAN_WIDTH_5:
-               rlm_req.rlm.bw = CMD_CBW_5MHZ;
-               break;
-       case NL80211_CHAN_WIDTH_10:
-               rlm_req.rlm.bw = CMD_CBW_10MHZ;
-               break;
-       case NL80211_CHAN_WIDTH_20_NOHT:
-       case NL80211_CHAN_WIDTH_20:
-       default:
-               rlm_req.rlm.bw = CMD_CBW_20MHZ;
-               rlm_req.rlm.ht_op_info = 0;
-               break;
-       }
-
-       if (rlm_req.rlm.control_channel < rlm_req.rlm.center_chan)
-               rlm_req.rlm.sco = 1; /* SCA */
-       else if (rlm_req.rlm.control_channel > rlm_req.rlm.center_chan)
-               rlm_req.rlm.sco = 3; /* SCB */
-
-       return mt76_mcu_send_msg(mdev, MCU_UNI_CMD(BSS_INFO_UPDATE), &rlm_req,
-                                sizeof(rlm_req), true);
+       return mt76_connac_mcu_uni_set_chctx(phy, mvif, NULL);
 }
 EXPORT_SYMBOL_GPL(mt76_connac_mcu_uni_add_bss);
 
index 8166722..7e1c9e8 100644 (file)
@@ -1747,6 +1747,9 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy,
 int mt76_connac_mcu_sta_ba(struct mt76_dev *dev, struct mt76_vif *mvif,
                           struct ieee80211_ampdu_params *params,
                           int cmd, bool enable, bool tx);
+int mt76_connac_mcu_uni_set_chctx(struct mt76_phy *phy,
+                                 struct mt76_vif *vif,
+                                 struct ieee80211_chanctx_conf *ctx);
 int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
                                struct ieee80211_vif *vif,
                                struct mt76_wcid *wcid,