OSDN Git Service

mt76: mt7915: introduce mt7915_mcu_twt_agrt_update mcu command
authorLorenzo Bianconi <lorenzo@kernel.org>
Thu, 23 Sep 2021 14:29:31 +0000 (16:29 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 20 Oct 2021 08:36:49 +0000 (10:36 +0200)
This is a preliminary patch to add TWT support to mt7915

Tested-by: Peter Chiu <chui-hao.chiu@mediatek.com>
Tested-by: Evelyn Tsai <evelyn.tsai@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
drivers/net/wireless/mediatek/mt76/mt7915/mcu.h
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h

index c6fd14f..82f6258 100644 (file)
@@ -3949,3 +3949,53 @@ int mt7915_mcu_update_bss_color(struct mt7915_dev *dev, struct ieee80211_vif *vi
        return mt76_mcu_skb_send_msg(&dev->mt76, skb,
                                     MCU_EXT_CMD(BSS_INFO_UPDATE), true);
 }
+
+#define TWT_AGRT_TRIGGER       BIT(0)
+#define TWT_AGRT_ANNOUNCE      BIT(1)
+#define TWT_AGRT_PROTECT       BIT(2)
+
+int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
+                              struct mt7915_vif *mvif,
+                              struct mt7915_twt_flow *flow,
+                              int cmd)
+{
+       struct {
+               u8 tbl_idx;
+               u8 cmd;
+               u8 own_mac_idx;
+               u8 flowid; /* 0xff for group id */
+               __le16 peer_id; /* specify the peer_id (msb=0)
+                                * or group_id (msb=1)
+                                */
+               u8 duration; /* 256 us */
+               u8 bss_idx;
+               __le64 start_tsf;
+               __le16 mantissa;
+               u8 exponent;
+               u8 is_ap;
+               u8 agrt_params;
+               u8 rsv[23];
+       } __packed req = {
+               .tbl_idx = flow->table_id,
+               .cmd = cmd,
+               .own_mac_idx = mvif->omac_idx,
+               .flowid = flow->id,
+               .peer_id = cpu_to_le16(flow->wcid),
+               .duration = flow->duration,
+               .bss_idx = mvif->idx,
+               .start_tsf = cpu_to_le64(flow->tsf),
+               .mantissa = flow->mantissa,
+               .exponent = flow->exp,
+               .is_ap = true,
+       };
+
+       if (flow->protection)
+               req.agrt_params |= TWT_AGRT_PROTECT;
+       if (!flow->flowtype)
+               req.agrt_params |= TWT_AGRT_ANNOUNCE;
+       if (flow->trigger)
+               req.agrt_params |= TWT_AGRT_TRIGGER;
+
+       return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TWT_AGRT_UPDATE),
+                                &req, sizeof(req), true);
+}
index e026592..0bd66c5 100644 (file)
@@ -277,6 +277,7 @@ enum {
        MCU_EXT_CMD_MWDS_SUPPORT = 0x80,
        MCU_EXT_CMD_SET_SER_TRIGGER = 0x81,
        MCU_EXT_CMD_SCS_CTRL = 0x82,
+       MCU_EXT_CMD_TWT_AGRT_UPDATE = 0x94,
        MCU_EXT_CMD_FW_DBG_CTRL = 0x95,
        MCU_EXT_CMD_SET_RDD_TH = 0x9d,
        MCU_EXT_CMD_MURU_CTRL = 0x9f,
@@ -287,6 +288,14 @@ enum {
 };
 
 enum {
+       MCU_TWT_AGRT_ADD,
+       MCU_TWT_AGRT_MODIFY,
+       MCU_TWT_AGRT_DELETE,
+       MCU_TWT_AGRT_TEARDOWN,
+       MCU_TWT_AGRT_GET_TSF,
+};
+
+enum {
        MCU_WA_PARAM_CMD_QUERY,
        MCU_WA_PARAM_CMD_SET,
        MCU_WA_PARAM_CMD_CAPABILITY,
index 2df22fa..9e9fea3 100644 (file)
@@ -74,6 +74,22 @@ struct mt7915_sta_key_conf {
        u8 key[16];
 };
 
+struct mt7915_twt_flow {
+       struct list_head list;
+       u64 start_tsf;
+       u64 tsf;
+       u32 duration;
+       u16 wcid;
+       __le16 mantissa;
+       u8 exp;
+       u8 table_id;
+       u8 id;
+       u8 protection:1;
+       u8 flowtype:1;
+       u8 trigger:1;
+       u8 sched:1;
+};
+
 struct mt7915_sta {
        struct mt76_wcid wcid; /* must be first */
 
@@ -342,6 +358,10 @@ int mt7915_dma_init(struct mt7915_dev *dev);
 void mt7915_dma_prefetch(struct mt7915_dev *dev);
 void mt7915_dma_cleanup(struct mt7915_dev *dev);
 int mt7915_mcu_init(struct mt7915_dev *dev);
+int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
+                              struct mt7915_vif *mvif,
+                              struct mt7915_twt_flow *flow,
+                              int cmd);
 int mt7915_mcu_add_dev_info(struct mt7915_phy *phy,
                            struct ieee80211_vif *vif, bool enable);
 int mt7915_mcu_add_bss_info(struct mt7915_phy *phy,