* Drivers indicate that they use this model by implementing the .wake_tx_queue
  * driver operation.
  *
- * Intermediate queues (struct ieee80211_txq) are kept per-sta per-tid, with a
- * single per-vif queue for multicast data frames.
+ * Intermediate queues (struct ieee80211_txq) are kept per-sta per-tid, with
+ * another per-sta for non-data/non-mgmt and bufferable management frames, and
+ * a single per-vif queue for multicast data frames.
  *
  * The driver is expected to initialize its private per-queue data for stations
  * and interfaces in the .add_interface and .sta_add ops.
  *     unlimited.
  * @support_p2p_ps: indicates whether the STA supports P2P PS mechanism or not.
  * @max_rc_amsdu_len: Maximum A-MSDU size in bytes recommended by rate control.
- * @txq: per-TID data TX queues (if driver uses the TXQ abstraction)
+ * @txq: per-TID data TX queues (if driver uses the TXQ abstraction); note that
+ *     the last entry (%IEEE80211_NUM_TIDS) is used for non-data frames
  */
 struct ieee80211_sta {
        u32 supp_rates[NUM_NL80211_BANDS];
        bool support_p2p_ps;
        u16 max_rc_amsdu_len;
 
-       struct ieee80211_txq *txq[IEEE80211_NUM_TIDS];
+       struct ieee80211_txq *txq[IEEE80211_NUM_TIDS + 1];
 
        /* must be last */
        u8 drv_priv[0] __aligned(sizeof(void *));
  *
  * @vif: &struct ieee80211_vif pointer from the add_interface callback.
  * @sta: station table entry, %NULL for per-vif queue
- * @tid: the TID for this queue (unused for per-vif queue)
+ * @tid: the TID for this queue (unused for per-vif queue),
+ *     %IEEE80211_NUM_TIDS for non-data (if enabled)
  * @ac: the AC for this queue
  * @drv_priv: driver private area, sized by hw->txq_data_size
  *
  * @IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP: The driver (or firmware) doesn't
  *     support QoS NDP for AP probing - that's most likely a driver bug.
  *
+ * @IEEE80211_HW_BUFF_MMPDU_TXQ: use the TXQ for bufferable MMPDUs, this of
+ *     course requires the driver to use TXQs to start with.
+ *
  * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays
  */
 enum ieee80211_hw_flags {
        IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA,
        IEEE80211_HW_DEAUTH_NEED_MGD_TX_PREP,
        IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP,
+       IEEE80211_HW_BUFF_MMPDU_TXQ,
 
        /* keep last, obviously */
        NUM_IEEE80211_HW_FLAGS
 
  *
  * Copyright 2007      Johannes Berg <johannes@sipsolutions.net>
  * Copyright 2013-2014  Intel Mobile Communications GmbH
+ * Copyright (C) 2018 Intel Corporation
  *
  * GPLv2
  *
        FLAG(SUPPORTS_TDLS_BUFFER_STA),
        FLAG(DEAUTH_NEED_MGD_TX_PREP),
        FLAG(DOESNT_SUPPORT_QOS_NDP),
+       FLAG(BUFF_MMPDU_TXQ),
 #undef FLAG
 };
 
 
 {
        struct sta_info *sta = file->private_data;
        struct ieee80211_local *local = sta->local;
-       size_t bufsz = AQM_TXQ_ENTRY_LEN*(IEEE80211_NUM_TIDS+1);
+       size_t bufsz = AQM_TXQ_ENTRY_LEN * (IEEE80211_NUM_TIDS + 2);
        char *buf = kzalloc(bufsz, GFP_KERNEL), *p = buf;
        struct txq_info *txqi;
        ssize_t rv;
                       bufsz+buf-p,
                       "tid ac backlog-bytes backlog-packets new-flows drops marks overlimit collisions tx-bytes tx-packets flags\n");
 
-       for (i = 0; i < IEEE80211_NUM_TIDS; i++) {
+       for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
+               if (!sta->sta.txq[i])
+                       continue;
                txqi = to_txq_info(sta->sta.txq[i]);
                p += scnprintf(p, bufsz+buf-p,
                               "%d %d %u %u %u %u %u %u %u %u %u 0x%lx(%s%s%s)\n",
 
        if (!sta->sta.txq[0])
                return;
 
-       for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) {
+       for (tid = 0; tid < IEEE80211_NUM_TIDS; tid++) {
                if (txq_has_queue(sta->sta.txq[tid]))
                        set_bit(tid, &sta->txq_buffered_tids);
                else
 
 
        if (sta->sta.txq[0]) {
                for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
-                       struct txq_info *txqi = to_txq_info(sta->sta.txq[i]);
+                       struct txq_info *txqi;
+
+                       if (!sta->sta.txq[i])
+                               continue;
+
+                       txqi = to_txq_info(sta->sta.txq[i]);
 
                        spin_lock_bh(&fq->lock);
                        ieee80211_txq_purge(local, txqi);
                for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
                        struct txq_info *txq = txq_data + i * size;
 
+                       /* might not do anything for the bufferable MMPDU TXQ */
                        ieee80211_txq_init(sdata, sta, txq, i);
                }
        }
        if (!ieee80211_hw_check(&local->hw, AP_LINK_PS))
                drv_sta_notify(local, sdata, STA_NOTIFY_AWAKE, &sta->sta);
 
-       if (sta->sta.txq[0]) {
-               for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
-                       if (!txq_has_queue(sta->sta.txq[i]))
-                               continue;
+       for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) {
+               if (!sta->sta.txq[i] || !txq_has_queue(sta->sta.txq[i]))
+                       continue;
 
-                       drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i]));
-               }
+               drv_wake_tx_queue(local, to_txq_info(sta->sta.txq[i]));
        }
 
        skb_queue_head_init(&pending);
                        return;
 
                for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) {
-                       if (!(driver_release_tids & BIT(tid)) ||
+                       if (!sta->sta.txq[tid] ||
+                           !(driver_release_tids & BIT(tid)) ||
                            txq_has_queue(sta->sta.txq[tid]))
                                continue;
 
 
            (info->control.flags & IEEE80211_TX_CTRL_PS_RESPONSE))
                return NULL;
 
-       if (!ieee80211_is_data_present(hdr->frame_control))
-               return NULL;
-
-       if (sta) {
+       if (unlikely(!ieee80211_is_data_present(hdr->frame_control))) {
+               if ((!ieee80211_is_mgmt(hdr->frame_control) ||
+                    ieee80211_is_bufferable_mmpdu(hdr->frame_control)) &&
+                   sta && sta->uploaded) {
+                       /*
+                        * This will be NULL if the driver didn't set the
+                        * opt-in hardware flag.
+                        */
+                       txq = sta->sta.txq[IEEE80211_NUM_TIDS];
+               }
+       } else if (sta) {
                u8 tid = skb->priority & IEEE80211_QOS_CTL_TID_MASK;
 
                if (!sta->uploaded)
 
        txqi->txq.vif = &sdata->vif;
 
-       if (sta) {
-               txqi->txq.sta = &sta->sta;
-               sta->sta.txq[tid] = &txqi->txq;
-               txqi->txq.tid = tid;
-               txqi->txq.ac = ieee80211_ac_from_tid(tid);
-       } else {
+       if (!sta) {
                sdata->vif.txq = &txqi->txq;
                txqi->txq.tid = 0;
                txqi->txq.ac = IEEE80211_AC_BE;
+
+               return;
+       }
+
+       if (tid == IEEE80211_NUM_TIDS) {
+               /* Drivers need to opt in to the bufferable MMPDU TXQ */
+               if (!ieee80211_hw_check(&sdata->local->hw, BUFF_MMPDU_TXQ))
+                       return;
+               txqi->txq.ac = IEEE80211_AC_VO;
+       } else {
+               txqi->txq.ac = ieee80211_ac_from_tid(tid);
        }
+
+       txqi->txq.sta = &sta->sta;
+       txqi->txq.tid = tid;
+       sta->sta.txq[tid] = &txqi->txq;
 }
 
 void ieee80211_txq_purge(struct ieee80211_local *local,