Commit 5d3a4a4b authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: mt7615: introduce rlm tlv in bss_info mcu command

Introduce rlm tlv header in bss_info mcu command in order to
inform the mcu about operating channel. Rlm header is necessary only if
the mcu is running low power functionalities (e.g offloaded scan)
Co-developed-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent bb366c5b
...@@ -410,15 +410,15 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw, ...@@ -410,15 +410,15 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
u32 changed) u32 changed)
{ {
struct mt7615_dev *dev = mt7615_hw_dev(hw); struct mt7615_dev *dev = mt7615_hw_dev(hw);
struct mt7615_phy *phy = mt7615_hw_phy(hw);
mutex_lock(&dev->mt76.mutex); mutex_lock(&dev->mt76.mutex);
if (changed & BSS_CHANGED_ASSOC) if (changed & BSS_CHANGED_ASSOC)
mt7615_mcu_add_bss_info(dev, vif, info->assoc); mt7615_mcu_add_bss_info(phy, vif, info->assoc);
if (changed & BSS_CHANGED_ERP_SLOT) { if (changed & BSS_CHANGED_ERP_SLOT) {
int slottime = info->use_short_slot ? 9 : 20; int slottime = info->use_short_slot ? 9 : 20;
struct mt7615_phy *phy = mt7615_hw_phy(hw);
if (slottime != phy->slottime) { if (slottime != phy->slottime) {
phy->slottime = slottime; phy->slottime = slottime;
...@@ -427,7 +427,7 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw, ...@@ -427,7 +427,7 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
} }
if (changed & BSS_CHANGED_BEACON_ENABLED) { if (changed & BSS_CHANGED_BEACON_ENABLED) {
mt7615_mcu_add_bss_info(dev, vif, info->enable_beacon); mt7615_mcu_add_bss_info(phy, vif, info->enable_beacon);
mt7615_mcu_sta_add(dev, vif, NULL, info->enable_beacon); mt7615_mcu_sta_add(dev, vif, NULL, info->enable_beacon);
} }
......
...@@ -967,10 +967,11 @@ mt7615_mcu_wtbl_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, ...@@ -967,10 +967,11 @@ mt7615_mcu_wtbl_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta,
} }
static int static int
mt7615_mcu_add_bss(struct mt7615_dev *dev, struct ieee80211_vif *vif, mt7615_mcu_add_bss(struct mt7615_phy *phy, struct ieee80211_vif *vif,
bool enable) bool enable)
{ {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct mt7615_dev *dev = phy->dev;
struct sk_buff *skb; struct sk_buff *skb;
skb = mt7615_mcu_alloc_sta_req(mvif, NULL); skb = mt7615_mcu_alloc_sta_req(mvif, NULL);
...@@ -1244,12 +1245,15 @@ mt7615_mcu_uni_ctrl_pm_state(struct mt7615_dev *dev, int band, int state) ...@@ -1244,12 +1245,15 @@ mt7615_mcu_uni_ctrl_pm_state(struct mt7615_dev *dev, int band, int state)
} }
static int static int
mt7615_mcu_uni_add_bss(struct mt7615_dev *dev, mt7615_mcu_uni_add_bss(struct mt7615_phy *phy,
struct ieee80211_vif *vif, bool enable) struct ieee80211_vif *vif, bool enable)
{ {
struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv; struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
int freq1 = chandef->center_freq1, freq2 = chandef->center_freq2;
struct mt7615_dev *dev = phy->dev;
struct {
struct { struct {
struct req_hdr {
u8 bss_idx; u8 bss_idx;
u8 pad[3]; u8 pad[3];
} __packed hdr; } __packed hdr;
...@@ -1267,12 +1271,18 @@ mt7615_mcu_uni_add_bss(struct mt7615_dev *dev, ...@@ -1267,12 +1271,18 @@ mt7615_mcu_uni_add_bss(struct mt7615_dev *dev,
__le16 bmc_tx_wlan_idx; __le16 bmc_tx_wlan_idx;
__le16 bcn_interval; __le16 bcn_interval;
u8 dtim_period; u8 dtim_period;
u8 phymode; u8 phymode; /* bit(0): A
* bit(1): B
* bit(2): G
* bit(3): GN
* bit(4): AN
* bit(5): AC
*/
__le16 sta_idx; __le16 sta_idx;
u8 nonht_basic_phy; u8 nonht_basic_phy;
u8 pad[3]; u8 pad[3];
} __packed basic; } __packed basic;
} req = { } basic_req = {
.hdr = { .hdr = {
.bss_idx = mvif->idx, .bss_idx = mvif->idx,
}, },
...@@ -1285,17 +1295,53 @@ mt7615_mcu_uni_add_bss(struct mt7615_dev *dev, ...@@ -1285,17 +1295,53 @@ mt7615_mcu_uni_add_bss(struct mt7615_dev *dev,
.band_idx = mvif->band_idx, .band_idx = mvif->band_idx,
.wmm_idx = mvif->wmm_idx, .wmm_idx = mvif->wmm_idx,
.active = enable, .active = enable,
.phymode = 0x38,
},
};
struct {
struct {
u8 bss_idx;
u8 pad[3];
} __packed hdr;
struct rlm_tlv {
__le16 tag;
__le16 len;
u8 control_channel;
u8 center_chan;
u8 center_chan2;
u8 bw;
u8 tx_streams;
u8 rx_streams;
u8 short_st;
u8 ht_op_info;
u8 sco;
u8 pad[3];
} __packed rlm;
} __packed rlm_req = {
.hdr = {
.bss_idx = mvif->idx,
},
.rlm = {
.tag = cpu_to_le16(UNI_BSS_INFO_RLM),
.len = cpu_to_le16(sizeof(struct rlm_tlv)),
.control_channel = chandef->chan->hw_value,
.center_chan = ieee80211_frequency_to_channel(freq1),
.center_chan2 = ieee80211_frequency_to_channel(freq2),
.tx_streams = hweight8(phy->mt76->antenna_mask),
.rx_streams = phy->chainmask,
.short_st = true,
}, },
}; };
u8 idx, tx_wlan_idx = 0; u8 idx, tx_wlan_idx = 0;
int err;
idx = mvif->omac_idx > EXT_BSSID_START ? HW_BSSID_0 : mvif->omac_idx; idx = mvif->omac_idx > EXT_BSSID_START ? HW_BSSID_0 : mvif->omac_idx;
req.basic.hw_bss_idx = idx; basic_req.basic.hw_bss_idx = idx;
switch (vif->type) { switch (vif->type) {
case NL80211_IFTYPE_MESH_POINT: case NL80211_IFTYPE_MESH_POINT:
case NL80211_IFTYPE_AP: case NL80211_IFTYPE_AP:
req.basic.conn_type = cpu_to_le32(CONNECTION_INFRA_AP); basic_req.basic.conn_type = cpu_to_le32(CONNECTION_INFRA_AP);
tx_wlan_idx = mvif->sta.wcid.idx; tx_wlan_idx = mvif->sta.wcid.idx;
break; break;
case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_STATION:
...@@ -1314,20 +1360,59 @@ mt7615_mcu_uni_add_bss(struct mt7615_dev *dev, ...@@ -1314,20 +1360,59 @@ mt7615_mcu_uni_add_bss(struct mt7615_dev *dev,
tx_wlan_idx = msta->wcid.idx; tx_wlan_idx = msta->wcid.idx;
rcu_read_unlock(); rcu_read_unlock();
} }
req.basic.conn_type = cpu_to_le32(CONNECTION_INFRA_STA); basic_req.basic.conn_type = cpu_to_le32(CONNECTION_INFRA_STA);
break; break;
default: default:
WARN_ON(1); WARN_ON(1);
break; break;
} }
memcpy(req.basic.bssid, vif->bss_conf.bssid, ETH_ALEN); memcpy(basic_req.basic.bssid, vif->bss_conf.bssid, ETH_ALEN);
req.basic.bmc_tx_wlan_idx = cpu_to_le16(tx_wlan_idx); basic_req.basic.bmc_tx_wlan_idx = cpu_to_le16(tx_wlan_idx);
req.basic.sta_idx = cpu_to_le16(tx_wlan_idx); basic_req.basic.sta_idx = cpu_to_le16(tx_wlan_idx);
req.basic.conn_state = !enable; basic_req.basic.conn_state = !enable;
err = __mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_BSS_INFO_UPDATE,
&basic_req, sizeof(basic_req), true);
if (err < 0)
return err;
if (!mt7615_firmware_offload(dev))
return 0;
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;
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(&dev->mt76, MCU_UNI_CMD_BSS_INFO_UPDATE, return __mt76_mcu_send_msg(&dev->mt76, MCU_UNI_CMD_BSS_INFO_UPDATE,
&req, sizeof(req), true); &rlm_req, sizeof(rlm_req), true);
} }
static int static int
......
...@@ -423,6 +423,7 @@ enum { ...@@ -423,6 +423,7 @@ enum {
enum { enum {
UNI_BSS_INFO_BASIC = 0, UNI_BSS_INFO_BASIC = 0,
UNI_BSS_INFO_RLM = 2,
UNI_BSS_INFO_BCN_CONTENT = 7, UNI_BSS_INFO_BCN_CONTENT = 7,
}; };
......
...@@ -166,7 +166,7 @@ struct mt7615_phy { ...@@ -166,7 +166,7 @@ struct mt7615_phy {
#define mt7615_mcu_add_rx_ba(dev, ...) (dev)->mcu_ops->add_rx_ba((dev), __VA_ARGS__) #define mt7615_mcu_add_rx_ba(dev, ...) (dev)->mcu_ops->add_rx_ba((dev), __VA_ARGS__)
#define mt7615_mcu_sta_add(dev, ...) (dev)->mcu_ops->sta_add((dev), __VA_ARGS__) #define mt7615_mcu_sta_add(dev, ...) (dev)->mcu_ops->sta_add((dev), __VA_ARGS__)
#define mt7615_mcu_add_dev_info(dev, ...) (dev)->mcu_ops->add_dev_info((dev), __VA_ARGS__) #define mt7615_mcu_add_dev_info(dev, ...) (dev)->mcu_ops->add_dev_info((dev), __VA_ARGS__)
#define mt7615_mcu_add_bss_info(dev, ...) (dev)->mcu_ops->add_bss_info((dev), __VA_ARGS__) #define mt7615_mcu_add_bss_info(phy, ...) (phy->dev)->mcu_ops->add_bss_info((phy), __VA_ARGS__)
#define mt7615_mcu_add_beacon(dev, ...) (dev)->mcu_ops->add_beacon_offload((dev), __VA_ARGS__) #define mt7615_mcu_add_beacon(dev, ...) (dev)->mcu_ops->add_beacon_offload((dev), __VA_ARGS__)
#define mt7615_mcu_set_pm(dev, ...) (dev)->mcu_ops->set_pm_state((dev), __VA_ARGS__) #define mt7615_mcu_set_pm(dev, ...) (dev)->mcu_ops->set_pm_state((dev), __VA_ARGS__)
struct mt7615_mcu_ops { struct mt7615_mcu_ops {
...@@ -181,7 +181,7 @@ struct mt7615_mcu_ops { ...@@ -181,7 +181,7 @@ struct mt7615_mcu_ops {
struct ieee80211_sta *sta, bool enable); struct ieee80211_sta *sta, bool enable);
int (*add_dev_info)(struct mt7615_dev *dev, int (*add_dev_info)(struct mt7615_dev *dev,
struct ieee80211_vif *vif, bool enable); struct ieee80211_vif *vif, bool enable);
int (*add_bss_info)(struct mt7615_dev *dev, struct ieee80211_vif *vif, int (*add_bss_info)(struct mt7615_phy *phy, struct ieee80211_vif *vif,
bool enable); bool enable);
int (*add_beacon_offload)(struct mt7615_dev *dev, int (*add_beacon_offload)(struct mt7615_dev *dev,
struct ieee80211_hw *hw, struct ieee80211_hw *hw,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment