root/drivers/net/wireless/ath/ath10k/htt.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ath10k_htt_connect
  2. ath10k_htt_init
  3. ath10k_htt_verify_version
  4. ath10k_htt_setup

   1 // SPDX-License-Identifier: ISC
   2 /*
   3  * Copyright (c) 2005-2011 Atheros Communications Inc.
   4  * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
   5  */
   6 
   7 #include <linux/slab.h>
   8 #include <linux/if_ether.h>
   9 
  10 #include "htt.h"
  11 #include "core.h"
  12 #include "debug.h"
  13 
  14 static const enum htt_t2h_msg_type htt_main_t2h_msg_types[] = {
  15         [HTT_MAIN_T2H_MSG_TYPE_VERSION_CONF] = HTT_T2H_MSG_TYPE_VERSION_CONF,
  16         [HTT_MAIN_T2H_MSG_TYPE_RX_IND] = HTT_T2H_MSG_TYPE_RX_IND,
  17         [HTT_MAIN_T2H_MSG_TYPE_RX_FLUSH] = HTT_T2H_MSG_TYPE_RX_FLUSH,
  18         [HTT_MAIN_T2H_MSG_TYPE_PEER_MAP] = HTT_T2H_MSG_TYPE_PEER_MAP,
  19         [HTT_MAIN_T2H_MSG_TYPE_PEER_UNMAP] = HTT_T2H_MSG_TYPE_PEER_UNMAP,
  20         [HTT_MAIN_T2H_MSG_TYPE_RX_ADDBA] = HTT_T2H_MSG_TYPE_RX_ADDBA,
  21         [HTT_MAIN_T2H_MSG_TYPE_RX_DELBA] = HTT_T2H_MSG_TYPE_RX_DELBA,
  22         [HTT_MAIN_T2H_MSG_TYPE_TX_COMPL_IND] = HTT_T2H_MSG_TYPE_TX_COMPL_IND,
  23         [HTT_MAIN_T2H_MSG_TYPE_PKTLOG] = HTT_T2H_MSG_TYPE_PKTLOG,
  24         [HTT_MAIN_T2H_MSG_TYPE_STATS_CONF] = HTT_T2H_MSG_TYPE_STATS_CONF,
  25         [HTT_MAIN_T2H_MSG_TYPE_RX_FRAG_IND] = HTT_T2H_MSG_TYPE_RX_FRAG_IND,
  26         [HTT_MAIN_T2H_MSG_TYPE_SEC_IND] = HTT_T2H_MSG_TYPE_SEC_IND,
  27         [HTT_MAIN_T2H_MSG_TYPE_TX_INSPECT_IND] =
  28                 HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
  29         [HTT_MAIN_T2H_MSG_TYPE_MGMT_TX_COMPL_IND] =
  30                 HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
  31         [HTT_MAIN_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND] =
  32                 HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
  33         [HTT_MAIN_T2H_MSG_TYPE_RX_PN_IND] = HTT_T2H_MSG_TYPE_RX_PN_IND,
  34         [HTT_MAIN_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND] =
  35                 HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
  36         [HTT_MAIN_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
  37 };
  38 
  39 static const enum htt_t2h_msg_type htt_10x_t2h_msg_types[] = {
  40         [HTT_10X_T2H_MSG_TYPE_VERSION_CONF] = HTT_T2H_MSG_TYPE_VERSION_CONF,
  41         [HTT_10X_T2H_MSG_TYPE_RX_IND] = HTT_T2H_MSG_TYPE_RX_IND,
  42         [HTT_10X_T2H_MSG_TYPE_RX_FLUSH] = HTT_T2H_MSG_TYPE_RX_FLUSH,
  43         [HTT_10X_T2H_MSG_TYPE_PEER_MAP] = HTT_T2H_MSG_TYPE_PEER_MAP,
  44         [HTT_10X_T2H_MSG_TYPE_PEER_UNMAP] = HTT_T2H_MSG_TYPE_PEER_UNMAP,
  45         [HTT_10X_T2H_MSG_TYPE_RX_ADDBA] = HTT_T2H_MSG_TYPE_RX_ADDBA,
  46         [HTT_10X_T2H_MSG_TYPE_RX_DELBA] = HTT_T2H_MSG_TYPE_RX_DELBA,
  47         [HTT_10X_T2H_MSG_TYPE_TX_COMPL_IND] = HTT_T2H_MSG_TYPE_TX_COMPL_IND,
  48         [HTT_10X_T2H_MSG_TYPE_PKTLOG] = HTT_T2H_MSG_TYPE_PKTLOG,
  49         [HTT_10X_T2H_MSG_TYPE_STATS_CONF] = HTT_T2H_MSG_TYPE_STATS_CONF,
  50         [HTT_10X_T2H_MSG_TYPE_RX_FRAG_IND] = HTT_T2H_MSG_TYPE_RX_FRAG_IND,
  51         [HTT_10X_T2H_MSG_TYPE_SEC_IND] = HTT_T2H_MSG_TYPE_SEC_IND,
  52         [HTT_10X_T2H_MSG_TYPE_RC_UPDATE_IND] = HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
  53         [HTT_10X_T2H_MSG_TYPE_TX_INSPECT_IND] = HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
  54         [HTT_10X_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
  55         [HTT_10X_T2H_MSG_TYPE_CHAN_CHANGE] = HTT_T2H_MSG_TYPE_CHAN_CHANGE,
  56         [HTT_10X_T2H_MSG_TYPE_AGGR_CONF] = HTT_T2H_MSG_TYPE_AGGR_CONF,
  57         [HTT_10X_T2H_MSG_TYPE_STATS_NOUPLOAD] = HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
  58         [HTT_10X_T2H_MSG_TYPE_MGMT_TX_COMPL_IND] =
  59                 HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
  60 };
  61 
  62 static const enum htt_t2h_msg_type htt_tlv_t2h_msg_types[] = {
  63         [HTT_TLV_T2H_MSG_TYPE_VERSION_CONF] = HTT_T2H_MSG_TYPE_VERSION_CONF,
  64         [HTT_TLV_T2H_MSG_TYPE_RX_IND] = HTT_T2H_MSG_TYPE_RX_IND,
  65         [HTT_TLV_T2H_MSG_TYPE_RX_FLUSH] = HTT_T2H_MSG_TYPE_RX_FLUSH,
  66         [HTT_TLV_T2H_MSG_TYPE_PEER_MAP] = HTT_T2H_MSG_TYPE_PEER_MAP,
  67         [HTT_TLV_T2H_MSG_TYPE_PEER_UNMAP] = HTT_T2H_MSG_TYPE_PEER_UNMAP,
  68         [HTT_TLV_T2H_MSG_TYPE_RX_ADDBA] = HTT_T2H_MSG_TYPE_RX_ADDBA,
  69         [HTT_TLV_T2H_MSG_TYPE_RX_DELBA] = HTT_T2H_MSG_TYPE_RX_DELBA,
  70         [HTT_TLV_T2H_MSG_TYPE_TX_COMPL_IND] = HTT_T2H_MSG_TYPE_TX_COMPL_IND,
  71         [HTT_TLV_T2H_MSG_TYPE_PKTLOG] = HTT_T2H_MSG_TYPE_PKTLOG,
  72         [HTT_TLV_T2H_MSG_TYPE_STATS_CONF] = HTT_T2H_MSG_TYPE_STATS_CONF,
  73         [HTT_TLV_T2H_MSG_TYPE_RX_FRAG_IND] = HTT_T2H_MSG_TYPE_RX_FRAG_IND,
  74         [HTT_TLV_T2H_MSG_TYPE_SEC_IND] = HTT_T2H_MSG_TYPE_SEC_IND,
  75         [HTT_TLV_T2H_MSG_TYPE_RC_UPDATE_IND] = HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
  76         [HTT_TLV_T2H_MSG_TYPE_TX_INSPECT_IND] = HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
  77         [HTT_TLV_T2H_MSG_TYPE_MGMT_TX_COMPL_IND] =
  78                 HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
  79         [HTT_TLV_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND] =
  80                 HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
  81         [HTT_TLV_T2H_MSG_TYPE_RX_PN_IND] = HTT_T2H_MSG_TYPE_RX_PN_IND,
  82         [HTT_TLV_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND] =
  83                 HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
  84         [HTT_TLV_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND] =
  85                 HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND,
  86         [HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE] =
  87                 HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE,
  88         [HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE] = HTT_T2H_MSG_TYPE_CHAN_CHANGE,
  89         [HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR] =
  90                 HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
  91         [HTT_TLV_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
  92 };
  93 
  94 static const enum htt_t2h_msg_type htt_10_4_t2h_msg_types[] = {
  95         [HTT_10_4_T2H_MSG_TYPE_VERSION_CONF] = HTT_T2H_MSG_TYPE_VERSION_CONF,
  96         [HTT_10_4_T2H_MSG_TYPE_RX_IND] = HTT_T2H_MSG_TYPE_RX_IND,
  97         [HTT_10_4_T2H_MSG_TYPE_RX_FLUSH] = HTT_T2H_MSG_TYPE_RX_FLUSH,
  98         [HTT_10_4_T2H_MSG_TYPE_PEER_MAP] = HTT_T2H_MSG_TYPE_PEER_MAP,
  99         [HTT_10_4_T2H_MSG_TYPE_PEER_UNMAP] = HTT_T2H_MSG_TYPE_PEER_UNMAP,
 100         [HTT_10_4_T2H_MSG_TYPE_RX_ADDBA] = HTT_T2H_MSG_TYPE_RX_ADDBA,
 101         [HTT_10_4_T2H_MSG_TYPE_RX_DELBA] = HTT_T2H_MSG_TYPE_RX_DELBA,
 102         [HTT_10_4_T2H_MSG_TYPE_TX_COMPL_IND] = HTT_T2H_MSG_TYPE_TX_COMPL_IND,
 103         [HTT_10_4_T2H_MSG_TYPE_PKTLOG] = HTT_T2H_MSG_TYPE_PKTLOG,
 104         [HTT_10_4_T2H_MSG_TYPE_STATS_CONF] = HTT_T2H_MSG_TYPE_STATS_CONF,
 105         [HTT_10_4_T2H_MSG_TYPE_RX_FRAG_IND] = HTT_T2H_MSG_TYPE_RX_FRAG_IND,
 106         [HTT_10_4_T2H_MSG_TYPE_SEC_IND] = HTT_T2H_MSG_TYPE_SEC_IND,
 107         [HTT_10_4_T2H_MSG_TYPE_RC_UPDATE_IND] = HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
 108         [HTT_10_4_T2H_MSG_TYPE_TX_INSPECT_IND] =
 109                                 HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
 110         [HTT_10_4_T2H_MSG_TYPE_MGMT_TX_COMPL_IND] =
 111                                 HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
 112         [HTT_10_4_T2H_MSG_TYPE_CHAN_CHANGE] = HTT_T2H_MSG_TYPE_CHAN_CHANGE,
 113         [HTT_10_4_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND] =
 114                                 HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
 115         [HTT_10_4_T2H_MSG_TYPE_RX_PN_IND] = HTT_T2H_MSG_TYPE_RX_PN_IND,
 116         [HTT_10_4_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND] =
 117                                 HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
 118         [HTT_10_4_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
 119         [HTT_10_4_T2H_MSG_TYPE_EN_STATS] = HTT_T2H_MSG_TYPE_EN_STATS,
 120         [HTT_10_4_T2H_MSG_TYPE_AGGR_CONF] = HTT_T2H_MSG_TYPE_AGGR_CONF,
 121         [HTT_10_4_T2H_MSG_TYPE_TX_FETCH_IND] =
 122                                 HTT_T2H_MSG_TYPE_TX_FETCH_IND,
 123         [HTT_10_4_T2H_MSG_TYPE_TX_FETCH_CONFIRM] =
 124                                 HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
 125         [HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD] =
 126                                 HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
 127         [HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND] =
 128                                 HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
 129         [HTT_10_4_T2H_MSG_TYPE_PEER_STATS] =
 130                                 HTT_T2H_MSG_TYPE_PEER_STATS,
 131 };
 132 
 133 int ath10k_htt_connect(struct ath10k_htt *htt)
 134 {
 135         struct ath10k_htc_svc_conn_req conn_req;
 136         struct ath10k_htc_svc_conn_resp conn_resp;
 137         int status;
 138 
 139         memset(&conn_req, 0, sizeof(conn_req));
 140         memset(&conn_resp, 0, sizeof(conn_resp));
 141 
 142         conn_req.ep_ops.ep_tx_complete = ath10k_htt_htc_tx_complete;
 143         conn_req.ep_ops.ep_rx_complete = ath10k_htt_htc_t2h_msg_handler;
 144 
 145         /* connect to control service */
 146         conn_req.service_id = ATH10K_HTC_SVC_ID_HTT_DATA_MSG;
 147 
 148         status = ath10k_htc_connect_service(&htt->ar->htc, &conn_req,
 149                                             &conn_resp);
 150 
 151         if (status)
 152                 return status;
 153 
 154         htt->eid = conn_resp.eid;
 155 
 156         return 0;
 157 }
 158 
 159 int ath10k_htt_init(struct ath10k *ar)
 160 {
 161         struct ath10k_htt *htt = &ar->htt;
 162 
 163         htt->ar = ar;
 164 
 165         /*
 166          * Prefetch enough data to satisfy target
 167          * classification engine.
 168          * This is for LL chips. HL chips will probably
 169          * transfer all frame in the tx fragment.
 170          */
 171         htt->prefetch_len =
 172                 36 + /* 802.11 + qos + ht */
 173                 4 + /* 802.1q */
 174                 8 + /* llc snap */
 175                 2; /* ip4 dscp or ip6 priority */
 176 
 177         switch (ar->running_fw->fw_file.htt_op_version) {
 178         case ATH10K_FW_HTT_OP_VERSION_10_4:
 179                 ar->htt.t2h_msg_types = htt_10_4_t2h_msg_types;
 180                 ar->htt.t2h_msg_types_max = HTT_10_4_T2H_NUM_MSGS;
 181                 break;
 182         case ATH10K_FW_HTT_OP_VERSION_10_1:
 183                 ar->htt.t2h_msg_types = htt_10x_t2h_msg_types;
 184                 ar->htt.t2h_msg_types_max = HTT_10X_T2H_NUM_MSGS;
 185                 break;
 186         case ATH10K_FW_HTT_OP_VERSION_TLV:
 187                 ar->htt.t2h_msg_types = htt_tlv_t2h_msg_types;
 188                 ar->htt.t2h_msg_types_max = HTT_TLV_T2H_NUM_MSGS;
 189                 break;
 190         case ATH10K_FW_HTT_OP_VERSION_MAIN:
 191                 ar->htt.t2h_msg_types = htt_main_t2h_msg_types;
 192                 ar->htt.t2h_msg_types_max = HTT_MAIN_T2H_NUM_MSGS;
 193                 break;
 194         case ATH10K_FW_HTT_OP_VERSION_MAX:
 195         case ATH10K_FW_HTT_OP_VERSION_UNSET:
 196                 WARN_ON(1);
 197                 return -EINVAL;
 198         }
 199         ath10k_htt_set_tx_ops(htt);
 200         ath10k_htt_set_rx_ops(htt);
 201 
 202         return 0;
 203 }
 204 
 205 #define HTT_TARGET_VERSION_TIMEOUT_HZ (3 * HZ)
 206 
 207 static int ath10k_htt_verify_version(struct ath10k_htt *htt)
 208 {
 209         struct ath10k *ar = htt->ar;
 210 
 211         ath10k_dbg(ar, ATH10K_DBG_BOOT, "htt target version %d.%d\n",
 212                    htt->target_version_major, htt->target_version_minor);
 213 
 214         if (htt->target_version_major != 2 &&
 215             htt->target_version_major != 3) {
 216                 ath10k_err(ar, "unsupported htt major version %d. supported versions are 2 and 3\n",
 217                            htt->target_version_major);
 218                 return -ENOTSUPP;
 219         }
 220 
 221         return 0;
 222 }
 223 
 224 int ath10k_htt_setup(struct ath10k_htt *htt)
 225 {
 226         struct ath10k *ar = htt->ar;
 227         int status;
 228 
 229         init_completion(&htt->target_version_received);
 230 
 231         status = ath10k_htt_h2t_ver_req_msg(htt);
 232         if (status)
 233                 return status;
 234 
 235         status = wait_for_completion_timeout(&htt->target_version_received,
 236                                              HTT_TARGET_VERSION_TIMEOUT_HZ);
 237         if (status == 0) {
 238                 ath10k_warn(ar, "htt version request timed out\n");
 239                 return -ETIMEDOUT;
 240         }
 241 
 242         status = ath10k_htt_verify_version(htt);
 243         if (status) {
 244                 ath10k_warn(ar, "failed to verify htt version: %d\n",
 245                             status);
 246                 return status;
 247         }
 248 
 249         status = ath10k_htt_send_frag_desc_bank_cfg(htt);
 250         if (status)
 251                 return status;
 252 
 253         status = ath10k_htt_send_rx_ring_cfg(htt);
 254         if (status) {
 255                 ath10k_warn(ar, "failed to setup rx ring: %d\n",
 256                             status);
 257                 return status;
 258         }
 259 
 260         status = ath10k_htt_h2t_aggr_cfg_msg(htt,
 261                                              htt->max_num_ampdu,
 262                                              htt->max_num_amsdu);
 263         if (status) {
 264                 ath10k_warn(ar, "failed to setup amsdu/ampdu limit: %d\n",
 265                             status);
 266                 return status;
 267         }
 268 
 269         return 0;
 270 }

/* [<][>][^][v][top][bottom][index][help] */