These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / net / wireless / ath / ath10k / htt.h
index 874bf44..2bad50e 100644 (file)
@@ -25,7 +25,9 @@
 #include <net/mac80211.h>
 
 #include "htc.h"
+#include "hw.h"
 #include "rx_desc.h"
+#include "hw.h"
 
 enum htt_dbg_stats_type {
        HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,
@@ -81,10 +83,39 @@ struct htt_ver_req {
  * around the mask + shift defs.
  */
 struct htt_data_tx_desc_frag {
-       __le32 paddr;
-       __le32 len;
+       union {
+               struct double_word_addr {
+                       __le32 paddr;
+                       __le32 len;
+               } __packed dword_addr;
+               struct triple_word_addr {
+                       __le32 paddr_lo;
+                       __le16 paddr_hi;
+                       __le16 len_16;
+               } __packed tword_addr;
+       } __packed;
 } __packed;
 
+struct htt_msdu_ext_desc {
+       __le32 tso_flag[3];
+       __le16 ip_identification;
+       u8 flags;
+       u8 reserved;
+       struct htt_data_tx_desc_frag frags[6];
+};
+
+#define        HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE         BIT(0)
+#define        HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE     BIT(1)
+#define        HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE     BIT(2)
+#define        HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE     BIT(3)
+#define        HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE     BIT(4)
+
+#define HTT_MSDU_CHECKSUM_ENABLE (HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE \
+                                | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE \
+                                | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE \
+                                | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE \
+                                | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE)
+
 enum htt_data_tx_desc_flags0 {
        HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT = 1 << 0,
        HTT_DATA_TX_DESC_FLAGS0_NO_AGGR         = 1 << 1,
@@ -253,6 +284,9 @@ struct htt_aggr_conf {
 } __packed;
 
 #define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32
+struct htt_mgmt_tx_desc_qca99x0 {
+       __le32 rate;
+} __packed;
 
 struct htt_mgmt_tx_desc {
        u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
@@ -261,6 +295,9 @@ struct htt_mgmt_tx_desc {
        __le32 len;
        __le32 vdev_id;
        u8 hdr[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN];
+       union {
+               struct htt_mgmt_tx_desc_qca99x0 qca99x0;
+       } __packed;
 } __packed;
 
 enum htt_mgmt_tx_status {
@@ -271,35 +308,144 @@ enum htt_mgmt_tx_status {
 
 /*=== target -> host messages ===============================================*/
 
-enum htt_t2h_msg_type {
-       HTT_T2H_MSG_TYPE_VERSION_CONF           = 0x0,
-       HTT_T2H_MSG_TYPE_RX_IND                 = 0x1,
-       HTT_T2H_MSG_TYPE_RX_FLUSH               = 0x2,
-       HTT_T2H_MSG_TYPE_PEER_MAP               = 0x3,
-       HTT_T2H_MSG_TYPE_PEER_UNMAP             = 0x4,
-       HTT_T2H_MSG_TYPE_RX_ADDBA               = 0x5,
-       HTT_T2H_MSG_TYPE_RX_DELBA               = 0x6,
-       HTT_T2H_MSG_TYPE_TX_COMPL_IND           = 0x7,
-       HTT_T2H_MSG_TYPE_PKTLOG                 = 0x8,
-       HTT_T2H_MSG_TYPE_STATS_CONF             = 0x9,
-       HTT_T2H_MSG_TYPE_RX_FRAG_IND            = 0xa,
-       HTT_T2H_MSG_TYPE_SEC_IND                = 0xb,
-       HTT_T2H_MSG_TYPE_RC_UPDATE_IND          = 0xc,
-       HTT_T2H_MSG_TYPE_TX_INSPECT_IND         = 0xd,
-       HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION     = 0xe,
-       HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND   = 0xf,
-       HTT_T2H_MSG_TYPE_RX_PN_IND              = 0x10,
-       HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
-       HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND    = 0x12,
+enum htt_main_t2h_msg_type {
+       HTT_MAIN_T2H_MSG_TYPE_VERSION_CONF             = 0x0,
+       HTT_MAIN_T2H_MSG_TYPE_RX_IND                   = 0x1,
+       HTT_MAIN_T2H_MSG_TYPE_RX_FLUSH                 = 0x2,
+       HTT_MAIN_T2H_MSG_TYPE_PEER_MAP                 = 0x3,
+       HTT_MAIN_T2H_MSG_TYPE_PEER_UNMAP               = 0x4,
+       HTT_MAIN_T2H_MSG_TYPE_RX_ADDBA                 = 0x5,
+       HTT_MAIN_T2H_MSG_TYPE_RX_DELBA                 = 0x6,
+       HTT_MAIN_T2H_MSG_TYPE_TX_COMPL_IND             = 0x7,
+       HTT_MAIN_T2H_MSG_TYPE_PKTLOG                   = 0x8,
+       HTT_MAIN_T2H_MSG_TYPE_STATS_CONF               = 0x9,
+       HTT_MAIN_T2H_MSG_TYPE_RX_FRAG_IND              = 0xa,
+       HTT_MAIN_T2H_MSG_TYPE_SEC_IND                  = 0xb,
+       HTT_MAIN_T2H_MSG_TYPE_TX_INSPECT_IND           = 0xd,
+       HTT_MAIN_T2H_MSG_TYPE_MGMT_TX_COMPL_IND        = 0xe,
+       HTT_MAIN_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND     = 0xf,
+       HTT_MAIN_T2H_MSG_TYPE_RX_PN_IND                = 0x10,
+       HTT_MAIN_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND   = 0x11,
+       HTT_MAIN_T2H_MSG_TYPE_TEST,
+       /* keep this last */
+       HTT_MAIN_T2H_NUM_MSGS
+};
+
+enum htt_10x_t2h_msg_type {
+       HTT_10X_T2H_MSG_TYPE_VERSION_CONF              = 0x0,
+       HTT_10X_T2H_MSG_TYPE_RX_IND                    = 0x1,
+       HTT_10X_T2H_MSG_TYPE_RX_FLUSH                  = 0x2,
+       HTT_10X_T2H_MSG_TYPE_PEER_MAP                  = 0x3,
+       HTT_10X_T2H_MSG_TYPE_PEER_UNMAP                = 0x4,
+       HTT_10X_T2H_MSG_TYPE_RX_ADDBA                  = 0x5,
+       HTT_10X_T2H_MSG_TYPE_RX_DELBA                  = 0x6,
+       HTT_10X_T2H_MSG_TYPE_TX_COMPL_IND              = 0x7,
+       HTT_10X_T2H_MSG_TYPE_PKTLOG                    = 0x8,
+       HTT_10X_T2H_MSG_TYPE_STATS_CONF                = 0x9,
+       HTT_10X_T2H_MSG_TYPE_RX_FRAG_IND               = 0xa,
+       HTT_10X_T2H_MSG_TYPE_SEC_IND                   = 0xb,
+       HTT_10X_T2H_MSG_TYPE_RC_UPDATE_IND             = 0xc,
+       HTT_10X_T2H_MSG_TYPE_TX_INSPECT_IND            = 0xd,
+       HTT_10X_T2H_MSG_TYPE_TEST                      = 0xe,
+       HTT_10X_T2H_MSG_TYPE_CHAN_CHANGE               = 0xf,
+       HTT_10X_T2H_MSG_TYPE_AGGR_CONF                 = 0x11,
+       HTT_10X_T2H_MSG_TYPE_STATS_NOUPLOAD            = 0x12,
+       HTT_10X_T2H_MSG_TYPE_MGMT_TX_COMPL_IND         = 0x13,
+       /* keep this last */
+       HTT_10X_T2H_NUM_MSGS
+};
+
+enum htt_tlv_t2h_msg_type {
+       HTT_TLV_T2H_MSG_TYPE_VERSION_CONF              = 0x0,
+       HTT_TLV_T2H_MSG_TYPE_RX_IND                    = 0x1,
+       HTT_TLV_T2H_MSG_TYPE_RX_FLUSH                  = 0x2,
+       HTT_TLV_T2H_MSG_TYPE_PEER_MAP                  = 0x3,
+       HTT_TLV_T2H_MSG_TYPE_PEER_UNMAP                = 0x4,
+       HTT_TLV_T2H_MSG_TYPE_RX_ADDBA                  = 0x5,
+       HTT_TLV_T2H_MSG_TYPE_RX_DELBA                  = 0x6,
+       HTT_TLV_T2H_MSG_TYPE_TX_COMPL_IND              = 0x7,
+       HTT_TLV_T2H_MSG_TYPE_PKTLOG                    = 0x8,
+       HTT_TLV_T2H_MSG_TYPE_STATS_CONF                = 0x9,
+       HTT_TLV_T2H_MSG_TYPE_RX_FRAG_IND               = 0xa,
+       HTT_TLV_T2H_MSG_TYPE_SEC_IND                   = 0xb,
+       HTT_TLV_T2H_MSG_TYPE_RC_UPDATE_IND             = 0xc, /* deprecated */
+       HTT_TLV_T2H_MSG_TYPE_TX_INSPECT_IND            = 0xd,
+       HTT_TLV_T2H_MSG_TYPE_MGMT_TX_COMPL_IND         = 0xe,
+       HTT_TLV_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND      = 0xf,
+       HTT_TLV_T2H_MSG_TYPE_RX_PN_IND                 = 0x10,
+       HTT_TLV_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND    = 0x11,
+       HTT_TLV_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND       = 0x12,
        /* 0x13 reservd */
-       HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE    = 0x14,
+       HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE       = 0x14,
+       HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE               = 0x15,
+       HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR           = 0x16,
+       HTT_TLV_T2H_MSG_TYPE_TEST,
+       /* keep this last */
+       HTT_TLV_T2H_NUM_MSGS
+};
 
-       /* FIXME: Do not depend on this event id. Numbering of this event id is
-        * broken across different firmware revisions and HTT version fails to
-        * indicate this.
-        */
-       HTT_T2H_MSG_TYPE_TEST,
+enum htt_10_4_t2h_msg_type {
+       HTT_10_4_T2H_MSG_TYPE_VERSION_CONF           = 0x0,
+       HTT_10_4_T2H_MSG_TYPE_RX_IND                 = 0x1,
+       HTT_10_4_T2H_MSG_TYPE_RX_FLUSH               = 0x2,
+       HTT_10_4_T2H_MSG_TYPE_PEER_MAP               = 0x3,
+       HTT_10_4_T2H_MSG_TYPE_PEER_UNMAP             = 0x4,
+       HTT_10_4_T2H_MSG_TYPE_RX_ADDBA               = 0x5,
+       HTT_10_4_T2H_MSG_TYPE_RX_DELBA               = 0x6,
+       HTT_10_4_T2H_MSG_TYPE_TX_COMPL_IND           = 0x7,
+       HTT_10_4_T2H_MSG_TYPE_PKTLOG                 = 0x8,
+       HTT_10_4_T2H_MSG_TYPE_STATS_CONF             = 0x9,
+       HTT_10_4_T2H_MSG_TYPE_RX_FRAG_IND            = 0xa,
+       HTT_10_4_T2H_MSG_TYPE_SEC_IND                = 0xb,
+       HTT_10_4_T2H_MSG_TYPE_RC_UPDATE_IND          = 0xc,
+       HTT_10_4_T2H_MSG_TYPE_TX_INSPECT_IND         = 0xd,
+       HTT_10_4_T2H_MSG_TYPE_MGMT_TX_COMPL_IND      = 0xe,
+       HTT_10_4_T2H_MSG_TYPE_CHAN_CHANGE            = 0xf,
+       HTT_10_4_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND   = 0x10,
+       HTT_10_4_T2H_MSG_TYPE_RX_PN_IND              = 0x11,
+       HTT_10_4_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x12,
+       HTT_10_4_T2H_MSG_TYPE_TEST                   = 0x13,
+       HTT_10_4_T2H_MSG_TYPE_EN_STATS               = 0x14,
+       HTT_10_4_T2H_MSG_TYPE_AGGR_CONF              = 0x15,
+       HTT_10_4_T2H_MSG_TYPE_TX_FETCH_IND           = 0x16,
+       HTT_10_4_T2H_MSG_TYPE_TX_FETCH_CONF          = 0x17,
+       HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD         = 0x18,
+       /* 0x19 to 0x2f are reserved */
+       HTT_10_4_T2H_MSG_TYPE_TX_LOW_LATENCY_IND     = 0x30,
+       /* keep this last */
+       HTT_10_4_T2H_NUM_MSGS
+};
 
+enum htt_t2h_msg_type {
+       HTT_T2H_MSG_TYPE_VERSION_CONF,
+       HTT_T2H_MSG_TYPE_RX_IND,
+       HTT_T2H_MSG_TYPE_RX_FLUSH,
+       HTT_T2H_MSG_TYPE_PEER_MAP,
+       HTT_T2H_MSG_TYPE_PEER_UNMAP,
+       HTT_T2H_MSG_TYPE_RX_ADDBA,
+       HTT_T2H_MSG_TYPE_RX_DELBA,
+       HTT_T2H_MSG_TYPE_TX_COMPL_IND,
+       HTT_T2H_MSG_TYPE_PKTLOG,
+       HTT_T2H_MSG_TYPE_STATS_CONF,
+       HTT_T2H_MSG_TYPE_RX_FRAG_IND,
+       HTT_T2H_MSG_TYPE_SEC_IND,
+       HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
+       HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
+       HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
+       HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
+       HTT_T2H_MSG_TYPE_RX_PN_IND,
+       HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
+       HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND,
+       HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE,
+       HTT_T2H_MSG_TYPE_CHAN_CHANGE,
+       HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
+       HTT_T2H_MSG_TYPE_AGGR_CONF,
+       HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
+       HTT_T2H_MSG_TYPE_TEST,
+       HTT_T2H_MSG_TYPE_EN_STATS,
+       HTT_T2H_MSG_TYPE_TX_FETCH_IND,
+       HTT_T2H_MSG_TYPE_TX_FETCH_CONF,
+       HTT_T2H_MSG_TYPE_TX_LOW_LATENCY_IND,
        /* keep this last */
        HTT_T2H_NUM_MSGS
 };
@@ -1222,6 +1368,7 @@ struct htt_tx_done {
        u32 msdu_id;
        bool discard;
        bool no_ack;
+       bool success;
 };
 
 struct htt_peer_map_event {
@@ -1248,6 +1395,12 @@ struct ath10k_htt {
        u8 target_version_major;
        u8 target_version_minor;
        struct completion target_version_received;
+       enum ath10k_fw_htt_op_version op_version;
+       u8 max_num_amsdu;
+       u8 max_num_ampdu;
+
+       const enum htt_t2h_msg_type *t2h_msg_types;
+       u32 t2h_msg_types_max;
 
        struct {
                /*
@@ -1332,9 +1485,9 @@ struct ath10k_htt {
        spinlock_t tx_lock;
        int max_num_pending_tx;
        int num_pending_tx;
+       int num_pending_mgmt_tx;
        struct idr pending_tx;
        wait_queue_head_t empty_tx_wq;
-       struct dma_pool *tx_pool;
 
        /* set if host-fw communication goes haywire
         * used to avoid further failures */
@@ -1350,6 +1503,16 @@ struct ath10k_htt {
 
        /* rx_status template */
        struct ieee80211_rx_status rx_status;
+
+       struct {
+               dma_addr_t paddr;
+               struct htt_msdu_ext_desc *vaddr;
+       } frag_desc;
+
+       struct {
+               dma_addr_t paddr;
+               struct ath10k_htt_txbuf *vaddr;
+       } txbuf;
 };
 
 #define RX_HTT_HDR_STATUS_LEN 64
@@ -1402,6 +1565,12 @@ struct htt_rx_desc {
 #define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
 #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
 
+/* These values are default in most firmware revisions and apparently are a
+ * sweet spot performance wise.
+ */
+#define ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT 3
+#define ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT 64
+
 int ath10k_htt_connect(struct ath10k_htt *htt);
 int ath10k_htt_init(struct ath10k *ar);
 int ath10k_htt_setup(struct ath10k_htt *htt);
@@ -1417,12 +1586,14 @@ void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
 void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
 int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
 int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie);
+int ath10k_htt_send_frag_desc_bank_cfg(struct ath10k_htt *htt);
 int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt);
 int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
                                u8 max_subfrms_ampdu,
                                u8 max_subfrms_amsdu);
+void ath10k_htt_hif_tx_complete(struct ath10k *ar, struct sk_buff *skb);
 
-void __ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);
+void __ath10k_htt_tx_dec_pending(struct ath10k_htt *htt, bool limit_mgmt_desc);
 int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb);
 void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
 int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *);