mac80211: use upstream patches for rtl8xxxu
[openwrt/staging/yousong.git] / package / kernel / mac80211 / patches / 652-0008-rtl8xxxu-Enable-aggregation-for-rtl8723au.patch
1 From 91dcbb7175317da7caafc3b05b002addd42cdabd Mon Sep 17 00:00:00 2001
2 From: Jes Sorensen <Jes.Sorensen@redhat.com>
3 Date: Mon, 27 Jun 2016 12:32:06 -0400
4 Subject: [PATCH] rtl8xxxu: Enable aggregation for rtl8723au
5
6 Implement rtl8xxxu_gen1_init_aggregation(). Aggregation should be the
7 same for all gen1 parts. We may want to allow for tuning parameters in
8 the fileopes struct. For now this is based allocating 16KB RX buffers,
9 leaving 16000 bytes for actual packets, and the rest for the skb
10 overhead.
11
12 Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
14 ---
15 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 +
16 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 2 ++
17 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 34 ++++++++++++++++++++++
18 3 files changed, 37 insertions(+)
19
20 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
21 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
22 @@ -1412,6 +1412,7 @@ void rtl8xxxu_gen1_report_connect(struct
23 u8 macid, bool connect);
24 void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv,
25 u8 macid, bool connect);
26 +void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv);
27 void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv);
28 void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv);
29 void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv);
30 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
31 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
32 @@ -377,6 +377,7 @@ struct rtl8xxxu_fileops rtl8723au_fops =
33 .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate,
34 .config_channel = rtl8xxxu_gen1_config_channel,
35 .parse_rx_desc = rtl8xxxu_parse_rxdesc16,
36 + .init_aggregation = rtl8xxxu_gen1_init_aggregation,
37 .enable_rf = rtl8xxxu_gen1_enable_rf,
38 .disable_rf = rtl8xxxu_gen1_disable_rf,
39 .usb_quirks = rtl8xxxu_gen1_usb_quirks,
40 @@ -384,6 +385,7 @@ struct rtl8xxxu_fileops rtl8723au_fops =
41 .update_rate_mask = rtl8xxxu_update_rate_mask,
42 .report_connect = rtl8xxxu_gen1_report_connect,
43 .writeN_block_size = 1024,
44 + .rx_agg_buf_size = 16000,
45 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
46 .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16),
47 .adda_1t_init = 0x0b1b25a0,
48 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
49 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
50 @@ -4405,6 +4405,40 @@ void rtl8xxxu_gen2_report_connect(struct
51 rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt));
52 }
53
54 +void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv)
55 +{
56 + u8 agg_ctrl, usb_spec, page_thresh;
57 +
58 + usb_spec = rtl8xxxu_read8(priv, REG_USB_SPECIAL_OPTION);
59 + usb_spec &= ~USB_SPEC_USB_AGG_ENABLE;
60 +
61 + agg_ctrl = rtl8xxxu_read8(priv, REG_TRXDMA_CTRL);
62 + agg_ctrl &= ~TRXDMA_CTRL_RXDMA_AGG_EN;
63 +
64 + agg_ctrl |= TRXDMA_CTRL_RXDMA_AGG_EN;
65 +
66 + rtl8xxxu_write8(priv, REG_TRXDMA_CTRL, agg_ctrl);
67 + rtl8xxxu_write8(priv, REG_USB_SPECIAL_OPTION, usb_spec);
68 +
69 + /*
70 + * The number of packets we can take looks to be buffer size / 512
71 + * which matches the 512 byte rounding we have to do when de-muxing
72 + * the packets.
73 + *
74 + * Sample numbers from the vendor driver:
75 + * USB High-Speed mode values:
76 + * RxAggBlockCount = 8 : 512 byte unit
77 + * RxAggBlockTimeout = 6
78 + * RxAggPageCount = 48 : 128 byte unit
79 + * RxAggPageTimeout = 4 or 6 (absolute time 34ms/(2^6))
80 + */
81 +
82 + page_thresh = (priv->fops->rx_agg_buf_size / 512);
83 + rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH, page_thresh);
84 + rtl8xxxu_write8(priv, REG_USB_DMA_AGG_TO, 4);
85 + priv->rx_buf_aggregation = 1;
86 +}
87 +
88 static void rtl8xxxu_set_basic_rates(struct rtl8xxxu_priv *priv, u32 rate_cfg)
89 {
90 u32 val32;