package/devel/binutils: Update to 2.27
[openwrt/staging/yousong.git] / package / kernel / mac80211 / patches / 660-0035-rtl8xxxu-Implement-rtl8xxxu_fill_txdesc_v3-for-8188e.patch
1 From 3c50918b180d091a49e412742a4f7aa1a89802b1 Mon Sep 17 00:00:00 2001
2 From: Jes Sorensen <Jes.Sorensen@redhat.com>
3 Date: Tue, 26 Jul 2016 14:01:14 -0400
4 Subject: [PATCH] rtl8xxxu: Implement rtl8xxxu_fill_txdesc_v3() for 8188eu
5
6 Getting closer but still no cigar.
7
8 Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
9 ---
10 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 11 +++
11 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c | 1 +
12 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 78 ++++++++++++++++++++++
13 3 files changed, 90 insertions(+)
14
15 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
16 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
17 @@ -510,6 +510,8 @@ struct rtl8xxxu_txdesc40 {
18 #define TXDESC_AMPDU_DENSITY_SHIFT 20
19 #define TXDESC40_BT_INT BIT(23)
20 #define TXDESC40_GID_SHIFT 24
21 +#define TXDESC_ANTENNA_SELECT_A BIT(24)
22 +#define TXDESC_ANTENNA_SELECT_B BIT(25)
23
24 /* Word 3 */
25 #define TXDESC40_USE_DRIVER_RATE BIT(8)
26 @@ -554,6 +556,10 @@ struct rtl8xxxu_txdesc40 {
27
28 /* Word 6 */
29 #define TXDESC_MAX_AGG_SHIFT 11
30 +#define TXDESC_USB_TX_AGG_SHIT 24
31 +
32 +/* Word 7 */
33 +#define TXDESC_ANTENNA_SELECT_C BIT(29)
34
35 /* Word 8 */
36 #define TXDESC40_HW_SEQ_ENABLE BIT(15)
37 @@ -1487,6 +1493,11 @@ void rtl8xxxu_fill_txdesc_v2(struct ieee
38 struct ieee80211_tx_info *tx_info,
39 struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi,
40 bool short_preamble, bool ampdu_enable,
41 + u32 rts_rate);
42 +void rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
43 + struct ieee80211_tx_info *tx_info,
44 + struct rtl8xxxu_txdesc32 *tx_desc32, bool sgi,
45 + bool short_preamble, bool ampdu_enable,
46 u32 rts_rate);
47
48 extern struct rtl8xxxu_fileops rtl8188eu_fops;
49 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
50 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188e.c
51 @@ -1217,6 +1217,7 @@ struct rtl8xxxu_fileops rtl8188eu_fops =
52 .set_tx_power = rtl8188e_set_tx_power,
53 .update_rate_mask = rtl8xxxu_gen2_update_rate_mask,
54 .report_connect = rtl8xxxu_gen2_report_connect,
55 + .fill_txdesc = rtl8xxxu_fill_txdesc_v3,
56 .writeN_block_size = 128,
57 .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16),
58 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
59 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
60 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
61 @@ -4923,6 +4923,84 @@ rtl8xxxu_fill_txdesc_v2(struct ieee80211
62 }
63 }
64
65 +/*
66 + * Fill in v3 (gen1) specific TX descriptor bits.
67 + * This format is a hybrid between the v1 and v2 formats, only seen
68 + * on 8188eu devices so far.
69 + */
70 +void
71 +rtl8xxxu_fill_txdesc_v3(struct ieee80211_hw *hw, struct ieee80211_hdr *hdr,
72 + struct ieee80211_tx_info *tx_info,
73 + struct rtl8xxxu_txdesc32 *tx_desc, bool sgi,
74 + bool short_preamble, bool ampdu_enable, u32 rts_rate)
75 +{
76 + struct ieee80211_rate *tx_rate = ieee80211_get_tx_rate(hw, tx_info);
77 + struct rtl8xxxu_priv *priv = hw->priv;
78 + struct device *dev = &priv->udev->dev;
79 + u32 rate;
80 + u16 rate_flags = tx_info->control.rates[0].flags;
81 + u16 seq_number;
82 +
83 + if (rate_flags & IEEE80211_TX_RC_MCS &&
84 + !ieee80211_is_mgmt(hdr->frame_control))
85 + rate = tx_info->control.rates[0].idx + DESC_RATE_MCS0;
86 + else
87 + rate = tx_rate->hw_value;
88 +
89 + if (rtl8xxxu_debug & RTL8XXXU_DEBUG_TX)
90 + dev_info(dev, "%s: TX rate: %d, pkt size %d\n",
91 + __func__, rate, cpu_to_le16(tx_desc->pkt_size));
92 +
93 + seq_number = IEEE80211_SEQ_TO_SN(le16_to_cpu(hdr->seq_ctrl));
94 +
95 + tx_desc->txdw5 = cpu_to_le32(rate);
96 +
97 + /*
98 + * Data/RTS rate FB limit
99 + */
100 + if (ieee80211_is_data(hdr->frame_control))
101 + tx_desc->txdw5 |= cpu_to_le32(0x0001ff00);
102 +
103 + tx_desc->txdw3 = cpu_to_le32((u32)seq_number << TXDESC32_SEQ_SHIFT);
104 +
105 + if (ampdu_enable)
106 + tx_desc->txdw2 |= cpu_to_le32(TXDESC40_AGG_ENABLE);
107 + else
108 + tx_desc->txdw2 |= cpu_to_le32(TXDESC40_AGG_BREAK);
109 +
110 + if (ieee80211_is_mgmt(hdr->frame_control)) {
111 + tx_desc->txdw5 = cpu_to_le32(rate);
112 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_USE_DRIVER_RATE);
113 + tx_desc->txdw5 |= cpu_to_le32(6 << TXDESC32_RETRY_LIMIT_SHIFT);
114 + tx_desc->txdw5 |= cpu_to_le32(TXDESC32_RETRY_LIMIT_ENABLE);
115 + }
116 +
117 + if (ieee80211_is_data_qos(hdr->frame_control))
118 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_QOS);
119 +
120 + if (short_preamble)
121 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_SHORT_PREAMBLE);
122 +
123 + if (sgi)
124 + tx_desc->txdw5 |= cpu_to_le32(TXDESC32_SHORT_GI);
125 +
126 + /*
127 + * rts_rate is zero if RTS/CTS or CTS to SELF are not enabled
128 + */
129 + tx_desc->txdw4 |= cpu_to_le32(rts_rate << TXDESC32_RTS_RATE_SHIFT);
130 + if (rate_flags & IEEE80211_TX_RC_USE_RTS_CTS) {
131 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_RTS_CTS_ENABLE);
132 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
133 + } else if (rate_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) {
134 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_CTS_SELF_ENABLE);
135 + tx_desc->txdw4 |= cpu_to_le32(TXDESC32_HW_RTS_ENABLE);
136 + }
137 +
138 + tx_desc->txdw2 |= cpu_to_le32(TXDESC_ANTENNA_SELECT_A |
139 + TXDESC_ANTENNA_SELECT_B);
140 + tx_desc->txdw7 |= cpu_to_le32(TXDESC_ANTENNA_SELECT_C);
141 +}
142 +
143 static void rtl8xxxu_tx(struct ieee80211_hw *hw,
144 struct ieee80211_tx_control *control,
145 struct sk_buff *skb)