104b8e659SRyder Lee /* SPDX-License-Identifier: ISC */
204b8e659SRyder Lee /* Copyright (C) 2019 MediaTek Inc. */
304b8e659SRyder Lee 
404b8e659SRyder Lee #ifndef __MT7615_MAC_H
504b8e659SRyder Lee #define __MT7615_MAC_H
604b8e659SRyder Lee 
704b8e659SRyder Lee #define MT_CT_PARSE_LEN			72
804b8e659SRyder Lee #define MT_CT_DMA_BUF_NUM		2
904b8e659SRyder Lee 
1004b8e659SRyder Lee #define MT_RXD0_LENGTH			GENMASK(15, 0)
11f40ac0f3SLorenzo Bianconi #define MT_RXD0_PKT_FLAG                GENMASK(19, 16)
1204b8e659SRyder Lee #define MT_RXD0_PKT_TYPE		GENMASK(31, 29)
1304b8e659SRyder Lee 
1404b8e659SRyder Lee #define MT_RXD0_NORMAL_ETH_TYPE_OFS	GENMASK(22, 16)
1504b8e659SRyder Lee #define MT_RXD0_NORMAL_IP_SUM		BIT(23)
1604b8e659SRyder Lee #define MT_RXD0_NORMAL_UDP_TCP_SUM	BIT(24)
1704b8e659SRyder Lee #define MT_RXD0_NORMAL_GROUP_1		BIT(25)
1804b8e659SRyder Lee #define MT_RXD0_NORMAL_GROUP_2		BIT(26)
1904b8e659SRyder Lee #define MT_RXD0_NORMAL_GROUP_3		BIT(27)
2004b8e659SRyder Lee #define MT_RXD0_NORMAL_GROUP_4		BIT(28)
2104b8e659SRyder Lee 
2204b8e659SRyder Lee enum rx_pkt_type {
2304b8e659SRyder Lee 	PKT_TYPE_TXS,
2404b8e659SRyder Lee 	PKT_TYPE_TXRXV,
2504b8e659SRyder Lee 	PKT_TYPE_NORMAL,
2604b8e659SRyder Lee 	PKT_TYPE_RX_DUP_RFB,
2704b8e659SRyder Lee 	PKT_TYPE_RX_TMR,
2804b8e659SRyder Lee 	PKT_TYPE_RETRIEVE,
2904b8e659SRyder Lee 	PKT_TYPE_TXRX_NOTIFY,
30f40ac0f3SLorenzo Bianconi 	PKT_TYPE_RX_EVENT,
31f40ac0f3SLorenzo Bianconi 	PKT_TYPE_NORMAL_MCU,
3204b8e659SRyder Lee };
3304b8e659SRyder Lee 
3404b8e659SRyder Lee #define MT_RXD1_NORMAL_BSSID		GENMASK(31, 26)
3504b8e659SRyder Lee #define MT_RXD1_NORMAL_PAYLOAD_FORMAT	GENMASK(25, 24)
36e78d73e0SRyder Lee #define MT_RXD1_FIRST_AMSDU_FRAME	GENMASK(1, 0)
37e78d73e0SRyder Lee #define MT_RXD1_MID_AMSDU_FRAME		BIT(1)
38e78d73e0SRyder Lee #define MT_RXD1_LAST_AMSDU_FRAME	BIT(0)
3904b8e659SRyder Lee #define MT_RXD1_NORMAL_HDR_TRANS	BIT(23)
4004b8e659SRyder Lee #define MT_RXD1_NORMAL_HDR_OFFSET	BIT(22)
4104b8e659SRyder Lee #define MT_RXD1_NORMAL_MAC_HDR_LEN	GENMASK(21, 16)
4204b8e659SRyder Lee #define MT_RXD1_NORMAL_CH_FREQ		GENMASK(15, 8)
4304b8e659SRyder Lee #define MT_RXD1_NORMAL_KEY_ID		GENMASK(7, 6)
4404b8e659SRyder Lee #define MT_RXD1_NORMAL_BEACON_UC	BIT(5)
4504b8e659SRyder Lee #define MT_RXD1_NORMAL_BEACON_MC	BIT(4)
4604b8e659SRyder Lee #define MT_RXD1_NORMAL_BF_REPORT	BIT(3)
4704b8e659SRyder Lee #define MT_RXD1_NORMAL_ADDR_TYPE	GENMASK(2, 1)
4804b8e659SRyder Lee #define MT_RXD1_NORMAL_BCAST		GENMASK(2, 1)
4904b8e659SRyder Lee #define MT_RXD1_NORMAL_MCAST		BIT(2)
5004b8e659SRyder Lee #define MT_RXD1_NORMAL_U2M		BIT(1)
5104b8e659SRyder Lee #define MT_RXD1_NORMAL_HTC_VLD		BIT(0)
5204b8e659SRyder Lee 
5304b8e659SRyder Lee #define MT_RXD2_NORMAL_NON_AMPDU	BIT(31)
5404b8e659SRyder Lee #define MT_RXD2_NORMAL_NON_AMPDU_SUB	BIT(30)
5504b8e659SRyder Lee #define MT_RXD2_NORMAL_NDATA		BIT(29)
5604b8e659SRyder Lee #define MT_RXD2_NORMAL_NULL_FRAME	BIT(28)
5704b8e659SRyder Lee #define MT_RXD2_NORMAL_FRAG		BIT(27)
5804b8e659SRyder Lee #define MT_RXD2_NORMAL_INT_FRAME	BIT(26)
5904b8e659SRyder Lee #define MT_RXD2_NORMAL_HDR_TRANS_ERROR	BIT(25)
6004b8e659SRyder Lee #define MT_RXD2_NORMAL_MAX_LEN_ERROR	BIT(24)
6104b8e659SRyder Lee #define MT_RXD2_NORMAL_AMSDU_ERR	BIT(23)
6204b8e659SRyder Lee #define MT_RXD2_NORMAL_LEN_MISMATCH	BIT(22)
6304b8e659SRyder Lee #define MT_RXD2_NORMAL_TKIP_MIC_ERR	BIT(21)
6404b8e659SRyder Lee #define MT_RXD2_NORMAL_ICV_ERR		BIT(20)
6504b8e659SRyder Lee #define MT_RXD2_NORMAL_CLM		BIT(19)
6604b8e659SRyder Lee #define MT_RXD2_NORMAL_CM		BIT(18)
6704b8e659SRyder Lee #define MT_RXD2_NORMAL_FCS_ERR		BIT(17)
6804b8e659SRyder Lee #define MT_RXD2_NORMAL_SW_BIT		BIT(16)
6904b8e659SRyder Lee #define MT_RXD2_NORMAL_SEC_MODE		GENMASK(15, 12)
7004b8e659SRyder Lee #define MT_RXD2_NORMAL_TID		GENMASK(11, 8)
7104b8e659SRyder Lee #define MT_RXD2_NORMAL_WLAN_IDX		GENMASK(7, 0)
7204b8e659SRyder Lee 
7304b8e659SRyder Lee #define MT_RXD3_NORMAL_PF_STS		GENMASK(31, 30)
7404b8e659SRyder Lee #define MT_RXD3_NORMAL_PF_MODE		BIT(29)
7504b8e659SRyder Lee #define MT_RXD3_NORMAL_CLS_BITMAP	GENMASK(28, 19)
7604b8e659SRyder Lee #define MT_RXD3_NORMAL_WOL		GENMASK(18, 14)
7704b8e659SRyder Lee #define MT_RXD3_NORMAL_MAGIC_PKT	BIT(13)
7804b8e659SRyder Lee #define MT_RXD3_NORMAL_OFLD		GENMASK(12, 11)
7904b8e659SRyder Lee #define MT_RXD3_NORMAL_CLS		BIT(10)
8004b8e659SRyder Lee #define MT_RXD3_NORMAL_PATTERN_DROP	BIT(9)
8104b8e659SRyder Lee #define MT_RXD3_NORMAL_TSF_COMPARE_LOSS	BIT(8)
8204b8e659SRyder Lee #define MT_RXD3_NORMAL_RXV_SEQ		GENMASK(7, 0)
8304b8e659SRyder Lee 
84*d4b98c63SRyder Lee #define MT_RXD4_FRAME_CONTROL		GENMASK(15, 0)
85*d4b98c63SRyder Lee 
86*d4b98c63SRyder Lee #define MT_RXD6_SEQ_CTRL		GENMASK(15, 0)
87*d4b98c63SRyder Lee #define MT_RXD6_QOS_CTL			GENMASK(31, 16)
88*d4b98c63SRyder Lee 
8904b8e659SRyder Lee #define MT_RXV1_ACID_DET_H		BIT(31)
9004b8e659SRyder Lee #define MT_RXV1_ACID_DET_L		BIT(30)
9104b8e659SRyder Lee #define MT_RXV1_VHTA2_B8_B3		GENMASK(29, 24)
9204b8e659SRyder Lee #define MT_RXV1_NUM_RX			GENMASK(23, 22)
9304b8e659SRyder Lee #define MT_RXV1_HT_NO_SOUND		BIT(21)
9404b8e659SRyder Lee #define MT_RXV1_HT_SMOOTH		BIT(20)
9504b8e659SRyder Lee #define MT_RXV1_HT_SHORT_GI		BIT(19)
9604b8e659SRyder Lee #define MT_RXV1_HT_AGGR			BIT(18)
9704b8e659SRyder Lee #define MT_RXV1_VHTA1_B22		BIT(17)
9804b8e659SRyder Lee #define MT_RXV1_FRAME_MODE		GENMASK(16, 15)
9904b8e659SRyder Lee #define MT_RXV1_TX_MODE			GENMASK(14, 12)
10004b8e659SRyder Lee #define MT_RXV1_HT_EXT_LTF		GENMASK(11, 10)
10104b8e659SRyder Lee #define MT_RXV1_HT_AD_CODE		BIT(9)
10204b8e659SRyder Lee #define MT_RXV1_HT_STBC			GENMASK(8, 7)
10304b8e659SRyder Lee #define MT_RXV1_TX_RATE			GENMASK(6, 0)
10404b8e659SRyder Lee 
10504b8e659SRyder Lee #define MT_RXV2_SEL_ANT			BIT(31)
10604b8e659SRyder Lee #define MT_RXV2_VALID_BIT		BIT(30)
10704b8e659SRyder Lee #define MT_RXV2_NSTS			GENMASK(29, 27)
10804b8e659SRyder Lee #define MT_RXV2_GROUP_ID		GENMASK(26, 21)
10904b8e659SRyder Lee #define MT_RXV2_LENGTH			GENMASK(20, 0)
11004b8e659SRyder Lee 
1114f0bce1cSFelix Fietkau #define MT_RXV3_WB_RSSI			GENMASK(31, 24)
1124f0bce1cSFelix Fietkau #define MT_RXV3_IB_RSSI			GENMASK(23, 16)
1134f0bce1cSFelix Fietkau 
114bf92e768SRyder Lee #define MT_RXV4_RCPI3			GENMASK(31, 24)
115bf92e768SRyder Lee #define MT_RXV4_RCPI2			GENMASK(23, 16)
116bf92e768SRyder Lee #define MT_RXV4_RCPI1			GENMASK(15, 8)
117bf92e768SRyder Lee #define MT_RXV4_RCPI0			GENMASK(7, 0)
118bf92e768SRyder Lee 
1194f0bce1cSFelix Fietkau #define MT_RXV5_FOE			GENMASK(11, 0)
1204f0bce1cSFelix Fietkau 
1210e544cb5SFelix Fietkau #define MT_RXV6_NF3			GENMASK(31, 24)
1220e544cb5SFelix Fietkau #define MT_RXV6_NF2			GENMASK(23, 16)
1230e544cb5SFelix Fietkau #define MT_RXV6_NF1			GENMASK(15, 8)
1240e544cb5SFelix Fietkau #define MT_RXV6_NF0			GENMASK(7, 0)
1250e544cb5SFelix Fietkau 
12604b8e659SRyder Lee enum tx_header_format {
12704b8e659SRyder Lee 	MT_HDR_FORMAT_802_3,
12804b8e659SRyder Lee 	MT_HDR_FORMAT_CMD,
12904b8e659SRyder Lee 	MT_HDR_FORMAT_802_11,
13004b8e659SRyder Lee 	MT_HDR_FORMAT_802_11_EXT,
13104b8e659SRyder Lee };
13204b8e659SRyder Lee 
13304b8e659SRyder Lee enum tx_pkt_type {
13404b8e659SRyder Lee 	MT_TX_TYPE_CT,
13504b8e659SRyder Lee 	MT_TX_TYPE_SF,
13604b8e659SRyder Lee 	MT_TX_TYPE_CMD,
13704b8e659SRyder Lee 	MT_TX_TYPE_FW,
13804b8e659SRyder Lee };
13904b8e659SRyder Lee 
14004b8e659SRyder Lee enum tx_port_idx {
14104b8e659SRyder Lee 	MT_TX_PORT_IDX_LMAC,
14204b8e659SRyder Lee 	MT_TX_PORT_IDX_MCU
14304b8e659SRyder Lee };
14404b8e659SRyder Lee 
14504b8e659SRyder Lee enum tx_mcu_port_q_idx {
14604b8e659SRyder Lee 	MT_TX_MCU_PORT_RX_Q0 = 0,
14704b8e659SRyder Lee 	MT_TX_MCU_PORT_RX_Q1,
14804b8e659SRyder Lee 	MT_TX_MCU_PORT_RX_Q2,
14904b8e659SRyder Lee 	MT_TX_MCU_PORT_RX_Q3,
15004b8e659SRyder Lee 	MT_TX_MCU_PORT_RX_FWDL = 0x1e
15104b8e659SRyder Lee };
15204b8e659SRyder Lee 
15304b8e659SRyder Lee enum tx_phy_bandwidth {
15404b8e659SRyder Lee 	MT_PHY_BW_20,
15504b8e659SRyder Lee 	MT_PHY_BW_40,
15604b8e659SRyder Lee 	MT_PHY_BW_80,
15704b8e659SRyder Lee 	MT_PHY_BW_160,
15804b8e659SRyder Lee };
15904b8e659SRyder Lee 
16004b8e659SRyder Lee #define MT_CT_INFO_APPLY_TXD		BIT(0)
16104b8e659SRyder Lee #define MT_CT_INFO_COPY_HOST_TXD_ALL	BIT(1)
16204b8e659SRyder Lee #define MT_CT_INFO_MGMT_FRAME		BIT(2)
16304b8e659SRyder Lee #define MT_CT_INFO_NONE_CIPHER_FRAME	BIT(3)
16404b8e659SRyder Lee #define MT_CT_INFO_HSR2_TX		BIT(4)
16504b8e659SRyder Lee 
16604b8e659SRyder Lee #define MT_TXD_SIZE			(8 * 4)
16704b8e659SRyder Lee 
168eb99cc95SLorenzo Bianconi #define MT_USB_TXD_SIZE			(MT_TXD_SIZE + 8 * 4)
169eb99cc95SLorenzo Bianconi #define MT_USB_HDR_SIZE			4
170eb99cc95SLorenzo Bianconi #define MT_USB_TAIL_SIZE		4
171eb99cc95SLorenzo Bianconi 
17204b8e659SRyder Lee #define MT_TXD0_P_IDX			BIT(31)
17304b8e659SRyder Lee #define MT_TXD0_Q_IDX			GENMASK(30, 26)
17404b8e659SRyder Lee #define MT_TXD0_UDP_TCP_SUM		BIT(24)
17504b8e659SRyder Lee #define MT_TXD0_IP_SUM			BIT(23)
17604b8e659SRyder Lee #define MT_TXD0_ETH_TYPE_OFFSET		GENMASK(22, 16)
17704b8e659SRyder Lee #define MT_TXD0_TX_BYTES		GENMASK(15, 0)
17804b8e659SRyder Lee 
17904b8e659SRyder Lee #define MT_TXD1_OWN_MAC			GENMASK(31, 26)
18004b8e659SRyder Lee #define MT_TXD1_PKT_FMT			GENMASK(25, 24)
18104b8e659SRyder Lee #define MT_TXD1_TID			GENMASK(23, 21)
18204b8e659SRyder Lee #define MT_TXD1_AMSDU			BIT(20)
18304b8e659SRyder Lee #define MT_TXD1_UNXV			BIT(19)
18404b8e659SRyder Lee #define MT_TXD1_HDR_PAD			GENMASK(18, 17)
18504b8e659SRyder Lee #define MT_TXD1_TXD_LEN			BIT(16)
18604b8e659SRyder Lee #define MT_TXD1_LONG_FORMAT		BIT(15)
18704b8e659SRyder Lee #define MT_TXD1_HDR_FORMAT		GENMASK(14, 13)
18804b8e659SRyder Lee #define MT_TXD1_HDR_INFO		GENMASK(12, 8)
18904b8e659SRyder Lee #define MT_TXD1_WLAN_IDX		GENMASK(7, 0)
19004b8e659SRyder Lee 
19104b8e659SRyder Lee #define MT_TXD2_FIX_RATE		BIT(31)
19204b8e659SRyder Lee #define MT_TXD2_TIMING_MEASURE		BIT(30)
19304b8e659SRyder Lee #define MT_TXD2_BA_DISABLE		BIT(29)
19404b8e659SRyder Lee #define MT_TXD2_POWER_OFFSET		GENMASK(28, 24)
19504b8e659SRyder Lee #define MT_TXD2_MAX_TX_TIME		GENMASK(23, 16)
19604b8e659SRyder Lee #define MT_TXD2_FRAG			GENMASK(15, 14)
19704b8e659SRyder Lee #define MT_TXD2_HTC_VLD			BIT(13)
19804b8e659SRyder Lee #define MT_TXD2_DURATION		BIT(12)
19904b8e659SRyder Lee #define MT_TXD2_BIP			BIT(11)
20004b8e659SRyder Lee #define MT_TXD2_MULTICAST		BIT(10)
20104b8e659SRyder Lee #define MT_TXD2_RTS			BIT(9)
20204b8e659SRyder Lee #define MT_TXD2_SOUNDING		BIT(8)
20304b8e659SRyder Lee #define MT_TXD2_NDPA			BIT(7)
20404b8e659SRyder Lee #define MT_TXD2_NDP			BIT(6)
20504b8e659SRyder Lee #define MT_TXD2_FRAME_TYPE		GENMASK(5, 4)
20604b8e659SRyder Lee #define MT_TXD2_SUB_TYPE		GENMASK(3, 0)
20704b8e659SRyder Lee 
20804b8e659SRyder Lee #define MT_TXD3_SN_VALID		BIT(31)
20904b8e659SRyder Lee #define MT_TXD3_PN_VALID		BIT(30)
21004b8e659SRyder Lee #define MT_TXD3_SEQ			GENMASK(27, 16)
21104b8e659SRyder Lee #define MT_TXD3_REM_TX_COUNT		GENMASK(15, 11)
21204b8e659SRyder Lee #define MT_TXD3_TX_COUNT		GENMASK(10, 6)
21304b8e659SRyder Lee #define MT_TXD3_PROTECT_FRAME		BIT(1)
21404b8e659SRyder Lee #define MT_TXD3_NO_ACK			BIT(0)
21504b8e659SRyder Lee 
21604b8e659SRyder Lee #define MT_TXD4_PN_LOW			GENMASK(31, 0)
21704b8e659SRyder Lee 
21804b8e659SRyder Lee #define MT_TXD5_PN_HIGH			GENMASK(31, 16)
21904b8e659SRyder Lee #define MT_TXD5_SW_POWER_MGMT		BIT(13)
22004b8e659SRyder Lee #define MT_TXD5_DA_SELECT		BIT(11)
22104b8e659SRyder Lee #define MT_TXD5_TX_STATUS_HOST		BIT(10)
22204b8e659SRyder Lee #define MT_TXD5_TX_STATUS_MCU		BIT(9)
22304b8e659SRyder Lee #define MT_TXD5_TX_STATUS_FMT		BIT(8)
22404b8e659SRyder Lee #define MT_TXD5_PID			GENMASK(7, 0)
22504b8e659SRyder Lee 
22604b8e659SRyder Lee #define MT_TXD6_FIXED_RATE		BIT(31)
22704b8e659SRyder Lee #define MT_TXD6_SGI			BIT(30)
22804b8e659SRyder Lee #define MT_TXD6_LDPC			BIT(29)
22904b8e659SRyder Lee #define MT_TXD6_TX_BF			BIT(28)
23004b8e659SRyder Lee #define MT_TXD6_TX_RATE			GENMASK(27, 16)
23104b8e659SRyder Lee #define MT_TXD6_ANT_ID			GENMASK(15, 4)
23204b8e659SRyder Lee #define MT_TXD6_DYN_BW			BIT(3)
23304b8e659SRyder Lee #define MT_TXD6_FIXED_BW		BIT(2)
23404b8e659SRyder Lee #define MT_TXD6_BW			GENMASK(1, 0)
23504b8e659SRyder Lee 
236f40ac0f3SLorenzo Bianconi /* MT7663 DW7 HW-AMSDU */
237f40ac0f3SLorenzo Bianconi #define MT_TXD7_HW_AMSDU_CAP		BIT(30)
23804b8e659SRyder Lee #define MT_TXD7_TYPE			GENMASK(21, 20)
23904b8e659SRyder Lee #define MT_TXD7_SUB_TYPE		GENMASK(19, 16)
240f40ac0f3SLorenzo Bianconi #define MT_TXD7_SPE_IDX			GENMASK(15, 11)
241f40ac0f3SLorenzo Bianconi #define MT_TXD7_SPE_IDX_SLE		BIT(10)
242f40ac0f3SLorenzo Bianconi 
243f40ac0f3SLorenzo Bianconi #define MT_TXD8_L_TYPE			GENMASK(5, 4)
244f40ac0f3SLorenzo Bianconi #define MT_TXD8_L_SUB_TYPE		GENMASK(3, 0)
24504b8e659SRyder Lee 
24604b8e659SRyder Lee #define MT_TX_RATE_STBC			BIT(11)
24704b8e659SRyder Lee #define MT_TX_RATE_NSS			GENMASK(10, 9)
24804b8e659SRyder Lee #define MT_TX_RATE_MODE			GENMASK(8, 6)
24904b8e659SRyder Lee #define MT_TX_RATE_IDX			GENMASK(5, 0)
25004b8e659SRyder Lee 
25104b8e659SRyder Lee #define MT_TXP_MAX_BUF_NUM		6
2526aa4ed79SFelix Fietkau #define MT_HW_TXP_MAX_MSDU_NUM		4
2536aa4ed79SFelix Fietkau #define MT_HW_TXP_MAX_BUF_NUM		4
25404b8e659SRyder Lee 
2556aa4ed79SFelix Fietkau #define MT_MSDU_ID_VALID		BIT(15)
2566aa4ed79SFelix Fietkau 
257c0f8055bSLorenzo Bianconi #define MT_TXD_LEN_MASK			GENMASK(11, 0)
2586aa4ed79SFelix Fietkau #define MT_TXD_LEN_MSDU_LAST		BIT(14)
2596aa4ed79SFelix Fietkau #define MT_TXD_LEN_AMSDU_LAST		BIT(15)
26089829c9eSLorenzo Bianconi /* mt7663 */
26189829c9eSLorenzo Bianconi #define MT_TXD_LEN_LAST			BIT(15)
2626aa4ed79SFelix Fietkau 
2636aa4ed79SFelix Fietkau struct mt7615_txp_ptr {
2646aa4ed79SFelix Fietkau 	__le32 buf0;
2656aa4ed79SFelix Fietkau 	__le16 len0;
2666aa4ed79SFelix Fietkau 	__le16 len1;
2676aa4ed79SFelix Fietkau 	__le32 buf1;
2686aa4ed79SFelix Fietkau } __packed __aligned(4);
2696aa4ed79SFelix Fietkau 
2706aa4ed79SFelix Fietkau struct mt7615_hw_txp {
2716aa4ed79SFelix Fietkau 	__le16 msdu_id[MT_HW_TXP_MAX_MSDU_NUM];
2726aa4ed79SFelix Fietkau 	struct mt7615_txp_ptr ptr[MT_HW_TXP_MAX_BUF_NUM / 2];
2736aa4ed79SFelix Fietkau } __packed __aligned(4);
2746aa4ed79SFelix Fietkau 
2756aa4ed79SFelix Fietkau struct mt7615_fw_txp {
27604b8e659SRyder Lee 	__le16 flags;
27704b8e659SRyder Lee 	__le16 token;
27804b8e659SRyder Lee 	u8 bss_idx;
27904b8e659SRyder Lee 	u8 rept_wds_wcid;
28004b8e659SRyder Lee 	u8 rsv;
28104b8e659SRyder Lee 	u8 nbuf;
28204b8e659SRyder Lee 	__le32 buf[MT_TXP_MAX_BUF_NUM];
28304b8e659SRyder Lee 	__le16 len[MT_TXP_MAX_BUF_NUM];
28413602c9dSFelix Fietkau } __packed __aligned(4);
28504b8e659SRyder Lee 
2866aa4ed79SFelix Fietkau struct mt7615_txp_common {
2876aa4ed79SFelix Fietkau 	union {
2886aa4ed79SFelix Fietkau 		struct mt7615_fw_txp fw;
2896aa4ed79SFelix Fietkau 		struct mt7615_hw_txp hw;
2906aa4ed79SFelix Fietkau 	};
2916aa4ed79SFelix Fietkau };
2926aa4ed79SFelix Fietkau 
29304b8e659SRyder Lee struct mt7615_tx_free {
29404b8e659SRyder Lee 	__le16 rx_byte_cnt;
29504b8e659SRyder Lee 	__le16 ctrl;
29604b8e659SRyder Lee 	u8 txd_cnt;
29704b8e659SRyder Lee 	u8 rsv[3];
29804b8e659SRyder Lee 	__le16 token[];
29913602c9dSFelix Fietkau } __packed __aligned(4);
30004b8e659SRyder Lee 
30104b8e659SRyder Lee #define MT_TX_FREE_MSDU_ID_CNT		GENMASK(6, 0)
30204b8e659SRyder Lee 
30304b8e659SRyder Lee #define MT_TXS0_PID			GENMASK(31, 24)
30404b8e659SRyder Lee #define MT_TXS0_BA_ERROR		BIT(22)
30504b8e659SRyder Lee #define MT_TXS0_PS_FLAG			BIT(21)
30604b8e659SRyder Lee #define MT_TXS0_TXOP_TIMEOUT		BIT(20)
30704b8e659SRyder Lee #define MT_TXS0_BIP_ERROR		BIT(19)
30804b8e659SRyder Lee 
30904b8e659SRyder Lee #define MT_TXS0_QUEUE_TIMEOUT		BIT(18)
31004b8e659SRyder Lee #define MT_TXS0_RTS_TIMEOUT		BIT(17)
31104b8e659SRyder Lee #define MT_TXS0_ACK_TIMEOUT		BIT(16)
31204b8e659SRyder Lee #define MT_TXS0_ACK_ERROR_MASK		GENMASK(18, 16)
31304b8e659SRyder Lee 
31404b8e659SRyder Lee #define MT_TXS0_TX_STATUS_HOST		BIT(15)
31504b8e659SRyder Lee #define MT_TXS0_TX_STATUS_MCU		BIT(14)
31604b8e659SRyder Lee #define MT_TXS0_TXS_FORMAT		BIT(13)
31704b8e659SRyder Lee #define MT_TXS0_FIXED_RATE		BIT(12)
31804b8e659SRyder Lee #define MT_TXS0_TX_RATE			GENMASK(11, 0)
31904b8e659SRyder Lee 
32004b8e659SRyder Lee #define MT_TXS1_ANT_ID			GENMASK(31, 20)
32104b8e659SRyder Lee #define MT_TXS1_RESP_RATE		GENMASK(19, 16)
32204b8e659SRyder Lee #define MT_TXS1_BW			GENMASK(15, 14)
32304b8e659SRyder Lee #define MT_TXS1_I_TXBF			BIT(13)
32404b8e659SRyder Lee #define MT_TXS1_E_TXBF			BIT(12)
32504b8e659SRyder Lee #define MT_TXS1_TID			GENMASK(11, 9)
32604b8e659SRyder Lee #define MT_TXS1_AMPDU			BIT(8)
32704b8e659SRyder Lee #define MT_TXS1_ACKED_MPDU		BIT(7)
32804b8e659SRyder Lee #define MT_TXS1_TX_POWER_DBM		GENMASK(6, 0)
32904b8e659SRyder Lee 
33004b8e659SRyder Lee #define MT_TXS2_WCID			GENMASK(31, 24)
33104b8e659SRyder Lee #define MT_TXS2_RXV_SEQNO		GENMASK(23, 16)
33204b8e659SRyder Lee #define MT_TXS2_TX_DELAY		GENMASK(15, 0)
33304b8e659SRyder Lee 
33404b8e659SRyder Lee #define MT_TXS3_LAST_TX_RATE		GENMASK(31, 29)
33504b8e659SRyder Lee #define MT_TXS3_TX_COUNT		GENMASK(28, 24)
33604b8e659SRyder Lee #define MT_TXS3_F1_TSSI1		GENMASK(23, 12)
33704b8e659SRyder Lee #define MT_TXS3_F1_TSSI0		GENMASK(11, 0)
33804b8e659SRyder Lee #define MT_TXS3_F0_SEQNO		GENMASK(11, 0)
33904b8e659SRyder Lee 
34004b8e659SRyder Lee #define MT_TXS4_F0_TIMESTAMP		GENMASK(31, 0)
34104b8e659SRyder Lee #define MT_TXS4_F1_TSSI3		GENMASK(23, 12)
34204b8e659SRyder Lee #define MT_TXS4_F1_TSSI2		GENMASK(11, 0)
34304b8e659SRyder Lee 
34404b8e659SRyder Lee #define MT_TXS5_F0_FRONT_TIME		GENMASK(24, 0)
34504b8e659SRyder Lee #define MT_TXS5_F1_NOISE_2		GENMASK(23, 16)
34604b8e659SRyder Lee #define MT_TXS5_F1_NOISE_1		GENMASK(15, 8)
34704b8e659SRyder Lee #define MT_TXS5_F1_NOISE_0		GENMASK(7, 0)
34804b8e659SRyder Lee 
34904b8e659SRyder Lee #define MT_TXS6_F1_RCPI_3		GENMASK(31, 24)
35004b8e659SRyder Lee #define MT_TXS6_F1_RCPI_2		GENMASK(23, 16)
35104b8e659SRyder Lee #define MT_TXS6_F1_RCPI_1		GENMASK(15, 8)
35204b8e659SRyder Lee #define MT_TXS6_F1_RCPI_0		GENMASK(7, 0)
35304b8e659SRyder Lee 
3542ce73efeSLorenzo Bianconi struct mt7615_dfs_pulse {
3552ce73efeSLorenzo Bianconi 	u32 max_width;		/* us */
3562ce73efeSLorenzo Bianconi 	int max_pwr;		/* dbm */
3572ce73efeSLorenzo Bianconi 	int min_pwr;		/* dbm */
3582ce73efeSLorenzo Bianconi 	u32 min_stgr_pri;	/* us */
3592ce73efeSLorenzo Bianconi 	u32 max_stgr_pri;	/* us */
3602ce73efeSLorenzo Bianconi 	u32 min_cr_pri;		/* us */
3612ce73efeSLorenzo Bianconi 	u32 max_cr_pri;		/* us */
3622ce73efeSLorenzo Bianconi };
3632ce73efeSLorenzo Bianconi 
3642ce73efeSLorenzo Bianconi struct mt7615_dfs_pattern {
3652ce73efeSLorenzo Bianconi 	u8 enb;
3662ce73efeSLorenzo Bianconi 	u8 stgr;
3672ce73efeSLorenzo Bianconi 	u8 min_crpn;
3682ce73efeSLorenzo Bianconi 	u8 max_crpn;
3692ce73efeSLorenzo Bianconi 	u8 min_crpr;
3702ce73efeSLorenzo Bianconi 	u8 min_pw;
3712ce73efeSLorenzo Bianconi 	u8 max_pw;
3722ce73efeSLorenzo Bianconi 	u32 min_pri;
3732ce73efeSLorenzo Bianconi 	u32 max_pri;
3742ce73efeSLorenzo Bianconi 	u8 min_crbn;
3752ce73efeSLorenzo Bianconi 	u8 max_crbn;
3762ce73efeSLorenzo Bianconi 	u8 min_stgpn;
3772ce73efeSLorenzo Bianconi 	u8 max_stgpn;
3782ce73efeSLorenzo Bianconi 	u8 min_stgpr;
3792ce73efeSLorenzo Bianconi };
3802ce73efeSLorenzo Bianconi 
3812ce73efeSLorenzo Bianconi struct mt7615_dfs_radar_spec {
3822ce73efeSLorenzo Bianconi 	struct mt7615_dfs_pulse pulse_th;
3832ce73efeSLorenzo Bianconi 	struct mt7615_dfs_pattern radar_pattern[16];
3842ce73efeSLorenzo Bianconi };
3852ce73efeSLorenzo Bianconi 
38692671eb9SLorenzo Bianconi enum mt7615_cipher_type {
38792671eb9SLorenzo Bianconi 	MT_CIPHER_NONE,
38892671eb9SLorenzo Bianconi 	MT_CIPHER_WEP40,
38992671eb9SLorenzo Bianconi 	MT_CIPHER_TKIP,
39092671eb9SLorenzo Bianconi 	MT_CIPHER_TKIP_NO_MIC,
39192671eb9SLorenzo Bianconi 	MT_CIPHER_AES_CCMP,
39292671eb9SLorenzo Bianconi 	MT_CIPHER_WEP104,
39392671eb9SLorenzo Bianconi 	MT_CIPHER_BIP_CMAC_128,
39492671eb9SLorenzo Bianconi 	MT_CIPHER_WEP128,
39592671eb9SLorenzo Bianconi 	MT_CIPHER_WAPI,
39692671eb9SLorenzo Bianconi 	MT_CIPHER_CCMP_256 = 10,
39792671eb9SLorenzo Bianconi 	MT_CIPHER_GCMP,
39892671eb9SLorenzo Bianconi 	MT_CIPHER_GCMP_256,
39992671eb9SLorenzo Bianconi };
40092671eb9SLorenzo Bianconi 
401294f17aeSLorenzo Bianconi static inline enum mt7615_cipher_type
402294f17aeSLorenzo Bianconi mt7615_mac_get_cipher(int cipher)
403294f17aeSLorenzo Bianconi {
404294f17aeSLorenzo Bianconi 	switch (cipher) {
405294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_WEP40:
406294f17aeSLorenzo Bianconi 		return MT_CIPHER_WEP40;
407294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_WEP104:
408294f17aeSLorenzo Bianconi 		return MT_CIPHER_WEP104;
409294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_TKIP:
410294f17aeSLorenzo Bianconi 		return MT_CIPHER_TKIP;
411294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_AES_CMAC:
412294f17aeSLorenzo Bianconi 		return MT_CIPHER_BIP_CMAC_128;
413294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_CCMP:
414294f17aeSLorenzo Bianconi 		return MT_CIPHER_AES_CCMP;
415294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_CCMP_256:
416294f17aeSLorenzo Bianconi 		return MT_CIPHER_CCMP_256;
417294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_GCMP:
418294f17aeSLorenzo Bianconi 		return MT_CIPHER_GCMP;
419294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_GCMP_256:
420294f17aeSLorenzo Bianconi 		return MT_CIPHER_GCMP_256;
421294f17aeSLorenzo Bianconi 	case WLAN_CIPHER_SUITE_SMS4:
422294f17aeSLorenzo Bianconi 		return MT_CIPHER_WAPI;
423294f17aeSLorenzo Bianconi 	default:
424294f17aeSLorenzo Bianconi 		return MT_CIPHER_NONE;
425294f17aeSLorenzo Bianconi 	}
426294f17aeSLorenzo Bianconi }
427294f17aeSLorenzo Bianconi 
4286aa4ed79SFelix Fietkau static inline struct mt7615_txp_common *
429373a9a13SLorenzo Bianconi mt7615_txwi_to_txp(struct mt76_dev *dev, struct mt76_txwi_cache *t)
430373a9a13SLorenzo Bianconi {
431373a9a13SLorenzo Bianconi 	u8 *txwi;
432373a9a13SLorenzo Bianconi 
433373a9a13SLorenzo Bianconi 	if (!t)
434373a9a13SLorenzo Bianconi 		return NULL;
435373a9a13SLorenzo Bianconi 
436373a9a13SLorenzo Bianconi 	txwi = mt76_get_txwi_ptr(dev, t);
437373a9a13SLorenzo Bianconi 
4386aa4ed79SFelix Fietkau 	return (struct mt7615_txp_common *)(txwi + MT_TXD_SIZE);
439373a9a13SLorenzo Bianconi }
440373a9a13SLorenzo Bianconi 
441d506017eSLorenzo Bianconi static inline u32 mt7615_mac_wtbl_addr(struct mt7615_dev *dev, int wcid)
442d506017eSLorenzo Bianconi {
443d506017eSLorenzo Bianconi 	return MT_WTBL_BASE(dev) + wcid * MT_WTBL_ENTRY_SIZE;
444d506017eSLorenzo Bianconi }
445d506017eSLorenzo Bianconi 
44604b8e659SRyder Lee #endif
447