1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
4 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
7 #ifndef __MT7601U_DMA_H
8 #define __MT7601U_DMA_H
10 #include <asm/unaligned.h>
11 #include <linux/skbuff.h>
13 #define MT_DMA_HDR_LEN 4
14 #define MT_RX_INFO_LEN 4
15 #define MT_FCE_INFO_LEN 4
16 #define MT_DMA_HDRS (MT_DMA_HDR_LEN + MT_RX_INFO_LEN)
18 /* Common Tx DMA descriptor fields */
19 #define MT_TXD_INFO_LEN GENMASK(15, 0)
20 #define MT_TXD_INFO_D_PORT GENMASK(29, 27)
21 #define MT_TXD_INFO_TYPE GENMASK(31, 30)
38 /* Tx DMA packet specific flags */
39 #define MT_TXD_PKT_INFO_NEXT_VLD BIT(16)
40 #define MT_TXD_PKT_INFO_TX_BURST BIT(17)
41 #define MT_TXD_PKT_INFO_80211 BIT(19)
42 #define MT_TXD_PKT_INFO_TSO BIT(20)
43 #define MT_TXD_PKT_INFO_CSO BIT(21)
44 #define MT_TXD_PKT_INFO_WIV BIT(24)
45 #define MT_TXD_PKT_INFO_QSEL GENMASK(26, 25)
54 /* Tx DMA MCU command specific flags */
55 #define MT_TXD_CMD_INFO_SEQ GENMASK(19, 16)
56 #define MT_TXD_CMD_INFO_TYPE GENMASK(26, 20)
58 static inline int mt7601u_dma_skb_wrap(struct sk_buff
*skb
,
59 enum mt76_msg_port d_port
,
60 enum mt76_info_type type
, u32 flags
)
65 * | 4B | xfer len | pad | 4B |
66 * | TXINFO | pkt/cmd | zero pad to 4B | zero |
68 * length field of TXINFO should be set to 'xfer len'.
72 FIELD_PREP(MT_TXD_INFO_LEN
, round_up(skb
->len
, 4)) |
73 FIELD_PREP(MT_TXD_INFO_D_PORT
, d_port
) |
74 FIELD_PREP(MT_TXD_INFO_TYPE
, type
);
76 put_unaligned_le32(info
, skb_push(skb
, sizeof(info
)));
77 return skb_put_padto(skb
, round_up(skb
->len
, 4) + 4);
81 mt7601u_dma_skb_wrap_pkt(struct sk_buff
*skb
, enum mt76_qsel qsel
, u32 flags
)
83 flags
|= FIELD_PREP(MT_TXD_PKT_INFO_QSEL
, qsel
);
84 return mt7601u_dma_skb_wrap(skb
, WLAN_PORT
, DMA_PACKET
, flags
);
87 /* Common Rx DMA descriptor fields */
88 #define MT_RXD_INFO_LEN GENMASK(13, 0)
89 #define MT_RXD_INFO_PCIE_INTR BIT(24)
90 #define MT_RXD_INFO_QSEL GENMASK(26, 25)
91 #define MT_RXD_INFO_PORT GENMASK(29, 27)
92 #define MT_RXD_INFO_TYPE GENMASK(31, 30)
94 /* Rx DMA packet specific flags */
95 #define MT_RXD_PKT_INFO_UDP_ERR BIT(16)
96 #define MT_RXD_PKT_INFO_TCP_ERR BIT(17)
97 #define MT_RXD_PKT_INFO_IP_ERR BIT(18)
98 #define MT_RXD_PKT_INFO_PKT_80211 BIT(19)
99 #define MT_RXD_PKT_INFO_L3L4_DONE BIT(20)
100 #define MT_RXD_PKT_INFO_MAC_LEN GENMASK(23, 21)
102 /* Rx DMA MCU command specific flags */
103 #define MT_RXD_CMD_INFO_SELF_GEN BIT(15)
104 #define MT_RXD_CMD_INFO_CMD_SEQ GENMASK(19, 16)
105 #define MT_RXD_CMD_INFO_EVT_TYPE GENMASK(23, 20)
113 EVENT_CARRIER_DETECT_RSP
,
114 EVENT_DFS_DETECT_RSP
,