linux/drivers/net/wireless/mediatek/mt76/mt7921/mcu.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: ISC */
   2/* Copyright (C) 2020 MediaTek Inc. */
   3
   4#ifndef __MT7921_MCU_H
   5#define __MT7921_MCU_H
   6
   7#include "../mt76_connac_mcu.h"
   8
   9struct mt7921_mcu_txd {
  10        __le32 txd[8];
  11
  12        __le16 len;
  13        __le16 pq_id;
  14
  15        u8 cid;
  16        u8 pkt_type;
  17        u8 set_query; /* FW don't care */
  18        u8 seq;
  19
  20        u8 uc_d2b0_rev;
  21        u8 ext_cid;
  22        u8 s2d_index;
  23        u8 ext_cid_ack;
  24
  25        u32 reserved[5];
  26} __packed __aligned(4);
  27
  28/**
  29 * struct mt7921_uni_txd - mcu command descriptor for firmware v3
  30 * @txd: hardware descriptor
  31 * @len: total length not including txd
  32 * @cid: command identifier
  33 * @pkt_type: must be 0xa0 (cmd packet by long format)
  34 * @frag_n: fragment number
  35 * @seq: sequence number
  36 * @checksum: 0 mean there is no checksum
  37 * @s2d_index: index for command source and destination
  38 *  Definition              | value | note
  39 *  CMD_S2D_IDX_H2N         | 0x00  | command from HOST to WM
  40 *  CMD_S2D_IDX_C2N         | 0x01  | command from WA to WM
  41 *  CMD_S2D_IDX_H2C         | 0x02  | command from HOST to WA
  42 *  CMD_S2D_IDX_H2N_AND_H2C | 0x03  | command from HOST to WA and WM
  43 *
  44 * @option: command option
  45 *  BIT[0]: UNI_CMD_OPT_BIT_ACK
  46 *          set to 1 to request a fw reply
  47 *          if UNI_CMD_OPT_BIT_0_ACK is set and UNI_CMD_OPT_BIT_2_SET_QUERY
  48 *          is set, mcu firmware will send response event EID = 0x01
  49 *          (UNI_EVENT_ID_CMD_RESULT) to the host.
  50 *  BIT[1]: UNI_CMD_OPT_BIT_UNI_CMD
  51 *          0: original command
  52 *          1: unified command
  53 *  BIT[2]: UNI_CMD_OPT_BIT_SET_QUERY
  54 *          0: QUERY command
  55 *          1: SET command
  56 */
  57struct mt7921_uni_txd {
  58        __le32 txd[8];
  59
  60        /* DW1 */
  61        __le16 len;
  62        __le16 cid;
  63
  64        /* DW2 */
  65        u8 reserved;
  66        u8 pkt_type;
  67        u8 frag_n;
  68        u8 seq;
  69
  70        /* DW3 */
  71        __le16 checksum;
  72        u8 s2d_index;
  73        u8 option;
  74
  75        /* DW4 */
  76        u8 reserved2[4];
  77} __packed __aligned(4);
  78
  79/* event table */
  80enum {
  81        MCU_EVENT_REG_ACCESS = 0x05,
  82        MCU_EVENT_LP_INFO = 0x07,
  83        MCU_EVENT_SCAN_DONE = 0x0d,
  84        MCU_EVENT_BSS_ABSENCE  = 0x11,
  85        MCU_EVENT_BSS_BEACON_LOSS = 0x13,
  86        MCU_EVENT_CH_PRIVILEGE = 0x18,
  87        MCU_EVENT_SCHED_SCAN_DONE = 0x23,
  88        MCU_EVENT_DBG_MSG = 0x27,
  89        MCU_EVENT_TXPWR = 0xd0,
  90        MCU_EVENT_COREDUMP = 0xf0,
  91};
  92
  93/* ext event table */
  94enum {
  95        MCU_EXT_EVENT_RATE_REPORT = 0x87,
  96};
  97
  98struct mt7921_mcu_rxd {
  99        __le32 rxd[6];
 100
 101        __le16 len;
 102        __le16 pkt_type_id;
 103
 104        u8 eid;
 105        u8 seq;
 106        __le16 __rsv;
 107
 108        u8 ext_eid;
 109        u8 __rsv1[2];
 110        u8 s2d_index;
 111};
 112
 113struct mt7921_mcu_eeprom_info {
 114        __le32 addr;
 115        __le32 valid;
 116        u8 data[16];
 117} __packed;
 118
 119#define MT_RA_RATE_NSS                  GENMASK(8, 6)
 120#define MT_RA_RATE_MCS                  GENMASK(3, 0)
 121#define MT_RA_RATE_TX_MODE              GENMASK(12, 9)
 122#define MT_RA_RATE_DCM_EN               BIT(4)
 123#define MT_RA_RATE_BW                   GENMASK(14, 13)
 124
 125#define MCU_PQ_ID(p, q)                 (((p) << 15) | ((q) << 10))
 126#define MCU_PKT_ID                      0xa0
 127
 128enum {
 129        MCU_Q_QUERY,
 130        MCU_Q_SET,
 131        MCU_Q_RESERVED,
 132        MCU_Q_NA
 133};
 134
 135enum {
 136        MCU_S2D_H2N,
 137        MCU_S2D_C2N,
 138        MCU_S2D_H2C,
 139        MCU_S2D_H2CN
 140};
 141
 142struct mt7921_mcu_uni_event {
 143        u8 cid;
 144        u8 pad[3];
 145        __le32 status; /* 0: success, others: fail */
 146} __packed;
 147
 148enum {
 149        PATCH_NOT_DL_SEM_FAIL,
 150        PATCH_IS_DL,
 151        PATCH_NOT_DL_SEM_SUCCESS,
 152        PATCH_REL_SEM_SUCCESS
 153};
 154
 155enum {
 156        FW_STATE_INITIAL,
 157        FW_STATE_FW_DOWNLOAD,
 158        FW_STATE_NORMAL_OPERATION,
 159        FW_STATE_NORMAL_TRX,
 160        FW_STATE_WACPU_RDY        = 7
 161};
 162
 163enum {
 164        EE_MODE_EFUSE,
 165        EE_MODE_BUFFER,
 166};
 167
 168enum {
 169        EE_FORMAT_BIN,
 170        EE_FORMAT_WHOLE,
 171        EE_FORMAT_MULTIPLE,
 172};
 173
 174enum {
 175        MCU_PHY_STATE_TX_RATE,
 176        MCU_PHY_STATE_RX_RATE,
 177        MCU_PHY_STATE_RSSI,
 178        MCU_PHY_STATE_CONTENTION_RX_RATE,
 179        MCU_PHY_STATE_OFDMLQ_CNINFO,
 180};
 181
 182struct sec_key {
 183        u8 cipher_id;
 184        u8 cipher_len;
 185        u8 key_id;
 186        u8 key_len;
 187        u8 key[32];
 188} __packed;
 189
 190struct sta_rec_sec {
 191        __le16 tag;
 192        __le16 len;
 193        u8 add;
 194        u8 n_cipher;
 195        u8 rsv[2];
 196
 197        struct sec_key key[2];
 198} __packed;
 199
 200enum mt7921_cipher_type {
 201        MT_CIPHER_NONE,
 202        MT_CIPHER_WEP40,
 203        MT_CIPHER_WEP104,
 204        MT_CIPHER_WEP128,
 205        MT_CIPHER_TKIP,
 206        MT_CIPHER_AES_CCMP,
 207        MT_CIPHER_CCMP_256,
 208        MT_CIPHER_GCMP,
 209        MT_CIPHER_GCMP_256,
 210        MT_CIPHER_WAPI,
 211        MT_CIPHER_BIP_CMAC_128,
 212};
 213
 214enum {
 215        CH_SWITCH_NORMAL = 0,
 216        CH_SWITCH_SCAN = 3,
 217        CH_SWITCH_MCC = 4,
 218        CH_SWITCH_DFS = 5,
 219        CH_SWITCH_BACKGROUND_SCAN_START = 6,
 220        CH_SWITCH_BACKGROUND_SCAN_RUNNING = 7,
 221        CH_SWITCH_BACKGROUND_SCAN_STOP = 8,
 222        CH_SWITCH_SCAN_BYPASS_DPD = 9
 223};
 224
 225enum {
 226        THERMAL_SENSOR_TEMP_QUERY,
 227        THERMAL_SENSOR_MANUAL_CTRL,
 228        THERMAL_SENSOR_INFO_QUERY,
 229        THERMAL_SENSOR_TASK_CTRL,
 230};
 231
 232enum {
 233        MT_EBF = BIT(0),        /* explicit beamforming */
 234        MT_IBF = BIT(1)         /* implicit beamforming */
 235};
 236
 237#define STA_CAP_WMM                     BIT(0)
 238#define STA_CAP_SGI_20                  BIT(4)
 239#define STA_CAP_SGI_40                  BIT(5)
 240#define STA_CAP_TX_STBC                 BIT(6)
 241#define STA_CAP_RX_STBC                 BIT(7)
 242#define STA_CAP_VHT_SGI_80              BIT(16)
 243#define STA_CAP_VHT_SGI_160             BIT(17)
 244#define STA_CAP_VHT_TX_STBC             BIT(18)
 245#define STA_CAP_VHT_RX_STBC             BIT(19)
 246#define STA_CAP_VHT_LDPC                BIT(23)
 247#define STA_CAP_LDPC                    BIT(24)
 248#define STA_CAP_HT                      BIT(26)
 249#define STA_CAP_VHT                     BIT(27)
 250#define STA_CAP_HE                      BIT(28)
 251
 252struct mt7921_mcu_reg_event {
 253        __le32 reg;
 254        __le32 val;
 255} __packed;
 256
 257struct mt7921_mcu_tx_config {
 258        u8 peer_addr[ETH_ALEN];
 259        u8 sw;
 260        u8 dis_rx_hdr_tran;
 261
 262        u8 aad_om;
 263        u8 pfmu_idx;
 264        __le16 partial_aid;
 265
 266        u8 ibf;
 267        u8 ebf;
 268        u8 is_ht;
 269        u8 is_vht;
 270
 271        u8 mesh;
 272        u8 baf_en;
 273        u8 cf_ack;
 274        u8 rdg_ba;
 275
 276        u8 rdg;
 277        u8 pm;
 278        u8 rts;
 279        u8 smps;
 280
 281        u8 txop_ps;
 282        u8 not_update_ipsm;
 283        u8 skip_tx;
 284        u8 ldpc;
 285
 286        u8 qos;
 287        u8 from_ds;
 288        u8 to_ds;
 289        u8 dyn_bw;
 290
 291        u8 amdsu_cross_lg;
 292        u8 check_per;
 293        u8 gid_63;
 294        u8 he;
 295
 296        u8 vht_ibf;
 297        u8 vht_ebf;
 298        u8 vht_ldpc;
 299        u8 he_ldpc;
 300} __packed;
 301
 302struct mt7921_mcu_sec_config {
 303        u8 wpi_flag;
 304        u8 rv;
 305        u8 ikv;
 306        u8 rkv;
 307
 308        u8 rcid;
 309        u8 rca1;
 310        u8 rca2;
 311        u8 even_pn;
 312
 313        u8 key_id;
 314        u8 muar_idx;
 315        u8 cipher_suit;
 316        u8 rsv[1];
 317} __packed;
 318
 319struct mt7921_mcu_key_config {
 320        u8 key[32];
 321} __packed;
 322
 323struct mt7921_mcu_rate_info {
 324        u8 mpdu_fail;
 325        u8 mpdu_tx;
 326        u8 rate_idx;
 327        u8 rsv[1];
 328        __le16 rate[8];
 329} __packed;
 330
 331struct mt7921_mcu_ba_config {
 332        u8 ba_en;
 333        u8 rsv[3];
 334        __le32 ba_winsize;
 335} __packed;
 336
 337struct mt7921_mcu_ant_id_config {
 338        u8 ant_id[4];
 339} __packed;
 340
 341struct mt7921_mcu_peer_cap {
 342        struct mt7921_mcu_ant_id_config ant_id_config;
 343
 344        u8 power_offset;
 345        u8 bw_selector;
 346        u8 change_bw_rate_n;
 347        u8 bw;
 348        u8 spe_idx;
 349
 350        u8 g2;
 351        u8 g4;
 352        u8 g8;
 353        u8 g16;
 354
 355        u8 mmss;
 356        u8 ampdu_factor;
 357        u8 rsv[1];
 358} __packed;
 359
 360struct mt7921_mcu_rx_cnt {
 361        u8 rx_rcpi[4];
 362        u8 rx_cc[4];
 363        u8 rx_cc_sel;
 364        u8 ce_rmsd;
 365        u8 rsv[2];
 366} __packed;
 367
 368struct mt7921_mcu_tx_cnt {
 369        __le16 rate1_cnt;
 370        __le16 rate1_fail_cnt;
 371        __le16 rate2_cnt;
 372        __le16 rate3_cnt;
 373        __le16 cur_bw_tx_cnt;
 374        __le16 cur_bw_tx_fail_cnt;
 375        __le16 other_bw_tx_cnt;
 376        __le16 other_bw_tx_fail_cnt;
 377} __packed;
 378
 379struct mt7921_mcu_wlan_info_event {
 380        struct mt7921_mcu_tx_config tx_config;
 381        struct mt7921_mcu_sec_config sec_config;
 382        struct mt7921_mcu_key_config key_config;
 383        struct mt7921_mcu_rate_info rate_info;
 384        struct mt7921_mcu_ba_config ba_config;
 385        struct mt7921_mcu_peer_cap peer_cap;
 386        struct mt7921_mcu_rx_cnt rx_cnt;
 387        struct mt7921_mcu_tx_cnt tx_cnt;
 388} __packed;
 389
 390struct mt7921_mcu_wlan_info {
 391        __le32 wlan_idx;
 392        struct mt7921_mcu_wlan_info_event event;
 393} __packed;
 394
 395struct mt7921_txpwr_req {
 396        u8 ver;
 397        u8 action;
 398        __le16 len;
 399        u8 dbdc_idx;
 400        u8 rsv[3];
 401} __packed;
 402
 403struct mt7921_txpwr_event {
 404        u8 ver;
 405        u8 action;
 406        __le16 len;
 407        struct mt7921_txpwr txpwr;
 408} __packed;
 409
 410#endif
 411