rtl8xxxu: add support for rtl8188eu
[openwrt/staging/rmilecki.git] / package / kernel / mac80211 / patches / 650-0013-rtl8xxxu-Enable-aggregation-for-rtl8723au.patch
1 From 7e9f37893c874ff2a01dfbf73d31d3de37359fc7 Mon Sep 17 00:00:00 2001
2 From: Jes Sorensen <Jes.Sorensen@redhat.com>
3 Date: Mon, 16 May 2016 21:50:57 -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 ---
14 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h | 1 +
15 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 2 ++
16 .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 34 ++++++++++++++++++++++
17 3 files changed, 37 insertions(+)
18
19 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
20 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.h
21 @@ -1412,6 +1412,7 @@ void rtl8xxxu_gen1_report_connect(struct
22 u8 macid, bool connect);
23 void rtl8xxxu_gen2_report_connect(struct rtl8xxxu_priv *priv,
24 u8 macid, bool connect);
25 +void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv);
26 void rtl8xxxu_gen1_enable_rf(struct rtl8xxxu_priv *priv);
27 void rtl8xxxu_gen1_disable_rf(struct rtl8xxxu_priv *priv);
28 void rtl8xxxu_gen2_disable_rf(struct rtl8xxxu_priv *priv);
29 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
30 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c
31 @@ -377,6 +377,7 @@ struct rtl8xxxu_fileops rtl8723au_fops =
32 .phy_iq_calibrate = rtl8xxxu_gen1_phy_iq_calibrate,
33 .config_channel = rtl8xxxu_gen1_config_channel,
34 .parse_rx_desc = rtl8xxxu_parse_rxdesc16,
35 + .init_aggregation = rtl8xxxu_gen1_init_aggregation,
36 .enable_rf = rtl8xxxu_gen1_enable_rf,
37 .disable_rf = rtl8xxxu_gen1_disable_rf,
38 .usb_quirks = rtl8xxxu_gen1_usb_quirks,
39 @@ -384,6 +385,7 @@ struct rtl8xxxu_fileops rtl8723au_fops =
40 .update_rate_mask = rtl8xxxu_update_rate_mask,
41 .report_connect = rtl8xxxu_gen1_report_connect,
42 .writeN_block_size = 1024,
43 + .rx_agg_buf_size = 16000,
44 .tx_desc_size = sizeof(struct rtl8xxxu_txdesc32),
45 .rx_desc_size = sizeof(struct rtl8xxxu_rxdesc16),
46 .adda_1t_init = 0x0b1b25a0,
47 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
48 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
49 @@ -4405,6 +4405,40 @@ void rtl8xxxu_gen2_report_connect(struct
50 rtl8xxxu_gen2_h2c_cmd(priv, &h2c, sizeof(h2c.media_status_rpt));
51 }
52
53 +void rtl8xxxu_gen1_init_aggregation(struct rtl8xxxu_priv *priv)
54 +{
55 + u8 agg_ctrl, usb_spec, page_thresh;
56 +
57 + usb_spec = rtl8xxxu_read8(priv, REG_USB_SPECIAL_OPTION);
58 + usb_spec &= ~USB_SPEC_USB_AGG_ENABLE;
59 +
60 + agg_ctrl = rtl8xxxu_read8(priv, REG_TRXDMA_CTRL);
61 + agg_ctrl &= ~TRXDMA_CTRL_RXDMA_AGG_EN;
62 +
63 + agg_ctrl |= TRXDMA_CTRL_RXDMA_AGG_EN;
64 +
65 + rtl8xxxu_write8(priv, REG_TRXDMA_CTRL, agg_ctrl);
66 + rtl8xxxu_write8(priv, REG_USB_SPECIAL_OPTION, usb_spec);
67 +
68 + /*
69 + * The number of packets we can take looks to be buffer size / 512
70 + * which matches the 512 byte rounding we have to do when de-muxing
71 + * the packets.
72 + *
73 + * Sample numbers from the vendor driver:
74 + * USB High-Speed mode values:
75 + * RxAggBlockCount = 8 : 512 byte unit
76 + * RxAggBlockTimeout = 6
77 + * RxAggPageCount = 48 : 128 byte unit
78 + * RxAggPageTimeout = 4 or 6 (absolute time 34ms/(2^6))
79 + */
80 +
81 + page_thresh = (priv->fops->rx_agg_buf_size / 512);
82 + rtl8xxxu_write8(priv, REG_RXDMA_AGG_PG_TH, page_thresh);
83 + rtl8xxxu_write8(priv, REG_USB_DMA_AGG_TO, 4);
84 + priv->rx_buf_aggregation = 1;
85 +}
86 +
87 static void rtl8xxxu_set_basic_rates(struct rtl8xxxu_priv *priv, u32 rate_cfg)
88 {
89 u32 val32;