]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - drivers/net/wireless/mediatek/mt7601u/dma.h
2 * Copyright (C) 2014 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #ifndef __MT7601U_DMA_H
16 #define __MT7601U_DMA_H
18 #include <asm/unaligned.h>
19 #include <linux/skbuff.h>
23 #define MT_DMA_HDR_LEN 4
24 #define MT_RX_INFO_LEN 4
25 #define MT_FCE_INFO_LEN 4
26 #define MT_DMA_HDRS (MT_DMA_HDR_LEN + MT_RX_INFO_LEN)
28 /* Common Tx DMA descriptor fields */
29 #define MT_TXD_INFO_LEN GENMASK(15, 0)
30 #define MT_TXD_INFO_D_PORT GENMASK(29, 27)
31 #define MT_TXD_INFO_TYPE GENMASK(31, 30)
48 /* Tx DMA packet specific flags */
49 #define MT_TXD_PKT_INFO_NEXT_VLD BIT(16)
50 #define MT_TXD_PKT_INFO_TX_BURST BIT(17)
51 #define MT_TXD_PKT_INFO_80211 BIT(19)
52 #define MT_TXD_PKT_INFO_TSO BIT(20)
53 #define MT_TXD_PKT_INFO_CSO BIT(21)
54 #define MT_TXD_PKT_INFO_WIV BIT(24)
55 #define MT_TXD_PKT_INFO_QSEL GENMASK(26, 25)
64 /* Tx DMA MCU command specific flags */
65 #define MT_TXD_CMD_INFO_SEQ GENMASK(19, 16)
66 #define MT_TXD_CMD_INFO_TYPE GENMASK(26, 20)
68 static inline int mt7601u_dma_skb_wrap(struct sk_buff
*skb
,
69 enum mt76_msg_port d_port
,
70 enum mt76_info_type type
, u32 flags
)
75 * | 4B | xfer len | pad | 4B |
76 * | TXINFO | pkt/cmd | zero pad to 4B | zero |
78 * length field of TXINFO should be set to 'xfer len'.
82 MT76_SET(MT_TXD_INFO_LEN
, round_up(skb
->len
, 4)) |
83 MT76_SET(MT_TXD_INFO_D_PORT
, d_port
) |
84 MT76_SET(MT_TXD_INFO_TYPE
, type
);
86 put_unaligned_le32(info
, skb_push(skb
, sizeof(info
)));
87 return skb_put_padto(skb
, round_up(skb
->len
, 4) + 4);
91 mt7601u_dma_skb_wrap_pkt(struct sk_buff
*skb
, enum mt76_qsel qsel
, u32 flags
)
93 flags
|= MT76_SET(MT_TXD_PKT_INFO_QSEL
, qsel
);
94 return mt7601u_dma_skb_wrap(skb
, WLAN_PORT
, DMA_PACKET
, flags
);
97 /* Common Rx DMA descriptor fields */
98 #define MT_RXD_INFO_LEN GENMASK(13, 0)
99 #define MT_RXD_INFO_PCIE_INTR BIT(24)
100 #define MT_RXD_INFO_QSEL GENMASK(26, 25)
101 #define MT_RXD_INFO_PORT GENMASK(29, 27)
102 #define MT_RXD_INFO_TYPE GENMASK(31, 30)
104 /* Rx DMA packet specific flags */
105 #define MT_RXD_PKT_INFO_UDP_ERR BIT(16)
106 #define MT_RXD_PKT_INFO_TCP_ERR BIT(17)
107 #define MT_RXD_PKT_INFO_IP_ERR BIT(18)
108 #define MT_RXD_PKT_INFO_PKT_80211 BIT(19)
109 #define MT_RXD_PKT_INFO_L3L4_DONE BIT(20)
110 #define MT_RXD_PKT_INFO_MAC_LEN GENMASK(23, 21)
112 /* Rx DMA MCU command specific flags */
113 #define MT_RXD_CMD_INFO_SELF_GEN BIT(15)
114 #define MT_RXD_CMD_INFO_CMD_SEQ GENMASK(19, 16)
115 #define MT_RXD_CMD_INFO_EVT_TYPE GENMASK(23, 20)
123 EVENT_CARRIER_DETECT_RSP
,
124 EVENT_DFS_DETECT_RSP
,