[OpenWrt-Devel] mac80211: backport rtlwifi fixes from wireless-testing
diff mbox

Message ID 20150202171444.GA8683@makrotopia.org
State Rejected
Headers show

Commit Message

Daniel Golle Feb. 2, 2015, 5:14 p.m. UTC
Fixes for various rtlwifi issues, including beaconing in AP and mesh mode
with rtl8192cu (which previously prevented AP mode from working on various
sunxi boards).
This is a temporary fix as all these patches were already merged in
wireless-testing, thus the next mac80211 compat-wireless version bump will
allow to remove them again.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 ...-setting-of-tx-descriptor-for-new-trx-flo.patch |  39 +
 ...ifi-Fix-errors-in-descriptor-manipulation.patch |  42 ++
 ...rtlwifi-rtl8192se-Fix-connection-problems.patch | 122 ++++
 ...ate-RCR-register-in-rtl_op_configure_filt.patch |  79 +++
 ...s-rtlwifi-Do-not-always-include-drivers-i.patch |  74 ++
 ...s-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch |  29 +
 ...tlwifi-rtl8821ae-Fix-5G-detection-problem.patch |  39 +
 ...10-rtlwifi-Change-order-in-device-startup.patch |  62 ++
 ...8192ce-Fix-editing-error-that-causes-sile.patch |  47 ++
 ...8192ce-Fix-kernel-crashes-due-to-missing-.patch |  88 +++
 ...tl8192ce-Fix-missing-interrupt-ready-flag.patch |  42 ++
 ...8821ae-fix-misspelling-of-current-functio.patch |  65 ++
 ...8192cu-Fix-sparse-non-static-symbol-warni.patch |  34 +
 ...-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch |  37 +
 ...ifi-rtl8192de-fw.c-Remove-unused-function.patch |  59 ++
 ...8821ae-Simplify-loading-of-WOWLAN-firmwar.patch | 211 ++++++
 ...l8821ae-Fix-typos-in-power-sequence-macro.patch |  33 +
 ...8192ce-Add-code-to-set-the-keep-alive-ope.patch |  50 ++
 ...8192ce-Update-setting-of-the-media-status.patch | 106 +++
 ...fi-rtl8192ce-Update-rate-setting-routines.patch | 199 ++++++
 ...tlwifi-rtl8192ce-Improve-RF-sleep-routine.patch |  35 +
 ...move-extraneous-argument-for-rate-mapping.patch | 138 ++++
 ...8723be-Switch-to-use-common-rate-mapping-.patch | 196 +++++
 ...8188ee-Switch-to-use-common-rate-mapping-.patch | 197 ++++++
 ...8723ae-Modify-driver-to-use-rate-mapping-.patch | 197 ++++++
 ...8192ee-Convert-driver-to-use-common-rate-.patch | 196 +++++
 ...vert-all-drivers-to-use-a-common-set-of-r.patch | 786 +++++++++++++++++++++
 ...tlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch |  85 +++
 ...8192cu-Rework-calls-to-rate-control-routi.patch |  62 ++
 ...8192de-Rework-calls-to-rate-control-routi.patch |  42 ++
 ...8821ae-Switch-to-use-common-rate-control-.patch | 498 +++++++++++++
 ...fi-rtl8192ee-trx.c-Remove-unused-function.patch |  64 ++
 ...fi-rtl8723be-phy.c-Remove-unused-function.patch |  69 ++
 ...-error-when-accessing-unmapped-memory-in-.patch | 126 ++++
 ...ifi-Unify-variable-naming-for-all-drivers.patch | 300 ++++++++
 ...-rtlwifi-rtl8723be-Improve-modinfo-output.patch |  40 ++
 ...ate-new-routine-to-initialize-the-DM-tabl.patch | 607 ++++++++++++++++
 ...8188ee-Convert-driver-to-use-the-common-D.patch |  73 ++
 ...8192c-common-Convert-driver-to-use-common.patch | 411 +++++++++++
 ...8192de-Convert-driver-to-use-common-DM-ta.patch |  68 ++
 ...8192ee-Convert-driver-to-use-common-DM-ta.patch |  71 ++
 ...8723ae-Convert-driver-to-use-common-DM-ta.patch |  62 ++
 ...8723be-Convert-driver-to-use-common-DM-ta.patch |  69 ++
 ...8821ae-Convert-driver-to-use-common-DM-ta.patch |  73 ++
 ...47-rtlwifi-Move-macro-definitions-to-core.patch | 140 ++++
 ...-rtl8192de-remove-redundant-else-if-check.patch |  46 ++
 ...-rtlwifi-add-support-to-send-beacon-frame.patch |  47 ++
 ...680-0050-rtl8192cu-fix-the-mesh-beaconing.patch |  31 +
 ...-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch |  38 +
 49 files changed, 6224 insertions(+)
 create mode 100644 package/kernel/mac80211/patches/680-0002-rtlwifi-Fix-setting-of-tx-descriptor-for-new-trx-flo.patch
 create mode 100644 package/kernel/mac80211/patches/680-0003-rtlwifi-Fix-errors-in-descriptor-manipulation.patch
 create mode 100644 package/kernel/mac80211/patches/680-0004-rtlwifi-rtl8192se-Fix-connection-problems.patch
 create mode 100644 package/kernel/mac80211/patches/680-0006-rtlwifi-update-RCR-register-in-rtl_op_configure_filt.patch
 create mode 100644 package/kernel/mac80211/patches/680-0007-net-wireless-rtlwifi-Do-not-always-include-drivers-i.patch
 create mode 100644 package/kernel/mac80211/patches/680-0008-net-wireless-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch
 create mode 100644 package/kernel/mac80211/patches/680-0009-rtlwifi-rtl8821ae-Fix-5G-detection-problem.patch
 create mode 100644 package/kernel/mac80211/patches/680-0010-rtlwifi-Change-order-in-device-startup.patch
 create mode 100644 package/kernel/mac80211/patches/680-0011-rtlwifi-rtl8192ce-Fix-editing-error-that-causes-sile.patch
 create mode 100644 package/kernel/mac80211/patches/680-0012-rtlwifi-rtl8192ce-Fix-kernel-crashes-due-to-missing-.patch
 create mode 100644 package/kernel/mac80211/patches/680-0013-rtlwifi-rtl8192ce-Fix-missing-interrupt-ready-flag.patch
 create mode 100644 package/kernel/mac80211/patches/680-0014-rtlwifi-rtl8821ae-fix-misspelling-of-current-functio.patch
 create mode 100644 package/kernel/mac80211/patches/680-0015-rtlwifi-rtl8192cu-Fix-sparse-non-static-symbol-warni.patch
 create mode 100644 package/kernel/mac80211/patches/680-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch
 create mode 100644 package/kernel/mac80211/patches/680-0017-rtlwifi-rtl8192de-fw.c-Remove-unused-function.patch
 create mode 100644 package/kernel/mac80211/patches/680-0018-rtlwifi-rtl8821ae-Simplify-loading-of-WOWLAN-firmwar.patch
 create mode 100644 package/kernel/mac80211/patches/680-0019-rtlwifi-rtl8821ae-Fix-typos-in-power-sequence-macro.patch
 create mode 100644 package/kernel/mac80211/patches/680-0020-rtlwifi-rtl8192ce-Add-code-to-set-the-keep-alive-ope.patch
 create mode 100644 package/kernel/mac80211/patches/680-0021-rtlwifi-rtl8192ce-Update-setting-of-the-media-status.patch
 create mode 100644 package/kernel/mac80211/patches/680-0022-rtlwifi-rtl8192ce-Update-rate-setting-routines.patch
 create mode 100644 package/kernel/mac80211/patches/680-0023-rtlwifi-rtl8192ce-Improve-RF-sleep-routine.patch
 create mode 100644 package/kernel/mac80211/patches/680-0024-rtlwifi-Remove-extraneous-argument-for-rate-mapping.patch
 create mode 100644 package/kernel/mac80211/patches/680-0025-rtlwifi-rtl8723be-Switch-to-use-common-rate-mapping-.patch
 create mode 100644 package/kernel/mac80211/patches/680-0026-rtlwifi-rtl8188ee-Switch-to-use-common-rate-mapping-.patch
 create mode 100644 package/kernel/mac80211/patches/680-0027-rtlwifi-rtl8723ae-Modify-driver-to-use-rate-mapping-.patch
 create mode 100644 package/kernel/mac80211/patches/680-0028-rtlwifi-rtl8192ee-Convert-driver-to-use-common-rate-.patch
 create mode 100644 package/kernel/mac80211/patches/680-0029-rtlwifi-Convert-all-drivers-to-use-a-common-set-of-r.patch
 create mode 100644 package/kernel/mac80211/patches/680-0030-rtlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch
 create mode 100644 package/kernel/mac80211/patches/680-0031-rtlwifi-rtl8192cu-Rework-calls-to-rate-control-routi.patch
 create mode 100644 package/kernel/mac80211/patches/680-0032-rtlwifi-rtl8192de-Rework-calls-to-rate-control-routi.patch
 create mode 100644 package/kernel/mac80211/patches/680-0033-rtlwifi-rtl8821ae-Switch-to-use-common-rate-control-.patch
 create mode 100644 package/kernel/mac80211/patches/680-0034-rtlwifi-rtl8192ee-trx.c-Remove-unused-function.patch
 create mode 100644 package/kernel/mac80211/patches/680-0035-rtlwifi-rtl8723be-phy.c-Remove-unused-function.patch
 create mode 100644 package/kernel/mac80211/patches/680-0036-rtlwifi-Fix-error-when-accessing-unmapped-memory-in-.patch
 create mode 100644 package/kernel/mac80211/patches/680-0037-rtlwifi-Unify-variable-naming-for-all-drivers.patch
 create mode 100644 package/kernel/mac80211/patches/680-0038-rtlwifi-rtl8723be-Improve-modinfo-output.patch
 create mode 100644 package/kernel/mac80211/patches/680-0039-rtlwifi-Create-new-routine-to-initialize-the-DM-tabl.patch
 create mode 100644 package/kernel/mac80211/patches/680-0040-rtlwifi-rtl8188ee-Convert-driver-to-use-the-common-D.patch
 create mode 100644 package/kernel/mac80211/patches/680-0041-rtlwifi-rtl8192c-common-Convert-driver-to-use-common.patch
 create mode 100644 package/kernel/mac80211/patches/680-0042-rtlwifi-rtl8192de-Convert-driver-to-use-common-DM-ta.patch
 create mode 100644 package/kernel/mac80211/patches/680-0043-rtlwifi-rtl8192ee-Convert-driver-to-use-common-DM-ta.patch
 create mode 100644 package/kernel/mac80211/patches/680-0044-rtlwifi-rtl8723ae-Convert-driver-to-use-common-DM-ta.patch
 create mode 100644 package/kernel/mac80211/patches/680-0045-rtlwifi-rtl8723be-Convert-driver-to-use-common-DM-ta.patch
 create mode 100644 package/kernel/mac80211/patches/680-0046-rtlwifi-rtl8821ae-Convert-driver-to-use-common-DM-ta.patch
 create mode 100644 package/kernel/mac80211/patches/680-0047-rtlwifi-Move-macro-definitions-to-core.patch
 create mode 100644 package/kernel/mac80211/patches/680-0048-rtlwifi-rtl8192de-remove-redundant-else-if-check.patch
 create mode 100644 package/kernel/mac80211/patches/680-0049-rtlwifi-add-support-to-send-beacon-frame.patch
 create mode 100644 package/kernel/mac80211/patches/680-0050-rtl8192cu-fix-the-mesh-beaconing.patch
 create mode 100644 package/kernel/mac80211/patches/680-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch

Comments

John Crispin Feb. 3, 2015, 8:02 a.m. UTC | #1
On 02/02/2015 18:14, Daniel Golle wrote:
> Fixes for various rtlwifi issues, including beaconing in AP and mesh mode
> with rtl8192cu (which previously prevented AP mode from working on various
> sunxi boards).
> This is a temporary fix as all these patches were already merged in
> wireless-testing, thus the next mac80211 compat-wireless version bump will
> allow to remove them again.
> 

with 6k inserts and almost 50 patches i am inclined to drop this and ask
you to wait for the next compat wireless update. would that be ok for you ?




> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> ---
>  ...-setting-of-tx-descriptor-for-new-trx-flo.patch |  39 +
>  ...ifi-Fix-errors-in-descriptor-manipulation.patch |  42 ++
>  ...rtlwifi-rtl8192se-Fix-connection-problems.patch | 122 ++++
>  ...ate-RCR-register-in-rtl_op_configure_filt.patch |  79 +++
>  ...s-rtlwifi-Do-not-always-include-drivers-i.patch |  74 ++
>  ...s-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch |  29 +
>  ...tlwifi-rtl8821ae-Fix-5G-detection-problem.patch |  39 +
>  ...10-rtlwifi-Change-order-in-device-startup.patch |  62 ++
>  ...8192ce-Fix-editing-error-that-causes-sile.patch |  47 ++
>  ...8192ce-Fix-kernel-crashes-due-to-missing-.patch |  88 +++
>  ...tl8192ce-Fix-missing-interrupt-ready-flag.patch |  42 ++
>  ...8821ae-fix-misspelling-of-current-functio.patch |  65 ++
>  ...8192cu-Fix-sparse-non-static-symbol-warni.patch |  34 +
>  ...-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch |  37 +
>  ...ifi-rtl8192de-fw.c-Remove-unused-function.patch |  59 ++
>  ...8821ae-Simplify-loading-of-WOWLAN-firmwar.patch | 211 ++++++
>  ...l8821ae-Fix-typos-in-power-sequence-macro.patch |  33 +
>  ...8192ce-Add-code-to-set-the-keep-alive-ope.patch |  50 ++
>  ...8192ce-Update-setting-of-the-media-status.patch | 106 +++
>  ...fi-rtl8192ce-Update-rate-setting-routines.patch | 199 ++++++
>  ...tlwifi-rtl8192ce-Improve-RF-sleep-routine.patch |  35 +
>  ...move-extraneous-argument-for-rate-mapping.patch | 138 ++++
>  ...8723be-Switch-to-use-common-rate-mapping-.patch | 196 +++++
>  ...8188ee-Switch-to-use-common-rate-mapping-.patch | 197 ++++++
>  ...8723ae-Modify-driver-to-use-rate-mapping-.patch | 197 ++++++
>  ...8192ee-Convert-driver-to-use-common-rate-.patch | 196 +++++
>  ...vert-all-drivers-to-use-a-common-set-of-r.patch | 786 +++++++++++++++++++++
>  ...tlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch |  85 +++
>  ...8192cu-Rework-calls-to-rate-control-routi.patch |  62 ++
>  ...8192de-Rework-calls-to-rate-control-routi.patch |  42 ++
>  ...8821ae-Switch-to-use-common-rate-control-.patch | 498 +++++++++++++
>  ...fi-rtl8192ee-trx.c-Remove-unused-function.patch |  64 ++
>  ...fi-rtl8723be-phy.c-Remove-unused-function.patch |  69 ++
>  ...-error-when-accessing-unmapped-memory-in-.patch | 126 ++++
>  ...ifi-Unify-variable-naming-for-all-drivers.patch | 300 ++++++++
>  ...-rtlwifi-rtl8723be-Improve-modinfo-output.patch |  40 ++
>  ...ate-new-routine-to-initialize-the-DM-tabl.patch | 607 ++++++++++++++++
>  ...8188ee-Convert-driver-to-use-the-common-D.patch |  73 ++
>  ...8192c-common-Convert-driver-to-use-common.patch | 411 +++++++++++
>  ...8192de-Convert-driver-to-use-common-DM-ta.patch |  68 ++
>  ...8192ee-Convert-driver-to-use-common-DM-ta.patch |  71 ++
>  ...8723ae-Convert-driver-to-use-common-DM-ta.patch |  62 ++
>  ...8723be-Convert-driver-to-use-common-DM-ta.patch |  69 ++
>  ...8821ae-Convert-driver-to-use-common-DM-ta.patch |  73 ++
>  ...47-rtlwifi-Move-macro-definitions-to-core.patch | 140 ++++
>  ...-rtl8192de-remove-redundant-else-if-check.patch |  46 ++
>  ...-rtlwifi-add-support-to-send-beacon-frame.patch |  47 ++
>  ...680-0050-rtl8192cu-fix-the-mesh-beaconing.patch |  31 +
>  ...-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch |  38 +
>  49 files changed, 6224 insertions(+)
>  create mode 100644 package/kernel/mac80211/patches/680-0002-rtlwifi-Fix-setting-of-tx-descriptor-for-new-trx-flo.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0003-rtlwifi-Fix-errors-in-descriptor-manipulation.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0004-rtlwifi-rtl8192se-Fix-connection-problems.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0006-rtlwifi-update-RCR-register-in-rtl_op_configure_filt.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0007-net-wireless-rtlwifi-Do-not-always-include-drivers-i.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0008-net-wireless-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0009-rtlwifi-rtl8821ae-Fix-5G-detection-problem.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0010-rtlwifi-Change-order-in-device-startup.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0011-rtlwifi-rtl8192ce-Fix-editing-error-that-causes-sile.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0012-rtlwifi-rtl8192ce-Fix-kernel-crashes-due-to-missing-.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0013-rtlwifi-rtl8192ce-Fix-missing-interrupt-ready-flag.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0014-rtlwifi-rtl8821ae-fix-misspelling-of-current-functio.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0015-rtlwifi-rtl8192cu-Fix-sparse-non-static-symbol-warni.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0017-rtlwifi-rtl8192de-fw.c-Remove-unused-function.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0018-rtlwifi-rtl8821ae-Simplify-loading-of-WOWLAN-firmwar.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0019-rtlwifi-rtl8821ae-Fix-typos-in-power-sequence-macro.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0020-rtlwifi-rtl8192ce-Add-code-to-set-the-keep-alive-ope.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0021-rtlwifi-rtl8192ce-Update-setting-of-the-media-status.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0022-rtlwifi-rtl8192ce-Update-rate-setting-routines.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0023-rtlwifi-rtl8192ce-Improve-RF-sleep-routine.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0024-rtlwifi-Remove-extraneous-argument-for-rate-mapping.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0025-rtlwifi-rtl8723be-Switch-to-use-common-rate-mapping-.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0026-rtlwifi-rtl8188ee-Switch-to-use-common-rate-mapping-.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0027-rtlwifi-rtl8723ae-Modify-driver-to-use-rate-mapping-.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0028-rtlwifi-rtl8192ee-Convert-driver-to-use-common-rate-.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0029-rtlwifi-Convert-all-drivers-to-use-a-common-set-of-r.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0030-rtlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0031-rtlwifi-rtl8192cu-Rework-calls-to-rate-control-routi.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0032-rtlwifi-rtl8192de-Rework-calls-to-rate-control-routi.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0033-rtlwifi-rtl8821ae-Switch-to-use-common-rate-control-.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0034-rtlwifi-rtl8192ee-trx.c-Remove-unused-function.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0035-rtlwifi-rtl8723be-phy.c-Remove-unused-function.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0036-rtlwifi-Fix-error-when-accessing-unmapped-memory-in-.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0037-rtlwifi-Unify-variable-naming-for-all-drivers.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0038-rtlwifi-rtl8723be-Improve-modinfo-output.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0039-rtlwifi-Create-new-routine-to-initialize-the-DM-tabl.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0040-rtlwifi-rtl8188ee-Convert-driver-to-use-the-common-D.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0041-rtlwifi-rtl8192c-common-Convert-driver-to-use-common.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0042-rtlwifi-rtl8192de-Convert-driver-to-use-common-DM-ta.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0043-rtlwifi-rtl8192ee-Convert-driver-to-use-common-DM-ta.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0044-rtlwifi-rtl8723ae-Convert-driver-to-use-common-DM-ta.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0045-rtlwifi-rtl8723be-Convert-driver-to-use-common-DM-ta.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0046-rtlwifi-rtl8821ae-Convert-driver-to-use-common-DM-ta.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0047-rtlwifi-Move-macro-definitions-to-core.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0048-rtlwifi-rtl8192de-remove-redundant-else-if-check.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0049-rtlwifi-add-support-to-send-beacon-frame.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0050-rtl8192cu-fix-the-mesh-beaconing.patch
>  create mode 100644 package/kernel/mac80211/patches/680-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch
> 
> diff --git a/package/kernel/mac80211/patches/680-0002-rtlwifi-Fix-setting-of-tx-descriptor-for-new-trx-flo.patch b/package/kernel/mac80211/patches/680-0002-rtlwifi-Fix-setting-of-tx-descriptor-for-new-trx-flo.patch
> new file mode 100644
> index 0000000..fbe941b
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0002-rtlwifi-Fix-setting-of-tx-descriptor-for-new-trx-flo.patch
> @@ -0,0 +1,39 @@
> +From fb6eaf2ccca7d3580931bcb4b735101b461f38cf Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Wed, 5 Nov 2014 19:10:52 -0600
> +Subject: [PATCH 02/51] rtlwifi: Fix setting of tx descriptor for new trx flow
> +
> +Device RTL8192EE uses a new form of trx flow. This fix sets up the descriptors
> +correctly.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/pci.c | 11 ++++++++---
> + 1 file changed, 8 insertions(+), 3 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
> +index 25daa87..116f746 100644
> +--- a/drivers/net/wireless/rtlwifi/pci.c
> ++++ b/drivers/net/wireless/rtlwifi/pci.c
> +@@ -1127,9 +1127,14 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
> + 
> + 	__skb_queue_tail(&ring->queue, pskb);
> + 
> +-	rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN,
> +-				    &temp_one);
> +-
> ++	if (rtlpriv->use_new_trx_flow) {
> ++		temp_one = 4;
> ++		rtlpriv->cfg->ops->set_desc(hw, (u8 *)pbuffer_desc, true,
> ++					    HW_DESC_OWN, (u8 *)&temp_one);
> ++	} else {
> ++		rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN,
> ++					    &temp_one);
> ++	}
> + 	return;
> + }
> + 
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0003-rtlwifi-Fix-errors-in-descriptor-manipulation.patch b/package/kernel/mac80211/patches/680-0003-rtlwifi-Fix-errors-in-descriptor-manipulation.patch
> new file mode 100644
> index 0000000..e4cfcaf
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0003-rtlwifi-Fix-errors-in-descriptor-manipulation.patch
> @@ -0,0 +1,42 @@
> +From caea2172c23465a77556b2e1d06412b532b90235 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Wed, 5 Nov 2014 19:10:53 -0600
> +Subject: [PATCH 03/51] rtlwifi: Fix errors in descriptor manipulation
> +
> +There are typos in the handling of the descriptor pointers where the wrong
> +descriptor is referenced. There is also an error in which the pointer is
> +incremented twice.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/pci.c | 5 ++---
> + 1 file changed, 2 insertions(+), 3 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
> +index 116f746..6d2b628 100644
> +--- a/drivers/net/wireless/rtlwifi/pci.c
> ++++ b/drivers/net/wireless/rtlwifi/pci.c
> +@@ -1375,9 +1375,9 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
> + 	ring->desc = NULL;
> + 	if (rtlpriv->use_new_trx_flow) {
> + 		pci_free_consistent(rtlpci->pdev,
> +-				    sizeof(*ring->desc) * ring->entries,
> ++				    sizeof(*ring->buffer_desc) * ring->entries,
> + 				    ring->buffer_desc, ring->buffer_desc_dma);
> +-		ring->desc = NULL;
> ++		ring->buffer_desc = NULL;
> + 	}
> + }
> + 
> +@@ -1548,7 +1548,6 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
> + 							 true,
> + 							 HW_DESC_TXBUFF_ADDR),
> + 						 skb->len, PCI_DMA_TODEVICE);
> +-				ring->idx = (ring->idx + 1) % ring->entries;
> + 				kfree_skb(skb);
> + 				ring->idx = (ring->idx + 1) % ring->entries;
> + 			}
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0004-rtlwifi-rtl8192se-Fix-connection-problems.patch b/package/kernel/mac80211/patches/680-0004-rtlwifi-rtl8192se-Fix-connection-problems.patch
> new file mode 100644
> index 0000000..15a8b1b
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0004-rtlwifi-rtl8192se-Fix-connection-problems.patch
> @@ -0,0 +1,122 @@
> +From d1cd5ba4ca8b41793f4e581dd1dbf46b7f2cf691 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Fri, 7 Nov 2014 10:05:12 -0600
> +Subject: [PATCH 04/51] rtlwifi: rtl8192se: Fix connection problems
> +
> +Changes in the vendor driver were added to rtlwifi, but some updates
> +to rtl8192se were missed, and the driver could neither scan nor connect.
> +There are other changes that will enhance performance, but this minimal
> +set fix the basic functionality.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/pci.c           |  3 ++-
> + drivers/net/wireless/rtlwifi/rtl8192se/hw.c  |  7 +++++--
> + drivers/net/wireless/rtlwifi/rtl8192se/phy.c |  2 ++
> + drivers/net/wireless/rtlwifi/rtl8192se/sw.c  | 16 ++++++++++++++++
> + 4 files changed, 25 insertions(+), 3 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
> +index 6d2b628..61f5d36 100644
> +--- a/drivers/net/wireless/rtlwifi/pci.c
> ++++ b/drivers/net/wireless/rtlwifi/pci.c
> +@@ -842,7 +842,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
> + 			break;
> + 		}
> + 		/* handle command packet here */
> +-		if (rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) {
> ++		if (rtlpriv->cfg->ops->rx_command_packet &&
> ++		    rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) {
> + 				dev_kfree_skb_any(skb);
> + 				goto end;
> + 		}
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
> +index 00e0670..5761d5b 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
> +@@ -1201,6 +1201,9 @@ static int _rtl92se_set_media_status(struct ieee80211_hw *hw,
> + 
> + 	}
> + 
> ++	if (type != NL80211_IFTYPE_AP &&
> ++	    rtlpriv->mac80211.link_state < MAC80211_LINKED)
> ++		bt_msr = rtl_read_byte(rtlpriv, MSR) & ~MSR_LINK_MASK;
> + 	rtl_write_byte(rtlpriv, (MSR), bt_msr);
> + 
> + 	temp = rtl_read_dword(rtlpriv, TCR);
> +@@ -1262,6 +1265,7 @@ void rtl92se_enable_interrupt(struct ieee80211_hw *hw)
> + 	rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]);
> + 	/* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */
> + 	rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F);
> ++	rtlpci->irq_enabled = true;
> + }
> + 
> + void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
> +@@ -1276,8 +1280,7 @@ void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
> + 	rtlpci = rtl_pcidev(rtl_pcipriv(hw));
> + 	rtl_write_dword(rtlpriv, INTA_MASK, 0);
> + 	rtl_write_dword(rtlpriv, INTA_MASK + 4, 0);
> +-
> +-	synchronize_irq(rtlpci->pdev->irq);
> ++	rtlpci->irq_enabled = false;
> + }
> + 
> + static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data)
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
> +index 77c5b5f..4b4612f 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
> +@@ -399,6 +399,8 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
> + 		case 2:
> + 			currentcmd = &postcommoncmd[*step];
> + 			break;
> ++		default:
> ++			return true;
> + 		}
> + 
> + 		if (currentcmd->cmdid == CMDID_END) {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
> +index aadba29..fb00386 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
> +@@ -236,6 +236,19 @@ static void rtl92s_deinit_sw_vars(struct ieee80211_hw *hw)
> + 	}
> + }
> + 
> ++static bool rtl92se_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue,
> ++				      u16 index)
> ++{
> ++	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
> ++	struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
> ++	u8 *entry = (u8 *)(&ring->desc[ring->idx]);
> ++	u8 own = (u8)rtl92se_get_desc(entry, true, HW_DESC_OWN);
> ++
> ++	if (own)
> ++		return false;
> ++	return true;
> ++}
> ++
> + static struct rtl_hal_ops rtl8192se_hal_ops = {
> + 	.init_sw_vars = rtl92s_init_sw_vars,
> + 	.deinit_sw_vars = rtl92s_deinit_sw_vars,
> +@@ -269,6 +282,7 @@ static struct rtl_hal_ops rtl8192se_hal_ops = {
> + 	.led_control = rtl92se_led_control,
> + 	.set_desc = rtl92se_set_desc,
> + 	.get_desc = rtl92se_get_desc,
> ++	.is_tx_desc_closed = rtl92se_is_tx_desc_closed,
> + 	.tx_polling = rtl92se_tx_polling,
> + 	.enable_hw_sec = rtl92se_enable_hw_security_config,
> + 	.set_key = rtl92se_set_key,
> +@@ -306,6 +320,8 @@ static struct rtl_hal_cfg rtl92se_hal_cfg = {
> + 	.maps[MAC_RCR_ACRC32] = RCR_ACRC32,
> + 	.maps[MAC_RCR_ACF] = RCR_ACF,
> + 	.maps[MAC_RCR_AAP] = RCR_AAP,
> ++	.maps[MAC_HIMR] = INTA_MASK,
> ++	.maps[MAC_HIMRE] = INTA_MASK + 4,
> + 
> + 	.maps[EFUSE_TEST] = REG_EFUSE_TEST,
> + 	.maps[EFUSE_CTRL] = REG_EFUSE_CTRL,
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0006-rtlwifi-update-RCR-register-in-rtl_op_configure_filt.patch b/package/kernel/mac80211/patches/680-0006-rtlwifi-update-RCR-register-in-rtl_op_configure_filt.patch
> new file mode 100644
> index 0000000..0d85398
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0006-rtlwifi-update-RCR-register-in-rtl_op_configure_filt.patch
> @@ -0,0 +1,79 @@
> +From 99958588fce8f570d1d48bd67775b8e6c5f92623 Mon Sep 17 00:00:00 2001
> +From: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> +Date: Sat, 22 Nov 2014 12:18:26 +0100
> +Subject: [PATCH 06/51] rtlwifi: update RCR register in
> + rtl_op_configure_filter()
> +
> +Reconfigure RCR register in rtl_op_configure_filter() in order to apply RX
> +filter configuration
> +
> +Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/core.c | 14 ++++++++++++++
> + 1 file changed, 14 insertions(+)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
> +index af52f0b..5fc6f52 100644
> +--- a/drivers/net/wireless/rtlwifi/core.c
> ++++ b/drivers/net/wireless/rtlwifi/core.c
> +@@ -786,6 +786,7 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
> + 				    unsigned int changed_flags,
> + 				    unsigned int *new_flags, u64 multicast)
> + {
> ++	bool update_rcr = false;
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> + 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
> + 
> +@@ -806,6 +807,7 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
> + 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
> + 				 "Disable receive multicast frame\n");
> + 		}
> ++		update_rcr = true;
> + 	}
> + 
> + 	if (changed_flags & FIF_FCSFAIL) {
> +@@ -818,6 +820,8 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
> + 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
> + 				 "Disable receive FCS error frame\n");
> + 		}
> ++		if (!update_rcr)
> ++			update_rcr = true;
> + 	}
> + 
> + 	/* if ssid not set to hw don't check bssid
> +@@ -832,6 +836,8 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
> + 				rtlpriv->cfg->ops->set_chk_bssid(hw, false);
> + 			else
> + 				rtlpriv->cfg->ops->set_chk_bssid(hw, true);
> ++			if (update_rcr)
> ++				update_rcr = false;
> + 		}
> + 	}
> + 
> +@@ -846,6 +852,8 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
> + 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
> + 				 "Disable receive control frame.\n");
> + 		}
> ++		if (!update_rcr)
> ++			update_rcr = true;
> + 	}
> + 
> + 	if (changed_flags & FIF_OTHER_BSS) {
> +@@ -858,7 +866,13 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
> + 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
> + 				 "Disable receive other BSS's frame.\n");
> + 		}
> ++		if (!update_rcr)
> ++			update_rcr = true;
> + 	}
> ++
> ++	if (update_rcr)
> ++		rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR,
> ++					      (u8 *)(&mac->rx_conf));
> + }
> + static int rtl_op_sta_add(struct ieee80211_hw *hw,
> + 			 struct ieee80211_vif *vif,
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0007-net-wireless-rtlwifi-Do-not-always-include-drivers-i.patch b/package/kernel/mac80211/patches/680-0007-net-wireless-rtlwifi-Do-not-always-include-drivers-i.patch
> new file mode 100644
> index 0000000..59cb09e
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0007-net-wireless-rtlwifi-Do-not-always-include-drivers-i.patch
> @@ -0,0 +1,74 @@
> +From 927a70874c34e862f6aea5ad9c4a5d2c3f140bcd Mon Sep 17 00:00:00 2001
> +From: Andreas Ruprecht <rupran@einserver.de>
> +Date: Mon, 24 Nov 2014 19:34:31 +0100
> +Subject: [PATCH 07/51] net: wireless: rtlwifi: Do not always include drivers
> + in obj-m
> +
> +In four of the rtlwifi drivers, the Makefile contains superfluous
> +statements indicating the compilation of the driver as an LKM
> +regardless of the corresponding Kconfig option.
> +
> +If the corresponding option is set to 'y', the build system will then
> +see the object file in obj-m and obj-y, which leads to a compilation
> +as a built-in only. Even though this leads to the desired behavior,
> +the unconditional appearance in obj-m is confusing for someone reading
> +the Makefile.
> +
> +This patch removes the superfluous Makefile statements.
> +
> +Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ee/Makefile | 3 ---
> + drivers/net/wireless/rtlwifi/rtl8723ae/Makefile | 3 ---
> + drivers/net/wireless/rtlwifi/rtl8723be/Makefile | 3 ---
> + drivers/net/wireless/rtlwifi/rtl8821ae/Makefile | 3 ---
> + 4 files changed, 12 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile b/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
> +index 11952b9..6bd46a9 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
> +@@ -1,6 +1,3 @@
> +-obj-m := rtl8192ee.o
> +-
> +-
> + rtl8192ee-objs :=		\
> + 		dm.o		\
> + 		fw.o		\
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/Makefile b/drivers/net/wireless/rtlwifi/rtl8723ae/Makefile
> +index 9c34a85..6220672 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723ae/Makefile
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/Makefile
> +@@ -1,6 +1,3 @@
> +-obj-m := rtl8723ae.o
> +-
> +-
> + rtl8723ae-objs :=		\
> + 		dm.o		\
> + 		fw.o		\
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/Makefile b/drivers/net/wireless/rtlwifi/rtl8723be/Makefile
> +index 59e416a..a77c341 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/Makefile
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/Makefile
> +@@ -1,6 +1,3 @@
> +-obj-m := rtl8723be.o
> +-
> +-
> + rtl8723be-objs :=		\
> + 		dm.o		\
> + 		fw.o		\
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/Makefile b/drivers/net/wireless/rtlwifi/rtl8821ae/Makefile
> +index 87ad604..f7a26f7 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/Makefile
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/Makefile
> +@@ -1,6 +1,3 @@
> +-obj-m := rtl8821ae.o
> +-
> +-
> + rtl8821ae-objs :=		\
> + 		dm.o		\
> + 		fw.o		\
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0008-net-wireless-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch b/package/kernel/mac80211/patches/680-0008-net-wireless-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch
> new file mode 100644
> index 0000000..aa409f6
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0008-net-wireless-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch
> @@ -0,0 +1,29 @@
> +From b880c6deabacc415488984f6a79918ec0fa2e53d Mon Sep 17 00:00:00 2001
> +From: Andreas Ruprecht <rupran@einserver.de>
> +Date: Mon, 24 Nov 2014 19:34:32 +0100
> +Subject: [PATCH 08/51] net: wireless: rtlwifi: rtl8192ee: Fix compilation of
> + the driver
> +
> +In the Makefile for this driver, the wrong Kconfig option is used
> +to trigger the compilation of the object file. This leads to the
> +driver only being included into the kernel when both CONFIG_RTL8821AE
> +and CONFIG_RTL8192AE are set to "y".
> +
> +Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ee/Makefile | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +Index: compat-wireless-2014-11-04/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
> +===================================================================
> +--- compat-wireless-2014-11-04.orig/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
> ++++ compat-wireless-2014-11-04/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
> +@@ -11,6 +11,6 @@ rtl8192ee-objs :=		\
> + 		trx.o		\
> + 
> + 
> +-obj-$(CPTCFG_RTL8821AE) += rtl8192ee.o
> ++obj-$(CPTCFG_RTL8192EE) += rtl8192ee.o
> + 
> + ccflags-y += -D__CHECK_ENDIAN__
> diff --git a/package/kernel/mac80211/patches/680-0009-rtlwifi-rtl8821ae-Fix-5G-detection-problem.patch b/package/kernel/mac80211/patches/680-0009-rtlwifi-rtl8821ae-Fix-5G-detection-problem.patch
> new file mode 100644
> index 0000000..03a5d3f
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0009-rtlwifi-rtl8821ae-Fix-5G-detection-problem.patch
> @@ -0,0 +1,39 @@
> +From a91ed1901a80b401afa1b718d941d3450d868151 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 25 Nov 2014 10:32:06 -0600
> +Subject: [PATCH 09/51] rtlwifi: rtl8821ae: Fix 5G detection problem
> +
> +The changes associated with moving this driver from staging to the regular
> +tree missed one section setting the allowable rates for the 5GHz band.
> +
> +This patch is needed to fix the regression reported in Bug #88811
> +(https://bugzilla.kernel.org/show_bug.cgi?id=88811).
> +
> +Reported-by: Valerio Passini <valerio.passini@unicam.it>
> +Tested-by: Valerio Passini <valerio.passini@unicam.it>
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Cc: Valerio Passini <valerio.passini@unicam.it>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8821ae/hw.c | 5 +++--
> + 1 file changed, 3 insertions(+), 2 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
> +index 310d316..8ec8200 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
> +@@ -3672,8 +3672,9 @@ static void rtl8821ae_update_hal_rate_mask(struct ieee80211_hw *hw,
> + 		mac->opmode == NL80211_IFTYPE_ADHOC)
> + 		macid = sta->aid + 1;
> + 	if (wirelessmode == WIRELESS_MODE_N_5G ||
> +-	    wirelessmode == WIRELESS_MODE_AC_5G)
> +-		ratr_bitmap = sta->supp_rates[NL80211_BAND_5GHZ];
> ++	    wirelessmode == WIRELESS_MODE_AC_5G ||
> ++	    wirelessmode == WIRELESS_MODE_A)
> ++		ratr_bitmap = sta->supp_rates[NL80211_BAND_5GHZ] << 4;
> + 	else
> + 		ratr_bitmap = sta->supp_rates[NL80211_BAND_2GHZ];
> + 
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0010-rtlwifi-Change-order-in-device-startup.patch b/package/kernel/mac80211/patches/680-0010-rtlwifi-Change-order-in-device-startup.patch
> new file mode 100644
> index 0000000..5ed3db4
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0010-rtlwifi-Change-order-in-device-startup.patch
> @@ -0,0 +1,62 @@
> +From 7d63a5f9b25ba6b130da8eb2d32a72b1462d0249 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 25 Nov 2014 10:32:07 -0600
> +Subject: [PATCH 10/51] rtlwifi: Change order in device startup
> +
> +The existing order of steps when starting the PCI devices works for
> +2.4G devices, but fails to initialize the 5G section of the RTL8821AE
> +hardware.
> +
> +This patch is needed to fix the regression reported in Bug #88811
> +(https://bugzilla.kernel.org/show_bug.cgi?id=88811).
> +
> +Reported-by: Valerio Passini <valerio.passini@unicam.it>
> +Tested-by: Valerio Passini <valerio.passini@unicam.it>
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Cc: Valerio Passini <valerio.passini@unicam.it>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/pci.c | 20 ++++++++++----------
> + 1 file changed, 10 insertions(+), 10 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
> +index 61f5d36..846a2e6 100644
> +--- a/drivers/net/wireless/rtlwifi/pci.c
> ++++ b/drivers/net/wireless/rtlwifi/pci.c
> +@@ -2249,6 +2249,16 @@ int rtl_pci_probe(struct pci_dev *pdev,
> + 	/*like read eeprom and so on */
> + 	rtlpriv->cfg->ops->read_eeprom_info(hw);
> + 
> ++	if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
> ++		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
> ++		err = -ENODEV;
> ++		goto fail3;
> ++	}
> ++	rtlpriv->cfg->ops->init_sw_leds(hw);
> ++
> ++	/*aspm */
> ++	rtl_pci_init_aspm(hw);
> ++
> + 	/* Init mac80211 sw */
> + 	err = rtl_init_core(hw);
> + 	if (err) {
> +@@ -2264,16 +2274,6 @@ int rtl_pci_probe(struct pci_dev *pdev,
> + 		goto fail3;
> + 	}
> + 
> +-	if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
> +-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
> +-		err = -ENODEV;
> +-		goto fail3;
> +-	}
> +-	rtlpriv->cfg->ops->init_sw_leds(hw);
> +-
> +-	/*aspm */
> +-	rtl_pci_init_aspm(hw);
> +-
> + 	err = ieee80211_register_hw(hw);
> + 	if (err) {
> + 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0011-rtlwifi-rtl8192ce-Fix-editing-error-that-causes-sile.patch b/package/kernel/mac80211/patches/680-0011-rtlwifi-rtl8192ce-Fix-editing-error-that-causes-sile.patch
> new file mode 100644
> index 0000000..6186b5c
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0011-rtlwifi-rtl8192ce-Fix-editing-error-that-causes-sile.patch
> @@ -0,0 +1,47 @@
> +From 99a82f734aa6c6d397e029e6dfa933f04e0fa8c8 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Fri, 28 Nov 2014 10:41:14 -0600
> +Subject: [PATCH 11/51] rtlwifi: rtl8192ce: Fix editing error that causes
> + silent memory corruption
> +
> +In the major update of the rtlwifi-family of drivers, there was an editing
> +mistake. Unfortunately, this particular error leads to memory corruption that
> +silently leads to failure of the system. This patch is one of three needed to
> +fix the kernel regression reported at https://bugzilla.kernel.org/show_bug.cgi?id=88951.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Reported-by: Catalin Iacob <iacobcatalin@gmail.com>
> +Tested-by: Catalin Iacob <iacobcatalin@gmail.com>
> +Cc: Catalin Iacob <iacobcatalin@gmail.com>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 7 +++----
> + 1 file changed, 3 insertions(+), 4 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +index dc3d20b..0916275 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +@@ -720,16 +720,15 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
> + 			break;
> + 		}
> + 	} else {
> +-		struct rx_desc_92c *pdesc = (struct rx_desc_92c *)p_desc;
> + 		switch (desc_name) {
> + 		case HW_DESC_OWN:
> +-			ret = GET_RX_DESC_OWN(pdesc);
> ++			ret = GET_RX_DESC_OWN(p_desc);
> + 			break;
> + 		case HW_DESC_RXPKT_LEN:
> +-			ret = GET_RX_DESC_PKT_LEN(pdesc);
> ++			ret = GET_RX_DESC_PKT_LEN(p_desc);
> + 			break;
> + 		case HW_DESC_RXBUFF_ADDR:
> +-			ret = GET_RX_STATUS_DESC_BUFF_ADDR(pdesc);
> ++			ret = GET_RX_DESC_BUFF_ADDR(p_desc);
> + 			break;
> + 		default:
> + 			RT_ASSERT(false, "ERR rxdesc :%d not process\n",
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0012-rtlwifi-rtl8192ce-Fix-kernel-crashes-due-to-missing-.patch b/package/kernel/mac80211/patches/680-0012-rtlwifi-rtl8192ce-Fix-kernel-crashes-due-to-missing-.patch
> new file mode 100644
> index 0000000..03e8132
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0012-rtlwifi-rtl8192ce-Fix-kernel-crashes-due-to-missing-.patch
> @@ -0,0 +1,88 @@
> +From f892914c03131a445b926b82815b03162c19288e Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Fri, 28 Nov 2014 10:41:15 -0600
> +Subject: [PATCH 12/51] rtlwifi: rtl8192ce: Fix kernel crashes due to missing
> + callback entry
> +
> +In the major update of the rtlwifi-family of drivers, one of the callback entries
> +was missed, which leads to memory corruption. Unfortunately, this corruption
> +never caused a kernel oops, but showed up in other parts of the system.
> +This patch is one of three needed to fix the kernel regression reported at
> +https://bugzilla.kernel.org/show_bug.cgi?id=88951.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Reported-by: Catalin Iacob <iacobcatalin@gmail.com>
> +Tested-by: Catalin Iacob <iacobcatalin@gmail.com>
> +Cc: Catalin Iacob <iacobcatalin@gmail.com>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ce/sw.c  |  3 +++
> + drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 17 +++++++++++++++++
> + drivers/net/wireless/rtlwifi/rtl8192ce/trx.h |  2 ++
> + 3 files changed, 22 insertions(+)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
> +index 46ea076..dd5aa08 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
> +@@ -228,6 +228,7 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = {
> + 	.led_control = rtl92ce_led_control,
> + 	.set_desc = rtl92ce_set_desc,
> + 	.get_desc = rtl92ce_get_desc,
> ++	.is_tx_desc_closed = rtl92ce_is_tx_desc_closed,
> + 	.tx_polling = rtl92ce_tx_polling,
> + 	.enable_hw_sec = rtl92ce_enable_hw_security_config,
> + 	.set_key = rtl92ce_set_key,
> +@@ -271,6 +272,8 @@ static struct rtl_hal_cfg rtl92ce_hal_cfg = {
> + 	.maps[MAC_RCR_ACRC32] = ACRC32,
> + 	.maps[MAC_RCR_ACF] = ACF,
> + 	.maps[MAC_RCR_AAP] = AAP,
> ++	.maps[MAC_HIMR] = REG_HIMR,
> ++	.maps[MAC_HIMRE] = REG_HIMRE,
> + 
> + 	.maps[EFUSE_TEST] = REG_EFUSE_TEST,
> + 	.maps[EFUSE_CTRL] = REG_EFUSE_CTRL,
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +index 0916275..e88dcd0 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +@@ -739,6 +739,23 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
> + 	return ret;
> + }
> + 
> ++bool rtl92ce_is_tx_desc_closed(struct ieee80211_hw *hw,
> ++			       u8 hw_queue, u16 index)
> ++{
> ++	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
> ++	struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
> ++	u8 *entry = (u8 *)(&ring->desc[ring->idx]);
> ++	u8 own = (u8)rtl92ce_get_desc(entry, true, HW_DESC_OWN);
> ++
> ++	/*beacon packet will only use the first
> ++	 *descriptor defautly,and the own may not
> ++	 *be cleared by the hardware
> ++	 */
> ++	if (own)
> ++		return false;
> ++	return true;
> ++}
> ++
> + void rtl92ce_tx_polling(struct ieee80211_hw *hw, u8 hw_queue)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
> +index 9a39ec4..4bec4b0 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
> +@@ -723,6 +723,8 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
> + void rtl92ce_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
> + 		      u8 desc_name, u8 *val);
> + u32 rtl92ce_get_desc(u8 *pdesc, bool istx, u8 desc_name);
> ++bool rtl92ce_is_tx_desc_closed(struct ieee80211_hw *hw,
> ++			       u8 hw_queue, u16 index);
> + void rtl92ce_tx_polling(struct ieee80211_hw *hw, u8 hw_queue);
> + void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
> + 			     bool b_firstseg, bool b_lastseg,
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0013-rtlwifi-rtl8192ce-Fix-missing-interrupt-ready-flag.patch b/package/kernel/mac80211/patches/680-0013-rtlwifi-rtl8192ce-Fix-missing-interrupt-ready-flag.patch
> new file mode 100644
> index 0000000..6f29b9f
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0013-rtlwifi-rtl8192ce-Fix-missing-interrupt-ready-flag.patch
> @@ -0,0 +1,42 @@
> +From 87141db0848aa20c43d453f5545efc8f390d4372 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Fri, 28 Nov 2014 10:41:16 -0600
> +Subject: [PATCH 13/51] rtlwifi: rtl8192ce: Fix missing interrupt ready flag
> +
> +Proper operation with the rewritten PCI mini driver requires that a flag be set
> +when interrupts are enabled. This flag was missed.  This patch is one of three needed to
> +fix the kernel regression reported at https://bugzilla.kernel.org/show_bug.cgi?id=88951.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Reported-by: Catalin Iacob <iacobcatalin@gmail.com>
> +Tested-by: Catalin Iacob <iacobcatalin@gmail.com>
> +Cc: Catalin Iacob <iacobcatalin@gmail.com>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 3 ++-
> + 1 file changed, 2 insertions(+), 1 deletion(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +index 55357d6..d2ec516 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +@@ -1287,6 +1287,7 @@ void rtl92ce_enable_interrupt(struct ieee80211_hw *hw)
> + 
> + 	rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF);
> + 	rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF);
> ++	rtlpci->irq_enabled = true;
> + }
> + 
> + void rtl92ce_disable_interrupt(struct ieee80211_hw *hw)
> +@@ -1296,7 +1297,7 @@ void rtl92ce_disable_interrupt(struct ieee80211_hw *hw)
> + 
> + 	rtl_write_dword(rtlpriv, REG_HIMR, IMR8190_DISABLED);
> + 	rtl_write_dword(rtlpriv, REG_HIMRE, IMR8190_DISABLED);
> +-	synchronize_irq(rtlpci->pdev->irq);
> ++	rtlpci->irq_enabled = false;
> + }
> + 
> + static void _rtl92ce_poweroff_adapter(struct ieee80211_hw *hw)
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0014-rtlwifi-rtl8821ae-fix-misspelling-of-current-functio.patch b/package/kernel/mac80211/patches/680-0014-rtlwifi-rtl8821ae-fix-misspelling-of-current-functio.patch
> new file mode 100644
> index 0000000..d1f755f
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0014-rtlwifi-rtl8821ae-fix-misspelling-of-current-functio.patch
> @@ -0,0 +1,65 @@
> +From cf2bcc97dd332aa1d28eeacba1d8f8f89eccb7aa Mon Sep 17 00:00:00 2001
> +From: Julia Lawall <Julia.Lawall@lip6.fr>
> +Date: Sun, 7 Dec 2014 20:20:58 +0100
> +Subject: [PATCH 14/51] rtlwifi: rtl8821ae: fix misspelling of current function
> + in string
> +
> +Replace a misspelled function name by %s and then __func__.
> +
> +8821 was written as 8812.
> +
> +This was done using Coccinelle, including the use of Levenshtein distance,
> +as proposed by Rasmus Villemoes.
> +
> +Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8821ae/dm.c | 11 +++++------
> + 1 file changed, 5 insertions(+), 6 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> +index 9be1061..ba30b0d 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> +@@ -2078,8 +2078,7 @@ void rtl8821ae_dm_txpwr_track_set_pwr(struct ieee80211_hw *hw,
> + 	if (rtldm->tx_rate != 0xFF)
> + 		tx_rate = rtl8821ae_hw_rate_to_mrate(hw, rtldm->tx_rate);
> + 
> +-	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
> +-		 "===>rtl8812ae_dm_txpwr_track_set_pwr\n");
> ++	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "===>%s\n", __func__);
> + 
> + 	if (tx_rate != 0xFF) { /* Mimic Modify High Rate BBSwing Limit.*/
> + 		/*CCK*/
> +@@ -2128,7 +2127,7 @@ void rtl8821ae_dm_txpwr_track_set_pwr(struct ieee80211_hw *hw,
> + 
> + 	if (method == BBSWING) {
> + 		RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
> +-			 "===>rtl8812ae_dm_txpwr_track_set_pwr\n");
> ++			 "===>%s\n", __func__);
> + 		if (rf_path == RF90_PATH_A) {
> + 			final_swing_idx[RF90_PATH_A] =
> + 				(rtldm->ofdm_index[RF90_PATH_A] >
> +@@ -2260,7 +2259,8 @@ void rtl8821ae_dm_txpower_tracking_callback_thermalmeter(
> + 	rtldm->txpower_trackinginit = true;
> + 
> + 	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
> +-		 "===>rtl8812ae_dm_txpower_tracking_callback_thermalmeter,\n pDM_Odm->BbSwingIdxCckBase: %d,pDM_Odm->BbSwingIdxOfdmBase[A]:%d, pDM_Odm->DefaultOfdmIndex: %d\n",
> ++		 "===>%s,\n pDM_Odm->BbSwingIdxCckBase: %d,pDM_Odm->BbSwingIdxOfdmBase[A]:%d, pDM_Odm->DefaultOfdmIndex: %d\n",
> ++		 __func__,
> + 		 rtldm->swing_idx_cck_base,
> + 		 rtldm->swing_idx_ofdm_base[RF90_PATH_A],
> + 		 rtldm->default_ofdm_index);
> +@@ -2539,8 +2539,7 @@ void rtl8821ae_dm_txpower_tracking_callback_thermalmeter(
> + 		}
> + 	}
> + 
> +-	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
> +-		 "<===rtl8812ae_dm_txpower_tracking_callback_thermalmeter\n");
> ++	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "<===%s\n", __func__);
> + }
> + 
> + void rtl8821ae_dm_check_txpower_tracking_thermalmeter(struct ieee80211_hw *hw)
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0015-rtlwifi-rtl8192cu-Fix-sparse-non-static-symbol-warni.patch b/package/kernel/mac80211/patches/680-0015-rtlwifi-rtl8192cu-Fix-sparse-non-static-symbol-warni.patch
> new file mode 100644
> index 0000000..b46b79d
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0015-rtlwifi-rtl8192cu-Fix-sparse-non-static-symbol-warni.patch
> @@ -0,0 +1,34 @@
> +From 8670d4d603794e643601707e9222df49a2430840 Mon Sep 17 00:00:00 2001
> +From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> +Date: Tue, 9 Dec 2014 21:18:43 +0800
> +Subject: [PATCH 15/51] rtlwifi: rtl8192cu: Fix sparse non static symbol
> + warning
> +
> +Fixes the following sparse warning:
> +
> +drivers/net/wireless/rtlwifi/rtl8192cu/hw.c:1595:6: warning:
> + symbol 'usb_cmd_send_packet' was not declared. Should it be static?
> +
> +Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> +Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> +index 873363a..5513217 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> +@@ -1592,7 +1592,7 @@ void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
> + 	}
> + }
> + 
> +-bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
> ++static bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
> + {
> +   /* Currently nothing happens here.
> +    * Traffic stops after some seconds in WPA2 802.11n mode.
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch b/package/kernel/mac80211/patches/680-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch
> new file mode 100644
> index 0000000..5f75b85
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch
> @@ -0,0 +1,37 @@
> +From 9a1dce3a059111a7289680f4b8c0ec4f8736b6ee Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Wed, 10 Dec 2014 14:38:29 -0600
> +Subject: [PATCH 16/51] rtlwifi: rtl8192ce: Set fw_ready flag
> +
> +The setting of this flag was missed in previous modifications.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Cc: Stable <stable@vger.kernel.org>
> +Signed-off-by: John W. Linville <linville@tuxdriver.com>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 2 ++
> + 1 file changed, 2 insertions(+)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +index d2ec516..5c646d5 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +@@ -955,6 +955,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
> + 	local_save_flags(flags);
> + 	local_irq_enable();
> + 
> ++	rtlhal->fw_ready = false;
> + 	rtlpriv->intf_ops->disable_aspm(hw);
> + 	rtstatus = _rtl92ce_init_mac(hw);
> + 	if (!rtstatus) {
> +@@ -971,6 +972,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
> + 		goto exit;
> + 	}
> + 
> ++	rtlhal->fw_ready = true;
> + 	rtlhal->last_hmeboxnum = 0;
> + 	rtl92c_phy_mac_config(hw);
> + 	/* because last function modify RCR, so we update
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0017-rtlwifi-rtl8192de-fw.c-Remove-unused-function.patch b/package/kernel/mac80211/patches/680-0017-rtlwifi-rtl8192de-fw.c-Remove-unused-function.patch
> new file mode 100644
> index 0000000..525e235
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0017-rtlwifi-rtl8192de-fw.c-Remove-unused-function.patch
> @@ -0,0 +1,59 @@
> +From 18e0c0bf3a5ea0f54384149570274d535341dc06 Mon Sep 17 00:00:00 2001
> +From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> +Date: Sun, 7 Dec 2014 23:00:13 +0100
> +Subject: [PATCH 17/51] rtlwifi: rtl8192de: fw.c: Remove unused function
> +
> +Remove the function rtl92d_set_fw_pwrmode_cmd() that is not used anywhere.
> +
> +This was partially found by using a static code analysis program called cppcheck.
> +
> +Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 17 -----------------
> + drivers/net/wireless/rtlwifi/rtl8192de/fw.h |  1 -
> + 2 files changed, 18 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
> +index 2317707..62ef820 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
> +@@ -540,23 +540,6 @@ void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw,
> + 	return;
> + }
> + 
> +-void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	u8 u1_h2c_set_pwrmode[3] = { 0 };
> +-	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
> +-
> +-	RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode);
> +-	SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode);
> +-	SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1);
> +-	SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode,
> +-					      ppsc->reg_max_lps_awakeintvl);
> +-	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
> +-		      "rtl92d_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode",
> +-		      u1_h2c_set_pwrmode, 3);
> +-	rtl92d_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode);
> +-}
> +-
> + static bool _rtl92d_cmd_send_packet(struct ieee80211_hw *hw,
> + 				    struct sk_buff *skb)
> + {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.h b/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
> +index a55a803..1646e7c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
> +@@ -136,7 +136,6 @@ int rtl92d_download_fw(struct ieee80211_hw *hw);
> + void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
> + 			 u32 cmd_len, u8 *p_cmdbuffer);
> + void rtl92d_firmware_selfreset(struct ieee80211_hw *hw);
> +-void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
> + void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished);
> + void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
> + 
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0018-rtlwifi-rtl8821ae-Simplify-loading-of-WOWLAN-firmwar.patch b/package/kernel/mac80211/patches/680-0018-rtlwifi-rtl8821ae-Simplify-loading-of-WOWLAN-firmwar.patch
> new file mode 100644
> index 0000000..9a96f77
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0018-rtlwifi-rtl8821ae-Simplify-loading-of-WOWLAN-firmwar.patch
> @@ -0,0 +1,211 @@
> +From fe89707f0afa17edbb1bf8381fea1d2457aeebaa Mon Sep 17 00:00:00 2001
> +From: Troy Tan <troy_tan@realsil.com.cn>
> +Date: Thu, 18 Dec 2014 03:05:25 -0600
> +Subject: [PATCH 18/51] rtlwifi: rtl8821ae: Simplify loading of WOWLAN firmware
> +
> +The existing method for loading both normal and WOWLAN firmware for the
> +device duplicates a lot of code. This solution is much cleaner.
> +
> +Signed-off-by: Troy Tan <troy_tan@realsil.com.cn>
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/core.c         | 24 +++++++++-
> + drivers/net/wireless/rtlwifi/core.h         |  1 +
> + drivers/net/wireless/rtlwifi/rtl8821ae/sw.c | 74 ++++++++++-------------------
> + drivers/net/wireless/rtlwifi/wifi.h         |  3 +-
> + 4 files changed, 48 insertions(+), 54 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
> +index 5fc6f52..deab852 100644
> +--- a/drivers/net/wireless/rtlwifi/core.c
> ++++ b/drivers/net/wireless/rtlwifi/core.c
> +@@ -95,7 +95,8 @@ void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
> + }
> + EXPORT_SYMBOL(rtl_bb_delay);
> + 
> +-void rtl_fw_cb(const struct firmware *firmware, void *context)
> ++static void rtl_fw_do_work(const struct firmware *firmware, void *context,
> ++			   bool is_wow)
> + {
> + 	struct ieee80211_hw *hw = context;
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +@@ -125,12 +126,31 @@ found_alt:
> + 		release_firmware(firmware);
> + 		return;
> + 	}
> +-	memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
> ++	if (!is_wow) {
> ++		memcpy(rtlpriv->rtlhal.pfirmware, firmware->data,
> ++		       firmware->size);
> ++		rtlpriv->rtlhal.fwsize = firmware->size;
> ++	} else {
> ++		memcpy(rtlpriv->rtlhal.wowlan_firmware, firmware->data,
> ++		       firmware->size);
> ++		rtlpriv->rtlhal.wowlan_fwsize = firmware->size;
> ++	}
> + 	rtlpriv->rtlhal.fwsize = firmware->size;
> + 	release_firmware(firmware);
> + }
> ++
> ++void rtl_fw_cb(const struct firmware *firmware, void *context)
> ++{
> ++	rtl_fw_do_work(firmware, context, false);
> ++}
> + EXPORT_SYMBOL(rtl_fw_cb);
> + 
> ++void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context)
> ++{
> ++	rtl_fw_do_work(firmware, context, true);
> ++}
> ++EXPORT_SYMBOL(rtl_wowlan_fw_cb);
> ++
> + /*mutex for start & stop is must here. */
> + static int rtl_op_start(struct ieee80211_hw *hw)
> + {
> +diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
> +index 624e1dc..8c87eb5 100644
> +--- a/drivers/net/wireless/rtlwifi/core.h
> ++++ b/drivers/net/wireless/rtlwifi/core.h
> +@@ -37,6 +37,7 @@
> + 
> + extern const struct ieee80211_ops rtl_ops;
> + void rtl_fw_cb(const struct firmware *firmware, void *context);
> ++void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context);
> + void rtl_addr_delay(u32 addr);
> + void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
> + 		     u32 mask, u32 data);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
> +index fc92dd6..a4988121 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
> +@@ -85,52 +85,6 @@ static void rtl8821ae_init_aspm_vars(struct ieee80211_hw *hw)
> + 	rtlpci->const_support_pciaspm = 1;
> + }
> + 
> +-static void load_wowlan_fw(struct rtl_priv *rtlpriv)
> +-{
> +-	/* callback routine to load wowlan firmware after main fw has
> +-	 * been loaded
> +-	 */
> +-	const struct firmware *wowlan_firmware;
> +-	char *fw_name = NULL;
> +-	int err;
> +-
> +-	/* for wowlan firmware buf */
> +-	rtlpriv->rtlhal.wowlan_firmware = vzalloc(0x8000);
> +-	if (!rtlpriv->rtlhal.wowlan_firmware) {
> +-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
> +-			 "Can't alloc buffer for wowlan fw.\n");
> +-		return;
> +-	}
> +-
> +-	if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8821AE)
> +-		fw_name = "rtlwifi/rtl8821aefw_wowlan.bin";
> +-	else
> +-		fw_name = "rtlwifi/rtl8812aefw_wowlan.bin";
> +-	err = request_firmware(&wowlan_firmware, fw_name, rtlpriv->io.dev);
> +-	if (err) {
> +-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
> +-			 "Failed to request wowlan firmware!\n");
> +-		goto error;
> +-	}
> +-
> +-	if (wowlan_firmware->size > 0x8000) {
> +-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
> +-			 "Wowlan Firmware is too big!\n");
> +-		goto error;
> +-	}
> +-
> +-	memcpy(rtlpriv->rtlhal.wowlan_firmware, wowlan_firmware->data,
> +-	       wowlan_firmware->size);
> +-	rtlpriv->rtlhal.wowlan_fwsize = wowlan_firmware->size;
> +-	release_firmware(wowlan_firmware);
> +-
> +-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "WOWLAN FirmwareDownload OK\n");
> +-	return;
> +-error:
> +-	release_firmware(wowlan_firmware);
> +-	vfree(rtlpriv->rtlhal.wowlan_firmware);
> +-}
> +-
> + /*InitializeVariables8812E*/
> + int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
> + {
> +@@ -231,7 +185,6 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
> + 	else if (rtlpriv->psc.reg_fwctrl_lps == 3)
> + 		rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE;
> + 
> +-	rtlpriv->rtl_fw_second_cb = load_wowlan_fw;
> + 	/* for firmware buf */
> + 	rtlpriv->rtlhal.pfirmware = vzalloc(0x8000);
> + 	if (!rtlpriv->rtlhal.pfirmware) {
> +@@ -239,20 +192,41 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
> + 			 "Can't alloc buffer for fw.\n");
> + 		return 1;
> + 	}
> ++	rtlpriv->rtlhal.wowlan_firmware = vzalloc(0x8000);
> ++	if (!rtlpriv->rtlhal.wowlan_firmware) {
> ++		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
> ++			 "Can't alloc buffer for wowlan fw.\n");
> ++		return 1;
> ++	}
> + 
> +-	if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE)
> ++	if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) {
> + 		rtlpriv->cfg->fw_name = "rtlwifi/rtl8812aefw.bin";
> +-	else
> ++		rtlpriv->cfg->wowlan_fw_name = "rtlwifi/rtl8812aefw_wowlan.bin";
> ++	} else {
> + 		rtlpriv->cfg->fw_name = "rtlwifi/rtl8821aefw.bin";
> ++		rtlpriv->cfg->wowlan_fw_name = "rtlwifi/rtl8821aefw_wowlan.bin";
> ++	}
> + 
> + 	rtlpriv->max_fw_size = 0x8000;
> ++	/*load normal firmware*/
> + 	pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name);
> + 	err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
> + 				      rtlpriv->io.dev, GFP_KERNEL, hw,
> + 				      rtl_fw_cb);
> + 	if (err) {
> + 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
> +-			 "Failed to request firmware!\n");
> ++			 "Failed to request normal firmware!\n");
> ++		return 1;
> ++	}
> ++	/*load wowlan firmware*/
> ++	pr_info("Using firmware %s\n", rtlpriv->cfg->wowlan_fw_name);
> ++	err = request_firmware_nowait(THIS_MODULE, 1,
> ++				      rtlpriv->cfg->wowlan_fw_name,
> ++				      rtlpriv->io.dev, GFP_KERNEL, hw,
> ++				      rtl_wowlan_fw_cb);
> ++	if (err) {
> ++		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
> ++			 "Failed to request wowlan firmware!\n");
> + 		return 1;
> + 	}
> + 	return 0;
> +diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
> +index 6866dcf..a233b26 100644
> +--- a/drivers/net/wireless/rtlwifi/wifi.h
> ++++ b/drivers/net/wireless/rtlwifi/wifi.h
> +@@ -2242,6 +2242,7 @@ struct rtl_hal_cfg {
> + 	char *name;
> + 	char *fw_name;
> + 	char *alt_fw_name;
> ++	char *wowlan_fw_name;
> + 	struct rtl_hal_ops *ops;
> + 	struct rtl_mod_params *mod_params;
> + 	struct rtl_hal_usbint_cfg *usb_interface_cfg;
> +@@ -2518,8 +2519,6 @@ struct proxim {
> + 
> + struct rtl_priv {
> + 	struct ieee80211_hw *hw;
> +-	/* Used to load a second firmware */
> +-	void (*rtl_fw_second_cb)(struct rtl_priv *rtlpriv);
> + 	struct completion firmware_loading_complete;
> + 	struct list_head list;
> + 	struct rtl_priv *buddy_priv;
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0019-rtlwifi-rtl8821ae-Fix-typos-in-power-sequence-macro.patch b/package/kernel/mac80211/patches/680-0019-rtlwifi-rtl8821ae-Fix-typos-in-power-sequence-macro.patch
> new file mode 100644
> index 0000000..09a3043
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0019-rtlwifi-rtl8821ae-Fix-typos-in-power-sequence-macro.patch
> @@ -0,0 +1,33 @@
> +From f091282fd367faa014ebc2aa0a2fd178a48b476d Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:26 -0600
> +Subject: [PATCH 19/51] rtlwifi: rtl8821ae: Fix typos in power-sequence macro
> +
> +Two of the macros that control power sequencing have values to be set that
> +contain bits that are not covered by the associated mask.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h b/drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h
> +index bf0b0ce..36b3e91 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h
> +@@ -93,9 +93,9 @@
> + 
> + #define RTL8812_TRANS_CARDEMU_TO_SUS					\
> + 	{0x0042, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK,\
> +-	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xF0, 0xcc}, \
> ++	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xF0, 0xc0}, \
> + 	{0x0042, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,\
> +-	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xF0, 0xEC}, \
> ++	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xF0, 0xE0}, \
> + 	{0x0043, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\
> + 	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x07 \
> + 	/* gpio11 input mode, gpio10~8 output mode */},	\
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0020-rtlwifi-rtl8192ce-Add-code-to-set-the-keep-alive-ope.patch b/package/kernel/mac80211/patches/680-0020-rtlwifi-rtl8192ce-Add-code-to-set-the-keep-alive-ope.patch
> new file mode 100644
> index 0000000..f80bd44
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0020-rtlwifi-rtl8192ce-Add-code-to-set-the-keep-alive-ope.patch
> @@ -0,0 +1,50 @@
> +From 1ed03272b58f1ed6545b99dde39c42358156af69 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:27 -0600
> +Subject: [PATCH 20/51] rtlwifi: rtl8192ce: Add code to set the keep-alive
> + operation
> +
> +This change helps the device maintain a connection.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h | 1 +
> + drivers/net/wireless/rtlwifi/rtl8192ce/hw.c       | 9 +++++++--
> + 2 files changed, 8 insertions(+), 2 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
> +index b64ae45..e9f4281 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
> +@@ -37,6 +37,7 @@
> + #define FW_8192C_POLLING_DELAY			5
> + #define FW_8192C_POLLING_TIMEOUT_COUNT		100
> + #define NORMAL_CHIP				BIT(4)
> ++#define H2C_92C_KEEP_ALIVE_CTRL			48
> + 
> + #define IS_FW_HEADER_EXIST(_pfwhdr)	\
> + 	((le16_to_cpu(_pfwhdr->signature)&0xFFF0) == 0x92C0 ||\
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +index 5c646d5..b63b78b 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +@@ -544,8 +544,13 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
> + 						(u8 *)(&fw_current_inps));
> + 			}
> + 		break; }
> +-	case HW_VAR_KEEP_ALIVE:
> +-		break;
> ++	case HW_VAR_KEEP_ALIVE: {
> ++		u8 array[2];
> ++
> ++		array[0] = 0xff;
> ++		array[1] = *((u8 *)val);
> ++		rtl92c_fill_h2c_cmd(hw, H2C_92C_KEEP_ALIVE_CTRL, 2, array);
> ++		break; }
> + 	default:
> + 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
> + 			 "switch case %d not processed\n", variable);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0021-rtlwifi-rtl8192ce-Update-setting-of-the-media-status.patch b/package/kernel/mac80211/patches/680-0021-rtlwifi-rtl8192ce-Update-setting-of-the-media-status.patch
> new file mode 100644
> index 0000000..4cb0e5a
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0021-rtlwifi-rtl8192ce-Update-setting-of-the-media-status.patch
> @@ -0,0 +1,106 @@
> +From 9d62c5531b515ef427cee13cca87777dba617c94 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:28 -0600
> +Subject: [PATCH 21/51] rtlwifi: rtl8192ce: Update setting of the media status
> +
> +This patch applies changes found in the latest vendor driver.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 51 ++++++++++++++++++-----------
> + 1 file changed, 31 insertions(+), 20 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +index b63b78b..2ee778a 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +@@ -1161,36 +1161,24 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> + 	u8 bt_msr = rtl_read_byte(rtlpriv, MSR);
> + 	enum led_ctl_mode ledaction = LED_CTL_NO_LINK;
> +-	bt_msr &= 0xfc;
> ++	u8 mode = MSR_NOLINK;
> + 
> +-	if (type == NL80211_IFTYPE_UNSPECIFIED ||
> +-	    type == NL80211_IFTYPE_STATION) {
> +-		_rtl92ce_stop_tx_beacon(hw);
> +-		_rtl92ce_enable_bcn_sub_func(hw);
> +-	} else if (type == NL80211_IFTYPE_ADHOC || type == NL80211_IFTYPE_AP ||
> +-		   type == NL80211_IFTYPE_MESH_POINT) {
> +-		_rtl92ce_resume_tx_beacon(hw);
> +-		_rtl92ce_disable_bcn_sub_func(hw);
> +-	} else {
> +-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
> +-			 "Set HW_VAR_MEDIA_STATUS: No such media status(%x)\n",
> +-			 type);
> +-	}
> ++	bt_msr &= 0xfc;
> + 
> + 	switch (type) {
> + 	case NL80211_IFTYPE_UNSPECIFIED:
> +-		bt_msr |= MSR_NOLINK;
> ++		mode = MSR_NOLINK;
> + 		ledaction = LED_CTL_LINK;
> + 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
> + 			 "Set Network type to NO LINK!\n");
> + 		break;
> + 	case NL80211_IFTYPE_ADHOC:
> +-		bt_msr |= MSR_ADHOC;
> ++		mode = MSR_ADHOC;
> + 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
> + 			 "Set Network type to Ad Hoc!\n");
> + 		break;
> + 	case NL80211_IFTYPE_STATION:
> +-		bt_msr |= MSR_INFRA;
> ++		mode = MSR_INFRA;
> + 		ledaction = LED_CTL_LINK;
> + 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
> + 			 "Set Network type to STA!\n");
> +@@ -1201,7 +1189,7 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
> + 			 "Set Network type to AP!\n");
> + 		break;
> + 	case NL80211_IFTYPE_MESH_POINT:
> +-		bt_msr |= MSR_ADHOC;
> ++		mode = MSR_ADHOC;
> + 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
> + 			 "Set Network type to Mesh Point!\n");
> + 		break;
> +@@ -1212,9 +1200,32 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
> + 
> + 	}
> + 
> +-	rtl_write_byte(rtlpriv, (MSR), bt_msr);
> ++	/* MSR_INFRA == Link in infrastructure network;
> ++	 * MSR_ADHOC == Link in ad hoc network;
> ++	 * Therefore, check link state is necessary.
> ++	 *
> ++	 * MSR_AP == AP mode; link state does not matter here.
> ++	 */
> ++	if (mode != MSR_AP &&
> ++	    rtlpriv->mac80211.link_state < MAC80211_LINKED) {
> ++		mode = MSR_NOLINK;
> ++		ledaction = LED_CTL_NO_LINK;
> ++	}
> ++	if (mode == MSR_NOLINK || mode == MSR_INFRA) {
> ++		_rtl92ce_stop_tx_beacon(hw);
> ++		_rtl92ce_enable_bcn_sub_func(hw);
> ++	} else if (mode == MSR_ADHOC || mode == MSR_AP) {
> ++		_rtl92ce_resume_tx_beacon(hw);
> ++		_rtl92ce_disable_bcn_sub_func(hw);
> ++	} else {
> ++		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
> ++			 "Set HW_VAR_MEDIA_STATUS: No such media status(%x).\n",
> ++			 mode);
> ++	}
> ++	rtl_write_byte(rtlpriv, (MSR), bt_msr | mode);
> ++
> + 	rtlpriv->cfg->ops->led_control(hw, ledaction);
> +-	if ((bt_msr & MSR_MASK) == MSR_AP)
> ++	if (mode == MSR_AP)
> + 		rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x00);
> + 	else
> + 		rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x66);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0022-rtlwifi-rtl8192ce-Update-rate-setting-routines.patch b/package/kernel/mac80211/patches/680-0022-rtlwifi-rtl8192ce-Update-rate-setting-routines.patch
> new file mode 100644
> index 0000000..6f52560
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0022-rtlwifi-rtl8192ce-Update-rate-setting-routines.patch
> @@ -0,0 +1,199 @@
> +From ff6ee6b0ce1f62936a916ef1c33015a2ec48925e Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:29 -0600
> +Subject: [PATCH 22/51] rtlwifi: rtl8192ce: Update rate setting routines
> +
> +These changes were found in the latest vendor driver.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 107 ++++++++++++----------------
> + 1 file changed, 44 insertions(+), 63 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +index 2ee778a..303b299 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
> +@@ -1168,7 +1168,6 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
> + 	switch (type) {
> + 	case NL80211_IFTYPE_UNSPECIFIED:
> + 		mode = MSR_NOLINK;
> +-		ledaction = LED_CTL_LINK;
> + 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
> + 			 "Set Network type to NO LINK!\n");
> + 		break;
> +@@ -1184,7 +1183,8 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
> + 			 "Set Network type to STA!\n");
> + 		break;
> + 	case NL80211_IFTYPE_AP:
> +-		bt_msr |= MSR_AP;
> ++		mode = MSR_AP;
> ++		ledaction = LED_CTL_LINK;
> + 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
> + 			 "Set Network type to AP!\n");
> + 		break;
> +@@ -1222,7 +1222,7 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
> + 			 "Set HW_VAR_MEDIA_STATUS: No such media status(%x).\n",
> + 			 mode);
> + 	}
> +-	rtl_write_byte(rtlpriv, (MSR), bt_msr | mode);
> ++	rtl_write_byte(rtlpriv, MSR, bt_msr | mode);
> + 
> + 	rtlpriv->cfg->ops->led_control(hw, ledaction);
> + 	if (mode == MSR_AP)
> +@@ -1849,7 +1849,6 @@ static void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw,
> + 	u32 ratr_value;
> + 	u8 ratr_index = 0;
> + 	u8 nmode = mac->ht_enable;
> +-	u8 mimo_ps = IEEE80211_SMPS_OFF;
> + 	u16 shortgi_rate;
> + 	u32 tmp_ratr_value;
> + 	u8 curtxbw_40mhz = mac->bw_40;
> +@@ -1858,6 +1857,7 @@ static void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw,
> + 	u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
> + 			       1 : 0;
> + 	enum wireless_mode wirelessmode = mac->mode;
> ++	u32 ratr_mask;
> + 
> + 	if (rtlhal->current_bandtype == BAND_ON_5G)
> + 		ratr_value = sta->supp_rates[1] << 4;
> +@@ -1881,19 +1881,13 @@ static void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw,
> + 	case WIRELESS_MODE_N_24G:
> + 	case WIRELESS_MODE_N_5G:
> + 		nmode = 1;
> +-		if (mimo_ps == IEEE80211_SMPS_STATIC) {
> +-			ratr_value &= 0x0007F005;
> +-		} else {
> +-			u32 ratr_mask;
> +-
> +-			if (get_rf_type(rtlphy) == RF_1T2R ||
> +-			    get_rf_type(rtlphy) == RF_1T1R)
> +-				ratr_mask = 0x000ff005;
> +-			else
> +-				ratr_mask = 0x0f0ff005;
> ++		if (get_rf_type(rtlphy) == RF_1T2R ||
> ++		    get_rf_type(rtlphy) == RF_1T1R)
> ++			ratr_mask = 0x000ff005;
> ++		else
> ++			ratr_mask = 0x0f0ff005;
> + 
> +-			ratr_value &= ratr_mask;
> +-		}
> ++		ratr_value &= ratr_mask;
> + 		break;
> + 	default:
> + 		if (rtlphy->rf_type == RF_1T2R)
> +@@ -1946,17 +1940,16 @@ static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw,
> + 	struct rtl_sta_info *sta_entry = NULL;
> + 	u32 ratr_bitmap;
> + 	u8 ratr_index;
> +-	u8 curtxbw_40mhz = (sta->bandwidth >= IEEE80211_STA_RX_BW_40) ? 1 : 0;
> +-	u8 curshortgi_40mhz = curtxbw_40mhz &&
> +-			      (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
> +-				1 : 0;
> ++	u8 curtxbw_40mhz = (sta->ht_cap.cap &
> ++			    IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1 : 0;
> ++	u8 curshortgi_40mhz = (sta->ht_cap.cap &
> ++			       IEEE80211_HT_CAP_SGI_40) ?  1 : 0;
> + 	u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
> + 				1 : 0;
> + 	enum wireless_mode wirelessmode = 0;
> + 	bool shortgi = false;
> + 	u8 rate_mask[5];
> + 	u8 macid = 0;
> +-	u8 mimo_ps = IEEE80211_SMPS_OFF;
> + 
> + 	sta_entry = (struct rtl_sta_info *) sta->drv_priv;
> + 	wirelessmode = sta_entry->wireless_mode;
> +@@ -2001,47 +1994,38 @@ static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw,
> + 	case WIRELESS_MODE_N_5G:
> + 		ratr_index = RATR_INX_WIRELESS_NGB;
> + 
> +-		if (mimo_ps == IEEE80211_SMPS_STATIC) {
> +-			if (rssi_level == 1)
> +-				ratr_bitmap &= 0x00070000;
> +-			else if (rssi_level == 2)
> +-				ratr_bitmap &= 0x0007f000;
> +-			else
> +-				ratr_bitmap &= 0x0007f005;
> ++		if (rtlphy->rf_type == RF_1T2R ||
> ++		    rtlphy->rf_type == RF_1T1R) {
> ++			if (curtxbw_40mhz) {
> ++				if (rssi_level == 1)
> ++					ratr_bitmap &= 0x000f0000;
> ++				else if (rssi_level == 2)
> ++					ratr_bitmap &= 0x000ff000;
> ++				else
> ++					ratr_bitmap &= 0x000ff015;
> ++			} else {
> ++				if (rssi_level == 1)
> ++					ratr_bitmap &= 0x000f0000;
> ++				else if (rssi_level == 2)
> ++					ratr_bitmap &= 0x000ff000;
> ++				else
> ++					ratr_bitmap &= 0x000ff005;
> ++			}
> + 		} else {
> +-			if (rtlphy->rf_type == RF_1T2R ||
> +-			    rtlphy->rf_type == RF_1T1R) {
> +-				if (curtxbw_40mhz) {
> +-					if (rssi_level == 1)
> +-						ratr_bitmap &= 0x000f0000;
> +-					else if (rssi_level == 2)
> +-						ratr_bitmap &= 0x000ff000;
> +-					else
> +-						ratr_bitmap &= 0x000ff015;
> +-				} else {
> +-					if (rssi_level == 1)
> +-						ratr_bitmap &= 0x000f0000;
> +-					else if (rssi_level == 2)
> +-						ratr_bitmap &= 0x000ff000;
> +-					else
> +-						ratr_bitmap &= 0x000ff005;
> +-				}
> ++			if (curtxbw_40mhz) {
> ++				if (rssi_level == 1)
> ++					ratr_bitmap &= 0x0f0f0000;
> ++				else if (rssi_level == 2)
> ++					ratr_bitmap &= 0x0f0ff000;
> ++				else
> ++					ratr_bitmap &= 0x0f0ff015;
> + 			} else {
> +-				if (curtxbw_40mhz) {
> +-					if (rssi_level == 1)
> +-						ratr_bitmap &= 0x0f0f0000;
> +-					else if (rssi_level == 2)
> +-						ratr_bitmap &= 0x0f0ff000;
> +-					else
> +-						ratr_bitmap &= 0x0f0ff015;
> +-				} else {
> +-					if (rssi_level == 1)
> +-						ratr_bitmap &= 0x0f0f0000;
> +-					else if (rssi_level == 2)
> +-						ratr_bitmap &= 0x0f0ff000;
> +-					else
> +-						ratr_bitmap &= 0x0f0ff005;
> +-				}
> ++				if (rssi_level == 1)
> ++					ratr_bitmap &= 0x0f0f0000;
> ++				else if (rssi_level == 2)
> ++					ratr_bitmap &= 0x0f0ff000;
> ++				else
> ++					ratr_bitmap &= 0x0f0ff005;
> + 			}
> + 		}
> + 
> +@@ -2074,9 +2058,6 @@ static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw,
> + 		 "Rate_index:%x, ratr_val:%x, %5phC\n",
> + 		 ratr_index, ratr_bitmap, rate_mask);
> + 	rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask);
> +-
> +-	if (macid != 0)
> +-		sta_entry->ratr_index = ratr_index;
> + }
> + 
> + void rtl92ce_update_hal_rate_tbl(struct ieee80211_hw *hw,
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0023-rtlwifi-rtl8192ce-Improve-RF-sleep-routine.patch b/package/kernel/mac80211/patches/680-0023-rtlwifi-rtl8192ce-Improve-RF-sleep-routine.patch
> new file mode 100644
> index 0000000..3fa78ed
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0023-rtlwifi-rtl8192ce-Improve-RF-sleep-routine.patch
> @@ -0,0 +1,35 @@
> +From 99057920a2f7360977979dc4c2ba60d5f9dc9e23 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:30 -0600
> +Subject: [PATCH 23/51] rtlwifi: rtl8192ce: Improve RF sleep routine
> +
> +These changes match those of the latest vendor driver.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | 5 +++--
> + 1 file changed, 3 insertions(+), 2 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
> +index bc5ca98..1ee5a6a 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
> +@@ -518,11 +518,12 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw,
> + 		}
> + 	case ERFSLEEP:{
> + 			if (ppsc->rfpwr_state == ERFOFF)
> +-				return false;
> ++				break;
> + 			for (queue_id = 0, i = 0;
> + 			     queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) {
> + 				ring = &pcipriv->dev.tx_ring[queue_id];
> +-				if (skb_queue_len(&ring->queue) == 0) {
> ++				if (queue_id == BEACON_QUEUE ||
> ++				    skb_queue_len(&ring->queue) == 0) {
> + 					queue_id++;
> + 					continue;
> + 				} else {
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0024-rtlwifi-Remove-extraneous-argument-for-rate-mapping.patch b/package/kernel/mac80211/patches/680-0024-rtlwifi-Remove-extraneous-argument-for-rate-mapping.patch
> new file mode 100644
> index 0000000..2b3f8aa
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0024-rtlwifi-Remove-extraneous-argument-for-rate-mapping.patch
> @@ -0,0 +1,138 @@
> +From f1f21770b11ca83d688b2791b163c2b892ca6fa6 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:31 -0600
> +Subject: [PATCH 24/51] rtlwifi: Remove extraneous argument for rate mapping
> +
> +Four of the drivers (92ce, 92cu, 92de, and 92se) supply an argument to the
> +rate-mapping routine that is never used, thus it can be removed.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/base.c          |  2 +-
> + drivers/net/wireless/rtlwifi/base.h          |  2 +-
> + drivers/net/wireless/rtlwifi/rtl8192ce/trx.c |  5 ++---
> + drivers/net/wireless/rtlwifi/rtl8192cu/trx.c |  6 ++----
> + drivers/net/wireless/rtlwifi/rtl8192de/trx.c |  3 +--
> + drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 11 +++++------
> + 6 files changed, 12 insertions(+), 17 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
> +index 40b6d1d..d4c8e95 100644
> +--- a/drivers/net/wireless/rtlwifi/base.c
> ++++ b/drivers/net/wireless/rtlwifi/base.c
> +@@ -883,7 +883,7 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
> +  * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
> +  */
> + int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
> +-			 bool isht, u8 desc_rate, bool first_ampdu)
> ++			 bool isht, u8 desc_rate)
> + {
> + 	int rate_idx;
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h
> +index 982f245..936c2bb 100644
> +--- a/drivers/net/wireless/rtlwifi/base.h
> ++++ b/drivers/net/wireless/rtlwifi/base.h
> +@@ -124,7 +124,7 @@ void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
> + 
> + bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
> + int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
> +-			 bool isht, u8 desc_rate, bool first_ampdu);
> ++			 bool isht, u8 desc_rate);
> + bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
> + u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +index e88dcd0..d25aeeb 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +@@ -400,9 +400,8 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * are use (RX_FLAG_HT)
> + 	 * Notice: this is diff with windows define
> + 	 */
> +-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
> +-				stats->is_ht, stats->rate,
> +-				stats->isfirst_ampdu);
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
> ++						   stats->rate);
> + 
> + 	rx_status->mactime = stats->timestamp_low;
> + 	if (phystatus) {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> +index f383d5f..fa30b26 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> +@@ -340,8 +340,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
> + 		rx_status->flag |= RX_FLAG_DECRYPTED;
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
> + 					(bool)GET_RX_DESC_RX_HT(pdesc),
> +-					(u8)GET_RX_DESC_RX_MCS(pdesc),
> +-					(bool)GET_RX_DESC_PAGGR(pdesc));
> ++					(u8)GET_RX_DESC_RX_MCS(pdesc));
> + 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
> + 	if (phystatus) {
> + 		p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
> +@@ -408,8 +407,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
> + 	/* Data rate */
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
> + 					(bool)GET_RX_DESC_RX_HT(rxdesc),
> +-					(u8)GET_RX_DESC_RX_MCS(rxdesc),
> +-					(bool)GET_RX_DESC_PAGGR(rxdesc));
> ++					(u8)GET_RX_DESC_RX_MCS(rxdesc));
> + 	/*  There is a phy status after this rx descriptor. */
> + 	if (GET_RX_DESC_PHY_STATUS(rxdesc)) {
> + 		p_drvinfo = (struct rx_fwinfo_92c *)(rxdesc + RTL_RX_DESC_SIZE);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> +index 8efbcc7..7fbae49 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> +@@ -514,8 +514,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,	struct rtl_stats *stats,
> + 		rx_status->flag |= RX_FLAG_DECRYPTED;
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
> + 					(bool)GET_RX_DESC_RXHT(pdesc),
> +-					(u8)GET_RX_DESC_RXMCS(pdesc),
> +-					(bool)GET_RX_DESC_PAGGR(pdesc));
> ++					(u8)GET_RX_DESC_RXMCS(pdesc));
> + 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
> + 	if (phystatus) {
> + 		p_drvinfo = (struct rx_fwinfo_92d *)(skb->data +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> +index 672fd3b..da053cb 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> +@@ -264,7 +264,6 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
> + 	struct rx_fwinfo *p_drvinfo;
> + 	u32 phystatus = (u32)GET_RX_STATUS_DESC_PHY_STATUS(pdesc);
> + 	struct ieee80211_hdr *hdr;
> +-	bool first_ampdu = false;
> + 
> + 	stats->length = (u16)GET_RX_STATUS_DESC_PKT_LEN(pdesc);
> + 	stats->rx_drvinfo_size = (u8)GET_RX_STATUS_DESC_DRVINFO_SIZE(pdesc) * 8;
> +@@ -319,8 +318,8 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
> + 			rx_status->flag |= RX_FLAG_DECRYPTED;
> + 	}
> + 
> +-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
> +-			      stats->is_ht, stats->rate, first_ampdu);
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
> ++						   stats->rate);
> + 
> + 	rx_status->mactime = stats->timestamp_low;
> + 	if (phystatus) {
> +@@ -398,9 +397,9 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
> + 
> + 		if (rtlhal->version == VERSION_8192S_ACUT) {
> + 			if (ptcb_desc->hw_rate == DESC92_RATE1M ||
> +-				ptcb_desc->hw_rate  == DESC92_RATE2M ||
> +-				ptcb_desc->hw_rate == DESC92_RATE5_5M ||
> +-				ptcb_desc->hw_rate == DESC92_RATE11M) {
> ++			    ptcb_desc->hw_rate  == DESC92_RATE2M ||
> ++			    ptcb_desc->hw_rate == DESC92_RATE5_5M ||
> ++			    ptcb_desc->hw_rate == DESC92_RATE11M) {
> + 				ptcb_desc->hw_rate = DESC92_RATE12M;
> + 			}
> + 		}
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0025-rtlwifi-rtl8723be-Switch-to-use-common-rate-mapping-.patch b/package/kernel/mac80211/patches/680-0025-rtlwifi-rtl8723be-Switch-to-use-common-rate-mapping-.patch
> new file mode 100644
> index 0000000..6ee667f
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0025-rtlwifi-rtl8723be-Switch-to-use-common-rate-mapping-.patch
> @@ -0,0 +1,196 @@
> +From 7e0dde9248c413485aa2eb2079782d8941f062c8 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:32 -0600
> +Subject: [PATCH 25/51] rtlwifi: rtl8723be: Switch to use common rate-mapping
> + routine
> +
> +This driver currently has its owm version of this routine that duplicates
> +a routine in rtlwifi.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8723be/trx.c | 160 +--------------------------
> + 1 file changed, 1 insertion(+), 159 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
> +index d6a1c70..cb23bed 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
> +@@ -47,164 +47,6 @@ static u8 _rtl8723be_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
> + 	return skb->priority;
> + }
> + 
> +-/* mac80211's rate_idx is like this:
> +- *
> +- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
> +- *
> +- * B/G rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
> +- *
> +- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
> +- * A rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
> +- */
> +-static int _rtl8723be_rate_mapping(struct ieee80211_hw *hw,
> +-				   bool isht, u8 desc_rate)
> +-{
> +-	int rate_idx;
> +-
> +-	if (!isht) {
> +-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
> +-			switch (desc_rate) {
> +-			case DESC92C_RATE1M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC92C_RATE2M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC92C_RATE5_5M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC92C_RATE11M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC92C_RATE6M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC92C_RATE9M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC92C_RATE12M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC92C_RATE18M:
> +-				rate_idx = 7;
> +-				break;
> +-			case DESC92C_RATE24M:
> +-				rate_idx = 8;
> +-				break;
> +-			case DESC92C_RATE36M:
> +-				rate_idx = 9;
> +-				break;
> +-			case DESC92C_RATE48M:
> +-				rate_idx = 10;
> +-				break;
> +-			case DESC92C_RATE54M:
> +-				rate_idx = 11;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		} else {
> +-			switch (desc_rate) {
> +-			case DESC92C_RATE6M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC92C_RATE9M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC92C_RATE12M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC92C_RATE18M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC92C_RATE24M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC92C_RATE36M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC92C_RATE48M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC92C_RATE54M:
> +-				rate_idx = 7;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		}
> +-	} else {
> +-		switch (desc_rate) {
> +-		case DESC92C_RATEMCS0:
> +-			rate_idx = 0;
> +-			break;
> +-		case DESC92C_RATEMCS1:
> +-			rate_idx = 1;
> +-			break;
> +-		case DESC92C_RATEMCS2:
> +-			rate_idx = 2;
> +-			break;
> +-		case DESC92C_RATEMCS3:
> +-			rate_idx = 3;
> +-			break;
> +-		case DESC92C_RATEMCS4:
> +-			rate_idx = 4;
> +-			break;
> +-		case DESC92C_RATEMCS5:
> +-			rate_idx = 5;
> +-			break;
> +-		case DESC92C_RATEMCS6:
> +-			rate_idx = 6;
> +-			break;
> +-		case DESC92C_RATEMCS7:
> +-			rate_idx = 7;
> +-			break;
> +-		case DESC92C_RATEMCS8:
> +-			rate_idx = 8;
> +-			break;
> +-		case DESC92C_RATEMCS9:
> +-			rate_idx = 9;
> +-			break;
> +-		case DESC92C_RATEMCS10:
> +-			rate_idx = 10;
> +-			break;
> +-		case DESC92C_RATEMCS11:
> +-			rate_idx = 11;
> +-			break;
> +-		case DESC92C_RATEMCS12:
> +-			rate_idx = 12;
> +-			break;
> +-		case DESC92C_RATEMCS13:
> +-			rate_idx = 13;
> +-			break;
> +-		case DESC92C_RATEMCS14:
> +-			rate_idx = 14;
> +-			break;
> +-		case DESC92C_RATEMCS15:
> +-			rate_idx = 15;
> +-			break;
> +-		default:
> +-			rate_idx = 0;
> +-			break;
> +-		}
> +-	}
> +-	return rate_idx;
> +-}
> +-
> + static void _rtl8723be_query_rxphystatus(struct ieee80211_hw *hw,
> + 					 struct rtl_stats *pstatus, u8 *pdesc,
> + 					 struct rx_fwinfo_8723be *p_drvinfo,
> +@@ -558,7 +400,7 @@ bool rtl8723be_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * supported rates or MCS index if HT rates
> + 	 * are use (RX_FLAG_HT)
> + 	 */
> +-	rx_status->rate_idx = _rtl8723be_rate_mapping(hw, status->is_ht,
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> + 						      status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0026-rtlwifi-rtl8188ee-Switch-to-use-common-rate-mapping-.patch b/package/kernel/mac80211/patches/680-0026-rtlwifi-rtl8188ee-Switch-to-use-common-rate-mapping-.patch
> new file mode 100644
> index 0000000..f418296
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0026-rtlwifi-rtl8188ee-Switch-to-use-common-rate-mapping-.patch
> @@ -0,0 +1,197 @@
> +From 5b243feff35ab6050893741bc1a7016fa3ae5a8b Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:33 -0600
> +Subject: [PATCH 26/51] rtlwifi: rtl8188ee: Switch to use common rate-mapping
> + routine
> +
> +This driver duplicates a routine found in the core.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8188ee/trx.c | 162 +--------------------------
> + 1 file changed, 2 insertions(+), 160 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
> +index df549c9..d430884 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
> +@@ -47,164 +47,6 @@ static u8 _rtl88ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
> + 	return skb->priority;
> + }
> + 
> +-/* mac80211's rate_idx is like this:
> +- *
> +- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
> +- *
> +- * B/G rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
> +- *
> +- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
> +- * A rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
> +- */
> +-static int _rtl88ee_rate_mapping(struct ieee80211_hw *hw,
> +-				 bool isht, u8 desc_rate)
> +-{
> +-	int rate_idx;
> +-
> +-	if (!isht) {
> +-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
> +-			switch (desc_rate) {
> +-			case DESC92C_RATE1M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC92C_RATE2M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC92C_RATE5_5M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC92C_RATE11M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC92C_RATE6M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC92C_RATE9M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC92C_RATE12M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC92C_RATE18M:
> +-				rate_idx = 7;
> +-				break;
> +-			case DESC92C_RATE24M:
> +-				rate_idx = 8;
> +-				break;
> +-			case DESC92C_RATE36M:
> +-				rate_idx = 9;
> +-				break;
> +-			case DESC92C_RATE48M:
> +-				rate_idx = 10;
> +-				break;
> +-			case DESC92C_RATE54M:
> +-				rate_idx = 11;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		} else {
> +-			switch (desc_rate) {
> +-			case DESC92C_RATE6M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC92C_RATE9M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC92C_RATE12M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC92C_RATE18M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC92C_RATE24M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC92C_RATE36M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC92C_RATE48M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC92C_RATE54M:
> +-				rate_idx = 7;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		}
> +-	} else {
> +-		switch (desc_rate) {
> +-		case DESC92C_RATEMCS0:
> +-			rate_idx = 0;
> +-			break;
> +-		case DESC92C_RATEMCS1:
> +-			rate_idx = 1;
> +-			break;
> +-		case DESC92C_RATEMCS2:
> +-			rate_idx = 2;
> +-			break;
> +-		case DESC92C_RATEMCS3:
> +-			rate_idx = 3;
> +-			break;
> +-		case DESC92C_RATEMCS4:
> +-			rate_idx = 4;
> +-			break;
> +-		case DESC92C_RATEMCS5:
> +-			rate_idx = 5;
> +-			break;
> +-		case DESC92C_RATEMCS6:
> +-			rate_idx = 6;
> +-			break;
> +-		case DESC92C_RATEMCS7:
> +-			rate_idx = 7;
> +-			break;
> +-		case DESC92C_RATEMCS8:
> +-			rate_idx = 8;
> +-			break;
> +-		case DESC92C_RATEMCS9:
> +-			rate_idx = 9;
> +-			break;
> +-		case DESC92C_RATEMCS10:
> +-			rate_idx = 10;
> +-			break;
> +-		case DESC92C_RATEMCS11:
> +-			rate_idx = 11;
> +-			break;
> +-		case DESC92C_RATEMCS12:
> +-			rate_idx = 12;
> +-			break;
> +-		case DESC92C_RATEMCS13:
> +-			rate_idx = 13;
> +-			break;
> +-		case DESC92C_RATEMCS14:
> +-			rate_idx = 14;
> +-			break;
> +-		case DESC92C_RATEMCS15:
> +-			rate_idx = 15;
> +-			break;
> +-		default:
> +-			rate_idx = 0;
> +-			break;
> +-		}
> +-	}
> +-	return rate_idx;
> +-}
> +-
> + static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw,
> + 			struct rtl_stats *pstatus, u8 *pdesc,
> + 			struct rx_fwinfo_88e *p_drvinfo,
> +@@ -630,8 +472,8 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * are use (RX_FLAG_HT)
> + 	 * Notice: this is diff with windows define
> + 	 */
> +-	rx_status->rate_idx = _rtl88ee_rate_mapping(hw,
> +-				status->is_ht, status->rate);
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> ++						   status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> + 	if (phystatus == true) {
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0027-rtlwifi-rtl8723ae-Modify-driver-to-use-rate-mapping-.patch b/package/kernel/mac80211/patches/680-0027-rtlwifi-rtl8723ae-Modify-driver-to-use-rate-mapping-.patch
> new file mode 100644
> index 0000000..435fa7c
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0027-rtlwifi-rtl8723ae-Modify-driver-to-use-rate-mapping-.patch
> @@ -0,0 +1,197 @@
> +From 8d3fc3a64ba34d859d6bb0de76bd1860b234cd1c Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:34 -0600
> +Subject: [PATCH 27/51] rtlwifi: rtl8723ae: Modify driver to use rate-mapping
> + routine in core
> +
> +This driver is also converted to use the rate-mapping code in the core.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8723ae/trx.c | 162 +--------------------------
> + 1 file changed, 2 insertions(+), 160 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
> +index d372cca..662a094 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
> +@@ -45,164 +45,6 @@ static u8 _rtl8723e_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
> + 	return skb->priority;
> + }
> + 
> +-/* mac80211's rate_idx is like this:
> +- *
> +- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
> +- *
> +- * B/G rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
> +- *
> +- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
> +- * A rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
> +- */
> +-static int _rtl8723e_rate_mapping(struct ieee80211_hw *hw,
> +-				  bool isht, u8 desc_rate)
> +-{
> +-	int rate_idx;
> +-
> +-	if (!isht) {
> +-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
> +-			switch (desc_rate) {
> +-			case DESC92C_RATE1M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC92C_RATE2M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC92C_RATE5_5M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC92C_RATE11M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC92C_RATE6M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC92C_RATE9M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC92C_RATE12M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC92C_RATE18M:
> +-				rate_idx = 7;
> +-				break;
> +-			case DESC92C_RATE24M:
> +-				rate_idx = 8;
> +-				break;
> +-			case DESC92C_RATE36M:
> +-				rate_idx = 9;
> +-				break;
> +-			case DESC92C_RATE48M:
> +-				rate_idx = 10;
> +-				break;
> +-			case DESC92C_RATE54M:
> +-				rate_idx = 11;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		} else {
> +-			switch (desc_rate) {
> +-			case DESC92C_RATE6M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC92C_RATE9M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC92C_RATE12M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC92C_RATE18M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC92C_RATE24M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC92C_RATE36M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC92C_RATE48M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC92C_RATE54M:
> +-				rate_idx = 7;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		}
> +-	} else {
> +-		switch (desc_rate) {
> +-		case DESC92C_RATEMCS0:
> +-			rate_idx = 0;
> +-			break;
> +-		case DESC92C_RATEMCS1:
> +-			rate_idx = 1;
> +-			break;
> +-		case DESC92C_RATEMCS2:
> +-			rate_idx = 2;
> +-			break;
> +-		case DESC92C_RATEMCS3:
> +-			rate_idx = 3;
> +-			break;
> +-		case DESC92C_RATEMCS4:
> +-			rate_idx = 4;
> +-			break;
> +-		case DESC92C_RATEMCS5:
> +-			rate_idx = 5;
> +-			break;
> +-		case DESC92C_RATEMCS6:
> +-			rate_idx = 6;
> +-			break;
> +-		case DESC92C_RATEMCS7:
> +-			rate_idx = 7;
> +-			break;
> +-		case DESC92C_RATEMCS8:
> +-			rate_idx = 8;
> +-			break;
> +-		case DESC92C_RATEMCS9:
> +-			rate_idx = 9;
> +-			break;
> +-		case DESC92C_RATEMCS10:
> +-			rate_idx = 10;
> +-			break;
> +-		case DESC92C_RATEMCS11:
> +-			rate_idx = 11;
> +-			break;
> +-		case DESC92C_RATEMCS12:
> +-			rate_idx = 12;
> +-			break;
> +-		case DESC92C_RATEMCS13:
> +-			rate_idx = 13;
> +-			break;
> +-		case DESC92C_RATEMCS14:
> +-			rate_idx = 14;
> +-			break;
> +-		case DESC92C_RATEMCS15:
> +-			rate_idx = 15;
> +-			break;
> +-		default:
> +-			rate_idx = 0;
> +-			break;
> +-		}
> +-	}
> +-	return rate_idx;
> +-}
> +-
> + static void _rtl8723e_query_rxphystatus(struct ieee80211_hw *hw,
> + 					struct rtl_stats *pstatus, u8 *pdesc,
> + 					struct rx_fwinfo_8723e *p_drvinfo,
> +@@ -503,8 +345,8 @@ bool rtl8723e_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * are use (RX_FLAG_HT)
> + 	 * Notice: this is diff with windows define
> + 	 */
> +-	rx_status->rate_idx = _rtl8723e_rate_mapping(hw,
> +-				status->is_ht, status->rate);
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> ++						   status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> + 	if (phystatus == true) {
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0028-rtlwifi-rtl8192ee-Convert-driver-to-use-common-rate-.patch b/package/kernel/mac80211/patches/680-0028-rtlwifi-rtl8192ee-Convert-driver-to-use-common-rate-.patch
> new file mode 100644
> index 0000000..9fff206
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0028-rtlwifi-rtl8192ee-Convert-driver-to-use-common-rate-.patch
> @@ -0,0 +1,196 @@
> +From 7b7d0d60a558d80165a18c0eceb1cc7b0c7d6439 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:35 -0600
> +Subject: [PATCH 28/51] rtlwifi: rtl8192ee: Convert driver to use common
> + rate-mapping code
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 163 +--------------------------
> + 1 file changed, 2 insertions(+), 161 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> +index 2fcbef1..fb46fb9 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> +@@ -47,164 +47,6 @@ static u8 _rtl92ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
> + 	return skb->priority;
> + }
> + 
> +-/* mac80211's rate_idx is like this:
> +- *
> +- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
> +- *
> +- * B/G rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
> +- *
> +- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
> +- * A rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
> +- */
> +-static int _rtl92ee_rate_mapping(struct ieee80211_hw *hw,
> +-				 bool isht, u8 desc_rate)
> +-{
> +-	int rate_idx;
> +-
> +-	if (!isht) {
> +-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
> +-			switch (desc_rate) {
> +-			case DESC92C_RATE1M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC92C_RATE2M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC92C_RATE5_5M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC92C_RATE11M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC92C_RATE6M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC92C_RATE9M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC92C_RATE12M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC92C_RATE18M:
> +-				rate_idx = 7;
> +-				break;
> +-			case DESC92C_RATE24M:
> +-				rate_idx = 8;
> +-				break;
> +-			case DESC92C_RATE36M:
> +-				rate_idx = 9;
> +-				break;
> +-			case DESC92C_RATE48M:
> +-				rate_idx = 10;
> +-				break;
> +-			case DESC92C_RATE54M:
> +-				rate_idx = 11;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		} else {
> +-			switch (desc_rate) {
> +-			case DESC92C_RATE6M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC92C_RATE9M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC92C_RATE12M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC92C_RATE18M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC92C_RATE24M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC92C_RATE36M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC92C_RATE48M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC92C_RATE54M:
> +-				rate_idx = 7;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		}
> +-	} else {
> +-		switch (desc_rate) {
> +-		case DESC92C_RATEMCS0:
> +-			rate_idx = 0;
> +-			break;
> +-		case DESC92C_RATEMCS1:
> +-			rate_idx = 1;
> +-			break;
> +-		case DESC92C_RATEMCS2:
> +-			rate_idx = 2;
> +-			break;
> +-		case DESC92C_RATEMCS3:
> +-			rate_idx = 3;
> +-			break;
> +-		case DESC92C_RATEMCS4:
> +-			rate_idx = 4;
> +-			break;
> +-		case DESC92C_RATEMCS5:
> +-			rate_idx = 5;
> +-			break;
> +-		case DESC92C_RATEMCS6:
> +-			rate_idx = 6;
> +-			break;
> +-		case DESC92C_RATEMCS7:
> +-			rate_idx = 7;
> +-			break;
> +-		case DESC92C_RATEMCS8:
> +-			rate_idx = 8;
> +-			break;
> +-		case DESC92C_RATEMCS9:
> +-			rate_idx = 9;
> +-			break;
> +-		case DESC92C_RATEMCS10:
> +-			rate_idx = 10;
> +-			break;
> +-		case DESC92C_RATEMCS11:
> +-			rate_idx = 11;
> +-			break;
> +-		case DESC92C_RATEMCS12:
> +-			rate_idx = 12;
> +-			break;
> +-		case DESC92C_RATEMCS13:
> +-			rate_idx = 13;
> +-			break;
> +-		case DESC92C_RATEMCS14:
> +-			rate_idx = 14;
> +-			break;
> +-		case DESC92C_RATEMCS15:
> +-			rate_idx = 15;
> +-			break;
> +-		default:
> +-			rate_idx = 0;
> +-			break;
> +-		}
> +-	}
> +-	return rate_idx;
> +-}
> +-
> + static void _rtl92ee_query_rxphystatus(struct ieee80211_hw *hw,
> + 				       struct rtl_stats *pstatus, u8 *pdesc,
> + 				       struct rx_fwinfo *p_drvinfo,
> +@@ -576,9 +418,8 @@ bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * are use (RX_FLAG_HT)
> + 	 * Notice: this is diff with windows define
> + 	 */
> +-	rx_status->rate_idx = _rtl92ee_rate_mapping(hw,
> +-						    status->is_ht,
> +-						    status->rate);
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> ++						   status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> + 	if (phystatus) {
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0029-rtlwifi-Convert-all-drivers-to-use-a-common-set-of-r.patch b/package/kernel/mac80211/patches/680-0029-rtlwifi-Convert-all-drivers-to-use-a-common-set-of-r.patch
> new file mode 100644
> index 0000000..10cb532
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0029-rtlwifi-Convert-all-drivers-to-use-a-common-set-of-r.patch
> @@ -0,0 +1,786 @@
> +From e0e776a3c85c27751ab4399616fc50a474cc8379 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:36 -0600
> +Subject: [PATCH 29/51] rtlwifi: Convert all drivers to use a common set of
> + rate descriptors
> +
> +This common set of rate descriptors is renamed to be DESC_RATExx.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/base.c          | 80 ++++++++++++++--------------
> + drivers/net/wireless/rtlwifi/rtl8192ce/sw.c  | 30 +++++------
> + drivers/net/wireless/rtlwifi/rtl8192ce/trx.c |  8 +--
> + drivers/net/wireless/rtlwifi/rtl8192cu/mac.c |  4 +-
> + drivers/net/wireless/rtlwifi/rtl8192cu/sw.c  | 28 +++++-----
> + drivers/net/wireless/rtlwifi/rtl8192cu/trx.c |  6 +--
> + drivers/net/wireless/rtlwifi/rtl8192de/sw.c  | 30 +++++------
> + drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 20 +++----
> + drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 12 ++---
> + drivers/net/wireless/rtlwifi/rtl8192ee/trx.h |  8 +--
> + drivers/net/wireless/rtlwifi/rtl8192se/def.h |  8 +--
> + drivers/net/wireless/rtlwifi/rtl8192se/sw.c  | 30 +++++------
> + drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 18 +++----
> + drivers/net/wireless/rtlwifi/rtl8821ae/def.h | 31 -----------
> + drivers/net/wireless/rtlwifi/wifi.h          | 72 ++++++++++++-------------
> + 15 files changed, 177 insertions(+), 208 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
> +index d4c8e95..23fc51e 100644
> +--- a/drivers/net/wireless/rtlwifi/base.c
> ++++ b/drivers/net/wireless/rtlwifi/base.c
> +@@ -867,20 +867,20 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
> +  *
> +  * B/G rate:
> +  * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92_RATE1M-->DESC92_RATE54M ==> idx is 0-->11,
> ++ * DESC_RATE1M-->DESC_RATE54M ==> idx is 0-->11,
> +  *
> +  * N rate:
> +  * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
> ++ * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
> +  *
> +  * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
> +  * A rate:
> +  * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC92_RATE6M-->DESC92_RATE54M ==> idx is 0-->7,
> ++ * DESC_RATE6M-->DESC_RATE54M ==> idx is 0-->7,
> +  *
> +  * N rate:
> +  * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
> ++ * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
> +  */
> + int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
> + 			 bool isht, u8 desc_rate)
> +@@ -890,40 +890,40 @@ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
> + 	if (false == isht) {
> + 		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
> + 			switch (desc_rate) {
> +-			case DESC92_RATE1M:
> ++			case DESC_RATE1M:
> + 				rate_idx = 0;
> + 				break;
> +-			case DESC92_RATE2M:
> ++			case DESC_RATE2M:
> + 				rate_idx = 1;
> + 				break;
> +-			case DESC92_RATE5_5M:
> ++			case DESC_RATE5_5M:
> + 				rate_idx = 2;
> + 				break;
> +-			case DESC92_RATE11M:
> ++			case DESC_RATE11M:
> + 				rate_idx = 3;
> + 				break;
> +-			case DESC92_RATE6M:
> ++			case DESC_RATE6M:
> + 				rate_idx = 4;
> + 				break;
> +-			case DESC92_RATE9M:
> ++			case DESC_RATE9M:
> + 				rate_idx = 5;
> + 				break;
> +-			case DESC92_RATE12M:
> ++			case DESC_RATE12M:
> + 				rate_idx = 6;
> + 				break;
> +-			case DESC92_RATE18M:
> ++			case DESC_RATE18M:
> + 				rate_idx = 7;
> + 				break;
> +-			case DESC92_RATE24M:
> ++			case DESC_RATE24M:
> + 				rate_idx = 8;
> + 				break;
> +-			case DESC92_RATE36M:
> ++			case DESC_RATE36M:
> + 				rate_idx = 9;
> + 				break;
> +-			case DESC92_RATE48M:
> ++			case DESC_RATE48M:
> + 				rate_idx = 10;
> + 				break;
> +-			case DESC92_RATE54M:
> ++			case DESC_RATE54M:
> + 				rate_idx = 11;
> + 				break;
> + 			default:
> +@@ -932,28 +932,28 @@ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
> + 			}
> + 		} else {
> + 			switch (desc_rate) {
> +-			case DESC92_RATE6M:
> ++			case DESC_RATE6M:
> + 				rate_idx = 0;
> + 				break;
> +-			case DESC92_RATE9M:
> ++			case DESC_RATE9M:
> + 				rate_idx = 1;
> + 				break;
> +-			case DESC92_RATE12M:
> ++			case DESC_RATE12M:
> + 				rate_idx = 2;
> + 				break;
> +-			case DESC92_RATE18M:
> ++			case DESC_RATE18M:
> + 				rate_idx = 3;
> + 				break;
> +-			case DESC92_RATE24M:
> ++			case DESC_RATE24M:
> + 				rate_idx = 4;
> + 				break;
> +-			case DESC92_RATE36M:
> ++			case DESC_RATE36M:
> + 				rate_idx = 5;
> + 				break;
> +-			case DESC92_RATE48M:
> ++			case DESC_RATE48M:
> + 				rate_idx = 6;
> + 				break;
> +-			case DESC92_RATE54M:
> ++			case DESC_RATE54M:
> + 				rate_idx = 7;
> + 				break;
> + 			default:
> +@@ -963,52 +963,52 @@ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
> + 		}
> + 	} else {
> + 		switch (desc_rate) {
> +-		case DESC92_RATEMCS0:
> ++		case DESC_RATEMCS0:
> + 			rate_idx = 0;
> + 			break;
> +-		case DESC92_RATEMCS1:
> ++		case DESC_RATEMCS1:
> + 			rate_idx = 1;
> + 			break;
> +-		case DESC92_RATEMCS2:
> ++		case DESC_RATEMCS2:
> + 			rate_idx = 2;
> + 			break;
> +-		case DESC92_RATEMCS3:
> ++		case DESC_RATEMCS3:
> + 			rate_idx = 3;
> + 			break;
> +-		case DESC92_RATEMCS4:
> ++		case DESC_RATEMCS4:
> + 			rate_idx = 4;
> + 			break;
> +-		case DESC92_RATEMCS5:
> ++		case DESC_RATEMCS5:
> + 			rate_idx = 5;
> + 			break;
> +-		case DESC92_RATEMCS6:
> ++		case DESC_RATEMCS6:
> + 			rate_idx = 6;
> + 			break;
> +-		case DESC92_RATEMCS7:
> ++		case DESC_RATEMCS7:
> + 			rate_idx = 7;
> + 			break;
> +-		case DESC92_RATEMCS8:
> ++		case DESC_RATEMCS8:
> + 			rate_idx = 8;
> + 			break;
> +-		case DESC92_RATEMCS9:
> ++		case DESC_RATEMCS9:
> + 			rate_idx = 9;
> + 			break;
> +-		case DESC92_RATEMCS10:
> ++		case DESC_RATEMCS10:
> + 			rate_idx = 10;
> + 			break;
> +-		case DESC92_RATEMCS11:
> ++		case DESC_RATEMCS11:
> + 			rate_idx = 11;
> + 			break;
> +-		case DESC92_RATEMCS12:
> ++		case DESC_RATEMCS12:
> + 			rate_idx = 12;
> + 			break;
> +-		case DESC92_RATEMCS13:
> ++		case DESC_RATEMCS13:
> + 			rate_idx = 13;
> + 			break;
> +-		case DESC92_RATEMCS14:
> ++		case DESC_RATEMCS14:
> + 			rate_idx = 14;
> + 			break;
> +-		case DESC92_RATEMCS15:
> ++		case DESC_RATEMCS15:
> + 			rate_idx = 15;
> + 			break;
> + 		default:
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
> +index dd5aa08..de6cb6c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
> +@@ -334,21 +334,21 @@ static struct rtl_hal_cfg rtl92ce_hal_cfg = {
> + 	.maps[RTL_IMR_ROK] = IMR_ROK,
> + 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNINT | IMR_TBDOK | IMR_TBDER),
> + 
> +-	.maps[RTL_RC_CCK_RATE1M] = DESC92_RATE1M,
> +-	.maps[RTL_RC_CCK_RATE2M] = DESC92_RATE2M,
> +-	.maps[RTL_RC_CCK_RATE5_5M] = DESC92_RATE5_5M,
> +-	.maps[RTL_RC_CCK_RATE11M] = DESC92_RATE11M,
> +-	.maps[RTL_RC_OFDM_RATE6M] = DESC92_RATE6M,
> +-	.maps[RTL_RC_OFDM_RATE9M] = DESC92_RATE9M,
> +-	.maps[RTL_RC_OFDM_RATE12M] = DESC92_RATE12M,
> +-	.maps[RTL_RC_OFDM_RATE18M] = DESC92_RATE18M,
> +-	.maps[RTL_RC_OFDM_RATE24M] = DESC92_RATE24M,
> +-	.maps[RTL_RC_OFDM_RATE36M] = DESC92_RATE36M,
> +-	.maps[RTL_RC_OFDM_RATE48M] = DESC92_RATE48M,
> +-	.maps[RTL_RC_OFDM_RATE54M] = DESC92_RATE54M,
> +-
> +-	.maps[RTL_RC_HT_RATEMCS7] = DESC92_RATEMCS7,
> +-	.maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
> ++	.maps[RTL_RC_CCK_RATE1M] = DESC_RATE1M,
> ++	.maps[RTL_RC_CCK_RATE2M] = DESC_RATE2M,
> ++	.maps[RTL_RC_CCK_RATE5_5M] = DESC_RATE5_5M,
> ++	.maps[RTL_RC_CCK_RATE11M] = DESC_RATE11M,
> ++	.maps[RTL_RC_OFDM_RATE6M] = DESC_RATE6M,
> ++	.maps[RTL_RC_OFDM_RATE9M] = DESC_RATE9M,
> ++	.maps[RTL_RC_OFDM_RATE12M] = DESC_RATE12M,
> ++	.maps[RTL_RC_OFDM_RATE18M] = DESC_RATE18M,
> ++	.maps[RTL_RC_OFDM_RATE24M] = DESC_RATE24M,
> ++	.maps[RTL_RC_OFDM_RATE36M] = DESC_RATE36M,
> ++	.maps[RTL_RC_OFDM_RATE48M] = DESC_RATE48M,
> ++	.maps[RTL_RC_OFDM_RATE54M] = DESC_RATE54M,
> ++
> ++	.maps[RTL_RC_HT_RATEMCS7] = DESC_RATEMCS7,
> ++	.maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15,
> + };
> + 
> + static const struct pci_device_id rtl92ce_pci_ids[] = {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +index d25aeeb..685faea 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +@@ -257,8 +257,8 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
> + 		pstats->recvsignalpower = rx_pwr_all;
> + 
> + 		/* (3)EVM of HT rate */
> +-		if (pstats->is_ht && pstats->rate >= DESC92_RATEMCS8 &&
> +-		    pstats->rate <= DESC92_RATEMCS15)
> ++		if (pstats->is_ht && pstats->rate >= DESC_RATEMCS8 &&
> ++		    pstats->rate <= DESC_RATEMCS15)
> + 			max_spatial_stream = 2;
> + 		else
> + 			max_spatial_stream = 1;
> +@@ -500,7 +500,7 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
> + 		SET_TX_DESC_RTS_BW(pdesc, 0);
> + 		SET_TX_DESC_RTS_SC(pdesc, tcb_desc->rts_sc);
> + 		SET_TX_DESC_RTS_SHORT(pdesc,
> +-				      ((tcb_desc->rts_rate <= DESC92_RATE54M) ?
> ++				      ((tcb_desc->rts_rate <= DESC_RATE54M) ?
> + 				       (tcb_desc->rts_use_shortpreamble ? 1 : 0)
> + 				       : (tcb_desc->rts_use_shortgi ? 1 : 0)));
> + 
> +@@ -623,7 +623,7 @@ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw,
> + 	if (firstseg)
> + 		SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN);
> + 
> +-	SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE1M);
> ++	SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
> + 
> + 	SET_TX_DESC_SEQ(pdesc, 0);
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
> +index c2d8ec6..133e395 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
> +@@ -880,8 +880,8 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
> + 		pstats->rxpower = rx_pwr_all;
> + 		pstats->recvsignalpower = rx_pwr_all;
> + 		if (GET_RX_DESC_RX_MCS(pdesc) &&
> +-		    GET_RX_DESC_RX_MCS(pdesc) >= DESC92_RATEMCS8 &&
> +-		    GET_RX_DESC_RX_MCS(pdesc) <= DESC92_RATEMCS15)
> ++		    GET_RX_DESC_RX_MCS(pdesc) >= DESC_RATEMCS8 &&
> ++		    GET_RX_DESC_RX_MCS(pdesc) <= DESC_RATEMCS15)
> + 			max_spatial_stream = 2;
> + 		else
> + 			max_spatial_stream = 1;
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
> +index e06bafe..90a714c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
> +@@ -257,20 +257,20 @@ static struct rtl_hal_cfg rtl92cu_hal_cfg = {
> + 	.maps[RTL_IMR_ROK] = IMR_ROK,
> + 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNINT | IMR_TBDOK | IMR_TBDER),
> + 
> +-	.maps[RTL_RC_CCK_RATE1M] = DESC92_RATE1M,
> +-	.maps[RTL_RC_CCK_RATE2M] = DESC92_RATE2M,
> +-	.maps[RTL_RC_CCK_RATE5_5M] = DESC92_RATE5_5M,
> +-	.maps[RTL_RC_CCK_RATE11M] = DESC92_RATE11M,
> +-	.maps[RTL_RC_OFDM_RATE6M] = DESC92_RATE6M,
> +-	.maps[RTL_RC_OFDM_RATE9M] = DESC92_RATE9M,
> +-	.maps[RTL_RC_OFDM_RATE12M] = DESC92_RATE12M,
> +-	.maps[RTL_RC_OFDM_RATE18M] = DESC92_RATE18M,
> +-	.maps[RTL_RC_OFDM_RATE24M] = DESC92_RATE24M,
> +-	.maps[RTL_RC_OFDM_RATE36M] = DESC92_RATE36M,
> +-	.maps[RTL_RC_OFDM_RATE48M] = DESC92_RATE48M,
> +-	.maps[RTL_RC_OFDM_RATE54M] = DESC92_RATE54M,
> +-	.maps[RTL_RC_HT_RATEMCS7] = DESC92_RATEMCS7,
> +-	.maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
> ++	.maps[RTL_RC_CCK_RATE1M] = DESC_RATE1M,
> ++	.maps[RTL_RC_CCK_RATE2M] = DESC_RATE2M,
> ++	.maps[RTL_RC_CCK_RATE5_5M] = DESC_RATE5_5M,
> ++	.maps[RTL_RC_CCK_RATE11M] = DESC_RATE11M,
> ++	.maps[RTL_RC_OFDM_RATE6M] = DESC_RATE6M,
> ++	.maps[RTL_RC_OFDM_RATE9M] = DESC_RATE9M,
> ++	.maps[RTL_RC_OFDM_RATE12M] = DESC_RATE12M,
> ++	.maps[RTL_RC_OFDM_RATE18M] = DESC_RATE18M,
> ++	.maps[RTL_RC_OFDM_RATE24M] = DESC_RATE24M,
> ++	.maps[RTL_RC_OFDM_RATE36M] = DESC_RATE36M,
> ++	.maps[RTL_RC_OFDM_RATE48M] = DESC_RATE48M,
> ++	.maps[RTL_RC_OFDM_RATE54M] = DESC_RATE54M,
> ++	.maps[RTL_RC_HT_RATEMCS7] = DESC_RATEMCS7,
> ++	.maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15,
> + };
> + 
> + #define USB_VENDER_ID_REALTEK		0x0bda
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> +index fa30b26..fe29876 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> +@@ -543,7 +543,7 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
> + 	SET_TX_DESC_RTS_BW(txdesc, 0);
> + 	SET_TX_DESC_RTS_SC(txdesc, tcb_desc->rts_sc);
> + 	SET_TX_DESC_RTS_SHORT(txdesc,
> +-			      ((tcb_desc->rts_rate <= DESC92_RATE54M) ?
> ++			      ((tcb_desc->rts_rate <= DESC_RATE54M) ?
> + 			       (tcb_desc->rts_use_shortpreamble ? 1 : 0)
> + 			       : (tcb_desc->rts_use_shortgi ? 1 : 0)));
> + 	if (mac->bw_40) {
> +@@ -642,7 +642,7 @@ void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc,
> + 	}
> + 	SET_TX_DESC_USE_RATE(pDesc, 1); /* use data rate which is set by Sw */
> + 	SET_TX_DESC_OWN(pDesc, 1);
> +-	SET_TX_DESC_TX_RATE(pDesc, DESC92_RATE1M);
> ++	SET_TX_DESC_TX_RATE(pDesc, DESC_RATE1M);
> + 	_rtl_tx_desc_checksum(pDesc);
> + }
> + 
> +@@ -658,7 +658,7 @@ void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
> + 	memset((void *)pdesc, 0, RTL_TX_HEADER_SIZE);
> + 	if (firstseg)
> + 		SET_TX_DESC_OFFSET(pdesc, RTL_TX_HEADER_SIZE);
> +-	SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE1M);
> ++	SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
> + 	SET_TX_DESC_SEQ(pdesc, 0);
> + 	SET_TX_DESC_LINIP(pdesc, 0);
> + 	SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
> +index a0aba08..b19d039 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
> +@@ -337,21 +337,21 @@ static struct rtl_hal_cfg rtl92de_hal_cfg = {
> + 	.maps[RTL_IMR_ROK] = IMR_ROK,
> + 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNINT | IMR_TBDOK | IMR_TBDER),
> + 
> +-	.maps[RTL_RC_CCK_RATE1M] = DESC92_RATE1M,
> +-	.maps[RTL_RC_CCK_RATE2M] = DESC92_RATE2M,
> +-	.maps[RTL_RC_CCK_RATE5_5M] = DESC92_RATE5_5M,
> +-	.maps[RTL_RC_CCK_RATE11M] = DESC92_RATE11M,
> +-	.maps[RTL_RC_OFDM_RATE6M] = DESC92_RATE6M,
> +-	.maps[RTL_RC_OFDM_RATE9M] = DESC92_RATE9M,
> +-	.maps[RTL_RC_OFDM_RATE12M] = DESC92_RATE12M,
> +-	.maps[RTL_RC_OFDM_RATE18M] = DESC92_RATE18M,
> +-	.maps[RTL_RC_OFDM_RATE24M] = DESC92_RATE24M,
> +-	.maps[RTL_RC_OFDM_RATE36M] = DESC92_RATE36M,
> +-	.maps[RTL_RC_OFDM_RATE48M] = DESC92_RATE48M,
> +-	.maps[RTL_RC_OFDM_RATE54M] = DESC92_RATE54M,
> +-
> +-	.maps[RTL_RC_HT_RATEMCS7] = DESC92_RATEMCS7,
> +-	.maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
> ++	.maps[RTL_RC_CCK_RATE1M] = DESC_RATE1M,
> ++	.maps[RTL_RC_CCK_RATE2M] = DESC_RATE2M,
> ++	.maps[RTL_RC_CCK_RATE5_5M] = DESC_RATE5_5M,
> ++	.maps[RTL_RC_CCK_RATE11M] = DESC_RATE11M,
> ++	.maps[RTL_RC_OFDM_RATE6M] = DESC_RATE6M,
> ++	.maps[RTL_RC_OFDM_RATE9M] = DESC_RATE9M,
> ++	.maps[RTL_RC_OFDM_RATE12M] = DESC_RATE12M,
> ++	.maps[RTL_RC_OFDM_RATE18M] = DESC_RATE18M,
> ++	.maps[RTL_RC_OFDM_RATE24M] = DESC_RATE24M,
> ++	.maps[RTL_RC_OFDM_RATE36M] = DESC_RATE36M,
> ++	.maps[RTL_RC_OFDM_RATE48M] = DESC_RATE48M,
> ++	.maps[RTL_RC_OFDM_RATE54M] = DESC_RATE54M,
> ++
> ++	.maps[RTL_RC_HT_RATEMCS7] = DESC_RATEMCS7,
> ++	.maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15,
> + };
> + 
> + static struct pci_device_id rtl92de_pci_ids[] = {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> +index 7fbae49..381a4c0 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> +@@ -235,8 +235,8 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
> + 		pstats->rx_pwdb_all = pwdb_all;
> + 		pstats->rxpower = rx_pwr_all;
> + 		pstats->recvsignalpower = rx_pwr_all;
> +-		if (pdesc->rxht && pdesc->rxmcs >= DESC92_RATEMCS8 &&
> +-		    pdesc->rxmcs <= DESC92_RATEMCS15)
> ++		if (pdesc->rxht && pdesc->rxmcs >= DESC_RATEMCS8 &&
> ++		    pdesc->rxmcs <= DESC_RATEMCS15)
> + 			max_spatial_stream = 2;
> + 		else
> + 			max_spatial_stream = 1;
> +@@ -611,14 +611,14 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
> + 		}
> + 		/* 5G have no CCK rate */
> + 		if (rtlhal->current_bandtype == BAND_ON_5G)
> +-			if (ptcb_desc->hw_rate < DESC92_RATE6M)
> +-				ptcb_desc->hw_rate = DESC92_RATE6M;
> ++			if (ptcb_desc->hw_rate < DESC_RATE6M)
> ++				ptcb_desc->hw_rate = DESC_RATE6M;
> + 		SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate);
> + 		if (ptcb_desc->use_shortgi || ptcb_desc->use_shortpreamble)
> + 			SET_TX_DESC_DATA_SHORTGI(pdesc, 1);
> + 
> + 		if (rtlhal->macphymode == DUALMAC_DUALPHY &&
> +-			ptcb_desc->hw_rate == DESC92_RATEMCS7)
> ++			ptcb_desc->hw_rate == DESC_RATEMCS7)
> + 			SET_TX_DESC_DATA_SHORTGI(pdesc, 1);
> + 
> + 		if (info->flags & IEEE80211_TX_CTL_AMPDU) {
> +@@ -634,13 +634,13 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
> + 		SET_TX_DESC_RTS_STBC(pdesc, ((ptcb_desc->rts_stbc) ? 1 : 0));
> + 		/* 5G have no CCK rate */
> + 		if (rtlhal->current_bandtype == BAND_ON_5G)
> +-			if (ptcb_desc->rts_rate < DESC92_RATE6M)
> +-				ptcb_desc->rts_rate = DESC92_RATE6M;
> ++			if (ptcb_desc->rts_rate < DESC_RATE6M)
> ++				ptcb_desc->rts_rate = DESC_RATE6M;
> + 		SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate);
> + 		SET_TX_DESC_RTS_BW(pdesc, 0);
> + 		SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc);
> + 		SET_TX_DESC_RTS_SHORT(pdesc, ((ptcb_desc->rts_rate <=
> +-			DESC92_RATE54M) ?
> ++			DESC_RATE54M) ?
> + 			(ptcb_desc->rts_use_shortpreamble ? 1 : 0) :
> + 			(ptcb_desc->rts_use_shortgi ? 1 : 0)));
> + 		if (bw_40) {
> +@@ -755,9 +755,9 @@ void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw,
> + 	 * The braces are needed no matter what checkpatch says
> + 	 */
> + 	if (rtlhal->current_bandtype == BAND_ON_5G) {
> +-		SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE6M);
> ++		SET_TX_DESC_TX_RATE(pdesc, DESC_RATE6M);
> + 	} else {
> +-		SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE1M);
> ++		SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
> + 	}
> + 	SET_TX_DESC_SEQ(pdesc, 0);
> + 	SET_TX_DESC_LINIP(pdesc, 0);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> +index fb46fb9..3ea7367 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> +@@ -187,8 +187,8 @@ static void _rtl92ee_query_rxphystatus(struct ieee80211_hw *hw,
> + 		pstatus->recvsignalpower = rx_pwr_all;
> + 
> + 		/* (3)EVM of HT rate */
> +-		if (pstatus->rate >= DESC92C_RATEMCS8 &&
> +-		    pstatus->rate <= DESC92C_RATEMCS15)
> ++		if (pstatus->rate >= DESC_RATEMCS8 &&
> ++		    pstatus->rate <= DESC_RATEMCS15)
> + 			max_spatial_stream = 2;
> + 		else
> + 			max_spatial_stream = 1;
> +@@ -742,13 +742,13 @@ void rtl92ee_tx_fill_desc(struct ieee80211_hw *hw,
> + 		} else {
> + 			if (rtlpriv->ra.is_special_data) {
> + 				ptcb_desc->use_driver_rate = true;
> +-				SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE11M);
> ++				SET_TX_DESC_TX_RATE(pdesc, DESC_RATE11M);
> + 			} else {
> + 				ptcb_desc->use_driver_rate = false;
> + 			}
> + 		}
> + 
> +-		if (ptcb_desc->hw_rate > DESC92C_RATEMCS0)
> ++		if (ptcb_desc->hw_rate > DESC_RATEMCS0)
> + 			short_gi = (ptcb_desc->use_shortgi) ? 1 : 0;
> + 		else
> + 			short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0;
> +@@ -768,7 +768,7 @@ void rtl92ee_tx_fill_desc(struct ieee80211_hw *hw,
> + 		SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate);
> + 		SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc);
> + 		SET_TX_DESC_RTS_SHORT(pdesc,
> +-				((ptcb_desc->rts_rate <= DESC92C_RATE54M) ?
> ++				((ptcb_desc->rts_rate <= DESC_RATE54M) ?
> + 				 (ptcb_desc->rts_use_shortpreamble ? 1 : 0) :
> + 				 (ptcb_desc->rts_use_shortgi ? 1 : 0)));
> + 
> +@@ -879,7 +879,7 @@ void rtl92ee_tx_fill_cmddesc(struct ieee80211_hw *hw,
> + 	if (firstseg)
> + 		SET_TX_DESC_OFFSET(pdesc, txdesc_len);
> + 
> +-	SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE1M);
> ++	SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
> + 
> + 	SET_TX_DESC_SEQ(pdesc, 0);
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
> +index 6f9be1c..45fd9db 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
> +@@ -591,10 +591,10 @@ do {								\
> + } while (0)
> + 
> + #define RTL92EE_RX_HAL_IS_CCK_RATE(rxmcs)\
> +-	(rxmcs == DESC92C_RATE1M ||\
> +-	 rxmcs == DESC92C_RATE2M ||\
> +-	 rxmcs == DESC92C_RATE5_5M ||\
> +-	 rxmcs == DESC92C_RATE11M)
> ++	(rxmcs == DESC_RATE1M ||\
> ++	 rxmcs == DESC_RATE2M ||\
> ++	 rxmcs == DESC_RATE5_5M ||\
> ++	 rxmcs == DESC_RATE11M)
> + 
> + #define IS_LITTLE_ENDIAN	1
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/def.h b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
> +index 6e7a70b..ef87c09 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/def.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
> +@@ -450,10 +450,10 @@
> + 	SHIFT_AND_MASK_LE(__pdesc + 24, 0, 32)
> + 
> + #define SE_RX_HAL_IS_CCK_RATE(_pdesc)\
> +-	(GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE1M ||	\
> +-	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE2M ||	\
> +-	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE5_5M ||\
> +-	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE11M)
> ++	(GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC_RATE1M ||	\
> ++	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC_RATE2M ||	\
> ++	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC_RATE5_5M ||\
> ++	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC_RATE11M)
> + 
> + enum rf_optype {
> + 	RF_OP_BY_SW_3WIRE = 0,
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
> +index fb00386..e1fd27c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
> +@@ -383,21 +383,21 @@ static struct rtl_hal_cfg rtl92se_hal_cfg = {
> + 	.maps[RTL_IMR_ROK] = IMR_ROK,
> + 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNINT | IMR_TBDOK | IMR_TBDER),
> + 
> +-	.maps[RTL_RC_CCK_RATE1M] = DESC92_RATE1M,
> +-	.maps[RTL_RC_CCK_RATE2M] = DESC92_RATE2M,
> +-	.maps[RTL_RC_CCK_RATE5_5M] = DESC92_RATE5_5M,
> +-	.maps[RTL_RC_CCK_RATE11M] = DESC92_RATE11M,
> +-	.maps[RTL_RC_OFDM_RATE6M] = DESC92_RATE6M,
> +-	.maps[RTL_RC_OFDM_RATE9M] = DESC92_RATE9M,
> +-	.maps[RTL_RC_OFDM_RATE12M] = DESC92_RATE12M,
> +-	.maps[RTL_RC_OFDM_RATE18M] = DESC92_RATE18M,
> +-	.maps[RTL_RC_OFDM_RATE24M] = DESC92_RATE24M,
> +-	.maps[RTL_RC_OFDM_RATE36M] = DESC92_RATE36M,
> +-	.maps[RTL_RC_OFDM_RATE48M] = DESC92_RATE48M,
> +-	.maps[RTL_RC_OFDM_RATE54M] = DESC92_RATE54M,
> +-
> +-	.maps[RTL_RC_HT_RATEMCS7] = DESC92_RATEMCS7,
> +-	.maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
> ++	.maps[RTL_RC_CCK_RATE1M] = DESC_RATE1M,
> ++	.maps[RTL_RC_CCK_RATE2M] = DESC_RATE2M,
> ++	.maps[RTL_RC_CCK_RATE5_5M] = DESC_RATE5_5M,
> ++	.maps[RTL_RC_CCK_RATE11M] = DESC_RATE11M,
> ++	.maps[RTL_RC_OFDM_RATE6M] = DESC_RATE6M,
> ++	.maps[RTL_RC_OFDM_RATE9M] = DESC_RATE9M,
> ++	.maps[RTL_RC_OFDM_RATE12M] = DESC_RATE12M,
> ++	.maps[RTL_RC_OFDM_RATE18M] = DESC_RATE18M,
> ++	.maps[RTL_RC_OFDM_RATE24M] = DESC_RATE24M,
> ++	.maps[RTL_RC_OFDM_RATE36M] = DESC_RATE36M,
> ++	.maps[RTL_RC_OFDM_RATE48M] = DESC_RATE48M,
> ++	.maps[RTL_RC_OFDM_RATE54M] = DESC_RATE54M,
> ++
> ++	.maps[RTL_RC_HT_RATEMCS7] = DESC_RATEMCS7,
> ++	.maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15,
> + };
> + 
> + static struct pci_device_id rtl92se_pci_ids[] = {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> +index da053cb..95eebff 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> +@@ -191,8 +191,8 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
> + 		pstats->rxpower = rx_pwr_all;
> + 		pstats->recvsignalpower = rx_pwr_all;
> + 
> +-		if (pstats->is_ht && pstats->rate >= DESC92_RATEMCS8 &&
> +-		    pstats->rate <= DESC92_RATEMCS15)
> ++		if (pstats->is_ht && pstats->rate >= DESC_RATEMCS8 &&
> ++		    pstats->rate <= DESC_RATEMCS15)
> + 			max_spatial_stream = 2;
> + 		else
> + 			max_spatial_stream = 1;
> +@@ -393,14 +393,14 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
> + 		SET_TX_DESC_RSVD_MACID(pdesc, reserved_macid);
> + 
> + 		SET_TX_DESC_TXHT(pdesc, ((ptcb_desc->hw_rate >=
> +-				 DESC92_RATEMCS0) ? 1 : 0));
> ++				 DESC_RATEMCS0) ? 1 : 0));
> + 
> + 		if (rtlhal->version == VERSION_8192S_ACUT) {
> +-			if (ptcb_desc->hw_rate == DESC92_RATE1M ||
> +-			    ptcb_desc->hw_rate  == DESC92_RATE2M ||
> +-			    ptcb_desc->hw_rate == DESC92_RATE5_5M ||
> +-			    ptcb_desc->hw_rate == DESC92_RATE11M) {
> +-				ptcb_desc->hw_rate = DESC92_RATE12M;
> ++			if (ptcb_desc->hw_rate == DESC_RATE1M ||
> ++			    ptcb_desc->hw_rate  == DESC_RATE2M ||
> ++			    ptcb_desc->hw_rate == DESC_RATE5_5M ||
> ++			    ptcb_desc->hw_rate == DESC_RATE11M) {
> ++				ptcb_desc->hw_rate = DESC_RATE12M;
> + 			}
> + 		}
> + 
> +@@ -429,7 +429,7 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
> + 		SET_TX_DESC_RTS_BANDWIDTH(pdesc, 0);
> + 		SET_TX_DESC_RTS_SUB_CARRIER(pdesc, ptcb_desc->rts_sc);
> + 		SET_TX_DESC_RTS_SHORT(pdesc, ((ptcb_desc->rts_rate <=
> +-		       DESC92_RATE54M) ?
> ++		       DESC_RATE54M) ?
> + 		       (ptcb_desc->rts_use_shortpreamble ? 1 : 0)
> + 		       : (ptcb_desc->rts_use_shortgi ? 1 : 0)));
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/def.h b/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
> +index a730985..53dc522 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
> +@@ -374,37 +374,6 @@ enum rtl_desc_qsel {
> + };
> + 
> + enum rtl_desc8821ae_rate {
> +-	DESC_RATE1M = 0x00,
> +-	DESC_RATE2M = 0x01,
> +-	DESC_RATE5_5M = 0x02,
> +-	DESC_RATE11M = 0x03,
> +-
> +-	DESC_RATE6M = 0x04,
> +-	DESC_RATE9M = 0x05,
> +-	DESC_RATE12M = 0x06,
> +-	DESC_RATE18M = 0x07,
> +-	DESC_RATE24M = 0x08,
> +-	DESC_RATE36M = 0x09,
> +-	DESC_RATE48M = 0x0a,
> +-	DESC_RATE54M = 0x0b,
> +-
> +-	DESC_RATEMCS0 = 0x0c,
> +-	DESC_RATEMCS1 = 0x0d,
> +-	DESC_RATEMCS2 = 0x0e,
> +-	DESC_RATEMCS3 = 0x0f,
> +-	DESC_RATEMCS4 = 0x10,
> +-	DESC_RATEMCS5 = 0x11,
> +-	DESC_RATEMCS6 = 0x12,
> +-	DESC_RATEMCS7 = 0x13,
> +-	DESC_RATEMCS8 = 0x14,
> +-	DESC_RATEMCS9 = 0x15,
> +-	DESC_RATEMCS10 = 0x16,
> +-	DESC_RATEMCS11 = 0x17,
> +-	DESC_RATEMCS12 = 0x18,
> +-	DESC_RATEMCS13 = 0x19,
> +-	DESC_RATEMCS14 = 0x1a,
> +-	DESC_RATEMCS15 = 0x1b,
> +-
> + 	DESC_RATEVHT1SS_MCS0 = 0x2c,
> + 	DESC_RATEVHT1SS_MCS1 = 0x2d,
> + 	DESC_RATEVHT1SS_MCS2 = 0x2e,
> +diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
> +index a233b26..26fd960 100644
> +--- a/drivers/net/wireless/rtlwifi/wifi.h
> ++++ b/drivers/net/wireless/rtlwifi/wifi.h
> +@@ -331,10 +331,10 @@ enum hardware_type {
> + (IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal))
> + 
> + #define RX_HAL_IS_CCK_RATE(rxmcs)			\
> +-	((rxmcs) == DESC92_RATE1M ||			\
> +-	 (rxmcs) == DESC92_RATE2M ||			\
> +-	 (rxmcs) == DESC92_RATE5_5M ||			\
> +-	 (rxmcs) == DESC92_RATE11M)
> ++	((rxmcs) == DESC_RATE1M ||			\
> ++	 (rxmcs) == DESC_RATE2M ||			\
> ++	 (rxmcs) == DESC_RATE5_5M ||			\
> ++	 (rxmcs) == DESC_RATE11M)
> + 
> + enum scan_operation_backup_opt {
> + 	SCAN_OPT_BACKUP = 0,
> +@@ -579,38 +579,38 @@ enum rtl_hal_state {
> + };
> + 
> + enum rtl_desc92_rate {
> +-	DESC92_RATE1M = 0x00,
> +-	DESC92_RATE2M = 0x01,
> +-	DESC92_RATE5_5M = 0x02,
> +-	DESC92_RATE11M = 0x03,
> +-
> +-	DESC92_RATE6M = 0x04,
> +-	DESC92_RATE9M = 0x05,
> +-	DESC92_RATE12M = 0x06,
> +-	DESC92_RATE18M = 0x07,
> +-	DESC92_RATE24M = 0x08,
> +-	DESC92_RATE36M = 0x09,
> +-	DESC92_RATE48M = 0x0a,
> +-	DESC92_RATE54M = 0x0b,
> +-
> +-	DESC92_RATEMCS0 = 0x0c,
> +-	DESC92_RATEMCS1 = 0x0d,
> +-	DESC92_RATEMCS2 = 0x0e,
> +-	DESC92_RATEMCS3 = 0x0f,
> +-	DESC92_RATEMCS4 = 0x10,
> +-	DESC92_RATEMCS5 = 0x11,
> +-	DESC92_RATEMCS6 = 0x12,
> +-	DESC92_RATEMCS7 = 0x13,
> +-	DESC92_RATEMCS8 = 0x14,
> +-	DESC92_RATEMCS9 = 0x15,
> +-	DESC92_RATEMCS10 = 0x16,
> +-	DESC92_RATEMCS11 = 0x17,
> +-	DESC92_RATEMCS12 = 0x18,
> +-	DESC92_RATEMCS13 = 0x19,
> +-	DESC92_RATEMCS14 = 0x1a,
> +-	DESC92_RATEMCS15 = 0x1b,
> +-	DESC92_RATEMCS15_SG = 0x1c,
> +-	DESC92_RATEMCS32 = 0x20,
> ++	DESC_RATE1M = 0x00,
> ++	DESC_RATE2M = 0x01,
> ++	DESC_RATE5_5M = 0x02,
> ++	DESC_RATE11M = 0x03,
> ++
> ++	DESC_RATE6M = 0x04,
> ++	DESC_RATE9M = 0x05,
> ++	DESC_RATE12M = 0x06,
> ++	DESC_RATE18M = 0x07,
> ++	DESC_RATE24M = 0x08,
> ++	DESC_RATE36M = 0x09,
> ++	DESC_RATE48M = 0x0a,
> ++	DESC_RATE54M = 0x0b,
> ++
> ++	DESC_RATEMCS0 = 0x0c,
> ++	DESC_RATEMCS1 = 0x0d,
> ++	DESC_RATEMCS2 = 0x0e,
> ++	DESC_RATEMCS3 = 0x0f,
> ++	DESC_RATEMCS4 = 0x10,
> ++	DESC_RATEMCS5 = 0x11,
> ++	DESC_RATEMCS6 = 0x12,
> ++	DESC_RATEMCS7 = 0x13,
> ++	DESC_RATEMCS8 = 0x14,
> ++	DESC_RATEMCS9 = 0x15,
> ++	DESC_RATEMCS10 = 0x16,
> ++	DESC_RATEMCS11 = 0x17,
> ++	DESC_RATEMCS12 = 0x18,
> ++	DESC_RATEMCS13 = 0x19,
> ++	DESC_RATEMCS14 = 0x1a,
> ++	DESC_RATEMCS15 = 0x1b,
> ++	DESC_RATEMCS15_SG = 0x1c,
> ++	DESC_RATEMCS32 = 0x20,
> + };
> + 
> + enum rtl_var_map {
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0030-rtlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch b/package/kernel/mac80211/patches/680-0030-rtlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch
> new file mode 100644
> index 0000000..bac0aec
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0030-rtlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch
> @@ -0,0 +1,85 @@
> +From 5a0791d0f5511bac894bc753cc68705ed5dea2c4 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:37 -0600
> +Subject: [PATCH 30/51] rtlwifi: rtl8821ae: Add VHT rate descriptors
> +
> +Device RTL8821AE is the first if the rtlwifi devices to implement 802.11ac
> +capability. As a result, VHT rate descriptors are needed. In addition, the
> +driver is converted to use the descriptors in rtlwifi.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8821ae/def.h | 23 -----------------------
> + drivers/net/wireless/rtlwifi/wifi.h          | 21 +++++++++++++++++++++
> + 2 files changed, 21 insertions(+), 23 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/def.h b/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
> +index 53dc522..ee7c208 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
> +@@ -373,29 +373,6 @@ enum rtl_desc_qsel {
> + 	QSLT_CMD = 0x13,
> + };
> + 
> +-enum rtl_desc8821ae_rate {
> +-	DESC_RATEVHT1SS_MCS0 = 0x2c,
> +-	DESC_RATEVHT1SS_MCS1 = 0x2d,
> +-	DESC_RATEVHT1SS_MCS2 = 0x2e,
> +-	DESC_RATEVHT1SS_MCS3 = 0x2f,
> +-	DESC_RATEVHT1SS_MCS4 = 0x30,
> +-	DESC_RATEVHT1SS_MCS5 = 0x31,
> +-	DESC_RATEVHT1SS_MCS6 = 0x32,
> +-	DESC_RATEVHT1SS_MCS7 = 0x33,
> +-	DESC_RATEVHT1SS_MCS8 = 0x34,
> +-	DESC_RATEVHT1SS_MCS9 = 0x35,
> +-	DESC_RATEVHT2SS_MCS0 = 0x36,
> +-	DESC_RATEVHT2SS_MCS1 = 0x37,
> +-	DESC_RATEVHT2SS_MCS2 = 0x38,
> +-	DESC_RATEVHT2SS_MCS3 = 0x39,
> +-	DESC_RATEVHT2SS_MCS4 = 0x3a,
> +-	DESC_RATEVHT2SS_MCS5 = 0x3b,
> +-	DESC_RATEVHT2SS_MCS6 = 0x3c,
> +-	DESC_RATEVHT2SS_MCS7 = 0x3d,
> +-	DESC_RATEVHT2SS_MCS8 = 0x3e,
> +-	DESC_RATEVHT2SS_MCS9 = 0x3f,
> +-};
> +-
> + enum rx_packet_type {
> + 	NORMAL_RX,
> + 	TX_REPORT1,
> +diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
> +index 26fd960..7a718fd 100644
> +--- a/drivers/net/wireless/rtlwifi/wifi.h
> ++++ b/drivers/net/wireless/rtlwifi/wifi.h
> +@@ -611,6 +611,27 @@ enum rtl_desc92_rate {
> + 	DESC_RATEMCS15 = 0x1b,
> + 	DESC_RATEMCS15_SG = 0x1c,
> + 	DESC_RATEMCS32 = 0x20,
> ++
> ++	DESC_RATEVHT1SS_MCS0 = 0x2c,
> ++	DESC_RATEVHT1SS_MCS1 = 0x2d,
> ++	DESC_RATEVHT1SS_MCS2 = 0x2e,
> ++	DESC_RATEVHT1SS_MCS3 = 0x2f,
> ++	DESC_RATEVHT1SS_MCS4 = 0x30,
> ++	DESC_RATEVHT1SS_MCS5 = 0x31,
> ++	DESC_RATEVHT1SS_MCS6 = 0x32,
> ++	DESC_RATEVHT1SS_MCS7 = 0x33,
> ++	DESC_RATEVHT1SS_MCS8 = 0x34,
> ++	DESC_RATEVHT1SS_MCS9 = 0x35,
> ++	DESC_RATEVHT2SS_MCS0 = 0x36,
> ++	DESC_RATEVHT2SS_MCS1 = 0x37,
> ++	DESC_RATEVHT2SS_MCS2 = 0x38,
> ++	DESC_RATEVHT2SS_MCS3 = 0x39,
> ++	DESC_RATEVHT2SS_MCS4 = 0x3a,
> ++	DESC_RATEVHT2SS_MCS5 = 0x3b,
> ++	DESC_RATEVHT2SS_MCS6 = 0x3c,
> ++	DESC_RATEVHT2SS_MCS7 = 0x3d,
> ++	DESC_RATEVHT2SS_MCS8 = 0x3e,
> ++	DESC_RATEVHT2SS_MCS9 = 0x3f,
> + };
> + 
> + enum rtl_var_map {
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0031-rtlwifi-rtl8192cu-Rework-calls-to-rate-control-routi.patch b/package/kernel/mac80211/patches/680-0031-rtlwifi-rtl8192cu-Rework-calls-to-rate-control-routi.patch
> new file mode 100644
> index 0000000..690e8df
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0031-rtlwifi-rtl8192cu-Rework-calls-to-rate-control-routi.patch
> @@ -0,0 +1,62 @@
> +From 6a7fd777078f02ba9c14fe1af4c4c3f3a5285a41 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:38 -0600
> +Subject: [PATCH 31/51] rtlwifi: rtl8192cu: Rework calls to rate-control
> + routine
> +
> +The code uses macros to determine the parameters that are passed to the
> +rate setting routine. A simpler method is implemented.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 12 ++++++------
> + 1 file changed, 6 insertions(+), 6 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> +index fe29876..5eccaba 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> +@@ -325,6 +325,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
> + 				   && (GET_RX_DESC_FAGGR(pdesc) == 1));
> + 	stats->timestamp_low = GET_RX_DESC_TSFL(pdesc);
> + 	stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc);
> ++	stats->is_ht = (bool)GET_RX_DESC_RX_HT(pdesc);
> + 	rx_status->freq = hw->conf.chandef.chan->center_freq;
> + 	rx_status->band = hw->conf.chandef.chan->band;
> + 	if (GET_RX_DESC_CRC32(pdesc))
> +@@ -338,9 +339,8 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
> + 	rx_status->flag |= RX_FLAG_MACTIME_START;
> + 	if (stats->decrypted)
> + 		rx_status->flag |= RX_FLAG_DECRYPTED;
> +-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
> +-					(bool)GET_RX_DESC_RX_HT(pdesc),
> +-					(u8)GET_RX_DESC_RX_MCS(pdesc));
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
> ++						   stats->rate);
> + 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
> + 	if (phystatus) {
> + 		p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
> +@@ -392,6 +392,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
> + 				   && (GET_RX_DESC_FAGGR(rxdesc) == 1));
> + 	stats.timestamp_low = GET_RX_DESC_TSFL(rxdesc);
> + 	stats.rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(rxdesc);
> ++	stats.is_ht = (bool)GET_RX_DESC_RX_HT(rxdesc);
> + 	/* TODO: is center_freq changed when doing scan? */
> + 	/* TODO: Shall we add protection or just skip those two step? */
> + 	rx_status->freq = hw->conf.chandef.chan->center_freq;
> +@@ -405,9 +406,8 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
> + 	if (GET_RX_DESC_RX_HT(rxdesc))
> + 		rx_status->flag |= RX_FLAG_HT;
> + 	/* Data rate */
> +-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
> +-					(bool)GET_RX_DESC_RX_HT(rxdesc),
> +-					(u8)GET_RX_DESC_RX_MCS(rxdesc));
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats.is_ht,
> ++						   stats.rate);
> + 	/*  There is a phy status after this rx descriptor. */
> + 	if (GET_RX_DESC_PHY_STATUS(rxdesc)) {
> + 		p_drvinfo = (struct rx_fwinfo_92c *)(rxdesc + RTL_RX_DESC_SIZE);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0032-rtlwifi-rtl8192de-Rework-calls-to-rate-control-routi.patch b/package/kernel/mac80211/patches/680-0032-rtlwifi-rtl8192de-Rework-calls-to-rate-control-routi.patch
> new file mode 100644
> index 0000000..1e2eba4
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0032-rtlwifi-rtl8192de-Rework-calls-to-rate-control-routi.patch
> @@ -0,0 +1,42 @@
> +From a160ba06c1bde5e0609f7ac475a9650224337933 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:39 -0600
> +Subject: [PATCH 32/51] rtlwifi: rtl8192de: Rework calls to rate-control
> + routine
> +
> +The code uses macros to determine the parameters that are passed to the
> +rate setting routine. A simpler method is implemented.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 6 +++---
> + 1 file changed, 3 insertions(+), 3 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> +index 381a4c0..547c6d0 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> +@@ -499,6 +499,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,	struct rtl_stats *stats,
> + 					 && (GET_RX_DESC_FAGGR(pdesc) == 1));
> + 	stats->timestamp_low = GET_RX_DESC_TSFL(pdesc);
> + 	stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc);
> ++	stats->is_ht = (bool)GET_RX_DESC_RXHT(pdesc);
> + 	rx_status->freq = hw->conf.chandef.chan->center_freq;
> + 	rx_status->band = hw->conf.chandef.chan->band;
> + 	if (GET_RX_DESC_CRC32(pdesc))
> +@@ -512,9 +513,8 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,	struct rtl_stats *stats,
> + 	rx_status->flag |= RX_FLAG_MACTIME_START;
> + 	if (stats->decrypted)
> + 		rx_status->flag |= RX_FLAG_DECRYPTED;
> +-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
> +-					(bool)GET_RX_DESC_RXHT(pdesc),
> +-					(u8)GET_RX_DESC_RXMCS(pdesc));
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
> ++						   stats->rate);
> + 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
> + 	if (phystatus) {
> + 		p_drvinfo = (struct rx_fwinfo_92d *)(skb->data +
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0033-rtlwifi-rtl8821ae-Switch-to-use-common-rate-control-.patch b/package/kernel/mac80211/patches/680-0033-rtlwifi-rtl8821ae-Switch-to-use-common-rate-control-.patch
> new file mode 100644
> index 0000000..20040d7
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0033-rtlwifi-rtl8821ae-Switch-to-use-common-rate-control-.patch
> @@ -0,0 +1,498 @@
> +From fd3cb22ad87fd53eb47dc64fd0cafd665d4124a1 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Thu, 18 Dec 2014 03:05:40 -0600
> +Subject: [PATCH 33/51] rtlwifi: rtl8821ae: Switch to use common rate control
> + routine
> +
> +With this change, all of the drivers now use the common routine. As this
> +driver has VHT capability, an additional parameter is needed, thus all the
> +drivers had to be modified.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/base.c          |  76 ++++++++-
> + drivers/net/wireless/rtlwifi/base.h          |   4 +-
> + drivers/net/wireless/rtlwifi/rtl8188ee/trx.c |   2 +-
> + drivers/net/wireless/rtlwifi/rtl8192ce/trx.c |   2 +-
> + drivers/net/wireless/rtlwifi/rtl8192cu/trx.c |   4 +-
> + drivers/net/wireless/rtlwifi/rtl8192de/trx.c |   2 +-
> + drivers/net/wireless/rtlwifi/rtl8192ee/trx.c |   2 +-
> + drivers/net/wireless/rtlwifi/rtl8192se/trx.c |   2 +-
> + drivers/net/wireless/rtlwifi/rtl8723ae/trx.c |   2 +-
> + drivers/net/wireless/rtlwifi/rtl8723be/trx.c |   2 +-
> + drivers/net/wireless/rtlwifi/rtl8821ae/trx.c | 232 +--------------------------
> + 11 files changed, 88 insertions(+), 242 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
> +index 23fc51e..1d46774 100644
> +--- a/drivers/net/wireless/rtlwifi/base.c
> ++++ b/drivers/net/wireless/rtlwifi/base.c
> +@@ -881,12 +881,84 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
> +  * N rate:
> +  * (rx_status->flag & RX_FLAG_HT) = 1,
> +  * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
> ++ *
> ++ * VHT rates:
> ++ * DESC_RATEVHT1SS_MCS0-->DESC_RATEVHT1SS_MCS9 ==> idx is 0-->9
> ++ * DESC_RATEVHT2SS_MCS0-->DESC_RATEVHT2SS_MCS9 ==> idx is 0-->9
> +  */
> +-int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
> +-			 bool isht, u8 desc_rate)
> ++int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht, bool isvht,
> ++			 u8 desc_rate)
> + {
> + 	int rate_idx;
> + 
> ++	if (isvht) {
> ++		switch (desc_rate) {
> ++		case DESC_RATEVHT1SS_MCS0:
> ++			rate_idx = 0;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS1:
> ++			rate_idx = 1;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS2:
> ++			rate_idx = 2;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS3:
> ++			rate_idx = 3;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS4:
> ++			rate_idx = 4;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS5:
> ++			rate_idx = 5;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS6:
> ++			rate_idx = 6;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS7:
> ++			rate_idx = 7;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS8:
> ++			rate_idx = 8;
> ++			break;
> ++		case DESC_RATEVHT1SS_MCS9:
> ++			rate_idx = 9;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS0:
> ++			rate_idx = 0;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS1:
> ++			rate_idx = 1;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS2:
> ++			rate_idx = 2;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS3:
> ++			rate_idx = 3;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS4:
> ++			rate_idx = 4;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS5:
> ++			rate_idx = 5;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS6:
> ++			rate_idx = 6;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS7:
> ++			rate_idx = 7;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS8:
> ++			rate_idx = 8;
> ++			break;
> ++		case DESC_RATEVHT2SS_MCS9:
> ++			rate_idx = 9;
> ++			break;
> ++		default:
> ++			rate_idx = 0;
> ++			break;
> ++		}
> ++		return rate_idx;
> ++	}
> + 	if (false == isht) {
> + 		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
> + 			switch (desc_rate) {
> +diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h
> +index 936c2bb..c6cb49c 100644
> +--- a/drivers/net/wireless/rtlwifi/base.h
> ++++ b/drivers/net/wireless/rtlwifi/base.h
> +@@ -123,8 +123,8 @@ void rtl_watch_dog_timer_callback(unsigned long data);
> + void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
> + 
> + bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
> +-int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
> +-			 bool isht, u8 desc_rate);
> ++int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht,
> ++			 bool isvht, u8 desc_rate);
> + bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
> + u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
> +index d430884..791efbe 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
> +@@ -473,7 +473,7 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * Notice: this is diff with windows define
> + 	 */
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> +-						   status->rate);
> ++						   false, status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> + 	if (phystatus == true) {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +index 685faea..84ddd4d 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
> +@@ -401,7 +401,7 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * Notice: this is diff with windows define
> + 	 */
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
> +-						   stats->rate);
> ++						   false, stats->rate);
> + 
> + 	rx_status->mactime = stats->timestamp_low;
> + 	if (phystatus) {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> +index 5eccaba..cbead00 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
> +@@ -340,7 +340,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
> + 	if (stats->decrypted)
> + 		rx_status->flag |= RX_FLAG_DECRYPTED;
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
> +-						   stats->rate);
> ++						   false, stats->rate);
> + 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
> + 	if (phystatus) {
> + 		p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
> +@@ -407,7 +407,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
> + 		rx_status->flag |= RX_FLAG_HT;
> + 	/* Data rate */
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats.is_ht,
> +-						   stats.rate);
> ++						   false, stats.rate);
> + 	/*  There is a phy status after this rx descriptor. */
> + 	if (GET_RX_DESC_PHY_STATUS(rxdesc)) {
> + 		p_drvinfo = (struct rx_fwinfo_92c *)(rxdesc + RTL_RX_DESC_SIZE);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> +index 547c6d0..1feaa62 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
> +@@ -514,7 +514,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,	struct rtl_stats *stats,
> + 	if (stats->decrypted)
> + 		rx_status->flag |= RX_FLAG_DECRYPTED;
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
> +-						   stats->rate);
> ++						   false, stats->rate);
> + 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
> + 	if (phystatus) {
> + 		p_drvinfo = (struct rx_fwinfo_92d *)(skb->data +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> +index 3ea7367..51806ac 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> +@@ -419,7 +419,7 @@ bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * Notice: this is diff with windows define
> + 	 */
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> +-						   status->rate);
> ++						   false, status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> + 	if (phystatus) {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> +index 95eebff..125b29b 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> +@@ -319,7 +319,7 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
> + 	}
> + 
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
> +-						   stats->rate);
> ++						   false, stats->rate);
> + 
> + 	rx_status->mactime = stats->timestamp_low;
> + 	if (phystatus) {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
> +index 662a094..2f7c144 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
> +@@ -346,7 +346,7 @@ bool rtl8723e_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * Notice: this is diff with windows define
> + 	 */
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> +-						   status->rate);
> ++						   false, status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> + 	if (phystatus == true) {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
> +index cb23bed..338ec9a 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
> +@@ -401,7 +401,7 @@ bool rtl8723be_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * are use (RX_FLAG_HT)
> + 	 */
> + 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> +-						      status->rate);
> ++						   false, status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> + 	if (phystatus) {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
> +index 383b86b..72af4b9 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
> +@@ -48,232 +48,6 @@ static u8 _rtl8821ae_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
> + 	return skb->priority;
> + }
> + 
> +-/* mac80211's rate_idx is like this:
> +- *
> +- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
> +- *
> +- * B/G rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC_RATE1M-->DESC_RATE54M ==> idx is 0-->11,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
> +- *
> +- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
> +- * A rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 0,
> +- * DESC_RATE6M-->DESC_RATE54M ==> idx is 0-->7,
> +- *
> +- * N rate:
> +- * (rx_status->flag & RX_FLAG_HT) = 1,
> +- * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
> +- */
> +-static int _rtl8821ae_rate_mapping(struct ieee80211_hw *hw,
> +-				   bool isht, bool isvht, u8 desc_rate)
> +-{
> +-	int rate_idx;
> +-
> +-	if (!isht) {
> +-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
> +-			switch (desc_rate) {
> +-			case DESC_RATE1M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC_RATE2M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC_RATE5_5M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC_RATE11M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC_RATE6M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC_RATE9M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC_RATE12M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC_RATE18M:
> +-				rate_idx = 7;
> +-				break;
> +-			case DESC_RATE24M:
> +-				rate_idx = 8;
> +-				break;
> +-			case DESC_RATE36M:
> +-				rate_idx = 9;
> +-				break;
> +-			case DESC_RATE48M:
> +-				rate_idx = 10;
> +-				break;
> +-			case DESC_RATE54M:
> +-				rate_idx = 11;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		} else {
> +-			switch (desc_rate) {
> +-			case DESC_RATE6M:
> +-				rate_idx = 0;
> +-				break;
> +-			case DESC_RATE9M:
> +-				rate_idx = 1;
> +-				break;
> +-			case DESC_RATE12M:
> +-				rate_idx = 2;
> +-				break;
> +-			case DESC_RATE18M:
> +-				rate_idx = 3;
> +-				break;
> +-			case DESC_RATE24M:
> +-				rate_idx = 4;
> +-				break;
> +-			case DESC_RATE36M:
> +-				rate_idx = 5;
> +-				break;
> +-			case DESC_RATE48M:
> +-				rate_idx = 6;
> +-				break;
> +-			case DESC_RATE54M:
> +-				rate_idx = 7;
> +-				break;
> +-			default:
> +-				rate_idx = 0;
> +-				break;
> +-			}
> +-		}
> +-	} else {
> +-		switch (desc_rate) {
> +-		case DESC_RATEMCS0:
> +-			rate_idx = 0;
> +-			break;
> +-		case DESC_RATEMCS1:
> +-			rate_idx = 1;
> +-			break;
> +-		case DESC_RATEMCS2:
> +-			rate_idx = 2;
> +-			break;
> +-		case DESC_RATEMCS3:
> +-			rate_idx = 3;
> +-			break;
> +-		case DESC_RATEMCS4:
> +-			rate_idx = 4;
> +-			break;
> +-		case DESC_RATEMCS5:
> +-			rate_idx = 5;
> +-			break;
> +-		case DESC_RATEMCS6:
> +-			rate_idx = 6;
> +-			break;
> +-		case DESC_RATEMCS7:
> +-			rate_idx = 7;
> +-			break;
> +-		case DESC_RATEMCS8:
> +-			rate_idx = 8;
> +-			break;
> +-		case DESC_RATEMCS9:
> +-			rate_idx = 9;
> +-			break;
> +-		case DESC_RATEMCS10:
> +-			rate_idx = 10;
> +-			break;
> +-		case DESC_RATEMCS11:
> +-			rate_idx = 11;
> +-			break;
> +-		case DESC_RATEMCS12:
> +-			rate_idx = 12;
> +-			break;
> +-		case DESC_RATEMCS13:
> +-			rate_idx = 13;
> +-			break;
> +-		case DESC_RATEMCS14:
> +-			rate_idx = 14;
> +-			break;
> +-		case DESC_RATEMCS15:
> +-			rate_idx = 15;
> +-			break;
> +-		default:
> +-			rate_idx = 0;
> +-			break;
> +-		}
> +-	}
> +-
> +-	if (isvht) {
> +-		switch (desc_rate) {
> +-		case DESC_RATEVHT1SS_MCS0:
> +-			rate_idx = 0;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS1:
> +-			rate_idx = 1;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS2:
> +-			rate_idx = 2;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS3:
> +-			rate_idx = 3;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS4:
> +-			rate_idx = 4;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS5:
> +-			rate_idx = 5;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS6:
> +-			rate_idx = 6;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS7:
> +-			rate_idx = 7;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS8:
> +-			rate_idx = 8;
> +-			break;
> +-		case DESC_RATEVHT1SS_MCS9:
> +-			rate_idx = 9;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS0:
> +-			rate_idx = 0;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS1:
> +-			rate_idx = 1;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS2:
> +-			rate_idx = 2;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS3:
> +-			rate_idx = 3;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS4:
> +-			rate_idx = 4;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS5:
> +-			rate_idx = 5;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS6:
> +-			rate_idx = 6;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS7:
> +-			rate_idx = 7;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS8:
> +-			rate_idx = 8;
> +-			break;
> +-		case DESC_RATEVHT2SS_MCS9:
> +-			rate_idx = 9;
> +-			break;
> +-		default:
> +-			rate_idx = 0;
> +-			break;
> +-		}
> +-	}
> +-	return rate_idx;
> +-}
> +-
> + static u16 odm_cfo(char value)
> + {
> + 	int ret_val;
> +@@ -766,9 +540,9 @@ bool rtl8821ae_rx_query_desc(struct ieee80211_hw *hw,
> + 	 * supported rates or MCS index if HT rates
> + 	 * are use (RX_FLAG_HT)
> + 	 */
> +-	rx_status->rate_idx =
> +-	  _rtl8821ae_rate_mapping(hw, status->is_ht,
> +-				  status->is_vht, status->rate);
> ++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
> ++						   status->is_vht,
> ++						   status->rate);
> + 
> + 	rx_status->mactime = status->timestamp_low;
> + 	if (phystatus) {
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0034-rtlwifi-rtl8192ee-trx.c-Remove-unused-function.patch b/package/kernel/mac80211/patches/680-0034-rtlwifi-rtl8192ee-trx.c-Remove-unused-function.patch
> new file mode 100644
> index 0000000..3050a93
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0034-rtlwifi-rtl8192ee-trx.c-Remove-unused-function.patch
> @@ -0,0 +1,64 @@
> +From 9898b77536b8569be2704964d3c519ef070e4a27 Mon Sep 17 00:00:00 2001
> +From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> +Date: Sat, 20 Dec 2014 13:48:14 +0100
> +Subject: [PATCH 34/51] rtlwifi: rtl8192ee: trx.c: Remove unused function
> +
> +Remove the function rtl92ee_get_available_desc() that is not used anywhere.
> +
> +This was partially found by using a static code analysis program called cppcheck.
> +
> +Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> +Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 21 ---------------------
> + drivers/net/wireless/rtlwifi/rtl8192ee/trx.h |  1 -
> + 2 files changed, 22 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> +index 51806ac..55d1da5 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
> +@@ -551,27 +551,6 @@ static u16 get_desc_addr_fr_q_idx(u16 queue_index)
> + 	return desc_address;
> + }
> + 
> +-void rtl92ee_get_available_desc(struct ieee80211_hw *hw, u8 q_idx)
> +-{
> +-	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	u16 point_diff = 0;
> +-	u16 current_tx_read_point = 0, current_tx_write_point = 0;
> +-	u32 tmp_4byte;
> +-
> +-	tmp_4byte = rtl_read_dword(rtlpriv,
> +-				   get_desc_addr_fr_q_idx(q_idx));
> +-	current_tx_read_point = (u16)((tmp_4byte >> 16) & 0x0fff);
> +-	current_tx_write_point = (u16)((tmp_4byte) & 0x0fff);
> +-
> +-	point_diff = ((current_tx_read_point > current_tx_write_point) ?
> +-		      (current_tx_read_point - current_tx_write_point) :
> +-		      (TX_DESC_NUM_92E - current_tx_write_point +
> +-		       current_tx_read_point));
> +-
> +-	rtlpci->tx_ring[q_idx].avl_desc = point_diff;
> +-}
> +-
> + void rtl92ee_pre_fill_tx_bd_desc(struct ieee80211_hw *hw,
> + 				 u8 *tx_bd_desc, u8 *desc, u8 queue_index,
> + 				 struct sk_buff *skb, dma_addr_t addr)
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
> +index 45fd9db..48504c2 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
> +@@ -829,7 +829,6 @@ void rtl92ee_rx_check_dma_ok(struct ieee80211_hw *hw, u8 *header_desc,
> + 			     u8 queue_index);
> + u16	rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw,
> + 					  u8 queue_index);
> +-void rtl92ee_get_available_desc(struct ieee80211_hw *hw, u8 queue_index);
> + void rtl92ee_pre_fill_tx_bd_desc(struct ieee80211_hw *hw,
> + 				 u8 *tx_bd_desc, u8 *desc, u8 queue_index,
> + 				 struct sk_buff *skb, dma_addr_t addr);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0035-rtlwifi-rtl8723be-phy.c-Remove-unused-function.patch b/package/kernel/mac80211/patches/680-0035-rtlwifi-rtl8723be-phy.c-Remove-unused-function.patch
> new file mode 100644
> index 0000000..4d5b1a4
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0035-rtlwifi-rtl8723be-phy.c-Remove-unused-function.patch
> @@ -0,0 +1,69 @@
> +From b30b2e0f3dbcde630b911bdc8fda8ae8300fff6a Mon Sep 17 00:00:00 2001
> +From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> +Date: Sat, 20 Dec 2014 23:59:18 +0100
> +Subject: [PATCH 35/51] rtlwifi: rtl8723be: phy.c: Remove unused function
> +
> +Remove the function rtl8723be_phy_get_txpower_level() that is not used anywhere.
> +
> +This was partially found by using a static code analysis program called cppcheck.
> +
> +Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> +Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8723be/phy.c | 25 -------------------------
> + drivers/net/wireless/rtlwifi/rtl8723be/phy.h |  2 --
> + 2 files changed, 27 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/phy.c b/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
> +index 20dcc25..b7b73cb 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
> +@@ -874,31 +874,6 @@ void rtl8723be_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw)
> + 		  ROFDM0_RXDETECTOR3, rtlphy->framesync);
> + }
> + 
> +-void rtl8723be_phy_get_txpower_level(struct ieee80211_hw *hw, long *powerlevel)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	struct rtl_phy *rtlphy = &rtlpriv->phy;
> +-	u8 txpwr_level;
> +-	long txpwr_dbm;
> +-
> +-	txpwr_level = rtlphy->cur_cck_txpwridx;
> +-	txpwr_dbm = rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_B,
> +-						 txpwr_level);
> +-	txpwr_level = rtlphy->cur_ofdm24g_txpwridx;
> +-	if (rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_G, txpwr_level) >
> +-	    txpwr_dbm)
> +-		txpwr_dbm =
> +-		    rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_G,
> +-						 txpwr_level);
> +-	txpwr_level = rtlphy->cur_ofdm24g_txpwridx;
> +-	if (rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_N_24G,
> +-					 txpwr_level) > txpwr_dbm)
> +-		txpwr_dbm =
> +-		    rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_N_24G,
> +-						 txpwr_level);
> +-	*powerlevel = txpwr_dbm;
> +-}
> +-
> + static u8 _rtl8723be_phy_get_ratesection_intxpower_byrate(enum radio_path path,
> + 							  u8 rate)
> + {
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/phy.h b/drivers/net/wireless/rtlwifi/rtl8723be/phy.h
> +index 6339738..9021d47 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/phy.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/phy.h
> +@@ -114,8 +114,6 @@ bool rtl8723be_phy_mac_config(struct ieee80211_hw *hw);
> + bool rtl8723be_phy_bb_config(struct ieee80211_hw *hw);
> + bool rtl8723be_phy_rf_config(struct ieee80211_hw *hw);
> + void rtl8723be_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw);
> +-void rtl8723be_phy_get_txpower_level(struct ieee80211_hw *hw,
> +-				     long *powerlevel);
> + void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw,
> + 				     u8 channel);
> + void rtl8723be_phy_scan_operation_backup(struct ieee80211_hw *hw,
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0036-rtlwifi-Fix-error-when-accessing-unmapped-memory-in-.patch b/package/kernel/mac80211/patches/680-0036-rtlwifi-Fix-error-when-accessing-unmapped-memory-in-.patch
> new file mode 100644
> index 0000000..59bdbfe
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0036-rtlwifi-Fix-error-when-accessing-unmapped-memory-in-.patch
> @@ -0,0 +1,126 @@
> +From e9538cf4f90713eca71b1d6a74b4eae1d445c664 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 30 Dec 2014 21:33:07 -0600
> +Subject: [PATCH 36/51] rtlwifi: Fix error when accessing unmapped memory in
> + skb
> +
> +These drivers use 9100-byte receive buffers, thus allocating an skb requires
> +an O(3) memory allocation. Under heavy memory loads and fragmentation, such
> +a request can fail. Previous versions of the driver have dropped the packet
> +and reused the old buffer; however, the new version introduced a bug in that
> +it released the old buffer before trying to allocate a new one. The previous
> +method is implemented here. The skb is unmapped before any attempt is made to
> +allocate another.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Cc: Stable <stable@vger.kernel.org>  [v3.18]
> +Reported-by: Eric Biggers <ebiggers3@gmail.com>
> +Cc: Eric Biggers <ebiggers3@gmail.com>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/pci.c | 32 ++++++++++++++++++++++++--------
> + 1 file changed, 24 insertions(+), 8 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
> +index 846a2e6..c70efb9 100644
> +--- a/drivers/net/wireless/rtlwifi/pci.c
> ++++ b/drivers/net/wireless/rtlwifi/pci.c
> +@@ -666,7 +666,8 @@ tx_status_ok:
> + }
> + 
> + static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw,
> +-				    u8 *entry, int rxring_idx, int desc_idx)
> ++				    struct sk_buff *new_skb, u8 *entry,
> ++				    int rxring_idx, int desc_idx)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> + 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
> +@@ -674,11 +675,15 @@ static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw,
> + 	u8 tmp_one = 1;
> + 	struct sk_buff *skb;
> + 
> ++	if (likely(new_skb)) {
> ++		skb = new_skb;
> ++		goto remap;
> ++	}
> + 	skb = dev_alloc_skb(rtlpci->rxbuffersize);
> + 	if (!skb)
> + 		return 0;
> +-	rtlpci->rx_ring[rxring_idx].rx_buf[desc_idx] = skb;
> + 
> ++remap:
> + 	/* just set skb->cb to mapping addr for pci_unmap_single use */
> + 	*((dma_addr_t *)skb->cb) =
> + 		pci_map_single(rtlpci->pdev, skb_tail_pointer(skb),
> +@@ -686,6 +691,7 @@ static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw,
> + 	bufferaddress = *((dma_addr_t *)skb->cb);
> + 	if (pci_dma_mapping_error(rtlpci->pdev, bufferaddress))
> + 		return 0;
> ++	rtlpci->rx_ring[rxring_idx].rx_buf[desc_idx] = skb;
> + 	if (rtlpriv->use_new_trx_flow) {
> + 		rtlpriv->cfg->ops->set_desc(hw, (u8 *)entry, false,
> + 					    HW_DESC_RX_PREPARE,
> +@@ -781,6 +787,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
> + 		/*rx pkt */
> + 		struct sk_buff *skb = rtlpci->rx_ring[rxring_idx].rx_buf[
> + 				      rtlpci->rx_ring[rxring_idx].idx];
> ++		struct sk_buff *new_skb;
> + 
> + 		if (rtlpriv->use_new_trx_flow) {
> + 			rx_remained_cnt =
> +@@ -807,6 +814,13 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
> + 		pci_unmap_single(rtlpci->pdev, *((dma_addr_t *)skb->cb),
> + 				 rtlpci->rxbuffersize, PCI_DMA_FROMDEVICE);
> + 
> ++		/* get a new skb - if fail, old one will be reused */
> ++		new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
> ++		if (unlikely(!new_skb)) {
> ++			pr_err("Allocation of new skb failed in %s\n",
> ++			       __func__);
> ++			goto no_new;
> ++		}
> + 		if (rtlpriv->use_new_trx_flow) {
> + 			buffer_desc =
> + 			  &rtlpci->rx_ring[rxring_idx].buffer_desc
> +@@ -911,14 +925,16 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
> + 			schedule_work(&rtlpriv->works.lps_change_work);
> + 		}
> + end:
> ++		skb = new_skb;
> ++no_new:
> + 		if (rtlpriv->use_new_trx_flow) {
> +-			_rtl_pci_init_one_rxdesc(hw, (u8 *)buffer_desc,
> ++			_rtl_pci_init_one_rxdesc(hw, skb, (u8 *)buffer_desc,
> + 						 rxring_idx,
> +-					       rtlpci->rx_ring[rxring_idx].idx);
> ++						 rtlpci->rx_ring[rxring_idx].idx);
> + 		} else {
> +-			_rtl_pci_init_one_rxdesc(hw, (u8 *)pdesc, rxring_idx,
> ++			_rtl_pci_init_one_rxdesc(hw, skb, (u8 *)pdesc,
> ++						 rxring_idx,
> + 						 rtlpci->rx_ring[rxring_idx].idx);
> +-
> + 			if (rtlpci->rx_ring[rxring_idx].idx ==
> + 			    rtlpci->rxringcount - 1)
> + 				rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc,
> +@@ -1307,7 +1323,7 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx)
> + 		rtlpci->rx_ring[rxring_idx].idx = 0;
> + 		for (i = 0; i < rtlpci->rxringcount; i++) {
> + 			entry = &rtlpci->rx_ring[rxring_idx].buffer_desc[i];
> +-			if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry,
> ++			if (!_rtl_pci_init_one_rxdesc(hw, NULL, (u8 *)entry,
> + 						      rxring_idx, i))
> + 				return -ENOMEM;
> + 		}
> +@@ -1332,7 +1348,7 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx)
> + 
> + 		for (i = 0; i < rtlpci->rxringcount; i++) {
> + 			entry = &rtlpci->rx_ring[rxring_idx].desc[i];
> +-			if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry,
> ++			if (!_rtl_pci_init_one_rxdesc(hw, NULL, (u8 *)entry,
> + 						      rxring_idx, i))
> + 				return -ENOMEM;
> + 		}
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0037-rtlwifi-Unify-variable-naming-for-all-drivers.patch b/package/kernel/mac80211/patches/680-0037-rtlwifi-Unify-variable-naming-for-all-drivers.patch
> new file mode 100644
> index 0000000..107aa0a
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0037-rtlwifi-Unify-variable-naming-for-all-drivers.patch
> @@ -0,0 +1,300 @@
> +From 1f6969fb230b79debcdf8ec3614162b553664396 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:02 -0600
> +Subject: [PATCH 37/51] rtlwifi: Unify variable naming for all drivers
> +
> +Some drivers refer to a particular quantity in the driver's private
> +are by one name, while others use a different name. These differences
> +are removed.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c |  2 +-
> + drivers/net/wireless/rtlwifi/rtl8192ee/dm.c       | 26 ++++++++++----------
> + drivers/net/wireless/rtlwifi/rtl8723be/dm.c       | 26 ++++++++++----------
> + drivers/net/wireless/rtlwifi/rtl8821ae/dm.c       | 30 +++++++++++------------
> + drivers/net/wireless/rtlwifi/wifi.h               |  2 --
> + 5 files changed, 42 insertions(+), 44 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> +index f6cb5ae..c3aad76 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> +@@ -221,7 +221,7 @@ static void rtl92c_dm_diginit(struct ieee80211_hw *hw)
> + 	dm_digtable->forbidden_igi = DM_DIG_MIN;
> + 	dm_digtable->large_fa_hit = 0;
> + 	dm_digtable->recover_cnt = 0;
> +-	dm_digtable->dig_dynamic_min  = 0x25;
> ++	dm_digtable->dig_min_0  = 0x25;
> + }
> + 
> + static u8 rtl92c_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> +index 77deedf..2fa4c45 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> +@@ -172,8 +172,8 @@ static void rtl92ee_dm_diginit(struct ieee80211_hw *hw)
> + 	dm_dig->forbidden_igi = DM_DIG_MIN;
> + 	dm_dig->large_fa_hit = 0;
> + 	dm_dig->recover_cnt = 0;
> +-	dm_dig->dig_dynamic_min = DM_DIG_MIN;
> +-	dm_dig->dig_dynamic_min_1 = DM_DIG_MIN;
> ++	dm_dig->dig_min_0 = DM_DIG_MIN;
> ++	dm_dig->dig_min_1 = DM_DIG_MIN;
> + 	dm_dig->media_connect_0 = false;
> + 	dm_dig->media_connect_1 = false;
> + 	rtlpriv->dm.dm_initialgain_enable = true;
> +@@ -298,7 +298,7 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> + 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
> + 	struct dig_t *dm_dig = &rtlpriv->dm_digtable;
> +-	u8 dig_dynamic_min , dig_maxofmin;
> ++	u8 dig_min_0, dig_maxofmin;
> + 	bool bfirstconnect , bfirstdisconnect;
> + 	u8 dm_dig_max, dm_dig_min;
> + 	u8 current_igi = dm_dig->cur_igvalue;
> +@@ -308,7 +308,7 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
> + 	if (mac->act_scanning)
> + 		return;
> + 
> +-	dig_dynamic_min = dm_dig->dig_dynamic_min;
> ++	dig_min_0 = dm_dig->dig_min_0;
> + 	bfirstconnect = (mac->link_state >= MAC80211_LINKED) &&
> + 			!dm_dig->media_connect_0;
> + 	bfirstdisconnect = (mac->link_state < MAC80211_LINKED) &&
> +@@ -329,19 +329,19 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
> + 		if (rtlpriv->dm.one_entry_only) {
> + 			offset = 0;
> + 			if (dm_dig->rssi_val_min - offset < dm_dig_min)
> +-				dig_dynamic_min = dm_dig_min;
> ++				dig_min_0 = dm_dig_min;
> + 			else if (dm_dig->rssi_val_min - offset >
> + 				 dig_maxofmin)
> +-				dig_dynamic_min = dig_maxofmin;
> ++				dig_min_0 = dig_maxofmin;
> + 			else
> +-				dig_dynamic_min = dm_dig->rssi_val_min - offset;
> ++				dig_min_0 = dm_dig->rssi_val_min - offset;
> + 		} else {
> +-			dig_dynamic_min = dm_dig_min;
> ++			dig_min_0 = dm_dig_min;
> + 		}
> + 
> + 	} else {
> + 		dm_dig->rx_gain_max = dm_dig_max;
> +-		dig_dynamic_min = dm_dig_min;
> ++		dig_min_0 = dm_dig_min;
> + 		RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "no link\n");
> + 	}
> + 
> +@@ -368,10 +368,10 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
> + 		} else {
> + 			if (dm_dig->large_fa_hit < 3) {
> + 				if ((dm_dig->forbidden_igi - 1) <
> +-				    dig_dynamic_min) {
> +-					dm_dig->forbidden_igi = dig_dynamic_min;
> ++				    dig_min_0) {
> ++					dm_dig->forbidden_igi = dig_min_0;
> + 					dm_dig->rx_gain_min =
> +-								dig_dynamic_min;
> ++								dig_min_0;
> + 				} else {
> + 					dm_dig->forbidden_igi--;
> + 					dm_dig->rx_gain_min =
> +@@ -430,7 +430,7 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
> + 	rtl92ee_dm_write_dig(hw , current_igi);
> + 	dm_dig->media_connect_0 = ((mac->link_state >= MAC80211_LINKED) ?
> + 				   true : false);
> +-	dm_dig->dig_dynamic_min = dig_dynamic_min;
> ++	dm_dig->dig_min_0 = dig_min_0;
> + }
> + 
> + void rtl92ee_dm_write_cck_cca_thres(struct ieee80211_hw *hw, u8 cur_thres)
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> +index dd7eb43..b92c521e 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> +@@ -232,8 +232,8 @@ static void rtl8723be_dm_diginit(struct ieee80211_hw *hw)
> + 	dm_digtable->forbidden_igi = DM_DIG_MIN;
> + 	dm_digtable->large_fa_hit = 0;
> + 	dm_digtable->recover_cnt = 0;
> +-	dm_digtable->dig_dynamic_min = DM_DIG_MIN;
> +-	dm_digtable->dig_dynamic_min_1 = DM_DIG_MIN;
> ++	dm_digtable->dig_min_0 = DM_DIG_MIN;
> ++	dm_digtable->dig_min_1 = DM_DIG_MIN;
> + 	dm_digtable->media_connect_0 = false;
> + 	dm_digtable->media_connect_1 = false;
> + 	rtlpriv->dm.dm_initialgain_enable = true;
> +@@ -424,7 +424,7 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> + 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
> + 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
> +-	u8 dig_dynamic_min, dig_maxofmin;
> ++	u8 dig_min_0, dig_maxofmin;
> + 	bool bfirstconnect, bfirstdisconnect;
> + 	u8 dm_dig_max, dm_dig_min;
> + 	u8 current_igi = dm_digtable->cur_igvalue;
> +@@ -434,7 +434,7 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
> + 	if (mac->act_scanning)
> + 		return;
> + 
> +-	dig_dynamic_min = dm_digtable->dig_dynamic_min;
> ++	dig_min_0 = dm_digtable->dig_min_0;
> + 	bfirstconnect = (mac->link_state >= MAC80211_LINKED) &&
> + 			!dm_digtable->media_connect_0;
> + 	bfirstdisconnect = (mac->link_state < MAC80211_LINKED) &&
> +@@ -456,20 +456,20 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
> + 		if (rtlpriv->dm.one_entry_only) {
> + 			offset = 12;
> + 			if (dm_digtable->rssi_val_min - offset < dm_dig_min)
> +-				dig_dynamic_min = dm_dig_min;
> ++				dig_min_0 = dm_dig_min;
> + 			else if (dm_digtable->rssi_val_min - offset >
> + 							dig_maxofmin)
> +-				dig_dynamic_min = dig_maxofmin;
> ++				dig_min_0 = dig_maxofmin;
> + 			else
> +-				dig_dynamic_min =
> ++				dig_min_0 =
> + 					dm_digtable->rssi_val_min - offset;
> + 		} else {
> +-			dig_dynamic_min = dm_dig_min;
> ++			dig_min_0 = dm_dig_min;
> + 		}
> + 
> + 	} else {
> + 		dm_digtable->rx_gain_max = dm_dig_max;
> +-		dig_dynamic_min = dm_dig_min;
> ++		dig_min_0 = dm_dig_min;
> + 		RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "no link\n");
> + 	}
> + 
> +@@ -497,11 +497,11 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
> + 		} else {
> + 			if (dm_digtable->large_fa_hit < 3) {
> + 				if ((dm_digtable->forbidden_igi - 1) <
> +-				     dig_dynamic_min) {
> ++				     dig_min_0) {
> + 					dm_digtable->forbidden_igi =
> +-							dig_dynamic_min;
> ++							dig_min_0;
> + 					dm_digtable->rx_gain_min =
> +-							dig_dynamic_min;
> ++							dig_min_0;
> + 				} else {
> + 					dm_digtable->forbidden_igi--;
> + 					dm_digtable->rx_gain_min =
> +@@ -552,7 +552,7 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
> + 	rtl8723be_dm_write_dig(hw, current_igi);
> + 	dm_digtable->media_connect_0 =
> + 		((mac->link_state >= MAC80211_LINKED) ? true : false);
> +-	dm_digtable->dig_dynamic_min = dig_dynamic_min;
> ++	dm_digtable->dig_min_0 = dig_min_0;
> + }
> + 
> + static void rtl8723be_dm_false_alarm_counter_statistics(
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> +index ba30b0d..8b0bfb2 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> +@@ -539,8 +539,8 @@ static void rtl8821ae_dm_diginit(struct ieee80211_hw *hw)
> + 	dm_digtable->forbidden_igi = DM_DIG_MIN;
> + 	dm_digtable->large_fa_hit = 0;
> + 	dm_digtable->recover_cnt = 0;
> +-	dm_digtable->dig_dynamic_min = DM_DIG_MIN;
> +-	dm_digtable->dig_dynamic_min_1 = DM_DIG_MIN;
> ++	dm_digtable->dig_min_0 = DM_DIG_MIN;
> ++	dm_digtable->dig_min_1 = DM_DIG_MIN;
> + 	dm_digtable->media_connect_0 = false;
> + 	dm_digtable->media_connect_1 = false;
> + 	rtlpriv->dm.dm_initialgain_enable = true;
> +@@ -822,7 +822,7 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
> + 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
> + 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
> + 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
> +-	u8 dig_dynamic_min;
> ++	u8 dig_min_0;
> + 	u8 dig_max_of_min;
> + 	bool first_connect, first_disconnect;
> + 	u8 dm_dig_max, dm_dig_min, offset;
> +@@ -837,7 +837,7 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
> + 	}
> + 
> + 	/*add by Neil Chen to avoid PSD is processing*/
> +-	dig_dynamic_min = dm_digtable->dig_dynamic_min;
> ++	dig_min_0 = dm_digtable->dig_min_0;
> + 	first_connect = (mac->link_state >= MAC80211_LINKED) &&
> + 			(!dm_digtable->media_connect_0);
> + 	first_disconnect = (mac->link_state < MAC80211_LINKED) &&
> +@@ -876,23 +876,23 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
> + 			offset = 0;
> + 
> + 			if (dm_digtable->rssi_val_min - offset < dm_dig_min)
> +-				dig_dynamic_min = dm_dig_min;
> ++				dig_min_0 = dm_dig_min;
> + 			else if (dm_digtable->rssi_val_min -
> + 				offset > dig_max_of_min)
> +-				dig_dynamic_min = dig_max_of_min;
> ++				dig_min_0 = dig_max_of_min;
> + 			else
> +-				dig_dynamic_min =
> ++				dig_min_0 =
> + 					dm_digtable->rssi_val_min - offset;
> + 
> + 			RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
> +-				 "bOneEntryOnly=TRUE, dig_dynamic_min=0x%x\n",
> +-				 dig_dynamic_min);
> ++				 "bOneEntryOnly=TRUE, dig_min_0=0x%x\n",
> ++				 dig_min_0);
> + 		} else {
> +-			dig_dynamic_min = dm_dig_min;
> ++			dig_min_0 = dm_dig_min;
> + 		}
> + 	} else {
> + 		dm_digtable->rx_gain_max = dm_dig_max;
> +-		dig_dynamic_min = dm_dig_min;
> ++		dig_min_0 = dm_dig_min;
> + 		RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
> + 			 "No Link\n");
> + 	}
> +@@ -925,11 +925,11 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
> + 		} else {
> + 			if (dm_digtable->large_fa_hit < 3) {
> + 				if ((dm_digtable->forbidden_igi - 1) <
> +-				    dig_dynamic_min) {
> ++				    dig_min_0) {
> + 					dm_digtable->forbidden_igi =
> +-						dig_dynamic_min;
> ++						dig_min_0;
> + 					dm_digtable->rx_gain_min =
> +-						dig_dynamic_min;
> ++						dig_min_0;
> + 					RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
> + 						 "Normal Case: At Lower Bound\n");
> + 				} else {
> +@@ -1024,7 +1024,7 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
> + 	rtl8821ae_dm_write_dig(hw, current_igi);
> + 	dm_digtable->media_connect_0 =
> + 		((mac->link_state >= MAC80211_LINKED) ? true : false);
> +-	dm_digtable->dig_dynamic_min = dig_dynamic_min;
> ++	dm_digtable->dig_min_0 = dig_min_0;
> + }
> + 
> + static void rtl8821ae_dm_common_info_self_update(struct ieee80211_hw *hw)
> +diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
> +index 7a718fd..b53d9dd 100644
> +--- a/drivers/net/wireless/rtlwifi/wifi.h
> ++++ b/drivers/net/wireless/rtlwifi/wifi.h
> +@@ -2412,8 +2412,6 @@ struct dig_t {
> + 	u8 pre_ccastate;
> + 	u8 cur_ccasate;
> + 	u8 large_fa_hit;
> +-	u8 dig_dynamic_min;
> +-	u8 dig_dynamic_min_1;
> + 	u8 forbidden_igi;
> + 	u8 dig_state;
> + 	u8 dig_highpwrstate;
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0038-rtlwifi-rtl8723be-Improve-modinfo-output.patch b/package/kernel/mac80211/patches/680-0038-rtlwifi-rtl8723be-Improve-modinfo-output.patch
> new file mode 100644
> index 0000000..fede8ad
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0038-rtlwifi-rtl8723be-Improve-modinfo-output.patch
> @@ -0,0 +1,40 @@
> +From 3f0c1cfa735a12dbe24c583d2ab833d348745856 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:03 -0600
> +Subject: [PATCH 38/51] rtlwifi: rtl8723be: Improve modinfo output
> +
> +The description of the power-save variables for this driver is not as
> +clear as for the others. The wording is changed to match the others.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8723be/sw.c | 10 ++++++----
> + 1 file changed, 6 insertions(+), 4 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/sw.c b/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
> +index 223eb42..1017f02 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
> +@@ -387,12 +387,14 @@ module_param_named(swlps, rtl8723be_mod_params.swctrl_lps, bool, 0444);
> + module_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444);
> + module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog,
> + 		   bool, 0444);
> +-MODULE_PARM_DESC(swenc, "using hardware crypto (default 0 [hardware])\n");
> +-MODULE_PARM_DESC(ips, "using no link power save (default 1 is open)\n");
> +-MODULE_PARM_DESC(fwlps, "using linked fw control power save (default 1 is open)\n");
> ++MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
> ++MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
> ++MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
> ++MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n");
> + MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 0)\n");
> + MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)");
> +-MODULE_PARM_DESC(disable_watchdog, "Set to 1 to disable the watchdog (default 0)\n");
> ++MODULE_PARM_DESC(disable_watchdog,
> ++		 "Set to 1 to disable the watchdog (default 0)\n");
> + 
> + static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
> + 
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0039-rtlwifi-Create-new-routine-to-initialize-the-DM-tabl.patch b/package/kernel/mac80211/patches/680-0039-rtlwifi-Create-new-routine-to-initialize-the-DM-tabl.patch
> new file mode 100644
> index 0000000..edc0b40
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0039-rtlwifi-Create-new-routine-to-initialize-the-DM-tabl.patch
> @@ -0,0 +1,607 @@
> +From 6f8214b6905741ac5c58958a35257e8103645c90 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:04 -0600
> +Subject: [PATCH 39/51] rtlwifi: Create new routine to initialize the DM tables
> +
> +Each of the drivers contains a routine that initializes the dm_digtable
> +member of the driver's private area. As a first step toward reducing the
> +size of the drivers, a copy of this driver is created in rtlwifi, and the
> +definitions of the parameters are moved there.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/core.c               | 34 +++++++++++++++++++++++
> + drivers/net/wireless/rtlwifi/core.h               | 24 ++++++++++++++++
> + drivers/net/wireless/rtlwifi/rtl8188ee/dm.c       |  1 +
> + drivers/net/wireless/rtlwifi/rtl8188ee/dm.h       | 22 ---------------
> + drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c |  1 +
> + drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h | 22 ---------------
> + drivers/net/wireless/rtlwifi/rtl8192ce/dm.c       |  1 +
> + drivers/net/wireless/rtlwifi/rtl8192ce/dm.h       | 13 ---------
> + drivers/net/wireless/rtlwifi/rtl8192de/dm.c       |  1 +
> + drivers/net/wireless/rtlwifi/rtl8192de/dm.h       | 22 ---------------
> + drivers/net/wireless/rtlwifi/rtl8192ee/dm.c       |  1 +
> + drivers/net/wireless/rtlwifi/rtl8192ee/dm.h       | 13 ---------
> + drivers/net/wireless/rtlwifi/rtl8192se/dm.c       |  1 +
> + drivers/net/wireless/rtlwifi/rtl8192se/dm.h       | 19 -------------
> + drivers/net/wireless/rtlwifi/rtl8723ae/dm.c       |  1 +
> + drivers/net/wireless/rtlwifi/rtl8723ae/dm.h       | 22 ---------------
> + drivers/net/wireless/rtlwifi/rtl8723be/dm.c       |  1 +
> + drivers/net/wireless/rtlwifi/rtl8723be/dm.h       | 22 ---------------
> + drivers/net/wireless/rtlwifi/rtl8821ae/dm.c       |  1 +
> + drivers/net/wireless/rtlwifi/rtl8821ae/dm.h       | 16 -----------
> + 20 files changed, 67 insertions(+), 171 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
> +index deab852..5aa3ab3 100644
> +--- a/drivers/net/wireless/rtlwifi/core.c
> ++++ b/drivers/net/wireless/rtlwifi/core.c
> +@@ -1871,3 +1871,37 @@ bool rtl_btc_status_false(void)
> + 	return false;
> + }
> + EXPORT_SYMBOL_GPL(rtl_btc_status_false);
> ++
> ++void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
> ++{
> ++	struct rtl_priv *rtlpriv = rtl_priv(hw);
> ++	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
> ++
> ++	dm_digtable->dig_enable_flag = true;
> ++	dm_digtable->cur_igvalue = cur_igvalue;
> ++	dm_digtable->pre_igvalue = 0;
> ++	dm_digtable->cur_sta_cstate = DIG_STA_DISCONNECT;
> ++	dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
> ++	dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
> ++	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
> ++	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
> ++	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
> ++	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
> ++	dm_digtable->rx_gain_max = DM_DIG_MAX;
> ++	dm_digtable->rx_gain_min = DM_DIG_MIN;
> ++	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
> ++	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
> ++	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
> ++	dm_digtable->pre_cck_cca_thres = 0xff;
> ++	dm_digtable->cur_cck_cca_thres = 0x83;
> ++	dm_digtable->forbidden_igi = DM_DIG_MIN;
> ++	dm_digtable->large_fa_hit = 0;
> ++	dm_digtable->recover_cnt = 0;
> ++	dm_digtable->dig_min_0 = 0x25;
> ++	dm_digtable->dig_min_1 = 0x25;
> ++	dm_digtable->media_connect_0 = false;
> ++	dm_digtable->media_connect_1 = false;
> ++	rtlpriv->dm.dm_initialgain_enable = true;
> ++	dm_digtable->bt30_cur_igi = 0x32;
> ++}
> ++EXPORT_SYMBOL(rtl_dm_diginit);
> +diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
> +index 8c87eb5..c0a0317 100644
> +--- a/drivers/net/wireless/rtlwifi/core.h
> ++++ b/drivers/net/wireless/rtlwifi/core.h
> +@@ -35,6 +35,29 @@
> + 
> + #define RTL_SUPPORTED_CTRL_FILTER	0xFF
> + 
> ++#define DM_DIG_THRESH_HIGH		40
> ++#define DM_DIG_THRESH_LOW		35
> ++#define DM_FALSEALARM_THRESH_LOW	400
> ++#define DM_FALSEALARM_THRESH_HIGH	1000
> ++
> ++#define DM_DIG_MAX			0x3e
> ++#define DM_DIG_MIN			0x1e
> ++#define DM_DIG_BACKOFF_MAX		12
> ++#define DM_DIG_BACKOFF_MIN		-4
> ++#define DM_DIG_BACKOFF_DEFAULT		10
> ++
> ++enum dm_dig_connect_e {
> ++	DIG_STA_DISCONNECT,
> ++	DIG_STA_CONNECT,
> ++	DIG_STA_BEFORE_CONNECT,
> ++	DIG_MULTISTA_DISCONNECT,
> ++	DIG_MULTISTA_CONNECT,
> ++	DIG_AP_DISCONNECT,
> ++	DIG_AP_CONNECT,
> ++	DIG_AP_ADD_STATION,
> ++	DIG_CONNECT_MAX
> ++};
> ++
> + extern const struct ieee80211_ops rtl_ops;
> + void rtl_fw_cb(const struct firmware *firmware, void *context);
> + void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context);
> +@@ -44,5 +67,6 @@ void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
> + void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data);
> + bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);
> + bool rtl_btc_status_false(void);
> ++void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igval);
> + 
> + #endif
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
> +index 2aa34d9..7ebf6e0 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
> +@@ -26,6 +26,7 @@
> + #include "../wifi.h"
> + #include "../base.h"
> + #include "../pci.h"
> ++#include "../core.h"
> + #include "reg.h"
> + #include "def.h"
> + #include "phy.h"
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> +index 64f1f3ea..6217b7c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> +@@ -186,15 +186,6 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW				25
> + #define BW_AUTO_SWITCH_LOW_HIGH				30
> + 
> +-#define DM_DIG_THRESH_HIGH				40
> +-#define DM_DIG_THRESH_LOW				35
> +-
> +-#define DM_FALSEALARM_THRESH_LOW			400
> +-#define DM_FALSEALARM_THRESH_HIGH			1000
> +-
> +-#define DM_DIG_MAX					0x3e
> +-#define DM_DIG_MIN					0x1e
> +-
> + #define DM_DIG_MAX_AP					0x32
> + #define DM_DIG_MIN_AP					0x20
> + 
> +@@ -204,10 +195,6 @@
> + #define DM_DIG_FA_TH1					0x300
> + #define DM_DIG_FA_TH2					0x400
> + 
> +-#define DM_DIG_BACKOFF_MAX				12
> +-#define DM_DIG_BACKOFF_MIN				-4
> +-#define DM_DIG_BACKOFF_DEFAULT				10
> +-
> + #define RXPATHSELECTION_SS_TH_W				30
> + #define RXPATHSELECTION_DIFF_TH				18
> + 
> +@@ -296,15 +283,6 @@ enum dm_dig_ext_port_alg_e {
> + 	DIG_EXT_PORT_STAGE_MAX = 4,
> + };
> + 
> +-enum dm_dig_connect_e {
> +-	DIG_STA_DISCONNECT = 0,
> +-	DIG_STA_CONNECT = 1,
> +-	DIG_STA_BEFORE_CONNECT = 2,
> +-	DIG_MULTISTA_DISCONNECT = 3,
> +-	DIG_MULTISTA_CONNECT = 4,
> +-	DIG_CONNECT_MAX
> +-};
> +-
> + enum pwr_track_control_method {
> + 	BBSWING,
> + 	TXAGC
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> +index c3aad76..dabe18f 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> +@@ -32,6 +32,7 @@
> + #include "phy_common.h"
> + #include "../pci.h"
> + #include "../base.h"
> ++#include "../core.h"
> + 
> + #define BT_RSSI_STATE_NORMAL_POWER	BIT_OFFSET_LEN_MASK_32(0, 1)
> + #define BT_RSSI_STATE_AMDPU_OFF		BIT_OFFSET_LEN_MASK_32(1, 1)
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
> +index 4f232a0..55ebffd 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
> +@@ -47,25 +47,12 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW			25
> + #define BW_AUTO_SWITCH_LOW_HIGH			30
> + 
> +-#define DM_DIG_THRESH_HIGH			40
> +-#define DM_DIG_THRESH_LOW			35
> +-
> +-#define DM_FALSEALARM_THRESH_LOW		400
> +-#define DM_FALSEALARM_THRESH_HIGH		1000
> +-
> +-#define DM_DIG_MAX				0x3e
> +-#define DM_DIG_MIN				0x1e
> +-
> + #define DM_DIG_FA_UPPER				0x32
> + #define DM_DIG_FA_LOWER				0x20
> + #define DM_DIG_FA_TH0				0x20
> + #define DM_DIG_FA_TH1				0x100
> + #define DM_DIG_FA_TH2				0x200
> + 
> +-#define DM_DIG_BACKOFF_MAX			12
> +-#define DM_DIG_BACKOFF_MIN			-4
> +-#define DM_DIG_BACKOFF_DEFAULT			10
> +-
> + #define RXPATHSELECTION_SS_TH_lOW		30
> + #define RXPATHSELECTION_DIFF_TH			18
> + 
> +@@ -157,15 +144,6 @@ enum dm_dig_ext_port_alg_e {
> + 	DIG_EXT_PORT_STAGE_MAX = 4,
> + };
> + 
> +-enum dm_dig_connect_e {
> +-	DIG_STA_DISCONNECT = 0,
> +-	DIG_STA_CONNECT = 1,
> +-	DIG_STA_BEFORE_CONNECT = 2,
> +-	DIG_MULTISTA_DISCONNECT = 3,
> +-	DIG_MULTISTA_CONNECT = 4,
> +-	DIG_CONNECT_MAX
> +-};
> +-
> + void rtl92c_dm_init(struct ieee80211_hw *hw);
> + void rtl92c_dm_watchdog(struct ieee80211_hw *hw);
> + void rtl92c_dm_write_dig(struct ieee80211_hw *hw);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
> +index 74f9c08..09898cf 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
> +@@ -30,6 +30,7 @@
> + #include "../wifi.h"
> + #include "../base.h"
> + #include "../pci.h"
> ++#include "../core.h"
> + #include "reg.h"
> + #include "def.h"
> + #include "phy.h"
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
> +index 9c5311c..38ba707 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
> +@@ -42,25 +42,12 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW			25
> + #define BW_AUTO_SWITCH_LOW_HIGH			30
> + 
> +-#define DM_DIG_THRESH_HIGH			40
> +-#define DM_DIG_THRESH_LOW			35
> +-
> +-#define DM_FALSEALARM_THRESH_LOW		400
> +-#define DM_FALSEALARM_THRESH_HIGH		1000
> +-
> +-#define DM_DIG_MAX				0x3e
> +-#define DM_DIG_MIN				0x1e
> +-
> + #define DM_DIG_FA_UPPER				0x32
> + #define DM_DIG_FA_LOWER				0x20
> + #define DM_DIG_FA_TH0				0x20
> + #define DM_DIG_FA_TH1				0x100
> + #define DM_DIG_FA_TH2				0x200
> + 
> +-#define DM_DIG_BACKOFF_MAX			12
> +-#define DM_DIG_BACKOFF_MIN			-4
> +-#define DM_DIG_BACKOFF_DEFAULT			10
> +-
> + #define RXPATHSELECTION_SS_TH_lOW		30
> + #define RXPATHSELECTION_DIFF_TH			18
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
> +index 304c443..75643ab 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
> +@@ -29,6 +29,7 @@
> + 
> + #include "../wifi.h"
> + #include "../base.h"
> ++#include "../core.h"
> + #include "reg.h"
> + #include "def.h"
> + #include "phy.h"
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
> +index 3fea0c1..d21b3bc 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
> +@@ -42,25 +42,12 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW			25
> + #define BW_AUTO_SWITCH_LOW_HIGH			30
> + 
> +-#define DM_DIG_THRESH_HIGH			40
> +-#define DM_DIG_THRESH_LOW			35
> +-
> +-#define DM_FALSEALARM_THRESH_LOW		400
> +-#define DM_FALSEALARM_THRESH_HIGH		1000
> +-
> +-#define DM_DIG_MAX				0x3e
> +-#define DM_DIG_MIN				0x1c
> +-
> + #define DM_DIG_FA_UPPER				0x32
> + #define DM_DIG_FA_LOWER				0x20
> + #define DM_DIG_FA_TH0				0x100
> + #define DM_DIG_FA_TH1				0x400
> + #define DM_DIG_FA_TH2				0x600
> + 
> +-#define DM_DIG_BACKOFF_MAX			12
> +-#define DM_DIG_BACKOFF_MIN			-4
> +-#define DM_DIG_BACKOFF_DEFAULT			10
> +-
> + #define RXPATHSELECTION_SS_TH_lOW		30
> + #define RXPATHSELECTION_DIFF_TH			18
> + 
> +@@ -142,15 +129,6 @@ enum dm_dig_ext_port_alg {
> + 	DIG_EXT_PORT_STAGE_MAX = 4,
> + };
> + 
> +-enum dm_dig_connect {
> +-	DIG_STA_DISCONNECT = 0,
> +-	DIG_STA_CONNECT = 1,
> +-	DIG_STA_BEFORE_CONNECT = 2,
> +-	DIG_MULTISTA_DISCONNECT = 3,
> +-	DIG_MULTISTA_CONNECT = 4,
> +-	DIG_CONNECT_MAX
> +-};
> +-
> + void rtl92d_dm_init(struct ieee80211_hw *hw);
> + void rtl92d_dm_watchdog(struct ieee80211_hw *hw);
> + void rtl92d_dm_init_edca_turbo(struct ieee80211_hw *hw);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> +index 2fa4c45..70e58d1 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> +@@ -26,6 +26,7 @@
> + #include "../wifi.h"
> + #include "../base.h"
> + #include "../pci.h"
> ++#include "../core.h"
> + #include "reg.h"
> + #include "def.h"
> + #include "phy.h"
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
> +index 881db7d..4880e19 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
> +@@ -189,15 +189,6 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW			25
> + #define BW_AUTO_SWITCH_LOW_HIGH			30
> + 
> +-#define DM_DIG_THRESH_HIGH			40
> +-#define DM_DIG_THRESH_LOW			35
> +-
> +-#define DM_FALSEALARM_THRESH_LOW		400
> +-#define DM_FALSEALARM_THRESH_HIGH		1000
> +-
> +-#define DM_DIG_MAX				0x3e
> +-#define DM_DIG_MIN				0x1e
> +-
> + #define DM_DIG_MAX_AP				0x32
> + #define DM_DIG_MIN_AP				0x20
> + 
> +@@ -207,10 +198,6 @@
> + #define DM_DIG_FA_TH1				0x300
> + #define DM_DIG_FA_TH2				0x400
> + 
> +-#define DM_DIG_BACKOFF_MAX			12
> +-#define DM_DIG_BACKOFF_MIN			-4
> +-#define DM_DIG_BACKOFF_DEFAULT			10
> +-
> + #define RXPATHSELECTION_SS_TH_LOW		30
> + #define RXPATHSELECTION_DIFF_TH			18
> + 
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
> +index b3a2d5e..6cac70b 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
> +@@ -29,6 +29,7 @@
> + 
> + #include "../wifi.h"
> + #include "../base.h"
> ++#include "../core.h"
> + #include "reg.h"
> + #include "def.h"
> + #include "phy.h"
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> +index 2e9052c..7d778d3 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> +@@ -54,16 +54,6 @@ enum dm_dig_sta {
> + 	DM_STA_DIG_MAX
> + };
> + 
> +-enum dm_dig_connect {
> +-	DIG_STA_DISCONNECT = 0,
> +-	DIG_STA_CONNECT = 1,
> +-	DIG_STA_BEFORE_CONNECT = 2,
> +-	DIG_AP_DISCONNECT = 3,
> +-	DIG_AP_CONNECT = 4,
> +-	DIG_AP_ADD_STATION = 5,
> +-	DIG_CONNECT_MAX
> +-};
> +-
> + enum dm_dig_ext_port_alg {
> + 	DIG_EXT_PORT_STAGE_0 = 0,
> + 	DIG_EXT_PORT_STAGE_1 = 1,
> +@@ -99,22 +89,13 @@ enum dm_ratr_sta {
> + #define	TX_POWER_NEAR_FIELD_THRESH_LVL2	74
> + #define	TX_POWER_NEAR_FIELD_THRESH_LVL1	67
> + 
> +-#define DM_DIG_THRESH_HIGH		40
> +-#define DM_DIG_THRESH_LOW		35
> +-#define	DM_FALSEALARM_THRESH_LOW	40
> +-#define	DM_FALSEALARM_THRESH_HIGH	1000
> + #define	DM_DIG_HIGH_PWR_THRESH_HIGH	75
> + #define	DM_DIG_HIGH_PWR_THRESH_LOW	70
> + #define	DM_DIG_BACKOFF			12
> +-#define	DM_DIG_MAX			0x3e
> +-#define	DM_DIG_MIN			0x1c
> + #define	DM_DIG_MIN_Netcore		0x12
> +-#define	DM_DIG_BACKOFF_MAX		12
> +-#define	DM_DIG_BACKOFF_MIN		-4
> + 
> + void rtl92s_dm_watchdog(struct ieee80211_hw *hw);
> + void rtl92s_dm_init(struct ieee80211_hw *hw);
> + void rtl92s_dm_init_edca_turbo(struct ieee80211_hw *hw);
> + 
> + #endif
> +-
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> +index a0e8692..80f4c54 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> +@@ -26,6 +26,7 @@
> + #include "../wifi.h"
> + #include "../base.h"
> + #include "../pci.h"
> ++#include "../core.h"
> + #include "reg.h"
> + #include "def.h"
> + #include "phy.h"
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
> +index 6fa0feb..c54024e 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
> +@@ -42,25 +42,12 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW			25
> + #define BW_AUTO_SWITCH_LOW_HIGH			30
> + 
> +-#define DM_DIG_THRESH_HIGH			40
> +-#define DM_DIG_THRESH_LOW			35
> +-
> +-#define DM_FALSEALARM_THRESH_LOW		400
> +-#define DM_FALSEALARM_THRESH_HIGH		1000
> +-
> +-#define DM_DIG_MAX				0x3e
> +-#define DM_DIG_MIN				0x1e
> +-
> + #define DM_DIG_FA_UPPER				0x32
> + #define DM_DIG_FA_LOWER				0x20
> + #define DM_DIG_FA_TH0				0x20
> + #define DM_DIG_FA_TH1				0x100
> + #define DM_DIG_FA_TH2				0x200
> + 
> +-#define DM_DIG_BACKOFF_MAX			12
> +-#define DM_DIG_BACKOFF_MIN			-4
> +-#define DM_DIG_BACKOFF_DEFAULT			10
> +-
> + #define RXPATHSELECTION_SS_TH_LOW		30
> + #define RXPATHSELECTION_DIFF_TH			18
> + 
> +@@ -142,15 +129,6 @@ enum dm_dig_ext_port_alg_e {
> + 	DIG_EXT_PORT_STAGE_MAX = 4,
> + };
> + 
> +-enum dm_dig_connect_e {
> +-	DIG_STA_DISCONNECT = 0,
> +-	DIG_STA_CONNECT = 1,
> +-	DIG_STA_BEFORE_CONNECT = 2,
> +-	DIG_MULTISTA_DISCONNECT = 3,
> +-	DIG_MULTISTA_CONNECT = 4,
> +-	DIG_CONNECT_MAX
> +-};
> +-
> + #define BT_RSSI_STATE_NORMAL_POWER      BIT_OFFSET_LEN_MASK_32(0, 1)
> + #define BT_RSSI_STATE_AMDPU_OFF         BIT_OFFSET_LEN_MASK_32(1, 1)
> + #define BT_RSSI_STATE_SPECIAL_LOW       BIT_OFFSET_LEN_MASK_32(2, 1)
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> +index b92c521e..ddf45d9 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> +@@ -26,6 +26,7 @@
> + #include "../wifi.h"
> + #include "../base.h"
> + #include "../pci.h"
> ++#include "../core.h"
> + #include "reg.h"
> + #include "def.h"
> + #include "phy.h"
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> +index e4c0e8a..f3e47ab 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> +@@ -180,15 +180,6 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW			25
> + #define BW_AUTO_SWITCH_LOW_HIGH			30
> + 
> +-#define DM_DIG_THRESH_HIGH			40
> +-#define DM_DIG_THRESH_LOW			35
> +-
> +-#define DM_FALSEALARM_THRESH_LOW		400
> +-#define DM_FALSEALARM_THRESH_HIGH		1000
> +-
> +-#define DM_DIG_MAX				0x3e
> +-#define DM_DIG_MIN				0x1e
> +-
> + #define DM_DIG_MAX_AP				0x32
> + #define DM_DIG_MIN_AP				0x20
> + 
> +@@ -198,10 +189,6 @@
> + #define DM_DIG_FA_TH1				0x300
> + #define DM_DIG_FA_TH2				0x400
> + 
> +-#define DM_DIG_BACKOFF_MAX			12
> +-#define DM_DIG_BACKOFF_MIN			-4
> +-#define DM_DIG_BACKOFF_DEFAULT			10
> +-
> + #define RXPATHSELECTION_SS_TH_LOW		30
> + #define RXPATHSELECTION_DIFF_TH			18
> + 
> +@@ -260,15 +247,6 @@ enum dm_dig_ext_port_alg_e {
> + 	DIG_EXT_PORT_STAGE_MAX	= 4,
> + };
> + 
> +-enum dm_dig_connect_e {
> +-	DIG_STA_DISCONNECT	= 0,
> +-	DIG_STA_CONNECT		= 1,
> +-	DIG_STA_BEFORE_CONNECT	= 2,
> +-	DIG_MULTISTA_DISCONNECT	= 3,
> +-	DIG_MULTISTA_CONNECT	= 4,
> +-	DIG_CONNECT_MAX
> +-};
> +-
> + enum pwr_track_control_method {
> + 	BBSWING,
> + 	TXAGC
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> +index 8b0bfb2..4af4613 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> +@@ -26,6 +26,7 @@
> + #include "../wifi.h"
> + #include "../base.h"
> + #include "../pci.h"
> ++#include "../core.h"
> + #include "reg.h"
> + #include "def.h"
> + #include "phy.h"
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> +index 9dd40dd..f311887 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> +@@ -187,9 +187,6 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW		25
> + #define BW_AUTO_SWITCH_LOW_HIGH		30
> + 
> +-#define DM_DIG_THRESH_HIGH			40
> +-#define DM_DIG_THRESH_LOW			35
> +-
> + #define DM_FALSEALARM_THRESH_LOW	400
> + #define DM_FALSEALARM_THRESH_HIGH	1000
> + 
> +@@ -205,10 +202,6 @@
> + #define DM_DIG_FA_TH1				0x300
> + #define DM_DIG_FA_TH2				0x400
> + 
> +-#define DM_DIG_BACKOFF_MAX			12
> +-#define DM_DIG_BACKOFF_MIN			-4
> +-#define DM_DIG_BACKOFF_DEFAULT		10
> +-
> + #define RXPATHSELECTION_SS_TH_LOW	30
> + #define RXPATHSELECTION_DIFF_TH		18
> + 
> +@@ -296,15 +289,6 @@ enum dm_dig_ext_port_alg_e {
> + 	DIG_EXT_PORT_STAGE_MAX = 4,
> + };
> + 
> +-enum dm_dig_connect_e {
> +-	DIG_STA_DISCONNECT = 0,
> +-	DIG_STA_CONNECT = 1,
> +-	DIG_STA_BEFORE_CONNECT = 2,
> +-	DIG_MULTISTA_DISCONNECT = 3,
> +-	DIG_MULTISTA_CONNECT = 4,
> +-	DIG_CONNECT_MAX
> +-};
> +-
> + enum pwr_track_control_method {
> + 	BBSWING,
> + 	TXAGC,
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0040-rtlwifi-rtl8188ee-Convert-driver-to-use-the-common-D.patch b/package/kernel/mac80211/patches/680-0040-rtlwifi-rtl8188ee-Convert-driver-to-use-the-common-D.patch
> new file mode 100644
> index 0000000..f89e2c3
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0040-rtlwifi-rtl8188ee-Convert-driver-to-use-the-common-D.patch
> @@ -0,0 +1,73 @@
> +From b5d4478dc35e0cd9ef482d22aba069a19fe04a04 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:05 -0600
> +Subject: [PATCH 40/51] rtlwifi: rtl8188ee: Convert driver to use the common DM
> + table init routine
> +
> +The previous patch created a routine in rtlwifi to initialize dm_digtable.
> +Driver rtl8188ee is converted to use that routine.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8188ee/dm.c | 35 ++---------------------------
> + 1 file changed, 2 insertions(+), 33 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
> +index 7ebf6e0..d930c1f 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
> +@@ -342,38 +342,6 @@ static void dm_tx_pwr_track_set_pwr(struct ieee80211_hw *hw,
> + 	}
> + }
> + 
> +-static void rtl88e_dm_diginit(struct ieee80211_hw *hw)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	struct dig_t *dm_dig = &rtlpriv->dm_digtable;
> +-
> +-	dm_dig->dig_enable_flag = true;
> +-	dm_dig->cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
> +-	dm_dig->pre_igvalue = 0;
> +-	dm_dig->cur_sta_cstate = DIG_STA_DISCONNECT;
> +-	dm_dig->presta_cstate = DIG_STA_DISCONNECT;
> +-	dm_dig->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
> +-	dm_dig->rssi_lowthresh = DM_DIG_THRESH_LOW;
> +-	dm_dig->rssi_highthresh = DM_DIG_THRESH_HIGH;
> +-	dm_dig->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
> +-	dm_dig->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
> +-	dm_dig->rx_gain_max = DM_DIG_MAX;
> +-	dm_dig->rx_gain_min = DM_DIG_MIN;
> +-	dm_dig->back_val = DM_DIG_BACKOFF_DEFAULT;
> +-	dm_dig->back_range_max = DM_DIG_BACKOFF_MAX;
> +-	dm_dig->back_range_min = DM_DIG_BACKOFF_MIN;
> +-	dm_dig->pre_cck_cca_thres = 0xff;
> +-	dm_dig->cur_cck_cca_thres = 0x83;
> +-	dm_dig->forbidden_igi = DM_DIG_MIN;
> +-	dm_dig->large_fa_hit = 0;
> +-	dm_dig->recover_cnt = 0;
> +-	dm_dig->dig_min_0 = 0x25;
> +-	dm_dig->dig_min_1 = 0x25;
> +-	dm_dig->media_connect_0 = false;
> +-	dm_dig->media_connect_1 = false;
> +-	rtlpriv->dm.dm_initialgain_enable = true;
> +-}
> +-
> + static u8 rtl88e_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +@@ -1797,9 +1765,10 @@ static void rtl88e_dm_antenna_diversity(struct ieee80211_hw *hw)
> + void rtl88e_dm_init(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> ++	u32 cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
> + 
> + 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
> +-	rtl88e_dm_diginit(hw);
> ++	rtl_dm_diginit(hw, cur_igvalue);
> + 	rtl88e_dm_init_dynamic_txpower(hw);
> + 	rtl88e_dm_init_edca_turbo(hw);
> + 	rtl88e_dm_init_rate_adaptive_mask(hw);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0041-rtlwifi-rtl8192c-common-Convert-driver-to-use-common.patch b/package/kernel/mac80211/patches/680-0041-rtlwifi-rtl8192c-common-Convert-driver-to-use-common.patch
> new file mode 100644
> index 0000000..b51dbcb
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0041-rtlwifi-rtl8192c-common-Convert-driver-to-use-common.patch
> @@ -0,0 +1,411 @@
> +From 3424a00fd559debf402559c226d9b1d895b94a5f Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:06 -0600
> +Subject: [PATCH 41/51] rtlwifi: rtl8192c-common: Convert driver to use common
> + DM table initialization
> +
> +These changes convert both rtl8192ce and rtl8192cu to use the new routine.
> +Some additional definitions are needed in the core, thus several of the
> +headers for other drivers are affected, but no other executable code is
> +changed.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/core.c               |  3 ++
> + drivers/net/wireless/rtlwifi/core.h               | 16 +++++++++
> + drivers/net/wireless/rtlwifi/rtl8188ee/dm.h       | 16 ---------
> + drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 44 ++++-------------------
> + drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h | 16 ---------
> + drivers/net/wireless/rtlwifi/rtl8192de/dm.h       | 16 ---------
> + drivers/net/wireless/rtlwifi/rtl8192se/dm.h       |  8 -----
> + drivers/net/wireless/rtlwifi/rtl8723ae/dm.c       | 14 ++++----
> + drivers/net/wireless/rtlwifi/rtl8723ae/dm.h       | 16 ---------
> + drivers/net/wireless/rtlwifi/rtl8723be/dm.h       |  8 -----
> + drivers/net/wireless/rtlwifi/rtl8821ae/dm.h       | 16 ---------
> + 11 files changed, 33 insertions(+), 140 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
> +index 5aa3ab3..eb20316 100644
> +--- a/drivers/net/wireless/rtlwifi/core.c
> ++++ b/drivers/net/wireless/rtlwifi/core.c
> +@@ -1878,6 +1878,7 @@ void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
> + 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
> + 
> + 	dm_digtable->dig_enable_flag = true;
> ++	dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
> + 	dm_digtable->cur_igvalue = cur_igvalue;
> + 	dm_digtable->pre_igvalue = 0;
> + 	dm_digtable->cur_sta_cstate = DIG_STA_DISCONNECT;
> +@@ -1903,5 +1904,7 @@ void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
> + 	dm_digtable->media_connect_1 = false;
> + 	rtlpriv->dm.dm_initialgain_enable = true;
> + 	dm_digtable->bt30_cur_igi = 0x32;
> ++	dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
> ++	dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI;
> + }
> + EXPORT_SYMBOL(rtl_dm_diginit);
> +diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
> +index c0a0317..1cde356 100644
> +--- a/drivers/net/wireless/rtlwifi/core.h
> ++++ b/drivers/net/wireless/rtlwifi/core.h
> +@@ -46,6 +46,22 @@
> + #define DM_DIG_BACKOFF_MIN		-4
> + #define DM_DIG_BACKOFF_DEFAULT		10
> + 
> ++enum cck_packet_detection_threshold {
> ++	CCK_PD_STAGE_LOWRSSI = 0,
> ++	CCK_PD_STAGE_HIGHRSSI = 1,
> ++	CCK_FA_STAGE_LOW = 2,
> ++	CCK_FA_STAGE_HIGH = 3,
> ++	CCK_PD_STAGE_MAX = 4,
> ++};
> ++
> ++enum dm_dig_ext_port_alg_e {
> ++	DIG_EXT_PORT_STAGE_0 = 0,
> ++	DIG_EXT_PORT_STAGE_1 = 1,
> ++	DIG_EXT_PORT_STAGE_2 = 2,
> ++	DIG_EXT_PORT_STAGE_3 = 3,
> ++	DIG_EXT_PORT_STAGE_MAX = 4,
> ++};
> ++
> + enum dm_dig_connect_e {
> + 	DIG_STA_DISCONNECT,
> + 	DIG_STA_CONNECT,
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> +index 6217b7c..51ad3f9 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> +@@ -249,14 +249,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
> + 	DIG_OP_TYPE_MAX
> + };
> + 
> +-enum tag_cck_packet_detection_threshold_type_definition {
> +-	CCK_PD_STAGE_LOWRSSI = 0,
> +-	CCK_PD_STAGE_HIGHRSSI = 1,
> +-	CCK_FA_STAGE_LOW = 2,
> +-	CCK_FA_STAGE_HIGH = 3,
> +-	CCK_PD_STAGE_MAX = 4,
> +-};
> +-
> + enum dm_1r_cca_e {
> + 	CCA_1R = 0,
> + 	CCA_2R = 1,
> +@@ -275,14 +267,6 @@ enum dm_sw_ant_switch_e {
> + 	ANS_ANTENNA_MAX = 3,
> + };
> + 
> +-enum dm_dig_ext_port_alg_e {
> +-	DIG_EXT_PORT_STAGE_0 = 0,
> +-	DIG_EXT_PORT_STAGE_1 = 1,
> +-	DIG_EXT_PORT_STAGE_2 = 2,
> +-	DIG_EXT_PORT_STAGE_3 = 3,
> +-	DIG_EXT_PORT_STAGE_MAX = 4,
> +-};
> +-
> + enum pwr_track_control_method {
> + 	BBSWING,
> + 	TXAGC
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> +index dabe18f..f5ee67c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> +@@ -195,36 +195,6 @@ void dm_savepowerindex(struct ieee80211_hw *hw)
> + }
> + EXPORT_SYMBOL_GPL(dm_savepowerindex);
> + 
> +-static void rtl92c_dm_diginit(struct ieee80211_hw *hw)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
> +-
> +-	dm_digtable->dig_enable_flag = true;
> +-	dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
> +-	dm_digtable->cur_igvalue = 0x20;
> +-	dm_digtable->pre_igvalue = 0x0;
> +-	dm_digtable->cursta_cstate = DIG_STA_DISCONNECT;
> +-	dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
> +-	dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
> +-	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
> +-	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
> +-	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
> +-	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
> +-	dm_digtable->rx_gain_max = DM_DIG_MAX;
> +-	dm_digtable->rx_gain_min = DM_DIG_MIN;
> +-	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
> +-	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
> +-	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
> +-	dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
> +-	dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LowRssi;
> +-
> +-	dm_digtable->forbidden_igi = DM_DIG_MIN;
> +-	dm_digtable->large_fa_hit = 0;
> +-	dm_digtable->recover_cnt = 0;
> +-	dm_digtable->dig_min_0  = 0x25;
> +-}
> +-
> + static u8 rtl92c_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +@@ -508,27 +478,27 @@ static void rtl92c_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
> + 		if (dm_digtable->rssi_val_min > 100)
> + 			dm_digtable->rssi_val_min = 100;
> + 
> +-		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LowRssi) {
> ++		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LOWRSSI) {
> + 			if (dm_digtable->rssi_val_min <= 25)
> + 				dm_digtable->cur_cck_pd_state =
> +-				    CCK_PD_STAGE_LowRssi;
> ++				    CCK_PD_STAGE_LOWRSSI;
> + 			else
> + 				dm_digtable->cur_cck_pd_state =
> +-				    CCK_PD_STAGE_HighRssi;
> ++				    CCK_PD_STAGE_HIGHRSSI;
> + 		} else {
> + 			if (dm_digtable->rssi_val_min <= 20)
> + 				dm_digtable->cur_cck_pd_state =
> +-				    CCK_PD_STAGE_LowRssi;
> ++				    CCK_PD_STAGE_LOWRSSI;
> + 			else
> + 				dm_digtable->cur_cck_pd_state =
> +-				    CCK_PD_STAGE_HighRssi;
> ++				    CCK_PD_STAGE_HIGHRSSI;
> + 		}
> + 	} else {
> + 		dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
> + 	}
> + 
> + 	if (dm_digtable->pre_cck_pd_state != dm_digtable->cur_cck_pd_state) {
> +-		if ((dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LowRssi) ||
> ++		if ((dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI) ||
> + 		    (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_MAX))
> + 			rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0x83);
> + 		else
> +@@ -1375,7 +1345,7 @@ void rtl92c_dm_init(struct ieee80211_hw *hw)
> + 	rtlpriv->dm.undec_sm_pwdb = -1;
> + 	rtlpriv->dm.undec_sm_cck = -1;
> + 	rtlpriv->dm.dm_initialgain_enable = true;
> +-	rtl92c_dm_diginit(hw);
> ++	rtl_dm_diginit(hw, 0x20);
> + 
> + 	rtlpriv->dm.dm_flag |= HAL_DM_HIPWR_DISABLE;
> + 	rtl92c_dm_init_dynamic_txpower(hw);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
> +index 55ebffd..4422e31 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
> +@@ -110,14 +110,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
> + 	DIG_OP_TYPE_MAX
> + };
> + 
> +-enum tag_cck_packet_detection_threshold_type_definition {
> +-	CCK_PD_STAGE_LowRssi = 0,
> +-	CCK_PD_STAGE_HighRssi = 1,
> +-	CCK_FA_STAGE_Low = 2,
> +-	CCK_FA_STAGE_High = 3,
> +-	CCK_PD_STAGE_MAX = 4,
> +-};
> +-
> + enum dm_1r_cca_e {
> + 	CCA_1R = 0,
> + 	CCA_2R = 1,
> +@@ -136,14 +128,6 @@ enum dm_sw_ant_switch_e {
> + 	ANS_ANTENNA_MAX = 3,
> + };
> + 
> +-enum dm_dig_ext_port_alg_e {
> +-	DIG_EXT_PORT_STAGE_0 = 0,
> +-	DIG_EXT_PORT_STAGE_1 = 1,
> +-	DIG_EXT_PORT_STAGE_2 = 2,
> +-	DIG_EXT_PORT_STAGE_3 = 3,
> +-	DIG_EXT_PORT_STAGE_MAX = 4,
> +-};
> +-
> + void rtl92c_dm_init(struct ieee80211_hw *hw);
> + void rtl92c_dm_watchdog(struct ieee80211_hw *hw);
> + void rtl92c_dm_write_dig(struct ieee80211_hw *hw);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
> +index d21b3bc..f2d318c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
> +@@ -95,14 +95,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
> + 	DIG_OP_TYPE_MAX
> + };
> + 
> +-enum tag_cck_packet_detection_threshold_type_definition {
> +-	CCK_PD_STAGE_LOWRSSI = 0,
> +-	CCK_PD_STAGE_HIGHRSSI = 1,
> +-	CCK_FA_STAGE_LOW = 2,
> +-	CCK_FA_STAGE_HIGH = 3,
> +-	CCK_PD_STAGE_MAX = 4,
> +-};
> +-
> + enum dm_1r_cca {
> + 	CCA_1R = 0,
> + 	CCA_2R = 1,
> +@@ -121,14 +113,6 @@ enum dm_sw_ant_switch {
> + 	ANS_ANTENNA_MAX = 3,
> + };
> + 
> +-enum dm_dig_ext_port_alg {
> +-	DIG_EXT_PORT_STAGE_0 = 0,
> +-	DIG_EXT_PORT_STAGE_1 = 1,
> +-	DIG_EXT_PORT_STAGE_2 = 2,
> +-	DIG_EXT_PORT_STAGE_3 = 3,
> +-	DIG_EXT_PORT_STAGE_MAX = 4,
> +-};
> +-
> + void rtl92d_dm_init(struct ieee80211_hw *hw);
> + void rtl92d_dm_watchdog(struct ieee80211_hw *hw);
> + void rtl92d_dm_init_edca_turbo(struct ieee80211_hw *hw);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> +index 7d778d3..be07d81 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> +@@ -54,14 +54,6 @@ enum dm_dig_sta {
> + 	DM_STA_DIG_MAX
> + };
> + 
> +-enum dm_dig_ext_port_alg {
> +-	DIG_EXT_PORT_STAGE_0 = 0,
> +-	DIG_EXT_PORT_STAGE_1 = 1,
> +-	DIG_EXT_PORT_STAGE_2 = 2,
> +-	DIG_EXT_PORT_STAGE_3 = 3,
> +-	DIG_EXT_PORT_STAGE_MAX = 4,
> +-};
> +-
> + enum dm_ratr_sta {
> + 	DM_RATR_STA_HIGH = 0,
> + 	DM_RATR_STA_MIDDLEHIGH = 1,
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> +index 80f4c54..8bd124c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> +@@ -396,30 +396,30 @@ static void rtl8723e_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
> + 	if (dm_digtable->cursta_cstate == DIG_STA_CONNECT) {
> + 		dm_digtable->rssi_val_min = rtl8723e_dm_initial_gain_min_pwdb(hw);
> + 
> +-		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LowRssi) {
> ++		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LOWRSSI) {
> + 			if (dm_digtable->rssi_val_min <= 25)
> + 				dm_digtable->cur_cck_pd_state =
> +-				    CCK_PD_STAGE_LowRssi;
> ++				    CCK_PD_STAGE_LOWRSSI;
> + 			else
> + 				dm_digtable->cur_cck_pd_state =
> +-				    CCK_PD_STAGE_HighRssi;
> ++				    CCK_PD_STAGE_HIGHRSSI;
> + 		} else {
> + 			if (dm_digtable->rssi_val_min <= 20)
> + 				dm_digtable->cur_cck_pd_state =
> +-				    CCK_PD_STAGE_LowRssi;
> ++				    CCK_PD_STAGE_LOWRSSI;
> + 			else
> + 				dm_digtable->cur_cck_pd_state =
> +-				    CCK_PD_STAGE_HighRssi;
> ++				    CCK_PD_STAGE_HIGHRSSI;
> + 		}
> + 	} else {
> + 		dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
> + 	}
> + 
> + 	if (dm_digtable->pre_cck_pd_state != dm_digtable->cur_cck_pd_state) {
> +-		if (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LowRssi) {
> ++		if (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI) {
> + 			if (rtlpriv->falsealm_cnt.cnt_cck_fail > 800)
> + 				dm_digtable->cur_cck_fa_state =
> +-				    CCK_FA_STAGE_High;
> ++				    CCK_FA_STAGE_HIGH;
> + 			else
> + 				dm_digtable->cur_cck_fa_state =
> + 				    CCK_FA_STAGE_LOW;
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
> +index c54024e..5711105 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
> +@@ -95,14 +95,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
> + 	DIG_OP_TYPE_MAX
> + };
> + 
> +-enum tag_cck_packet_detection_threshold_type_definition {
> +-	CCK_PD_STAGE_LowRssi = 0,
> +-	CCK_PD_STAGE_HighRssi = 1,
> +-	CCK_FA_STAGE_LOW = 2,
> +-	CCK_FA_STAGE_High = 3,
> +-	CCK_PD_STAGE_MAX = 4,
> +-};
> +-
> + enum dm_1r_cca_e {
> + 	CCA_1R = 0,
> + 	CCA_2R = 1,
> +@@ -121,14 +113,6 @@ enum dm_sw_ant_switch_e {
> + 	ANS_ANTENNA_MAX = 3,
> + };
> + 
> +-enum dm_dig_ext_port_alg_e {
> +-	DIG_EXT_PORT_STAGE_0 = 0,
> +-	DIG_EXT_PORT_STAGE_1 = 1,
> +-	DIG_EXT_PORT_STAGE_2 = 2,
> +-	DIG_EXT_PORT_STAGE_3 = 3,
> +-	DIG_EXT_PORT_STAGE_MAX = 4,
> +-};
> +-
> + #define BT_RSSI_STATE_NORMAL_POWER      BIT_OFFSET_LEN_MASK_32(0, 1)
> + #define BT_RSSI_STATE_AMDPU_OFF         BIT_OFFSET_LEN_MASK_32(1, 1)
> + #define BT_RSSI_STATE_SPECIAL_LOW       BIT_OFFSET_LEN_MASK_32(2, 1)
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> +index f3e47ab..533b4f2 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> +@@ -239,14 +239,6 @@ enum dm_sw_ant_switch_e {
> + 	ANS_ANTENNA_MAX	= 3,
> + };
> + 
> +-enum dm_dig_ext_port_alg_e {
> +-	DIG_EXT_PORT_STAGE_0	= 0,
> +-	DIG_EXT_PORT_STAGE_1	= 1,
> +-	DIG_EXT_PORT_STAGE_2	= 2,
> +-	DIG_EXT_PORT_STAGE_3	= 3,
> +-	DIG_EXT_PORT_STAGE_MAX	= 4,
> +-};
> +-
> + enum pwr_track_control_method {
> + 	BBSWING,
> + 	TXAGC
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> +index f311887..5516557 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> +@@ -255,14 +255,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
> + 	DIG_OP_TYPE_MAX
> + };
> + 
> +-enum tag_cck_packet_detection_threshold_type_definition {
> +-	CCK_PD_STAGE_LOWRSSI = 0,
> +-	CCK_PD_STAGE_HIGHRSSI = 1,
> +-	CCK_FA_STAGE_LOW = 2,
> +-	CCK_FA_STAGE_HIGH = 3,
> +-	CCK_PD_STAGE_MAX = 4,
> +-};
> +-
> + enum dm_1r_cca_e {
> + 	CCA_1R = 0,
> + 	CCA_2R = 1,
> +@@ -281,14 +273,6 @@ enum dm_sw_ant_switch_e {
> + 	ANS_ANTENNA_MAX = 3,
> + };
> + 
> +-enum dm_dig_ext_port_alg_e {
> +-	DIG_EXT_PORT_STAGE_0 = 0,
> +-	DIG_EXT_PORT_STAGE_1 = 1,
> +-	DIG_EXT_PORT_STAGE_2 = 2,
> +-	DIG_EXT_PORT_STAGE_3 = 3,
> +-	DIG_EXT_PORT_STAGE_MAX = 4,
> +-};
> +-
> + enum pwr_track_control_method {
> + 	BBSWING,
> + 	TXAGC,
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0042-rtlwifi-rtl8192de-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0042-rtlwifi-rtl8192de-Convert-driver-to-use-common-DM-ta.patch
> new file mode 100644
> index 0000000..7b45006
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0042-rtlwifi-rtl8192de-Convert-driver-to-use-common-DM-ta.patch
> @@ -0,0 +1,68 @@
> +From 8b17c1f3a5e058952177339d0310f27a4fb42c13 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:07 -0600
> +Subject: [PATCH 42/51] rtlwifi: rtl8192de: Convert driver to use common DM
> + table initialization
> +
> +This patch converts driver rtl8192de to use the common routine to
> +initialize dm_digtable.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192de/dm.c | 32 +++--------------------------
> + 1 file changed, 3 insertions(+), 29 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
> +index 75643ab..a1be5a6 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
> +@@ -156,34 +156,6 @@ static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
> + 	{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}     /* 32, -16.0dB */
> + };
> + 
> +-static void rtl92d_dm_diginit(struct ieee80211_hw *hw)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	struct dig_t *de_digtable = &rtlpriv->dm_digtable;
> +-
> +-	de_digtable->dig_enable_flag = true;
> +-	de_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
> +-	de_digtable->cur_igvalue = 0x20;
> +-	de_digtable->pre_igvalue = 0x0;
> +-	de_digtable->cursta_cstate = DIG_STA_DISCONNECT;
> +-	de_digtable->presta_cstate = DIG_STA_DISCONNECT;
> +-	de_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
> +-	de_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
> +-	de_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
> +-	de_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
> +-	de_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
> +-	de_digtable->rx_gain_max = DM_DIG_FA_UPPER;
> +-	de_digtable->rx_gain_min = DM_DIG_FA_LOWER;
> +-	de_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
> +-	de_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
> +-	de_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
> +-	de_digtable->pre_cck_pd_state = CCK_PD_STAGE_LOWRSSI;
> +-	de_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
> +-	de_digtable->large_fa_hit = 0;
> +-	de_digtable->recover_cnt = 0;
> +-	de_digtable->forbidden_igi = DM_DIG_FA_LOWER;
> +-}
> +-
> + static void rtl92d_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw)
> + {
> + 	u32 ret_value;
> +@@ -1306,7 +1278,9 @@ void rtl92d_dm_init(struct ieee80211_hw *hw)
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> + 
> + 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
> +-	rtl92d_dm_diginit(hw);
> ++	rtl_dm_diginit(hw, 0x20);
> ++	rtlpriv->dm_digtable.rx_gain_max = DM_DIG_FA_UPPER;
> ++	rtlpriv->dm_digtable.rx_gain_min = DM_DIG_FA_LOWER;
> + 	rtl92d_dm_init_dynamic_txpower(hw);
> + 	rtl92d_dm_init_edca_turbo(hw);
> + 	rtl92d_dm_init_rate_adaptive_mask(hw);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0043-rtlwifi-rtl8192ee-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0043-rtlwifi-rtl8192ee-Convert-driver-to-use-common-DM-ta.patch
> new file mode 100644
> index 0000000..b522d52
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0043-rtlwifi-rtl8192ee-Convert-driver-to-use-common-DM-ta.patch
> @@ -0,0 +1,71 @@
> +From 153cb55731b68ddf7b0ebaa55536b56d766b47e6 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:08 -0600
> +Subject: [PATCH 43/51] rtlwifi: rtl8192ee: Convert driver to use common DM
> + table initialization
> +
> +Convert driver rtl8192ee to use the common routine to initialize
> +dm_digtable.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192ee/dm.c | 32 ++---------------------------
> + 1 file changed, 2 insertions(+), 30 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> +index 70e58d1..459f3d0 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
> +@@ -152,35 +152,6 @@ static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
> + 	{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}  /* 32, -16.0dB */
> + };
> + 
> +-static void rtl92ee_dm_diginit(struct ieee80211_hw *hw)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	struct dig_t *dm_dig = &rtlpriv->dm_digtable;
> +-
> +-	dm_dig->cur_igvalue = rtl_get_bbreg(hw, DM_REG_IGI_A_11N,
> +-					    DM_BIT_IGI_11N);
> +-	dm_dig->rssi_lowthresh = DM_DIG_THRESH_LOW;
> +-	dm_dig->rssi_highthresh = DM_DIG_THRESH_HIGH;
> +-	dm_dig->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
> +-	dm_dig->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
> +-	dm_dig->rx_gain_max = DM_DIG_MAX;
> +-	dm_dig->rx_gain_min = DM_DIG_MIN;
> +-	dm_dig->back_val = DM_DIG_BACKOFF_DEFAULT;
> +-	dm_dig->back_range_max = DM_DIG_BACKOFF_MAX;
> +-	dm_dig->back_range_min = DM_DIG_BACKOFF_MIN;
> +-	dm_dig->pre_cck_cca_thres = 0xff;
> +-	dm_dig->cur_cck_cca_thres = 0x83;
> +-	dm_dig->forbidden_igi = DM_DIG_MIN;
> +-	dm_dig->large_fa_hit = 0;
> +-	dm_dig->recover_cnt = 0;
> +-	dm_dig->dig_min_0 = DM_DIG_MIN;
> +-	dm_dig->dig_min_1 = DM_DIG_MIN;
> +-	dm_dig->media_connect_0 = false;
> +-	dm_dig->media_connect_1 = false;
> +-	rtlpriv->dm.dm_initialgain_enable = true;
> +-	dm_dig->bt30_cur_igi = 0x32;
> +-}
> +-
> + static void rtl92ee_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw)
> + {
> + 	u32 ret_value;
> +@@ -1089,10 +1060,11 @@ static void rtl92ee_dm_init_dynamic_atc_switch(struct ieee80211_hw *hw)
> + void rtl92ee_dm_init(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> ++	u32 cur_igvalue = rtl_get_bbreg(hw, DM_REG_IGI_A_11N, DM_BIT_IGI_11N);
> + 
> + 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
> + 
> +-	rtl92ee_dm_diginit(hw);
> ++	rtl_dm_diginit(hw, cur_igvalue);
> + 	rtl92ee_dm_init_rate_adaptive_mask(hw);
> + 	rtl92ee_dm_init_primary_cca_check(hw);
> + 	rtl92ee_dm_init_edca_turbo(hw);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0044-rtlwifi-rtl8723ae-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0044-rtlwifi-rtl8723ae-Convert-driver-to-use-common-DM-ta.patch
> new file mode 100644
> index 0000000..2f29e77
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0044-rtlwifi-rtl8723ae-Convert-driver-to-use-common-DM-ta.patch
> @@ -0,0 +1,62 @@
> +From 3592c54b6c8e85a1713515f463379c6a97bf8009 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:09 -0600
> +Subject: [PATCH 44/51] rtlwifi: rtl8723ae: Convert driver to use common DM
> + table initialization
> +
> +Convert driver rtl8723ae to use common routine rtl_dm_diginit().
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8723ae/dm.c | 27 +--------------------------
> + 1 file changed, 1 insertion(+), 26 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> +index 8bd124c..4c1c96c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
> +@@ -147,31 +147,6 @@ static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
> + 	{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}
> + };
> + 
> +-static void rtl8723e_dm_diginit(struct ieee80211_hw *hw)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
> +-
> +-	dm_digtable->dig_enable_flag = true;
> +-	dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
> +-	dm_digtable->cur_igvalue = 0x20;
> +-	dm_digtable->pre_igvalue = 0x0;
> +-	dm_digtable->cursta_cstate = DIG_STA_DISCONNECT;
> +-	dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
> +-	dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
> +-	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
> +-	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
> +-	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
> +-	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
> +-	dm_digtable->rx_gain_max = DM_DIG_MAX;
> +-	dm_digtable->rx_gain_min = DM_DIG_MIN;
> +-	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
> +-	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
> +-	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
> +-	dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
> +-	dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
> +-}
> +-
> + static u8 rtl8723e_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +@@ -819,7 +794,7 @@ void rtl8723e_dm_init(struct ieee80211_hw *hw)
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> + 
> + 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
> +-	rtl8723e_dm_diginit(hw);
> ++	rtl_dm_diginit(hw, 0x20);
> + 	rtl8723_dm_init_dynamic_txpower(hw);
> + 	rtl8723_dm_init_edca_turbo(hw);
> + 	rtl8723e_dm_init_rate_adaptive_mask(hw);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0045-rtlwifi-rtl8723be-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0045-rtlwifi-rtl8723be-Convert-driver-to-use-common-DM-ta.patch
> new file mode 100644
> index 0000000..8c5e5ff
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0045-rtlwifi-rtl8723be-Convert-driver-to-use-common-DM-ta.patch
> @@ -0,0 +1,69 @@
> +From ac2f0baefab920a3f9117993eb1455b40b265ab5 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:10 -0600
> +Subject: [PATCH 45/51] rtlwifi: rtl8723be: Convert driver to use common DM
> + table initialization
> +
> +Convert driver rtl8723be to use routine rtl_dm_diginit().
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8723be/dm.c | 32 ++---------------------------
> + 1 file changed, 2 insertions(+), 30 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> +index ddf45d9..2367e8f 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
> +@@ -212,35 +212,6 @@ void rtl8723be_dm_txpower_track_adjust(struct ieee80211_hw *hw, u8 type,
> + 		(pwr_val << 16) | (pwr_val << 24);
> + }
> + 
> +-static void rtl8723be_dm_diginit(struct ieee80211_hw *hw)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
> +-
> +-	dm_digtable->dig_enable_flag = true;
> +-	dm_digtable->cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
> +-	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
> +-	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
> +-	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
> +-	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
> +-	dm_digtable->rx_gain_max = DM_DIG_MAX;
> +-	dm_digtable->rx_gain_min = DM_DIG_MIN;
> +-	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
> +-	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
> +-	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
> +-	dm_digtable->pre_cck_cca_thres = 0xff;
> +-	dm_digtable->cur_cck_cca_thres = 0x83;
> +-	dm_digtable->forbidden_igi = DM_DIG_MIN;
> +-	dm_digtable->large_fa_hit = 0;
> +-	dm_digtable->recover_cnt = 0;
> +-	dm_digtable->dig_min_0 = DM_DIG_MIN;
> +-	dm_digtable->dig_min_1 = DM_DIG_MIN;
> +-	dm_digtable->media_connect_0 = false;
> +-	dm_digtable->media_connect_1 = false;
> +-	rtlpriv->dm.dm_initialgain_enable = true;
> +-	dm_digtable->bt30_cur_igi = 0x32;
> +-}
> +-
> + void rtl8723be_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +@@ -294,9 +265,10 @@ static void rtl8723be_dm_init_dynamic_atc_switch(struct ieee80211_hw *hw)
> + void rtl8723be_dm_init(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> ++	u32 cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
> + 
> + 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
> +-	rtl8723be_dm_diginit(hw);
> ++	rtl_dm_diginit(hw, cur_igvalue);
> + 	rtl8723be_dm_init_rate_adaptive_mask(hw);
> + 	rtl8723_dm_init_edca_turbo(hw);
> + 	rtl8723_dm_init_dynamic_bb_powersaving(hw);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0046-rtlwifi-rtl8821ae-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0046-rtlwifi-rtl8821ae-Convert-driver-to-use-common-DM-ta.patch
> new file mode 100644
> index 0000000..7c49dcb
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0046-rtlwifi-rtl8821ae-Convert-driver-to-use-common-DM-ta.patch
> @@ -0,0 +1,73 @@
> +From 9259ee79208a95aa20a9824717a9f22b0a52cccd Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:11 -0600
> +Subject: [PATCH 46/51] rtlwifi: rtl8821ae: Convert driver to use common DM
> + table initialization
> +
> +Convert driver to use routine rtl_dm_diginit().
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8821ae/dm.c | 31 ++---------------------------
> + 1 file changed, 2 insertions(+), 29 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> +index 4af4613..0b2082d 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
> +@@ -520,34 +520,6 @@ void rtl8821ae_dm_initialize_txpower_tracking_thermalmeter(
> + 	}
> + }
> + 
> +-static void rtl8821ae_dm_diginit(struct ieee80211_hw *hw)
> +-{
> +-	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +-	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
> +-
> +-	dm_digtable->cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
> +-	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
> +-	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
> +-	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
> +-	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
> +-	dm_digtable->rx_gain_max = DM_DIG_MAX;
> +-	dm_digtable->rx_gain_min = DM_DIG_MIN;
> +-	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
> +-	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
> +-	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
> +-	dm_digtable->pre_cck_cca_thres = 0xff;
> +-	dm_digtable->cur_cck_cca_thres = 0x83;
> +-	dm_digtable->forbidden_igi = DM_DIG_MIN;
> +-	dm_digtable->large_fa_hit = 0;
> +-	dm_digtable->recover_cnt = 0;
> +-	dm_digtable->dig_min_0 = DM_DIG_MIN;
> +-	dm_digtable->dig_min_1 = DM_DIG_MIN;
> +-	dm_digtable->media_connect_0 = false;
> +-	dm_digtable->media_connect_1 = false;
> +-	rtlpriv->dm.dm_initialgain_enable = true;
> +-	dm_digtable->bt30_cur_igi = 0x32;
> +-}
> +-
> + void rtl8821ae_dm_init_edca_turbo(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> +@@ -607,6 +579,7 @@ void rtl8821ae_dm_init(struct ieee80211_hw *hw)
> + {
> + 	struct rtl_priv *rtlpriv = rtl_priv(hw);
> + 	struct rtl_phy *rtlphy = &rtlpriv->phy;
> ++	u32 cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
> + 
> + 	spin_lock(&rtlpriv->locks.iqk_lock);
> + 	rtlphy->lck_inprogress = false;
> +@@ -614,7 +587,7 @@ void rtl8821ae_dm_init(struct ieee80211_hw *hw)
> + 
> + 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
> + 	rtl8821ae_dm_common_info_self_init(hw);
> +-	rtl8821ae_dm_diginit(hw);
> ++	rtl_dm_diginit(hw, cur_igvalue);
> + 	rtl8821ae_dm_init_rate_adaptive_mask(hw);
> + 	rtl8821ae_dm_init_edca_turbo(hw);
> + 	rtl8821ae_dm_initialize_txpower_tracking_thermalmeter(hw);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0047-rtlwifi-Move-macro-definitions-to-core.patch b/package/kernel/mac80211/patches/680-0047-rtlwifi-Move-macro-definitions-to-core.patch
> new file mode 100644
> index 0000000..faf34c1
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0047-rtlwifi-Move-macro-definitions-to-core.patch
> @@ -0,0 +1,140 @@
> +From ed0fb7eb2b2d27a07610b75d1f3a68cc22716347 Mon Sep 17 00:00:00 2001
> +From: Larry Finger <Larry.Finger@lwfinger.net>
> +Date: Tue, 6 Jan 2015 09:58:12 -0600
> +Subject: [PATCH 47/51] rtlwifi: Move macro definitions to core
> +
> +Several of the drivers still were defining their own copies of various
> +macros. These are all moved into the core.
> +
> +Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/core.h         | 1 +
> + drivers/net/wireless/rtlwifi/rtl8188ee/dm.h | 3 ---
> + drivers/net/wireless/rtlwifi/rtl8192ee/dm.h | 3 ---
> + drivers/net/wireless/rtlwifi/rtl8192se/dm.c | 6 +++---
> + drivers/net/wireless/rtlwifi/rtl8192se/dm.h | 1 -
> + drivers/net/wireless/rtlwifi/rtl8723be/dm.h | 3 ---
> + drivers/net/wireless/rtlwifi/rtl8821ae/dm.h | 9 ---------
> + 7 files changed, 4 insertions(+), 22 deletions(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
> +index 1cde356..7b64e34 100644
> +--- a/drivers/net/wireless/rtlwifi/core.h
> ++++ b/drivers/net/wireless/rtlwifi/core.h
> +@@ -42,6 +42,7 @@
> + 
> + #define DM_DIG_MAX			0x3e
> + #define DM_DIG_MIN			0x1e
> ++#define DM_DIG_MAX_AP			0x32
> + #define DM_DIG_BACKOFF_MAX		12
> + #define DM_DIG_BACKOFF_MIN		-4
> + #define DM_DIG_BACKOFF_DEFAULT		10
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> +index 51ad3f9..071ccee 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
> +@@ -186,9 +186,6 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW				25
> + #define BW_AUTO_SWITCH_LOW_HIGH				30
> + 
> +-#define DM_DIG_MAX_AP					0x32
> +-#define DM_DIG_MIN_AP					0x20
> +-
> + #define DM_DIG_FA_UPPER					0x3e
> + #define DM_DIG_FA_LOWER					0x1e
> + #define DM_DIG_FA_TH0					0x200
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
> +index 4880e19..107d5a4 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
> +@@ -189,9 +189,6 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW			25
> + #define BW_AUTO_SWITCH_LOW_HIGH			30
> + 
> +-#define DM_DIG_MAX_AP				0x32
> +-#define DM_DIG_MIN_AP				0x20
> +-
> + #define DM_DIG_FA_UPPER				0x3e
> + #define DM_DIG_FA_LOWER				0x1e
> + #define DM_DIG_FA_TH0				0x200
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
> +index 6cac70b..575980b 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
> +@@ -470,7 +470,7 @@ static void _rtl92s_dm_initial_gain_sta_beforeconnect(struct ieee80211_hw *hw)
> + 			if (digtable->backoff_enable_flag)
> + 				rtl92s_backoff_enable_flag(hw);
> + 			else
> +-				digtable->back_val = DM_DIG_BACKOFF;
> ++				digtable->back_val = DM_DIG_BACKOFF_MAX;
> + 
> + 			if ((digtable->rssi_val + 10 - digtable->back_val) >
> + 				digtable->rx_gain_max)
> +@@ -504,7 +504,7 @@ static void _rtl92s_dm_initial_gain_sta_beforeconnect(struct ieee80211_hw *hw)
> + 		digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
> + 		rtl92s_phy_set_fw_cmd(hw, FW_CMD_DIG_ENABLE);
> + 
> +-		digtable->back_val = DM_DIG_BACKOFF;
> ++		digtable->back_val = DM_DIG_BACKOFF_MAX;
> + 		digtable->cur_igvalue = rtlpriv->phy.default_initialgain[0];
> + 		digtable->pre_igvalue = 0;
> + 		return;
> +@@ -692,7 +692,7 @@ static void _rtl92s_dm_init_dig(struct ieee80211_hw *hw)
> + 
> + 	/* for dig debug rssi value */
> + 	digtable->rssi_val = 50;
> +-	digtable->back_val = DM_DIG_BACKOFF;
> ++	digtable->back_val = DM_DIG_BACKOFF_MAX;
> + 	digtable->rx_gain_max = DM_DIG_MAX;
> + 
> + 	digtable->rx_gain_min = DM_DIG_MIN;
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> +index be07d81..de6ac79 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
> +@@ -83,7 +83,6 @@ enum dm_ratr_sta {
> + 
> + #define	DM_DIG_HIGH_PWR_THRESH_HIGH	75
> + #define	DM_DIG_HIGH_PWR_THRESH_LOW	70
> +-#define	DM_DIG_BACKOFF			12
> + #define	DM_DIG_MIN_Netcore		0x12
> + 
> + void rtl92s_dm_watchdog(struct ieee80211_hw *hw);
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> +index 533b4f2..f752a2c 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
> +@@ -180,9 +180,6 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW			25
> + #define BW_AUTO_SWITCH_LOW_HIGH			30
> + 
> +-#define DM_DIG_MAX_AP				0x32
> +-#define DM_DIG_MIN_AP				0x20
> +-
> + #define DM_DIG_FA_UPPER				0x3e
> + #define DM_DIG_FA_LOWER				0x1e
> + #define DM_DIG_FA_TH0				0x200
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> +index 5516557..625a6bb 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> ++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
> +@@ -187,15 +187,6 @@
> + #define BW_AUTO_SWITCH_HIGH_LOW		25
> + #define BW_AUTO_SWITCH_LOW_HIGH		30
> + 
> +-#define DM_FALSEALARM_THRESH_LOW	400
> +-#define DM_FALSEALARM_THRESH_HIGH	1000
> +-
> +-#define DM_DIG_MAX					0x3e
> +-#define DM_DIG_MIN					0x1e
> +-
> +-#define DM_DIG_MAX_AP				0x32
> +-#define DM_DIG_MIN_AP				0x20
> +-
> + #define DM_DIG_FA_UPPER				0x3e
> + #define DM_DIG_FA_LOWER				0x1e
> + #define DM_DIG_FA_TH0				200
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0048-rtlwifi-rtl8192de-remove-redundant-else-if-check.patch b/package/kernel/mac80211/patches/680-0048-rtlwifi-rtl8192de-remove-redundant-else-if-check.patch
> new file mode 100644
> index 0000000..9457e6d
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0048-rtlwifi-rtl8192de-remove-redundant-else-if-check.patch
> @@ -0,0 +1,46 @@
> +From 59b23ebd7fd0af3facd174e96ee4dbc1494fa215 Mon Sep 17 00:00:00 2001
> +From: Colin Ian King <colin.king@canonical.com>
> +Date: Tue, 13 Jan 2015 14:07:34 +0000
> +Subject: [PATCH 48/51] rtlwifi/rtl8192de: remove redundant else if check
> +
> +The else if check condition checks for the opposite of the
> +if check, hence the else if check is redundant and can be
> +replaced with a simple else:
> +
> +if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) {
> +	..
> +} else if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY) {
> +	..
> +}
> +
> +replaced with:
> +
> +if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) {
> +	..
> +} else {
> +	..
> +}
> +
> +Signed-off-by: Colin Ian King <colin.king@canonical.com>
> +Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 2 +-
> + 1 file changed, 1 insertion(+), 1 deletion(-)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
> +index 280c3da..01bcc2d 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
> +@@ -546,7 +546,7 @@ static bool _rtl92de_llt_table_init(struct ieee80211_hw *hw)
> + 		txpktbuf_bndy = 246;
> + 		value8 = 0;
> + 		value32 = 0x80bf0d29;
> +-	} else if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY) {
> ++	} else {
> + 		maxPage = 127;
> + 		txpktbuf_bndy = 123;
> + 		value8 = 0;
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0049-rtlwifi-add-support-to-send-beacon-frame.patch b/package/kernel/mac80211/patches/680-0049-rtlwifi-add-support-to-send-beacon-frame.patch
> new file mode 100644
> index 0000000..d7e8abe
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0049-rtlwifi-add-support-to-send-beacon-frame.patch
> @@ -0,0 +1,47 @@
> +From 33511b157bbcebaef853cc1811992b664a2e5862 Mon Sep 17 00:00:00 2001
> +From: Taehee Yoo <ap420073@gmail.com>
> +Date: Wed, 21 Jan 2015 16:58:19 +0900
> +Subject: [PATCH 49/51] rtlwifi: add support to send beacon frame.
> +
> +In AP mode, beacon frame is necessary to keep connection.
> +this patch adds a sending beacon frame routine in initialization routine.
> +
> +Signed-off-by: Taehee Yoo <ap420073@gmail.com>
> +Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/core.c | 11 +++++++++++
> + 1 file changed, 11 insertions(+)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
> +index eb20316..a31a127 100644
> +--- a/drivers/net/wireless/rtlwifi/core.c
> ++++ b/drivers/net/wireless/rtlwifi/core.c
> +@@ -1010,6 +1010,16 @@ static int rtl_op_conf_tx(struct ieee80211_hw *hw,
> + 	return 0;
> + }
> + 
> ++static void send_beacon_frame(struct ieee80211_hw *hw,
> ++			      struct ieee80211_vif *vif)
> ++{
> ++	struct rtl_priv *rtlpriv = rtl_priv(hw);
> ++	struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
> ++
> ++	if (skb)
> ++		rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, NULL);
> ++}
> ++
> + static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
> + 				    struct ieee80211_vif *vif,
> + 				    struct ieee80211_bss_conf *bss_conf,
> +@@ -1040,6 +1050,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
> + 
> + 				if (rtlpriv->cfg->ops->linked_set_reg)
> + 					rtlpriv->cfg->ops->linked_set_reg(hw);
> ++				send_beacon_frame(hw, vif);
> + 			}
> + 		}
> + 		if ((changed & BSS_CHANGED_BEACON_ENABLED &&
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0050-rtl8192cu-fix-the-mesh-beaconing.patch b/package/kernel/mac80211/patches/680-0050-rtl8192cu-fix-the-mesh-beaconing.patch
> new file mode 100644
> index 0000000..8254fde
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0050-rtl8192cu-fix-the-mesh-beaconing.patch
> @@ -0,0 +1,31 @@
> +From 0b70dc273c13da02241b5b9e76fca5a714bd2965 Mon Sep 17 00:00:00 2001
> +From: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
> +Date: Fri, 23 Jan 2015 16:59:24 +0800
> +Subject: [PATCH 50/51] rtl8192cu: fix the mesh beaconing
> +
> +Patch "rtlwifi: add support to send beacon frame" allows
> +the beaconing of rtl8192cu. But mesh beaconing is not
> +working. Fix this.
> +
> +Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
> +Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 1 +
> + 1 file changed, 1 insertion(+)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> +index 5513217..e5a7c4f 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> +@@ -1509,6 +1509,7 @@ void rtl92cu_set_beacon_related_registers(struct ieee80211_hw *hw)
> + 	/* TODO: Modify later (Find the right parameters)
> + 	 * NOTE: Fix test chip's bug (about contention windows's randomness) */
> + 	if ((mac->opmode == NL80211_IFTYPE_ADHOC) ||
> ++	    (mac->opmode == NL80211_IFTYPE_MESH_POINT) ||
> + 	    (mac->opmode == NL80211_IFTYPE_AP)) {
> + 		rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_CCK, 0x50);
> + 		rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_OFDM, 0x50);
> +-- 
> +2.2.2
> +
> diff --git a/package/kernel/mac80211/patches/680-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch b/package/kernel/mac80211/patches/680-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch
> new file mode 100644
> index 0000000..35074be
> --- /dev/null
> +++ b/package/kernel/mac80211/patches/680-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch
> @@ -0,0 +1,38 @@
> +From 314112e0023acddaae1b43d549bc03be29a146ce Mon Sep 17 00:00:00 2001
> +From: Taehee Yoo <ap420073@gmail.com>
> +Date: Sat, 24 Jan 2015 20:55:40 +0900
> +Subject: [PATCH 51/51] rtlwifi: rtl8192cu: Set fw_ready flag
> +
> +After rtl8192cu download firmware routine, set fw_ready flag.
> +
> +Signed-off-by: Taehee Yoo <ap420073@gmail.com>
> +Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
> +Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
> +---
> + drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 3 +++
> + 1 file changed, 3 insertions(+)
> +
> +diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> +index e5a7c4f..fe4b699 100644
> +--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> ++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
> +@@ -1000,6 +1000,7 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw)
> + 	local_save_flags(flags);
> + 	local_irq_enable();
> + 
> ++	rtlhal->fw_ready = false;
> + 	rtlhal->hw_type = HARDWARE_TYPE_RTL8192CU;
> + 	err = _rtl92cu_init_mac(hw);
> + 	if (err) {
> +@@ -1013,6 +1014,8 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw)
> + 		err = 1;
> + 		goto exit;
> + 	}
> ++
> ++	rtlhal->fw_ready = true;
> + 	rtlhal->last_hmeboxnum = 0; /* h2c */
> + 	_rtl92cu_phy_param_tab_init(hw);
> + 	rtl92cu_phy_mac_config(hw);
> +-- 
> +2.2.2
> +
>

Patch
diff mbox

diff --git a/package/kernel/mac80211/patches/680-0002-rtlwifi-Fix-setting-of-tx-descriptor-for-new-trx-flo.patch b/package/kernel/mac80211/patches/680-0002-rtlwifi-Fix-setting-of-tx-descriptor-for-new-trx-flo.patch
new file mode 100644
index 0000000..fbe941b
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0002-rtlwifi-Fix-setting-of-tx-descriptor-for-new-trx-flo.patch
@@ -0,0 +1,39 @@ 
+From fb6eaf2ccca7d3580931bcb4b735101b461f38cf Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Wed, 5 Nov 2014 19:10:52 -0600
+Subject: [PATCH 02/51] rtlwifi: Fix setting of tx descriptor for new trx flow
+
+Device RTL8192EE uses a new form of trx flow. This fix sets up the descriptors
+correctly.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/pci.c | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
+index 25daa87..116f746 100644
+--- a/drivers/net/wireless/rtlwifi/pci.c
++++ b/drivers/net/wireless/rtlwifi/pci.c
+@@ -1127,9 +1127,14 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw)
+ 
+ 	__skb_queue_tail(&ring->queue, pskb);
+ 
+-	rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN,
+-				    &temp_one);
+-
++	if (rtlpriv->use_new_trx_flow) {
++		temp_one = 4;
++		rtlpriv->cfg->ops->set_desc(hw, (u8 *)pbuffer_desc, true,
++					    HW_DESC_OWN, (u8 *)&temp_one);
++	} else {
++		rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc, true, HW_DESC_OWN,
++					    &temp_one);
++	}
+ 	return;
+ }
+ 
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0003-rtlwifi-Fix-errors-in-descriptor-manipulation.patch b/package/kernel/mac80211/patches/680-0003-rtlwifi-Fix-errors-in-descriptor-manipulation.patch
new file mode 100644
index 0000000..e4cfcaf
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0003-rtlwifi-Fix-errors-in-descriptor-manipulation.patch
@@ -0,0 +1,42 @@ 
+From caea2172c23465a77556b2e1d06412b532b90235 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Wed, 5 Nov 2014 19:10:53 -0600
+Subject: [PATCH 03/51] rtlwifi: Fix errors in descriptor manipulation
+
+There are typos in the handling of the descriptor pointers where the wrong
+descriptor is referenced. There is also an error in which the pointer is
+incremented twice.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/pci.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
+index 116f746..6d2b628 100644
+--- a/drivers/net/wireless/rtlwifi/pci.c
++++ b/drivers/net/wireless/rtlwifi/pci.c
+@@ -1375,9 +1375,9 @@ static void _rtl_pci_free_tx_ring(struct ieee80211_hw *hw,
+ 	ring->desc = NULL;
+ 	if (rtlpriv->use_new_trx_flow) {
+ 		pci_free_consistent(rtlpci->pdev,
+-				    sizeof(*ring->desc) * ring->entries,
++				    sizeof(*ring->buffer_desc) * ring->entries,
+ 				    ring->buffer_desc, ring->buffer_desc_dma);
+-		ring->desc = NULL;
++		ring->buffer_desc = NULL;
+ 	}
+ }
+ 
+@@ -1548,7 +1548,6 @@ int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw)
+ 							 true,
+ 							 HW_DESC_TXBUFF_ADDR),
+ 						 skb->len, PCI_DMA_TODEVICE);
+-				ring->idx = (ring->idx + 1) % ring->entries;
+ 				kfree_skb(skb);
+ 				ring->idx = (ring->idx + 1) % ring->entries;
+ 			}
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0004-rtlwifi-rtl8192se-Fix-connection-problems.patch b/package/kernel/mac80211/patches/680-0004-rtlwifi-rtl8192se-Fix-connection-problems.patch
new file mode 100644
index 0000000..15a8b1b
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0004-rtlwifi-rtl8192se-Fix-connection-problems.patch
@@ -0,0 +1,122 @@ 
+From d1cd5ba4ca8b41793f4e581dd1dbf46b7f2cf691 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Fri, 7 Nov 2014 10:05:12 -0600
+Subject: [PATCH 04/51] rtlwifi: rtl8192se: Fix connection problems
+
+Changes in the vendor driver were added to rtlwifi, but some updates
+to rtl8192se were missed, and the driver could neither scan nor connect.
+There are other changes that will enhance performance, but this minimal
+set fix the basic functionality.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/pci.c           |  3 ++-
+ drivers/net/wireless/rtlwifi/rtl8192se/hw.c  |  7 +++++--
+ drivers/net/wireless/rtlwifi/rtl8192se/phy.c |  2 ++
+ drivers/net/wireless/rtlwifi/rtl8192se/sw.c  | 16 ++++++++++++++++
+ 4 files changed, 25 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
+index 6d2b628..61f5d36 100644
+--- a/drivers/net/wireless/rtlwifi/pci.c
++++ b/drivers/net/wireless/rtlwifi/pci.c
+@@ -842,7 +842,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
+ 			break;
+ 		}
+ 		/* handle command packet here */
+-		if (rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) {
++		if (rtlpriv->cfg->ops->rx_command_packet &&
++		    rtlpriv->cfg->ops->rx_command_packet(hw, stats, skb)) {
+ 				dev_kfree_skb_any(skb);
+ 				goto end;
+ 		}
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+index 00e0670..5761d5b 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+@@ -1201,6 +1201,9 @@ static int _rtl92se_set_media_status(struct ieee80211_hw *hw,
+ 
+ 	}
+ 
++	if (type != NL80211_IFTYPE_AP &&
++	    rtlpriv->mac80211.link_state < MAC80211_LINKED)
++		bt_msr = rtl_read_byte(rtlpriv, MSR) & ~MSR_LINK_MASK;
+ 	rtl_write_byte(rtlpriv, (MSR), bt_msr);
+ 
+ 	temp = rtl_read_dword(rtlpriv, TCR);
+@@ -1262,6 +1265,7 @@ void rtl92se_enable_interrupt(struct ieee80211_hw *hw)
+ 	rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]);
+ 	/* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */
+ 	rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F);
++	rtlpci->irq_enabled = true;
+ }
+ 
+ void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
+@@ -1276,8 +1280,7 @@ void rtl92se_disable_interrupt(struct ieee80211_hw *hw)
+ 	rtlpci = rtl_pcidev(rtl_pcipriv(hw));
+ 	rtl_write_dword(rtlpriv, INTA_MASK, 0);
+ 	rtl_write_dword(rtlpriv, INTA_MASK + 4, 0);
+-
+-	synchronize_irq(rtlpci->pdev->irq);
++	rtlpci->irq_enabled = false;
+ }
+ 
+ static u8 _rtl92s_set_sysclk(struct ieee80211_hw *hw, u8 data)
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
+index 77c5b5f..4b4612f 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c
+@@ -399,6 +399,8 @@ static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw *hw,
+ 		case 2:
+ 			currentcmd = &postcommoncmd[*step];
+ 			break;
++		default:
++			return true;
+ 		}
+ 
+ 		if (currentcmd->cmdid == CMDID_END) {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+index aadba29..fb00386 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+@@ -236,6 +236,19 @@ static void rtl92s_deinit_sw_vars(struct ieee80211_hw *hw)
+ 	}
+ }
+ 
++static bool rtl92se_is_tx_desc_closed(struct ieee80211_hw *hw, u8 hw_queue,
++				      u16 index)
++{
++	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
++	struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
++	u8 *entry = (u8 *)(&ring->desc[ring->idx]);
++	u8 own = (u8)rtl92se_get_desc(entry, true, HW_DESC_OWN);
++
++	if (own)
++		return false;
++	return true;
++}
++
+ static struct rtl_hal_ops rtl8192se_hal_ops = {
+ 	.init_sw_vars = rtl92s_init_sw_vars,
+ 	.deinit_sw_vars = rtl92s_deinit_sw_vars,
+@@ -269,6 +282,7 @@ static struct rtl_hal_ops rtl8192se_hal_ops = {
+ 	.led_control = rtl92se_led_control,
+ 	.set_desc = rtl92se_set_desc,
+ 	.get_desc = rtl92se_get_desc,
++	.is_tx_desc_closed = rtl92se_is_tx_desc_closed,
+ 	.tx_polling = rtl92se_tx_polling,
+ 	.enable_hw_sec = rtl92se_enable_hw_security_config,
+ 	.set_key = rtl92se_set_key,
+@@ -306,6 +320,8 @@ static struct rtl_hal_cfg rtl92se_hal_cfg = {
+ 	.maps[MAC_RCR_ACRC32] = RCR_ACRC32,
+ 	.maps[MAC_RCR_ACF] = RCR_ACF,
+ 	.maps[MAC_RCR_AAP] = RCR_AAP,
++	.maps[MAC_HIMR] = INTA_MASK,
++	.maps[MAC_HIMRE] = INTA_MASK + 4,
+ 
+ 	.maps[EFUSE_TEST] = REG_EFUSE_TEST,
+ 	.maps[EFUSE_CTRL] = REG_EFUSE_CTRL,
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0006-rtlwifi-update-RCR-register-in-rtl_op_configure_filt.patch b/package/kernel/mac80211/patches/680-0006-rtlwifi-update-RCR-register-in-rtl_op_configure_filt.patch
new file mode 100644
index 0000000..0d85398
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0006-rtlwifi-update-RCR-register-in-rtl_op_configure_filt.patch
@@ -0,0 +1,79 @@ 
+From 99958588fce8f570d1d48bd67775b8e6c5f92623 Mon Sep 17 00:00:00 2001
+From: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
+Date: Sat, 22 Nov 2014 12:18:26 +0100
+Subject: [PATCH 06/51] rtlwifi: update RCR register in
+ rtl_op_configure_filter()
+
+Reconfigure RCR register in rtl_op_configure_filter() in order to apply RX
+filter configuration
+
+Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/core.c | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
+index af52f0b..5fc6f52 100644
+--- a/drivers/net/wireless/rtlwifi/core.c
++++ b/drivers/net/wireless/rtlwifi/core.c
+@@ -786,6 +786,7 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
+ 				    unsigned int changed_flags,
+ 				    unsigned int *new_flags, u64 multicast)
+ {
++	bool update_rcr = false;
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+ 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
+ 
+@@ -806,6 +807,7 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
+ 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
+ 				 "Disable receive multicast frame\n");
+ 		}
++		update_rcr = true;
+ 	}
+ 
+ 	if (changed_flags & FIF_FCSFAIL) {
+@@ -818,6 +820,8 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
+ 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
+ 				 "Disable receive FCS error frame\n");
+ 		}
++		if (!update_rcr)
++			update_rcr = true;
+ 	}
+ 
+ 	/* if ssid not set to hw don't check bssid
+@@ -832,6 +836,8 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
+ 				rtlpriv->cfg->ops->set_chk_bssid(hw, false);
+ 			else
+ 				rtlpriv->cfg->ops->set_chk_bssid(hw, true);
++			if (update_rcr)
++				update_rcr = false;
+ 		}
+ 	}
+ 
+@@ -846,6 +852,8 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
+ 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
+ 				 "Disable receive control frame.\n");
+ 		}
++		if (!update_rcr)
++			update_rcr = true;
+ 	}
+ 
+ 	if (changed_flags & FIF_OTHER_BSS) {
+@@ -858,7 +866,13 @@ static void rtl_op_configure_filter(struct ieee80211_hw *hw,
+ 			RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD,
+ 				 "Disable receive other BSS's frame.\n");
+ 		}
++		if (!update_rcr)
++			update_rcr = true;
+ 	}
++
++	if (update_rcr)
++		rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR,
++					      (u8 *)(&mac->rx_conf));
+ }
+ static int rtl_op_sta_add(struct ieee80211_hw *hw,
+ 			 struct ieee80211_vif *vif,
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0007-net-wireless-rtlwifi-Do-not-always-include-drivers-i.patch b/package/kernel/mac80211/patches/680-0007-net-wireless-rtlwifi-Do-not-always-include-drivers-i.patch
new file mode 100644
index 0000000..59cb09e
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0007-net-wireless-rtlwifi-Do-not-always-include-drivers-i.patch
@@ -0,0 +1,74 @@ 
+From 927a70874c34e862f6aea5ad9c4a5d2c3f140bcd Mon Sep 17 00:00:00 2001
+From: Andreas Ruprecht <rupran@einserver.de>
+Date: Mon, 24 Nov 2014 19:34:31 +0100
+Subject: [PATCH 07/51] net: wireless: rtlwifi: Do not always include drivers
+ in obj-m
+
+In four of the rtlwifi drivers, the Makefile contains superfluous
+statements indicating the compilation of the driver as an LKM
+regardless of the corresponding Kconfig option.
+
+If the corresponding option is set to 'y', the build system will then
+see the object file in obj-m and obj-y, which leads to a compilation
+as a built-in only. Even though this leads to the desired behavior,
+the unconditional appearance in obj-m is confusing for someone reading
+the Makefile.
+
+This patch removes the superfluous Makefile statements.
+
+Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ee/Makefile | 3 ---
+ drivers/net/wireless/rtlwifi/rtl8723ae/Makefile | 3 ---
+ drivers/net/wireless/rtlwifi/rtl8723be/Makefile | 3 ---
+ drivers/net/wireless/rtlwifi/rtl8821ae/Makefile | 3 ---
+ 4 files changed, 12 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile b/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
+index 11952b9..6bd46a9 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
+@@ -1,6 +1,3 @@
+-obj-m := rtl8192ee.o
+-
+-
+ rtl8192ee-objs :=		\
+ 		dm.o		\
+ 		fw.o		\
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/Makefile b/drivers/net/wireless/rtlwifi/rtl8723ae/Makefile
+index 9c34a85..6220672 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/Makefile
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/Makefile
+@@ -1,6 +1,3 @@
+-obj-m := rtl8723ae.o
+-
+-
+ rtl8723ae-objs :=		\
+ 		dm.o		\
+ 		fw.o		\
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/Makefile b/drivers/net/wireless/rtlwifi/rtl8723be/Makefile
+index 59e416a..a77c341 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/Makefile
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/Makefile
+@@ -1,6 +1,3 @@
+-obj-m := rtl8723be.o
+-
+-
+ rtl8723be-objs :=		\
+ 		dm.o		\
+ 		fw.o		\
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/Makefile b/drivers/net/wireless/rtlwifi/rtl8821ae/Makefile
+index 87ad604..f7a26f7 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/Makefile
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/Makefile
+@@ -1,6 +1,3 @@
+-obj-m := rtl8821ae.o
+-
+-
+ rtl8821ae-objs :=		\
+ 		dm.o		\
+ 		fw.o		\
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0008-net-wireless-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch b/package/kernel/mac80211/patches/680-0008-net-wireless-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch
new file mode 100644
index 0000000..aa409f6
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0008-net-wireless-rtlwifi-rtl8192ee-Fix-compilation-of-th.patch
@@ -0,0 +1,29 @@ 
+From b880c6deabacc415488984f6a79918ec0fa2e53d Mon Sep 17 00:00:00 2001
+From: Andreas Ruprecht <rupran@einserver.de>
+Date: Mon, 24 Nov 2014 19:34:32 +0100
+Subject: [PATCH 08/51] net: wireless: rtlwifi: rtl8192ee: Fix compilation of
+ the driver
+
+In the Makefile for this driver, the wrong Kconfig option is used
+to trigger the compilation of the object file. This leads to the
+driver only being included into the kernel when both CONFIG_RTL8821AE
+and CONFIG_RTL8192AE are set to "y".
+
+Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ee/Makefile | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+Index: compat-wireless-2014-11-04/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
+===================================================================
+--- compat-wireless-2014-11-04.orig/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
++++ compat-wireless-2014-11-04/drivers/net/wireless/rtlwifi/rtl8192ee/Makefile
+@@ -11,6 +11,6 @@ rtl8192ee-objs :=		\
+ 		trx.o		\
+ 
+ 
+-obj-$(CPTCFG_RTL8821AE) += rtl8192ee.o
++obj-$(CPTCFG_RTL8192EE) += rtl8192ee.o
+ 
+ ccflags-y += -D__CHECK_ENDIAN__
diff --git a/package/kernel/mac80211/patches/680-0009-rtlwifi-rtl8821ae-Fix-5G-detection-problem.patch b/package/kernel/mac80211/patches/680-0009-rtlwifi-rtl8821ae-Fix-5G-detection-problem.patch
new file mode 100644
index 0000000..03a5d3f
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0009-rtlwifi-rtl8821ae-Fix-5G-detection-problem.patch
@@ -0,0 +1,39 @@ 
+From a91ed1901a80b401afa1b718d941d3450d868151 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 25 Nov 2014 10:32:06 -0600
+Subject: [PATCH 09/51] rtlwifi: rtl8821ae: Fix 5G detection problem
+
+The changes associated with moving this driver from staging to the regular
+tree missed one section setting the allowable rates for the 5GHz band.
+
+This patch is needed to fix the regression reported in Bug #88811
+(https://bugzilla.kernel.org/show_bug.cgi?id=88811).
+
+Reported-by: Valerio Passini <valerio.passini@unicam.it>
+Tested-by: Valerio Passini <valerio.passini@unicam.it>
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Cc: Valerio Passini <valerio.passini@unicam.it>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8821ae/hw.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
+index 310d316..8ec8200 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/hw.c
+@@ -3672,8 +3672,9 @@ static void rtl8821ae_update_hal_rate_mask(struct ieee80211_hw *hw,
+ 		mac->opmode == NL80211_IFTYPE_ADHOC)
+ 		macid = sta->aid + 1;
+ 	if (wirelessmode == WIRELESS_MODE_N_5G ||
+-	    wirelessmode == WIRELESS_MODE_AC_5G)
+-		ratr_bitmap = sta->supp_rates[NL80211_BAND_5GHZ];
++	    wirelessmode == WIRELESS_MODE_AC_5G ||
++	    wirelessmode == WIRELESS_MODE_A)
++		ratr_bitmap = sta->supp_rates[NL80211_BAND_5GHZ] << 4;
+ 	else
+ 		ratr_bitmap = sta->supp_rates[NL80211_BAND_2GHZ];
+ 
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0010-rtlwifi-Change-order-in-device-startup.patch b/package/kernel/mac80211/patches/680-0010-rtlwifi-Change-order-in-device-startup.patch
new file mode 100644
index 0000000..5ed3db4
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0010-rtlwifi-Change-order-in-device-startup.patch
@@ -0,0 +1,62 @@ 
+From 7d63a5f9b25ba6b130da8eb2d32a72b1462d0249 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 25 Nov 2014 10:32:07 -0600
+Subject: [PATCH 10/51] rtlwifi: Change order in device startup
+
+The existing order of steps when starting the PCI devices works for
+2.4G devices, but fails to initialize the 5G section of the RTL8821AE
+hardware.
+
+This patch is needed to fix the regression reported in Bug #88811
+(https://bugzilla.kernel.org/show_bug.cgi?id=88811).
+
+Reported-by: Valerio Passini <valerio.passini@unicam.it>
+Tested-by: Valerio Passini <valerio.passini@unicam.it>
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Cc: Valerio Passini <valerio.passini@unicam.it>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/pci.c | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
+index 61f5d36..846a2e6 100644
+--- a/drivers/net/wireless/rtlwifi/pci.c
++++ b/drivers/net/wireless/rtlwifi/pci.c
+@@ -2249,6 +2249,16 @@ int rtl_pci_probe(struct pci_dev *pdev,
+ 	/*like read eeprom and so on */
+ 	rtlpriv->cfg->ops->read_eeprom_info(hw);
+ 
++	if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
++		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
++		err = -ENODEV;
++		goto fail3;
++	}
++	rtlpriv->cfg->ops->init_sw_leds(hw);
++
++	/*aspm */
++	rtl_pci_init_aspm(hw);
++
+ 	/* Init mac80211 sw */
+ 	err = rtl_init_core(hw);
+ 	if (err) {
+@@ -2264,16 +2274,6 @@ int rtl_pci_probe(struct pci_dev *pdev,
+ 		goto fail3;
+ 	}
+ 
+-	if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
+-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
+-		err = -ENODEV;
+-		goto fail3;
+-	}
+-	rtlpriv->cfg->ops->init_sw_leds(hw);
+-
+-	/*aspm */
+-	rtl_pci_init_aspm(hw);
+-
+ 	err = ieee80211_register_hw(hw);
+ 	if (err) {
+ 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0011-rtlwifi-rtl8192ce-Fix-editing-error-that-causes-sile.patch b/package/kernel/mac80211/patches/680-0011-rtlwifi-rtl8192ce-Fix-editing-error-that-causes-sile.patch
new file mode 100644
index 0000000..6186b5c
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0011-rtlwifi-rtl8192ce-Fix-editing-error-that-causes-sile.patch
@@ -0,0 +1,47 @@ 
+From 99a82f734aa6c6d397e029e6dfa933f04e0fa8c8 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Fri, 28 Nov 2014 10:41:14 -0600
+Subject: [PATCH 11/51] rtlwifi: rtl8192ce: Fix editing error that causes
+ silent memory corruption
+
+In the major update of the rtlwifi-family of drivers, there was an editing
+mistake. Unfortunately, this particular error leads to memory corruption that
+silently leads to failure of the system. This patch is one of three needed to
+fix the kernel regression reported at https://bugzilla.kernel.org/show_bug.cgi?id=88951.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Reported-by: Catalin Iacob <iacobcatalin@gmail.com>
+Tested-by: Catalin Iacob <iacobcatalin@gmail.com>
+Cc: Catalin Iacob <iacobcatalin@gmail.com>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+index dc3d20b..0916275 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+@@ -720,16 +720,15 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
+ 			break;
+ 		}
+ 	} else {
+-		struct rx_desc_92c *pdesc = (struct rx_desc_92c *)p_desc;
+ 		switch (desc_name) {
+ 		case HW_DESC_OWN:
+-			ret = GET_RX_DESC_OWN(pdesc);
++			ret = GET_RX_DESC_OWN(p_desc);
+ 			break;
+ 		case HW_DESC_RXPKT_LEN:
+-			ret = GET_RX_DESC_PKT_LEN(pdesc);
++			ret = GET_RX_DESC_PKT_LEN(p_desc);
+ 			break;
+ 		case HW_DESC_RXBUFF_ADDR:
+-			ret = GET_RX_STATUS_DESC_BUFF_ADDR(pdesc);
++			ret = GET_RX_DESC_BUFF_ADDR(p_desc);
+ 			break;
+ 		default:
+ 			RT_ASSERT(false, "ERR rxdesc :%d not process\n",
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0012-rtlwifi-rtl8192ce-Fix-kernel-crashes-due-to-missing-.patch b/package/kernel/mac80211/patches/680-0012-rtlwifi-rtl8192ce-Fix-kernel-crashes-due-to-missing-.patch
new file mode 100644
index 0000000..03e8132
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0012-rtlwifi-rtl8192ce-Fix-kernel-crashes-due-to-missing-.patch
@@ -0,0 +1,88 @@ 
+From f892914c03131a445b926b82815b03162c19288e Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Fri, 28 Nov 2014 10:41:15 -0600
+Subject: [PATCH 12/51] rtlwifi: rtl8192ce: Fix kernel crashes due to missing
+ callback entry
+
+In the major update of the rtlwifi-family of drivers, one of the callback entries
+was missed, which leads to memory corruption. Unfortunately, this corruption
+never caused a kernel oops, but showed up in other parts of the system.
+This patch is one of three needed to fix the kernel regression reported at
+https://bugzilla.kernel.org/show_bug.cgi?id=88951.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Reported-by: Catalin Iacob <iacobcatalin@gmail.com>
+Tested-by: Catalin Iacob <iacobcatalin@gmail.com>
+Cc: Catalin Iacob <iacobcatalin@gmail.com>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ce/sw.c  |  3 +++
+ drivers/net/wireless/rtlwifi/rtl8192ce/trx.c | 17 +++++++++++++++++
+ drivers/net/wireless/rtlwifi/rtl8192ce/trx.h |  2 ++
+ 3 files changed, 22 insertions(+)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+index 46ea076..dd5aa08 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+@@ -228,6 +228,7 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = {
+ 	.led_control = rtl92ce_led_control,
+ 	.set_desc = rtl92ce_set_desc,
+ 	.get_desc = rtl92ce_get_desc,
++	.is_tx_desc_closed = rtl92ce_is_tx_desc_closed,
+ 	.tx_polling = rtl92ce_tx_polling,
+ 	.enable_hw_sec = rtl92ce_enable_hw_security_config,
+ 	.set_key = rtl92ce_set_key,
+@@ -271,6 +272,8 @@ static struct rtl_hal_cfg rtl92ce_hal_cfg = {
+ 	.maps[MAC_RCR_ACRC32] = ACRC32,
+ 	.maps[MAC_RCR_ACF] = ACF,
+ 	.maps[MAC_RCR_AAP] = AAP,
++	.maps[MAC_HIMR] = REG_HIMR,
++	.maps[MAC_HIMRE] = REG_HIMRE,
+ 
+ 	.maps[EFUSE_TEST] = REG_EFUSE_TEST,
+ 	.maps[EFUSE_CTRL] = REG_EFUSE_CTRL,
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+index 0916275..e88dcd0 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+@@ -739,6 +739,23 @@ u32 rtl92ce_get_desc(u8 *p_desc, bool istx, u8 desc_name)
+ 	return ret;
+ }
+ 
++bool rtl92ce_is_tx_desc_closed(struct ieee80211_hw *hw,
++			       u8 hw_queue, u16 index)
++{
++	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
++	struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue];
++	u8 *entry = (u8 *)(&ring->desc[ring->idx]);
++	u8 own = (u8)rtl92ce_get_desc(entry, true, HW_DESC_OWN);
++
++	/*beacon packet will only use the first
++	 *descriptor defautly,and the own may not
++	 *be cleared by the hardware
++	 */
++	if (own)
++		return false;
++	return true;
++}
++
+ void rtl92ce_tx_polling(struct ieee80211_hw *hw, u8 hw_queue)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
+index 9a39ec4..4bec4b0 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.h
+@@ -723,6 +723,8 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
+ void rtl92ce_set_desc(struct ieee80211_hw *hw, u8 *pdesc, bool istx,
+ 		      u8 desc_name, u8 *val);
+ u32 rtl92ce_get_desc(u8 *pdesc, bool istx, u8 desc_name);
++bool rtl92ce_is_tx_desc_closed(struct ieee80211_hw *hw,
++			       u8 hw_queue, u16 index);
+ void rtl92ce_tx_polling(struct ieee80211_hw *hw, u8 hw_queue);
+ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
+ 			     bool b_firstseg, bool b_lastseg,
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0013-rtlwifi-rtl8192ce-Fix-missing-interrupt-ready-flag.patch b/package/kernel/mac80211/patches/680-0013-rtlwifi-rtl8192ce-Fix-missing-interrupt-ready-flag.patch
new file mode 100644
index 0000000..6f29b9f
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0013-rtlwifi-rtl8192ce-Fix-missing-interrupt-ready-flag.patch
@@ -0,0 +1,42 @@ 
+From 87141db0848aa20c43d453f5545efc8f390d4372 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Fri, 28 Nov 2014 10:41:16 -0600
+Subject: [PATCH 13/51] rtlwifi: rtl8192ce: Fix missing interrupt ready flag
+
+Proper operation with the rewritten PCI mini driver requires that a flag be set
+when interrupts are enabled. This flag was missed.  This patch is one of three needed to
+fix the kernel regression reported at https://bugzilla.kernel.org/show_bug.cgi?id=88951.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Reported-by: Catalin Iacob <iacobcatalin@gmail.com>
+Tested-by: Catalin Iacob <iacobcatalin@gmail.com>
+Cc: Catalin Iacob <iacobcatalin@gmail.com>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+index 55357d6..d2ec516 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+@@ -1287,6 +1287,7 @@ void rtl92ce_enable_interrupt(struct ieee80211_hw *hw)
+ 
+ 	rtl_write_dword(rtlpriv, REG_HIMR, rtlpci->irq_mask[0] & 0xFFFFFFFF);
+ 	rtl_write_dword(rtlpriv, REG_HIMRE, rtlpci->irq_mask[1] & 0xFFFFFFFF);
++	rtlpci->irq_enabled = true;
+ }
+ 
+ void rtl92ce_disable_interrupt(struct ieee80211_hw *hw)
+@@ -1296,7 +1297,7 @@ void rtl92ce_disable_interrupt(struct ieee80211_hw *hw)
+ 
+ 	rtl_write_dword(rtlpriv, REG_HIMR, IMR8190_DISABLED);
+ 	rtl_write_dword(rtlpriv, REG_HIMRE, IMR8190_DISABLED);
+-	synchronize_irq(rtlpci->pdev->irq);
++	rtlpci->irq_enabled = false;
+ }
+ 
+ static void _rtl92ce_poweroff_adapter(struct ieee80211_hw *hw)
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0014-rtlwifi-rtl8821ae-fix-misspelling-of-current-functio.patch b/package/kernel/mac80211/patches/680-0014-rtlwifi-rtl8821ae-fix-misspelling-of-current-functio.patch
new file mode 100644
index 0000000..d1f755f
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0014-rtlwifi-rtl8821ae-fix-misspelling-of-current-functio.patch
@@ -0,0 +1,65 @@ 
+From cf2bcc97dd332aa1d28eeacba1d8f8f89eccb7aa Mon Sep 17 00:00:00 2001
+From: Julia Lawall <Julia.Lawall@lip6.fr>
+Date: Sun, 7 Dec 2014 20:20:58 +0100
+Subject: [PATCH 14/51] rtlwifi: rtl8821ae: fix misspelling of current function
+ in string
+
+Replace a misspelled function name by %s and then __func__.
+
+8821 was written as 8812.
+
+This was done using Coccinelle, including the use of Levenshtein distance,
+as proposed by Rasmus Villemoes.
+
+Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8821ae/dm.c | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+index 9be1061..ba30b0d 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+@@ -2078,8 +2078,7 @@ void rtl8821ae_dm_txpwr_track_set_pwr(struct ieee80211_hw *hw,
+ 	if (rtldm->tx_rate != 0xFF)
+ 		tx_rate = rtl8821ae_hw_rate_to_mrate(hw, rtldm->tx_rate);
+ 
+-	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
+-		 "===>rtl8812ae_dm_txpwr_track_set_pwr\n");
++	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "===>%s\n", __func__);
+ 
+ 	if (tx_rate != 0xFF) { /* Mimic Modify High Rate BBSwing Limit.*/
+ 		/*CCK*/
+@@ -2128,7 +2127,7 @@ void rtl8821ae_dm_txpwr_track_set_pwr(struct ieee80211_hw *hw,
+ 
+ 	if (method == BBSWING) {
+ 		RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
+-			 "===>rtl8812ae_dm_txpwr_track_set_pwr\n");
++			 "===>%s\n", __func__);
+ 		if (rf_path == RF90_PATH_A) {
+ 			final_swing_idx[RF90_PATH_A] =
+ 				(rtldm->ofdm_index[RF90_PATH_A] >
+@@ -2260,7 +2259,8 @@ void rtl8821ae_dm_txpower_tracking_callback_thermalmeter(
+ 	rtldm->txpower_trackinginit = true;
+ 
+ 	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
+-		 "===>rtl8812ae_dm_txpower_tracking_callback_thermalmeter,\n pDM_Odm->BbSwingIdxCckBase: %d,pDM_Odm->BbSwingIdxOfdmBase[A]:%d, pDM_Odm->DefaultOfdmIndex: %d\n",
++		 "===>%s,\n pDM_Odm->BbSwingIdxCckBase: %d,pDM_Odm->BbSwingIdxOfdmBase[A]:%d, pDM_Odm->DefaultOfdmIndex: %d\n",
++		 __func__,
+ 		 rtldm->swing_idx_cck_base,
+ 		 rtldm->swing_idx_ofdm_base[RF90_PATH_A],
+ 		 rtldm->default_ofdm_index);
+@@ -2539,8 +2539,7 @@ void rtl8821ae_dm_txpower_tracking_callback_thermalmeter(
+ 		}
+ 	}
+ 
+-	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
+-		 "<===rtl8812ae_dm_txpower_tracking_callback_thermalmeter\n");
++	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, "<===%s\n", __func__);
+ }
+ 
+ void rtl8821ae_dm_check_txpower_tracking_thermalmeter(struct ieee80211_hw *hw)
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0015-rtlwifi-rtl8192cu-Fix-sparse-non-static-symbol-warni.patch b/package/kernel/mac80211/patches/680-0015-rtlwifi-rtl8192cu-Fix-sparse-non-static-symbol-warni.patch
new file mode 100644
index 0000000..b46b79d
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0015-rtlwifi-rtl8192cu-Fix-sparse-non-static-symbol-warni.patch
@@ -0,0 +1,34 @@ 
+From 8670d4d603794e643601707e9222df49a2430840 Mon Sep 17 00:00:00 2001
+From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
+Date: Tue, 9 Dec 2014 21:18:43 +0800
+Subject: [PATCH 15/51] rtlwifi: rtl8192cu: Fix sparse non static symbol
+ warning
+
+Fixes the following sparse warning:
+
+drivers/net/wireless/rtlwifi/rtl8192cu/hw.c:1595:6: warning:
+ symbol 'usb_cmd_send_packet' was not declared. Should it be static?
+
+Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+index 873363a..5513217 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+@@ -1592,7 +1592,7 @@ void rtl92cu_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
+ 	}
+ }
+ 
+-bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
++static bool usb_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
+ {
+   /* Currently nothing happens here.
+    * Traffic stops after some seconds in WPA2 802.11n mode.
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch b/package/kernel/mac80211/patches/680-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch
new file mode 100644
index 0000000..5f75b85
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0016-rtlwifi-rtl8192ce-Set-fw_ready-flag.patch
@@ -0,0 +1,37 @@ 
+From 9a1dce3a059111a7289680f4b8c0ec4f8736b6ee Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Wed, 10 Dec 2014 14:38:29 -0600
+Subject: [PATCH 16/51] rtlwifi: rtl8192ce: Set fw_ready flag
+
+The setting of this flag was missed in previous modifications.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Cc: Stable <stable@vger.kernel.org>
+Signed-off-by: John W. Linville <linville@tuxdriver.com>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+index d2ec516..5c646d5 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+@@ -955,6 +955,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
+ 	local_save_flags(flags);
+ 	local_irq_enable();
+ 
++	rtlhal->fw_ready = false;
+ 	rtlpriv->intf_ops->disable_aspm(hw);
+ 	rtstatus = _rtl92ce_init_mac(hw);
+ 	if (!rtstatus) {
+@@ -971,6 +972,7 @@ int rtl92ce_hw_init(struct ieee80211_hw *hw)
+ 		goto exit;
+ 	}
+ 
++	rtlhal->fw_ready = true;
+ 	rtlhal->last_hmeboxnum = 0;
+ 	rtl92c_phy_mac_config(hw);
+ 	/* because last function modify RCR, so we update
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0017-rtlwifi-rtl8192de-fw.c-Remove-unused-function.patch b/package/kernel/mac80211/patches/680-0017-rtlwifi-rtl8192de-fw.c-Remove-unused-function.patch
new file mode 100644
index 0000000..525e235
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0017-rtlwifi-rtl8192de-fw.c-Remove-unused-function.patch
@@ -0,0 +1,59 @@ 
+From 18e0c0bf3a5ea0f54384149570274d535341dc06 Mon Sep 17 00:00:00 2001
+From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
+Date: Sun, 7 Dec 2014 23:00:13 +0100
+Subject: [PATCH 17/51] rtlwifi: rtl8192de: fw.c: Remove unused function
+
+Remove the function rtl92d_set_fw_pwrmode_cmd() that is not used anywhere.
+
+This was partially found by using a static code analysis program called cppcheck.
+
+Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192de/fw.c | 17 -----------------
+ drivers/net/wireless/rtlwifi/rtl8192de/fw.h |  1 -
+ 2 files changed, 18 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
+index 2317707..62ef820 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.c
+@@ -540,23 +540,6 @@ void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw,
+ 	return;
+ }
+ 
+-void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	u8 u1_h2c_set_pwrmode[3] = { 0 };
+-	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
+-
+-	RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode);
+-	SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode);
+-	SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, 1);
+-	SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode,
+-					      ppsc->reg_max_lps_awakeintvl);
+-	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG,
+-		      "rtl92d_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode",
+-		      u1_h2c_set_pwrmode, 3);
+-	rtl92d_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode);
+-}
+-
+ static bool _rtl92d_cmd_send_packet(struct ieee80211_hw *hw,
+ 				    struct sk_buff *skb)
+ {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/fw.h b/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
+index a55a803..1646e7c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/fw.h
+@@ -136,7 +136,6 @@ int rtl92d_download_fw(struct ieee80211_hw *hw);
+ void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
+ 			 u32 cmd_len, u8 *p_cmdbuffer);
+ void rtl92d_firmware_selfreset(struct ieee80211_hw *hw);
+-void rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
+ void rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished);
+ void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
+ 
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0018-rtlwifi-rtl8821ae-Simplify-loading-of-WOWLAN-firmwar.patch b/package/kernel/mac80211/patches/680-0018-rtlwifi-rtl8821ae-Simplify-loading-of-WOWLAN-firmwar.patch
new file mode 100644
index 0000000..9a96f77
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0018-rtlwifi-rtl8821ae-Simplify-loading-of-WOWLAN-firmwar.patch
@@ -0,0 +1,211 @@ 
+From fe89707f0afa17edbb1bf8381fea1d2457aeebaa Mon Sep 17 00:00:00 2001
+From: Troy Tan <troy_tan@realsil.com.cn>
+Date: Thu, 18 Dec 2014 03:05:25 -0600
+Subject: [PATCH 18/51] rtlwifi: rtl8821ae: Simplify loading of WOWLAN firmware
+
+The existing method for loading both normal and WOWLAN firmware for the
+device duplicates a lot of code. This solution is much cleaner.
+
+Signed-off-by: Troy Tan <troy_tan@realsil.com.cn>
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/core.c         | 24 +++++++++-
+ drivers/net/wireless/rtlwifi/core.h         |  1 +
+ drivers/net/wireless/rtlwifi/rtl8821ae/sw.c | 74 ++++++++++-------------------
+ drivers/net/wireless/rtlwifi/wifi.h         |  3 +-
+ 4 files changed, 48 insertions(+), 54 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
+index 5fc6f52..deab852 100644
+--- a/drivers/net/wireless/rtlwifi/core.c
++++ b/drivers/net/wireless/rtlwifi/core.c
+@@ -95,7 +95,8 @@ void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data)
+ }
+ EXPORT_SYMBOL(rtl_bb_delay);
+ 
+-void rtl_fw_cb(const struct firmware *firmware, void *context)
++static void rtl_fw_do_work(const struct firmware *firmware, void *context,
++			   bool is_wow)
+ {
+ 	struct ieee80211_hw *hw = context;
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+@@ -125,12 +126,31 @@ found_alt:
+ 		release_firmware(firmware);
+ 		return;
+ 	}
+-	memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
++	if (!is_wow) {
++		memcpy(rtlpriv->rtlhal.pfirmware, firmware->data,
++		       firmware->size);
++		rtlpriv->rtlhal.fwsize = firmware->size;
++	} else {
++		memcpy(rtlpriv->rtlhal.wowlan_firmware, firmware->data,
++		       firmware->size);
++		rtlpriv->rtlhal.wowlan_fwsize = firmware->size;
++	}
+ 	rtlpriv->rtlhal.fwsize = firmware->size;
+ 	release_firmware(firmware);
+ }
++
++void rtl_fw_cb(const struct firmware *firmware, void *context)
++{
++	rtl_fw_do_work(firmware, context, false);
++}
+ EXPORT_SYMBOL(rtl_fw_cb);
+ 
++void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context)
++{
++	rtl_fw_do_work(firmware, context, true);
++}
++EXPORT_SYMBOL(rtl_wowlan_fw_cb);
++
+ /*mutex for start & stop is must here. */
+ static int rtl_op_start(struct ieee80211_hw *hw)
+ {
+diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
+index 624e1dc..8c87eb5 100644
+--- a/drivers/net/wireless/rtlwifi/core.h
++++ b/drivers/net/wireless/rtlwifi/core.h
+@@ -37,6 +37,7 @@
+ 
+ extern const struct ieee80211_ops rtl_ops;
+ void rtl_fw_cb(const struct firmware *firmware, void *context);
++void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context);
+ void rtl_addr_delay(u32 addr);
+ void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
+ 		     u32 mask, u32 data);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c b/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
+index fc92dd6..a4988121 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/sw.c
+@@ -85,52 +85,6 @@ static void rtl8821ae_init_aspm_vars(struct ieee80211_hw *hw)
+ 	rtlpci->const_support_pciaspm = 1;
+ }
+ 
+-static void load_wowlan_fw(struct rtl_priv *rtlpriv)
+-{
+-	/* callback routine to load wowlan firmware after main fw has
+-	 * been loaded
+-	 */
+-	const struct firmware *wowlan_firmware;
+-	char *fw_name = NULL;
+-	int err;
+-
+-	/* for wowlan firmware buf */
+-	rtlpriv->rtlhal.wowlan_firmware = vzalloc(0x8000);
+-	if (!rtlpriv->rtlhal.wowlan_firmware) {
+-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+-			 "Can't alloc buffer for wowlan fw.\n");
+-		return;
+-	}
+-
+-	if (rtlpriv->rtlhal.hw_type == HARDWARE_TYPE_RTL8821AE)
+-		fw_name = "rtlwifi/rtl8821aefw_wowlan.bin";
+-	else
+-		fw_name = "rtlwifi/rtl8812aefw_wowlan.bin";
+-	err = request_firmware(&wowlan_firmware, fw_name, rtlpriv->io.dev);
+-	if (err) {
+-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+-			 "Failed to request wowlan firmware!\n");
+-		goto error;
+-	}
+-
+-	if (wowlan_firmware->size > 0x8000) {
+-		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+-			 "Wowlan Firmware is too big!\n");
+-		goto error;
+-	}
+-
+-	memcpy(rtlpriv->rtlhal.wowlan_firmware, wowlan_firmware->data,
+-	       wowlan_firmware->size);
+-	rtlpriv->rtlhal.wowlan_fwsize = wowlan_firmware->size;
+-	release_firmware(wowlan_firmware);
+-
+-	RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "WOWLAN FirmwareDownload OK\n");
+-	return;
+-error:
+-	release_firmware(wowlan_firmware);
+-	vfree(rtlpriv->rtlhal.wowlan_firmware);
+-}
+-
+ /*InitializeVariables8812E*/
+ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
+ {
+@@ -231,7 +185,6 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
+ 	else if (rtlpriv->psc.reg_fwctrl_lps == 3)
+ 		rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE;
+ 
+-	rtlpriv->rtl_fw_second_cb = load_wowlan_fw;
+ 	/* for firmware buf */
+ 	rtlpriv->rtlhal.pfirmware = vzalloc(0x8000);
+ 	if (!rtlpriv->rtlhal.pfirmware) {
+@@ -239,20 +192,41 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
+ 			 "Can't alloc buffer for fw.\n");
+ 		return 1;
+ 	}
++	rtlpriv->rtlhal.wowlan_firmware = vzalloc(0x8000);
++	if (!rtlpriv->rtlhal.wowlan_firmware) {
++		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
++			 "Can't alloc buffer for wowlan fw.\n");
++		return 1;
++	}
+ 
+-	if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE)
++	if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) {
+ 		rtlpriv->cfg->fw_name = "rtlwifi/rtl8812aefw.bin";
+-	else
++		rtlpriv->cfg->wowlan_fw_name = "rtlwifi/rtl8812aefw_wowlan.bin";
++	} else {
+ 		rtlpriv->cfg->fw_name = "rtlwifi/rtl8821aefw.bin";
++		rtlpriv->cfg->wowlan_fw_name = "rtlwifi/rtl8821aefw_wowlan.bin";
++	}
+ 
+ 	rtlpriv->max_fw_size = 0x8000;
++	/*load normal firmware*/
+ 	pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name);
+ 	err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
+ 				      rtlpriv->io.dev, GFP_KERNEL, hw,
+ 				      rtl_fw_cb);
+ 	if (err) {
+ 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+-			 "Failed to request firmware!\n");
++			 "Failed to request normal firmware!\n");
++		return 1;
++	}
++	/*load wowlan firmware*/
++	pr_info("Using firmware %s\n", rtlpriv->cfg->wowlan_fw_name);
++	err = request_firmware_nowait(THIS_MODULE, 1,
++				      rtlpriv->cfg->wowlan_fw_name,
++				      rtlpriv->io.dev, GFP_KERNEL, hw,
++				      rtl_wowlan_fw_cb);
++	if (err) {
++		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
++			 "Failed to request wowlan firmware!\n");
+ 		return 1;
+ 	}
+ 	return 0;
+diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
+index 6866dcf..a233b26 100644
+--- a/drivers/net/wireless/rtlwifi/wifi.h
++++ b/drivers/net/wireless/rtlwifi/wifi.h
+@@ -2242,6 +2242,7 @@ struct rtl_hal_cfg {
+ 	char *name;
+ 	char *fw_name;
+ 	char *alt_fw_name;
++	char *wowlan_fw_name;
+ 	struct rtl_hal_ops *ops;
+ 	struct rtl_mod_params *mod_params;
+ 	struct rtl_hal_usbint_cfg *usb_interface_cfg;
+@@ -2518,8 +2519,6 @@ struct proxim {
+ 
+ struct rtl_priv {
+ 	struct ieee80211_hw *hw;
+-	/* Used to load a second firmware */
+-	void (*rtl_fw_second_cb)(struct rtl_priv *rtlpriv);
+ 	struct completion firmware_loading_complete;
+ 	struct list_head list;
+ 	struct rtl_priv *buddy_priv;
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0019-rtlwifi-rtl8821ae-Fix-typos-in-power-sequence-macro.patch b/package/kernel/mac80211/patches/680-0019-rtlwifi-rtl8821ae-Fix-typos-in-power-sequence-macro.patch
new file mode 100644
index 0000000..09a3043
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0019-rtlwifi-rtl8821ae-Fix-typos-in-power-sequence-macro.patch
@@ -0,0 +1,33 @@ 
+From f091282fd367faa014ebc2aa0a2fd178a48b476d Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:26 -0600
+Subject: [PATCH 19/51] rtlwifi: rtl8821ae: Fix typos in power-sequence macro
+
+Two of the macros that control power sequencing have values to be set that
+contain bits that are not covered by the associated mask.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h b/drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h
+index bf0b0ce..36b3e91 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/pwrseq.h
+@@ -93,9 +93,9 @@
+ 
+ #define RTL8812_TRANS_CARDEMU_TO_SUS					\
+ 	{0x0042, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK,\
+-	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xF0, 0xcc}, \
++	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xF0, 0xc0}, \
+ 	{0x0042, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,\
+-	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xF0, 0xEC}, \
++	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xF0, 0xE0}, \
+ 	{0x0043, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\
+ 	PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x07 \
+ 	/* gpio11 input mode, gpio10~8 output mode */},	\
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0020-rtlwifi-rtl8192ce-Add-code-to-set-the-keep-alive-ope.patch b/package/kernel/mac80211/patches/680-0020-rtlwifi-rtl8192ce-Add-code-to-set-the-keep-alive-ope.patch
new file mode 100644
index 0000000..f80bd44
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0020-rtlwifi-rtl8192ce-Add-code-to-set-the-keep-alive-ope.patch
@@ -0,0 +1,50 @@ 
+From 1ed03272b58f1ed6545b99dde39c42358156af69 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:27 -0600
+Subject: [PATCH 20/51] rtlwifi: rtl8192ce: Add code to set the keep-alive
+ operation
+
+This change helps the device maintain a connection.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h | 1 +
+ drivers/net/wireless/rtlwifi/rtl8192ce/hw.c       | 9 +++++++--
+ 2 files changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
+index b64ae45..e9f4281 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h
+@@ -37,6 +37,7 @@
+ #define FW_8192C_POLLING_DELAY			5
+ #define FW_8192C_POLLING_TIMEOUT_COUNT		100
+ #define NORMAL_CHIP				BIT(4)
++#define H2C_92C_KEEP_ALIVE_CTRL			48
+ 
+ #define IS_FW_HEADER_EXIST(_pfwhdr)	\
+ 	((le16_to_cpu(_pfwhdr->signature)&0xFFF0) == 0x92C0 ||\
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+index 5c646d5..b63b78b 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+@@ -544,8 +544,13 @@ void rtl92ce_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
+ 						(u8 *)(&fw_current_inps));
+ 			}
+ 		break; }
+-	case HW_VAR_KEEP_ALIVE:
+-		break;
++	case HW_VAR_KEEP_ALIVE: {
++		u8 array[2];
++
++		array[0] = 0xff;
++		array[1] = *((u8 *)val);
++		rtl92c_fill_h2c_cmd(hw, H2C_92C_KEEP_ALIVE_CTRL, 2, array);
++		break; }
+ 	default:
+ 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+ 			 "switch case %d not processed\n", variable);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0021-rtlwifi-rtl8192ce-Update-setting-of-the-media-status.patch b/package/kernel/mac80211/patches/680-0021-rtlwifi-rtl8192ce-Update-setting-of-the-media-status.patch
new file mode 100644
index 0000000..4cb0e5a
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0021-rtlwifi-rtl8192ce-Update-setting-of-the-media-status.patch
@@ -0,0 +1,106 @@ 
+From 9d62c5531b515ef427cee13cca87777dba617c94 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:28 -0600
+Subject: [PATCH 21/51] rtlwifi: rtl8192ce: Update setting of the media status
+
+This patch applies changes found in the latest vendor driver.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 51 ++++++++++++++++++-----------
+ 1 file changed, 31 insertions(+), 20 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+index b63b78b..2ee778a 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+@@ -1161,36 +1161,24 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+ 	u8 bt_msr = rtl_read_byte(rtlpriv, MSR);
+ 	enum led_ctl_mode ledaction = LED_CTL_NO_LINK;
+-	bt_msr &= 0xfc;
++	u8 mode = MSR_NOLINK;
+ 
+-	if (type == NL80211_IFTYPE_UNSPECIFIED ||
+-	    type == NL80211_IFTYPE_STATION) {
+-		_rtl92ce_stop_tx_beacon(hw);
+-		_rtl92ce_enable_bcn_sub_func(hw);
+-	} else if (type == NL80211_IFTYPE_ADHOC || type == NL80211_IFTYPE_AP ||
+-		   type == NL80211_IFTYPE_MESH_POINT) {
+-		_rtl92ce_resume_tx_beacon(hw);
+-		_rtl92ce_disable_bcn_sub_func(hw);
+-	} else {
+-		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
+-			 "Set HW_VAR_MEDIA_STATUS: No such media status(%x)\n",
+-			 type);
+-	}
++	bt_msr &= 0xfc;
+ 
+ 	switch (type) {
+ 	case NL80211_IFTYPE_UNSPECIFIED:
+-		bt_msr |= MSR_NOLINK;
++		mode = MSR_NOLINK;
+ 		ledaction = LED_CTL_LINK;
+ 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+ 			 "Set Network type to NO LINK!\n");
+ 		break;
+ 	case NL80211_IFTYPE_ADHOC:
+-		bt_msr |= MSR_ADHOC;
++		mode = MSR_ADHOC;
+ 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+ 			 "Set Network type to Ad Hoc!\n");
+ 		break;
+ 	case NL80211_IFTYPE_STATION:
+-		bt_msr |= MSR_INFRA;
++		mode = MSR_INFRA;
+ 		ledaction = LED_CTL_LINK;
+ 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+ 			 "Set Network type to STA!\n");
+@@ -1201,7 +1189,7 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
+ 			 "Set Network type to AP!\n");
+ 		break;
+ 	case NL80211_IFTYPE_MESH_POINT:
+-		bt_msr |= MSR_ADHOC;
++		mode = MSR_ADHOC;
+ 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+ 			 "Set Network type to Mesh Point!\n");
+ 		break;
+@@ -1212,9 +1200,32 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
+ 
+ 	}
+ 
+-	rtl_write_byte(rtlpriv, (MSR), bt_msr);
++	/* MSR_INFRA == Link in infrastructure network;
++	 * MSR_ADHOC == Link in ad hoc network;
++	 * Therefore, check link state is necessary.
++	 *
++	 * MSR_AP == AP mode; link state does not matter here.
++	 */
++	if (mode != MSR_AP &&
++	    rtlpriv->mac80211.link_state < MAC80211_LINKED) {
++		mode = MSR_NOLINK;
++		ledaction = LED_CTL_NO_LINK;
++	}
++	if (mode == MSR_NOLINK || mode == MSR_INFRA) {
++		_rtl92ce_stop_tx_beacon(hw);
++		_rtl92ce_enable_bcn_sub_func(hw);
++	} else if (mode == MSR_ADHOC || mode == MSR_AP) {
++		_rtl92ce_resume_tx_beacon(hw);
++		_rtl92ce_disable_bcn_sub_func(hw);
++	} else {
++		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
++			 "Set HW_VAR_MEDIA_STATUS: No such media status(%x).\n",
++			 mode);
++	}
++	rtl_write_byte(rtlpriv, (MSR), bt_msr | mode);
++
+ 	rtlpriv->cfg->ops->led_control(hw, ledaction);
+-	if ((bt_msr & MSR_MASK) == MSR_AP)
++	if (mode == MSR_AP)
+ 		rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x00);
+ 	else
+ 		rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x66);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0022-rtlwifi-rtl8192ce-Update-rate-setting-routines.patch b/package/kernel/mac80211/patches/680-0022-rtlwifi-rtl8192ce-Update-rate-setting-routines.patch
new file mode 100644
index 0000000..6f52560
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0022-rtlwifi-rtl8192ce-Update-rate-setting-routines.patch
@@ -0,0 +1,199 @@ 
+From ff6ee6b0ce1f62936a916ef1c33015a2ec48925e Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:29 -0600
+Subject: [PATCH 22/51] rtlwifi: rtl8192ce: Update rate setting routines
+
+These changes were found in the latest vendor driver.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ce/hw.c | 107 ++++++++++++----------------
+ 1 file changed, 44 insertions(+), 63 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+index 2ee778a..303b299 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/hw.c
+@@ -1168,7 +1168,6 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
+ 	switch (type) {
+ 	case NL80211_IFTYPE_UNSPECIFIED:
+ 		mode = MSR_NOLINK;
+-		ledaction = LED_CTL_LINK;
+ 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+ 			 "Set Network type to NO LINK!\n");
+ 		break;
+@@ -1184,7 +1183,8 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
+ 			 "Set Network type to STA!\n");
+ 		break;
+ 	case NL80211_IFTYPE_AP:
+-		bt_msr |= MSR_AP;
++		mode = MSR_AP;
++		ledaction = LED_CTL_LINK;
+ 		RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
+ 			 "Set Network type to AP!\n");
+ 		break;
+@@ -1222,7 +1222,7 @@ static int _rtl92ce_set_media_status(struct ieee80211_hw *hw,
+ 			 "Set HW_VAR_MEDIA_STATUS: No such media status(%x).\n",
+ 			 mode);
+ 	}
+-	rtl_write_byte(rtlpriv, (MSR), bt_msr | mode);
++	rtl_write_byte(rtlpriv, MSR, bt_msr | mode);
+ 
+ 	rtlpriv->cfg->ops->led_control(hw, ledaction);
+ 	if (mode == MSR_AP)
+@@ -1849,7 +1849,6 @@ static void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw,
+ 	u32 ratr_value;
+ 	u8 ratr_index = 0;
+ 	u8 nmode = mac->ht_enable;
+-	u8 mimo_ps = IEEE80211_SMPS_OFF;
+ 	u16 shortgi_rate;
+ 	u32 tmp_ratr_value;
+ 	u8 curtxbw_40mhz = mac->bw_40;
+@@ -1858,6 +1857,7 @@ static void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw,
+ 	u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
+ 			       1 : 0;
+ 	enum wireless_mode wirelessmode = mac->mode;
++	u32 ratr_mask;
+ 
+ 	if (rtlhal->current_bandtype == BAND_ON_5G)
+ 		ratr_value = sta->supp_rates[1] << 4;
+@@ -1881,19 +1881,13 @@ static void rtl92ce_update_hal_rate_table(struct ieee80211_hw *hw,
+ 	case WIRELESS_MODE_N_24G:
+ 	case WIRELESS_MODE_N_5G:
+ 		nmode = 1;
+-		if (mimo_ps == IEEE80211_SMPS_STATIC) {
+-			ratr_value &= 0x0007F005;
+-		} else {
+-			u32 ratr_mask;
+-
+-			if (get_rf_type(rtlphy) == RF_1T2R ||
+-			    get_rf_type(rtlphy) == RF_1T1R)
+-				ratr_mask = 0x000ff005;
+-			else
+-				ratr_mask = 0x0f0ff005;
++		if (get_rf_type(rtlphy) == RF_1T2R ||
++		    get_rf_type(rtlphy) == RF_1T1R)
++			ratr_mask = 0x000ff005;
++		else
++			ratr_mask = 0x0f0ff005;
+ 
+-			ratr_value &= ratr_mask;
+-		}
++		ratr_value &= ratr_mask;
+ 		break;
+ 	default:
+ 		if (rtlphy->rf_type == RF_1T2R)
+@@ -1946,17 +1940,16 @@ static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw,
+ 	struct rtl_sta_info *sta_entry = NULL;
+ 	u32 ratr_bitmap;
+ 	u8 ratr_index;
+-	u8 curtxbw_40mhz = (sta->bandwidth >= IEEE80211_STA_RX_BW_40) ? 1 : 0;
+-	u8 curshortgi_40mhz = curtxbw_40mhz &&
+-			      (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
+-				1 : 0;
++	u8 curtxbw_40mhz = (sta->ht_cap.cap &
++			    IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1 : 0;
++	u8 curshortgi_40mhz = (sta->ht_cap.cap &
++			       IEEE80211_HT_CAP_SGI_40) ?  1 : 0;
+ 	u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
+ 				1 : 0;
+ 	enum wireless_mode wirelessmode = 0;
+ 	bool shortgi = false;
+ 	u8 rate_mask[5];
+ 	u8 macid = 0;
+-	u8 mimo_ps = IEEE80211_SMPS_OFF;
+ 
+ 	sta_entry = (struct rtl_sta_info *) sta->drv_priv;
+ 	wirelessmode = sta_entry->wireless_mode;
+@@ -2001,47 +1994,38 @@ static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw,
+ 	case WIRELESS_MODE_N_5G:
+ 		ratr_index = RATR_INX_WIRELESS_NGB;
+ 
+-		if (mimo_ps == IEEE80211_SMPS_STATIC) {
+-			if (rssi_level == 1)
+-				ratr_bitmap &= 0x00070000;
+-			else if (rssi_level == 2)
+-				ratr_bitmap &= 0x0007f000;
+-			else
+-				ratr_bitmap &= 0x0007f005;
++		if (rtlphy->rf_type == RF_1T2R ||
++		    rtlphy->rf_type == RF_1T1R) {
++			if (curtxbw_40mhz) {
++				if (rssi_level == 1)
++					ratr_bitmap &= 0x000f0000;
++				else if (rssi_level == 2)
++					ratr_bitmap &= 0x000ff000;
++				else
++					ratr_bitmap &= 0x000ff015;
++			} else {
++				if (rssi_level == 1)
++					ratr_bitmap &= 0x000f0000;
++				else if (rssi_level == 2)
++					ratr_bitmap &= 0x000ff000;
++				else
++					ratr_bitmap &= 0x000ff005;
++			}
+ 		} else {
+-			if (rtlphy->rf_type == RF_1T2R ||
+-			    rtlphy->rf_type == RF_1T1R) {
+-				if (curtxbw_40mhz) {
+-					if (rssi_level == 1)
+-						ratr_bitmap &= 0x000f0000;
+-					else if (rssi_level == 2)
+-						ratr_bitmap &= 0x000ff000;
+-					else
+-						ratr_bitmap &= 0x000ff015;
+-				} else {
+-					if (rssi_level == 1)
+-						ratr_bitmap &= 0x000f0000;
+-					else if (rssi_level == 2)
+-						ratr_bitmap &= 0x000ff000;
+-					else
+-						ratr_bitmap &= 0x000ff005;
+-				}
++			if (curtxbw_40mhz) {
++				if (rssi_level == 1)
++					ratr_bitmap &= 0x0f0f0000;
++				else if (rssi_level == 2)
++					ratr_bitmap &= 0x0f0ff000;
++				else
++					ratr_bitmap &= 0x0f0ff015;
+ 			} else {
+-				if (curtxbw_40mhz) {
+-					if (rssi_level == 1)
+-						ratr_bitmap &= 0x0f0f0000;
+-					else if (rssi_level == 2)
+-						ratr_bitmap &= 0x0f0ff000;
+-					else
+-						ratr_bitmap &= 0x0f0ff015;
+-				} else {
+-					if (rssi_level == 1)
+-						ratr_bitmap &= 0x0f0f0000;
+-					else if (rssi_level == 2)
+-						ratr_bitmap &= 0x0f0ff000;
+-					else
+-						ratr_bitmap &= 0x0f0ff005;
+-				}
++				if (rssi_level == 1)
++					ratr_bitmap &= 0x0f0f0000;
++				else if (rssi_level == 2)
++					ratr_bitmap &= 0x0f0ff000;
++				else
++					ratr_bitmap &= 0x0f0ff005;
+ 			}
+ 		}
+ 
+@@ -2074,9 +2058,6 @@ static void rtl92ce_update_hal_rate_mask(struct ieee80211_hw *hw,
+ 		 "Rate_index:%x, ratr_val:%x, %5phC\n",
+ 		 ratr_index, ratr_bitmap, rate_mask);
+ 	rtl92c_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask);
+-
+-	if (macid != 0)
+-		sta_entry->ratr_index = ratr_index;
+ }
+ 
+ void rtl92ce_update_hal_rate_tbl(struct ieee80211_hw *hw,
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0023-rtlwifi-rtl8192ce-Improve-RF-sleep-routine.patch b/package/kernel/mac80211/patches/680-0023-rtlwifi-rtl8192ce-Improve-RF-sleep-routine.patch
new file mode 100644
index 0000000..3fa78ed
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0023-rtlwifi-rtl8192ce-Improve-RF-sleep-routine.patch
@@ -0,0 +1,35 @@ 
+From 99057920a2f7360977979dc4c2ba60d5f9dc9e23 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:30 -0600
+Subject: [PATCH 23/51] rtlwifi: rtl8192ce: Improve RF sleep routine
+
+These changes match those of the latest vendor driver.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
+index bc5ca98..1ee5a6a 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c
+@@ -518,11 +518,12 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw,
+ 		}
+ 	case ERFSLEEP:{
+ 			if (ppsc->rfpwr_state == ERFOFF)
+-				return false;
++				break;
+ 			for (queue_id = 0, i = 0;
+ 			     queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) {
+ 				ring = &pcipriv->dev.tx_ring[queue_id];
+-				if (skb_queue_len(&ring->queue) == 0) {
++				if (queue_id == BEACON_QUEUE ||
++				    skb_queue_len(&ring->queue) == 0) {
+ 					queue_id++;
+ 					continue;
+ 				} else {
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0024-rtlwifi-Remove-extraneous-argument-for-rate-mapping.patch b/package/kernel/mac80211/patches/680-0024-rtlwifi-Remove-extraneous-argument-for-rate-mapping.patch
new file mode 100644
index 0000000..2b3f8aa
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0024-rtlwifi-Remove-extraneous-argument-for-rate-mapping.patch
@@ -0,0 +1,138 @@ 
+From f1f21770b11ca83d688b2791b163c2b892ca6fa6 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:31 -0600
+Subject: [PATCH 24/51] rtlwifi: Remove extraneous argument for rate mapping
+
+Four of the drivers (92ce, 92cu, 92de, and 92se) supply an argument to the
+rate-mapping routine that is never used, thus it can be removed.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/base.c          |  2 +-
+ drivers/net/wireless/rtlwifi/base.h          |  2 +-
+ drivers/net/wireless/rtlwifi/rtl8192ce/trx.c |  5 ++---
+ drivers/net/wireless/rtlwifi/rtl8192cu/trx.c |  6 ++----
+ drivers/net/wireless/rtlwifi/rtl8192de/trx.c |  3 +--
+ drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 11 +++++------
+ 6 files changed, 12 insertions(+), 17 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
+index 40b6d1d..d4c8e95 100644
+--- a/drivers/net/wireless/rtlwifi/base.c
++++ b/drivers/net/wireless/rtlwifi/base.c
+@@ -883,7 +883,7 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
+  * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
+  */
+ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
+-			 bool isht, u8 desc_rate, bool first_ampdu)
++			 bool isht, u8 desc_rate)
+ {
+ 	int rate_idx;
+ 
+diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h
+index 982f245..936c2bb 100644
+--- a/drivers/net/wireless/rtlwifi/base.h
++++ b/drivers/net/wireless/rtlwifi/base.h
+@@ -124,7 +124,7 @@ void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
+ 
+ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
+ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
+-			 bool isht, u8 desc_rate, bool first_ampdu);
++			 bool isht, u8 desc_rate);
+ bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
+ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
+ 
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+index e88dcd0..d25aeeb 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+@@ -400,9 +400,8 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * are use (RX_FLAG_HT)
+ 	 * Notice: this is diff with windows define
+ 	 */
+-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
+-				stats->is_ht, stats->rate,
+-				stats->isfirst_ampdu);
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
++						   stats->rate);
+ 
+ 	rx_status->mactime = stats->timestamp_low;
+ 	if (phystatus) {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+index f383d5f..fa30b26 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+@@ -340,8 +340,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
+ 		rx_status->flag |= RX_FLAG_DECRYPTED;
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
+ 					(bool)GET_RX_DESC_RX_HT(pdesc),
+-					(u8)GET_RX_DESC_RX_MCS(pdesc),
+-					(bool)GET_RX_DESC_PAGGR(pdesc));
++					(u8)GET_RX_DESC_RX_MCS(pdesc));
+ 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
+ 	if (phystatus) {
+ 		p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
+@@ -408,8 +407,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
+ 	/* Data rate */
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
+ 					(bool)GET_RX_DESC_RX_HT(rxdesc),
+-					(u8)GET_RX_DESC_RX_MCS(rxdesc),
+-					(bool)GET_RX_DESC_PAGGR(rxdesc));
++					(u8)GET_RX_DESC_RX_MCS(rxdesc));
+ 	/*  There is a phy status after this rx descriptor. */
+ 	if (GET_RX_DESC_PHY_STATUS(rxdesc)) {
+ 		p_drvinfo = (struct rx_fwinfo_92c *)(rxdesc + RTL_RX_DESC_SIZE);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+index 8efbcc7..7fbae49 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+@@ -514,8 +514,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,	struct rtl_stats *stats,
+ 		rx_status->flag |= RX_FLAG_DECRYPTED;
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
+ 					(bool)GET_RX_DESC_RXHT(pdesc),
+-					(u8)GET_RX_DESC_RXMCS(pdesc),
+-					(bool)GET_RX_DESC_PAGGR(pdesc));
++					(u8)GET_RX_DESC_RXMCS(pdesc));
+ 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
+ 	if (phystatus) {
+ 		p_drvinfo = (struct rx_fwinfo_92d *)(skb->data +
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+index 672fd3b..da053cb 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+@@ -264,7 +264,6 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
+ 	struct rx_fwinfo *p_drvinfo;
+ 	u32 phystatus = (u32)GET_RX_STATUS_DESC_PHY_STATUS(pdesc);
+ 	struct ieee80211_hdr *hdr;
+-	bool first_ampdu = false;
+ 
+ 	stats->length = (u16)GET_RX_STATUS_DESC_PKT_LEN(pdesc);
+ 	stats->rx_drvinfo_size = (u8)GET_RX_STATUS_DESC_DRVINFO_SIZE(pdesc) * 8;
+@@ -319,8 +318,8 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
+ 			rx_status->flag |= RX_FLAG_DECRYPTED;
+ 	}
+ 
+-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
+-			      stats->is_ht, stats->rate, first_ampdu);
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
++						   stats->rate);
+ 
+ 	rx_status->mactime = stats->timestamp_low;
+ 	if (phystatus) {
+@@ -398,9 +397,9 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
+ 
+ 		if (rtlhal->version == VERSION_8192S_ACUT) {
+ 			if (ptcb_desc->hw_rate == DESC92_RATE1M ||
+-				ptcb_desc->hw_rate  == DESC92_RATE2M ||
+-				ptcb_desc->hw_rate == DESC92_RATE5_5M ||
+-				ptcb_desc->hw_rate == DESC92_RATE11M) {
++			    ptcb_desc->hw_rate  == DESC92_RATE2M ||
++			    ptcb_desc->hw_rate == DESC92_RATE5_5M ||
++			    ptcb_desc->hw_rate == DESC92_RATE11M) {
+ 				ptcb_desc->hw_rate = DESC92_RATE12M;
+ 			}
+ 		}
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0025-rtlwifi-rtl8723be-Switch-to-use-common-rate-mapping-.patch b/package/kernel/mac80211/patches/680-0025-rtlwifi-rtl8723be-Switch-to-use-common-rate-mapping-.patch
new file mode 100644
index 0000000..6ee667f
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0025-rtlwifi-rtl8723be-Switch-to-use-common-rate-mapping-.patch
@@ -0,0 +1,196 @@ 
+From 7e0dde9248c413485aa2eb2079782d8941f062c8 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:32 -0600
+Subject: [PATCH 25/51] rtlwifi: rtl8723be: Switch to use common rate-mapping
+ routine
+
+This driver currently has its owm version of this routine that duplicates
+a routine in rtlwifi.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8723be/trx.c | 160 +--------------------------
+ 1 file changed, 1 insertion(+), 159 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
+index d6a1c70..cb23bed 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
+@@ -47,164 +47,6 @@ static u8 _rtl8723be_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
+ 	return skb->priority;
+ }
+ 
+-/* mac80211's rate_idx is like this:
+- *
+- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
+- *
+- * B/G rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
+- *
+- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
+- * A rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
+- */
+-static int _rtl8723be_rate_mapping(struct ieee80211_hw *hw,
+-				   bool isht, u8 desc_rate)
+-{
+-	int rate_idx;
+-
+-	if (!isht) {
+-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
+-			switch (desc_rate) {
+-			case DESC92C_RATE1M:
+-				rate_idx = 0;
+-				break;
+-			case DESC92C_RATE2M:
+-				rate_idx = 1;
+-				break;
+-			case DESC92C_RATE5_5M:
+-				rate_idx = 2;
+-				break;
+-			case DESC92C_RATE11M:
+-				rate_idx = 3;
+-				break;
+-			case DESC92C_RATE6M:
+-				rate_idx = 4;
+-				break;
+-			case DESC92C_RATE9M:
+-				rate_idx = 5;
+-				break;
+-			case DESC92C_RATE12M:
+-				rate_idx = 6;
+-				break;
+-			case DESC92C_RATE18M:
+-				rate_idx = 7;
+-				break;
+-			case DESC92C_RATE24M:
+-				rate_idx = 8;
+-				break;
+-			case DESC92C_RATE36M:
+-				rate_idx = 9;
+-				break;
+-			case DESC92C_RATE48M:
+-				rate_idx = 10;
+-				break;
+-			case DESC92C_RATE54M:
+-				rate_idx = 11;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		} else {
+-			switch (desc_rate) {
+-			case DESC92C_RATE6M:
+-				rate_idx = 0;
+-				break;
+-			case DESC92C_RATE9M:
+-				rate_idx = 1;
+-				break;
+-			case DESC92C_RATE12M:
+-				rate_idx = 2;
+-				break;
+-			case DESC92C_RATE18M:
+-				rate_idx = 3;
+-				break;
+-			case DESC92C_RATE24M:
+-				rate_idx = 4;
+-				break;
+-			case DESC92C_RATE36M:
+-				rate_idx = 5;
+-				break;
+-			case DESC92C_RATE48M:
+-				rate_idx = 6;
+-				break;
+-			case DESC92C_RATE54M:
+-				rate_idx = 7;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		}
+-	} else {
+-		switch (desc_rate) {
+-		case DESC92C_RATEMCS0:
+-			rate_idx = 0;
+-			break;
+-		case DESC92C_RATEMCS1:
+-			rate_idx = 1;
+-			break;
+-		case DESC92C_RATEMCS2:
+-			rate_idx = 2;
+-			break;
+-		case DESC92C_RATEMCS3:
+-			rate_idx = 3;
+-			break;
+-		case DESC92C_RATEMCS4:
+-			rate_idx = 4;
+-			break;
+-		case DESC92C_RATEMCS5:
+-			rate_idx = 5;
+-			break;
+-		case DESC92C_RATEMCS6:
+-			rate_idx = 6;
+-			break;
+-		case DESC92C_RATEMCS7:
+-			rate_idx = 7;
+-			break;
+-		case DESC92C_RATEMCS8:
+-			rate_idx = 8;
+-			break;
+-		case DESC92C_RATEMCS9:
+-			rate_idx = 9;
+-			break;
+-		case DESC92C_RATEMCS10:
+-			rate_idx = 10;
+-			break;
+-		case DESC92C_RATEMCS11:
+-			rate_idx = 11;
+-			break;
+-		case DESC92C_RATEMCS12:
+-			rate_idx = 12;
+-			break;
+-		case DESC92C_RATEMCS13:
+-			rate_idx = 13;
+-			break;
+-		case DESC92C_RATEMCS14:
+-			rate_idx = 14;
+-			break;
+-		case DESC92C_RATEMCS15:
+-			rate_idx = 15;
+-			break;
+-		default:
+-			rate_idx = 0;
+-			break;
+-		}
+-	}
+-	return rate_idx;
+-}
+-
+ static void _rtl8723be_query_rxphystatus(struct ieee80211_hw *hw,
+ 					 struct rtl_stats *pstatus, u8 *pdesc,
+ 					 struct rx_fwinfo_8723be *p_drvinfo,
+@@ -558,7 +400,7 @@ bool rtl8723be_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * supported rates or MCS index if HT rates
+ 	 * are use (RX_FLAG_HT)
+ 	 */
+-	rx_status->rate_idx = _rtl8723be_rate_mapping(hw, status->is_ht,
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
+ 						      status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0026-rtlwifi-rtl8188ee-Switch-to-use-common-rate-mapping-.patch b/package/kernel/mac80211/patches/680-0026-rtlwifi-rtl8188ee-Switch-to-use-common-rate-mapping-.patch
new file mode 100644
index 0000000..f418296
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0026-rtlwifi-rtl8188ee-Switch-to-use-common-rate-mapping-.patch
@@ -0,0 +1,197 @@ 
+From 5b243feff35ab6050893741bc1a7016fa3ae5a8b Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:33 -0600
+Subject: [PATCH 26/51] rtlwifi: rtl8188ee: Switch to use common rate-mapping
+ routine
+
+This driver duplicates a routine found in the core.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8188ee/trx.c | 162 +--------------------------
+ 1 file changed, 2 insertions(+), 160 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
+index df549c9..d430884 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
+@@ -47,164 +47,6 @@ static u8 _rtl88ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
+ 	return skb->priority;
+ }
+ 
+-/* mac80211's rate_idx is like this:
+- *
+- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
+- *
+- * B/G rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
+- *
+- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
+- * A rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
+- */
+-static int _rtl88ee_rate_mapping(struct ieee80211_hw *hw,
+-				 bool isht, u8 desc_rate)
+-{
+-	int rate_idx;
+-
+-	if (!isht) {
+-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
+-			switch (desc_rate) {
+-			case DESC92C_RATE1M:
+-				rate_idx = 0;
+-				break;
+-			case DESC92C_RATE2M:
+-				rate_idx = 1;
+-				break;
+-			case DESC92C_RATE5_5M:
+-				rate_idx = 2;
+-				break;
+-			case DESC92C_RATE11M:
+-				rate_idx = 3;
+-				break;
+-			case DESC92C_RATE6M:
+-				rate_idx = 4;
+-				break;
+-			case DESC92C_RATE9M:
+-				rate_idx = 5;
+-				break;
+-			case DESC92C_RATE12M:
+-				rate_idx = 6;
+-				break;
+-			case DESC92C_RATE18M:
+-				rate_idx = 7;
+-				break;
+-			case DESC92C_RATE24M:
+-				rate_idx = 8;
+-				break;
+-			case DESC92C_RATE36M:
+-				rate_idx = 9;
+-				break;
+-			case DESC92C_RATE48M:
+-				rate_idx = 10;
+-				break;
+-			case DESC92C_RATE54M:
+-				rate_idx = 11;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		} else {
+-			switch (desc_rate) {
+-			case DESC92C_RATE6M:
+-				rate_idx = 0;
+-				break;
+-			case DESC92C_RATE9M:
+-				rate_idx = 1;
+-				break;
+-			case DESC92C_RATE12M:
+-				rate_idx = 2;
+-				break;
+-			case DESC92C_RATE18M:
+-				rate_idx = 3;
+-				break;
+-			case DESC92C_RATE24M:
+-				rate_idx = 4;
+-				break;
+-			case DESC92C_RATE36M:
+-				rate_idx = 5;
+-				break;
+-			case DESC92C_RATE48M:
+-				rate_idx = 6;
+-				break;
+-			case DESC92C_RATE54M:
+-				rate_idx = 7;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		}
+-	} else {
+-		switch (desc_rate) {
+-		case DESC92C_RATEMCS0:
+-			rate_idx = 0;
+-			break;
+-		case DESC92C_RATEMCS1:
+-			rate_idx = 1;
+-			break;
+-		case DESC92C_RATEMCS2:
+-			rate_idx = 2;
+-			break;
+-		case DESC92C_RATEMCS3:
+-			rate_idx = 3;
+-			break;
+-		case DESC92C_RATEMCS4:
+-			rate_idx = 4;
+-			break;
+-		case DESC92C_RATEMCS5:
+-			rate_idx = 5;
+-			break;
+-		case DESC92C_RATEMCS6:
+-			rate_idx = 6;
+-			break;
+-		case DESC92C_RATEMCS7:
+-			rate_idx = 7;
+-			break;
+-		case DESC92C_RATEMCS8:
+-			rate_idx = 8;
+-			break;
+-		case DESC92C_RATEMCS9:
+-			rate_idx = 9;
+-			break;
+-		case DESC92C_RATEMCS10:
+-			rate_idx = 10;
+-			break;
+-		case DESC92C_RATEMCS11:
+-			rate_idx = 11;
+-			break;
+-		case DESC92C_RATEMCS12:
+-			rate_idx = 12;
+-			break;
+-		case DESC92C_RATEMCS13:
+-			rate_idx = 13;
+-			break;
+-		case DESC92C_RATEMCS14:
+-			rate_idx = 14;
+-			break;
+-		case DESC92C_RATEMCS15:
+-			rate_idx = 15;
+-			break;
+-		default:
+-			rate_idx = 0;
+-			break;
+-		}
+-	}
+-	return rate_idx;
+-}
+-
+ static void _rtl88ee_query_rxphystatus(struct ieee80211_hw *hw,
+ 			struct rtl_stats *pstatus, u8 *pdesc,
+ 			struct rx_fwinfo_88e *p_drvinfo,
+@@ -630,8 +472,8 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * are use (RX_FLAG_HT)
+ 	 * Notice: this is diff with windows define
+ 	 */
+-	rx_status->rate_idx = _rtl88ee_rate_mapping(hw,
+-				status->is_ht, status->rate);
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
++						   status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+ 	if (phystatus == true) {
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0027-rtlwifi-rtl8723ae-Modify-driver-to-use-rate-mapping-.patch b/package/kernel/mac80211/patches/680-0027-rtlwifi-rtl8723ae-Modify-driver-to-use-rate-mapping-.patch
new file mode 100644
index 0000000..435fa7c
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0027-rtlwifi-rtl8723ae-Modify-driver-to-use-rate-mapping-.patch
@@ -0,0 +1,197 @@ 
+From 8d3fc3a64ba34d859d6bb0de76bd1860b234cd1c Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:34 -0600
+Subject: [PATCH 27/51] rtlwifi: rtl8723ae: Modify driver to use rate-mapping
+ routine in core
+
+This driver is also converted to use the rate-mapping code in the core.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8723ae/trx.c | 162 +--------------------------
+ 1 file changed, 2 insertions(+), 160 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
+index d372cca..662a094 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
+@@ -45,164 +45,6 @@ static u8 _rtl8723e_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
+ 	return skb->priority;
+ }
+ 
+-/* mac80211's rate_idx is like this:
+- *
+- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
+- *
+- * B/G rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
+- *
+- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
+- * A rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
+- */
+-static int _rtl8723e_rate_mapping(struct ieee80211_hw *hw,
+-				  bool isht, u8 desc_rate)
+-{
+-	int rate_idx;
+-
+-	if (!isht) {
+-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
+-			switch (desc_rate) {
+-			case DESC92C_RATE1M:
+-				rate_idx = 0;
+-				break;
+-			case DESC92C_RATE2M:
+-				rate_idx = 1;
+-				break;
+-			case DESC92C_RATE5_5M:
+-				rate_idx = 2;
+-				break;
+-			case DESC92C_RATE11M:
+-				rate_idx = 3;
+-				break;
+-			case DESC92C_RATE6M:
+-				rate_idx = 4;
+-				break;
+-			case DESC92C_RATE9M:
+-				rate_idx = 5;
+-				break;
+-			case DESC92C_RATE12M:
+-				rate_idx = 6;
+-				break;
+-			case DESC92C_RATE18M:
+-				rate_idx = 7;
+-				break;
+-			case DESC92C_RATE24M:
+-				rate_idx = 8;
+-				break;
+-			case DESC92C_RATE36M:
+-				rate_idx = 9;
+-				break;
+-			case DESC92C_RATE48M:
+-				rate_idx = 10;
+-				break;
+-			case DESC92C_RATE54M:
+-				rate_idx = 11;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		} else {
+-			switch (desc_rate) {
+-			case DESC92C_RATE6M:
+-				rate_idx = 0;
+-				break;
+-			case DESC92C_RATE9M:
+-				rate_idx = 1;
+-				break;
+-			case DESC92C_RATE12M:
+-				rate_idx = 2;
+-				break;
+-			case DESC92C_RATE18M:
+-				rate_idx = 3;
+-				break;
+-			case DESC92C_RATE24M:
+-				rate_idx = 4;
+-				break;
+-			case DESC92C_RATE36M:
+-				rate_idx = 5;
+-				break;
+-			case DESC92C_RATE48M:
+-				rate_idx = 6;
+-				break;
+-			case DESC92C_RATE54M:
+-				rate_idx = 7;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		}
+-	} else {
+-		switch (desc_rate) {
+-		case DESC92C_RATEMCS0:
+-			rate_idx = 0;
+-			break;
+-		case DESC92C_RATEMCS1:
+-			rate_idx = 1;
+-			break;
+-		case DESC92C_RATEMCS2:
+-			rate_idx = 2;
+-			break;
+-		case DESC92C_RATEMCS3:
+-			rate_idx = 3;
+-			break;
+-		case DESC92C_RATEMCS4:
+-			rate_idx = 4;
+-			break;
+-		case DESC92C_RATEMCS5:
+-			rate_idx = 5;
+-			break;
+-		case DESC92C_RATEMCS6:
+-			rate_idx = 6;
+-			break;
+-		case DESC92C_RATEMCS7:
+-			rate_idx = 7;
+-			break;
+-		case DESC92C_RATEMCS8:
+-			rate_idx = 8;
+-			break;
+-		case DESC92C_RATEMCS9:
+-			rate_idx = 9;
+-			break;
+-		case DESC92C_RATEMCS10:
+-			rate_idx = 10;
+-			break;
+-		case DESC92C_RATEMCS11:
+-			rate_idx = 11;
+-			break;
+-		case DESC92C_RATEMCS12:
+-			rate_idx = 12;
+-			break;
+-		case DESC92C_RATEMCS13:
+-			rate_idx = 13;
+-			break;
+-		case DESC92C_RATEMCS14:
+-			rate_idx = 14;
+-			break;
+-		case DESC92C_RATEMCS15:
+-			rate_idx = 15;
+-			break;
+-		default:
+-			rate_idx = 0;
+-			break;
+-		}
+-	}
+-	return rate_idx;
+-}
+-
+ static void _rtl8723e_query_rxphystatus(struct ieee80211_hw *hw,
+ 					struct rtl_stats *pstatus, u8 *pdesc,
+ 					struct rx_fwinfo_8723e *p_drvinfo,
+@@ -503,8 +345,8 @@ bool rtl8723e_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * are use (RX_FLAG_HT)
+ 	 * Notice: this is diff with windows define
+ 	 */
+-	rx_status->rate_idx = _rtl8723e_rate_mapping(hw,
+-				status->is_ht, status->rate);
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
++						   status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+ 	if (phystatus == true) {
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0028-rtlwifi-rtl8192ee-Convert-driver-to-use-common-rate-.patch b/package/kernel/mac80211/patches/680-0028-rtlwifi-rtl8192ee-Convert-driver-to-use-common-rate-.patch
new file mode 100644
index 0000000..9fff206
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0028-rtlwifi-rtl8192ee-Convert-driver-to-use-common-rate-.patch
@@ -0,0 +1,196 @@ 
+From 7b7d0d60a558d80165a18c0eceb1cc7b0c7d6439 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:35 -0600
+Subject: [PATCH 28/51] rtlwifi: rtl8192ee: Convert driver to use common
+ rate-mapping code
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 163 +--------------------------
+ 1 file changed, 2 insertions(+), 161 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+index 2fcbef1..fb46fb9 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+@@ -47,164 +47,6 @@ static u8 _rtl92ee_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
+ 	return skb->priority;
+ }
+ 
+-/* mac80211's rate_idx is like this:
+- *
+- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
+- *
+- * B/G rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
+- *
+- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
+- * A rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15
+- */
+-static int _rtl92ee_rate_mapping(struct ieee80211_hw *hw,
+-				 bool isht, u8 desc_rate)
+-{
+-	int rate_idx;
+-
+-	if (!isht) {
+-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
+-			switch (desc_rate) {
+-			case DESC92C_RATE1M:
+-				rate_idx = 0;
+-				break;
+-			case DESC92C_RATE2M:
+-				rate_idx = 1;
+-				break;
+-			case DESC92C_RATE5_5M:
+-				rate_idx = 2;
+-				break;
+-			case DESC92C_RATE11M:
+-				rate_idx = 3;
+-				break;
+-			case DESC92C_RATE6M:
+-				rate_idx = 4;
+-				break;
+-			case DESC92C_RATE9M:
+-				rate_idx = 5;
+-				break;
+-			case DESC92C_RATE12M:
+-				rate_idx = 6;
+-				break;
+-			case DESC92C_RATE18M:
+-				rate_idx = 7;
+-				break;
+-			case DESC92C_RATE24M:
+-				rate_idx = 8;
+-				break;
+-			case DESC92C_RATE36M:
+-				rate_idx = 9;
+-				break;
+-			case DESC92C_RATE48M:
+-				rate_idx = 10;
+-				break;
+-			case DESC92C_RATE54M:
+-				rate_idx = 11;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		} else {
+-			switch (desc_rate) {
+-			case DESC92C_RATE6M:
+-				rate_idx = 0;
+-				break;
+-			case DESC92C_RATE9M:
+-				rate_idx = 1;
+-				break;
+-			case DESC92C_RATE12M:
+-				rate_idx = 2;
+-				break;
+-			case DESC92C_RATE18M:
+-				rate_idx = 3;
+-				break;
+-			case DESC92C_RATE24M:
+-				rate_idx = 4;
+-				break;
+-			case DESC92C_RATE36M:
+-				rate_idx = 5;
+-				break;
+-			case DESC92C_RATE48M:
+-				rate_idx = 6;
+-				break;
+-			case DESC92C_RATE54M:
+-				rate_idx = 7;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		}
+-	} else {
+-		switch (desc_rate) {
+-		case DESC92C_RATEMCS0:
+-			rate_idx = 0;
+-			break;
+-		case DESC92C_RATEMCS1:
+-			rate_idx = 1;
+-			break;
+-		case DESC92C_RATEMCS2:
+-			rate_idx = 2;
+-			break;
+-		case DESC92C_RATEMCS3:
+-			rate_idx = 3;
+-			break;
+-		case DESC92C_RATEMCS4:
+-			rate_idx = 4;
+-			break;
+-		case DESC92C_RATEMCS5:
+-			rate_idx = 5;
+-			break;
+-		case DESC92C_RATEMCS6:
+-			rate_idx = 6;
+-			break;
+-		case DESC92C_RATEMCS7:
+-			rate_idx = 7;
+-			break;
+-		case DESC92C_RATEMCS8:
+-			rate_idx = 8;
+-			break;
+-		case DESC92C_RATEMCS9:
+-			rate_idx = 9;
+-			break;
+-		case DESC92C_RATEMCS10:
+-			rate_idx = 10;
+-			break;
+-		case DESC92C_RATEMCS11:
+-			rate_idx = 11;
+-			break;
+-		case DESC92C_RATEMCS12:
+-			rate_idx = 12;
+-			break;
+-		case DESC92C_RATEMCS13:
+-			rate_idx = 13;
+-			break;
+-		case DESC92C_RATEMCS14:
+-			rate_idx = 14;
+-			break;
+-		case DESC92C_RATEMCS15:
+-			rate_idx = 15;
+-			break;
+-		default:
+-			rate_idx = 0;
+-			break;
+-		}
+-	}
+-	return rate_idx;
+-}
+-
+ static void _rtl92ee_query_rxphystatus(struct ieee80211_hw *hw,
+ 				       struct rtl_stats *pstatus, u8 *pdesc,
+ 				       struct rx_fwinfo *p_drvinfo,
+@@ -576,9 +418,8 @@ bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * are use (RX_FLAG_HT)
+ 	 * Notice: this is diff with windows define
+ 	 */
+-	rx_status->rate_idx = _rtl92ee_rate_mapping(hw,
+-						    status->is_ht,
+-						    status->rate);
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
++						   status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+ 	if (phystatus) {
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0029-rtlwifi-Convert-all-drivers-to-use-a-common-set-of-r.patch b/package/kernel/mac80211/patches/680-0029-rtlwifi-Convert-all-drivers-to-use-a-common-set-of-r.patch
new file mode 100644
index 0000000..10cb532
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0029-rtlwifi-Convert-all-drivers-to-use-a-common-set-of-r.patch
@@ -0,0 +1,786 @@ 
+From e0e776a3c85c27751ab4399616fc50a474cc8379 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:36 -0600
+Subject: [PATCH 29/51] rtlwifi: Convert all drivers to use a common set of
+ rate descriptors
+
+This common set of rate descriptors is renamed to be DESC_RATExx.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/base.c          | 80 ++++++++++++++--------------
+ drivers/net/wireless/rtlwifi/rtl8192ce/sw.c  | 30 +++++------
+ drivers/net/wireless/rtlwifi/rtl8192ce/trx.c |  8 +--
+ drivers/net/wireless/rtlwifi/rtl8192cu/mac.c |  4 +-
+ drivers/net/wireless/rtlwifi/rtl8192cu/sw.c  | 28 +++++-----
+ drivers/net/wireless/rtlwifi/rtl8192cu/trx.c |  6 +--
+ drivers/net/wireless/rtlwifi/rtl8192de/sw.c  | 30 +++++------
+ drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 20 +++----
+ drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 12 ++---
+ drivers/net/wireless/rtlwifi/rtl8192ee/trx.h |  8 +--
+ drivers/net/wireless/rtlwifi/rtl8192se/def.h |  8 +--
+ drivers/net/wireless/rtlwifi/rtl8192se/sw.c  | 30 +++++------
+ drivers/net/wireless/rtlwifi/rtl8192se/trx.c | 18 +++----
+ drivers/net/wireless/rtlwifi/rtl8821ae/def.h | 31 -----------
+ drivers/net/wireless/rtlwifi/wifi.h          | 72 ++++++++++++-------------
+ 15 files changed, 177 insertions(+), 208 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
+index d4c8e95..23fc51e 100644
+--- a/drivers/net/wireless/rtlwifi/base.c
++++ b/drivers/net/wireless/rtlwifi/base.c
+@@ -867,20 +867,20 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
+  *
+  * B/G rate:
+  * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92_RATE1M-->DESC92_RATE54M ==> idx is 0-->11,
++ * DESC_RATE1M-->DESC_RATE54M ==> idx is 0-->11,
+  *
+  * N rate:
+  * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
++ * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
+  *
+  * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
+  * A rate:
+  * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC92_RATE6M-->DESC92_RATE54M ==> idx is 0-->7,
++ * DESC_RATE6M-->DESC_RATE54M ==> idx is 0-->7,
+  *
+  * N rate:
+  * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC92_RATEMCS0-->DESC92_RATEMCS15 ==> idx is 0-->15
++ * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
+  */
+ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
+ 			 bool isht, u8 desc_rate)
+@@ -890,40 +890,40 @@ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
+ 	if (false == isht) {
+ 		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
+ 			switch (desc_rate) {
+-			case DESC92_RATE1M:
++			case DESC_RATE1M:
+ 				rate_idx = 0;
+ 				break;
+-			case DESC92_RATE2M:
++			case DESC_RATE2M:
+ 				rate_idx = 1;
+ 				break;
+-			case DESC92_RATE5_5M:
++			case DESC_RATE5_5M:
+ 				rate_idx = 2;
+ 				break;
+-			case DESC92_RATE11M:
++			case DESC_RATE11M:
+ 				rate_idx = 3;
+ 				break;
+-			case DESC92_RATE6M:
++			case DESC_RATE6M:
+ 				rate_idx = 4;
+ 				break;
+-			case DESC92_RATE9M:
++			case DESC_RATE9M:
+ 				rate_idx = 5;
+ 				break;
+-			case DESC92_RATE12M:
++			case DESC_RATE12M:
+ 				rate_idx = 6;
+ 				break;
+-			case DESC92_RATE18M:
++			case DESC_RATE18M:
+ 				rate_idx = 7;
+ 				break;
+-			case DESC92_RATE24M:
++			case DESC_RATE24M:
+ 				rate_idx = 8;
+ 				break;
+-			case DESC92_RATE36M:
++			case DESC_RATE36M:
+ 				rate_idx = 9;
+ 				break;
+-			case DESC92_RATE48M:
++			case DESC_RATE48M:
+ 				rate_idx = 10;
+ 				break;
+-			case DESC92_RATE54M:
++			case DESC_RATE54M:
+ 				rate_idx = 11;
+ 				break;
+ 			default:
+@@ -932,28 +932,28 @@ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
+ 			}
+ 		} else {
+ 			switch (desc_rate) {
+-			case DESC92_RATE6M:
++			case DESC_RATE6M:
+ 				rate_idx = 0;
+ 				break;
+-			case DESC92_RATE9M:
++			case DESC_RATE9M:
+ 				rate_idx = 1;
+ 				break;
+-			case DESC92_RATE12M:
++			case DESC_RATE12M:
+ 				rate_idx = 2;
+ 				break;
+-			case DESC92_RATE18M:
++			case DESC_RATE18M:
+ 				rate_idx = 3;
+ 				break;
+-			case DESC92_RATE24M:
++			case DESC_RATE24M:
+ 				rate_idx = 4;
+ 				break;
+-			case DESC92_RATE36M:
++			case DESC_RATE36M:
+ 				rate_idx = 5;
+ 				break;
+-			case DESC92_RATE48M:
++			case DESC_RATE48M:
+ 				rate_idx = 6;
+ 				break;
+-			case DESC92_RATE54M:
++			case DESC_RATE54M:
+ 				rate_idx = 7;
+ 				break;
+ 			default:
+@@ -963,52 +963,52 @@ int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
+ 		}
+ 	} else {
+ 		switch (desc_rate) {
+-		case DESC92_RATEMCS0:
++		case DESC_RATEMCS0:
+ 			rate_idx = 0;
+ 			break;
+-		case DESC92_RATEMCS1:
++		case DESC_RATEMCS1:
+ 			rate_idx = 1;
+ 			break;
+-		case DESC92_RATEMCS2:
++		case DESC_RATEMCS2:
+ 			rate_idx = 2;
+ 			break;
+-		case DESC92_RATEMCS3:
++		case DESC_RATEMCS3:
+ 			rate_idx = 3;
+ 			break;
+-		case DESC92_RATEMCS4:
++		case DESC_RATEMCS4:
+ 			rate_idx = 4;
+ 			break;
+-		case DESC92_RATEMCS5:
++		case DESC_RATEMCS5:
+ 			rate_idx = 5;
+ 			break;
+-		case DESC92_RATEMCS6:
++		case DESC_RATEMCS6:
+ 			rate_idx = 6;
+ 			break;
+-		case DESC92_RATEMCS7:
++		case DESC_RATEMCS7:
+ 			rate_idx = 7;
+ 			break;
+-		case DESC92_RATEMCS8:
++		case DESC_RATEMCS8:
+ 			rate_idx = 8;
+ 			break;
+-		case DESC92_RATEMCS9:
++		case DESC_RATEMCS9:
+ 			rate_idx = 9;
+ 			break;
+-		case DESC92_RATEMCS10:
++		case DESC_RATEMCS10:
+ 			rate_idx = 10;
+ 			break;
+-		case DESC92_RATEMCS11:
++		case DESC_RATEMCS11:
+ 			rate_idx = 11;
+ 			break;
+-		case DESC92_RATEMCS12:
++		case DESC_RATEMCS12:
+ 			rate_idx = 12;
+ 			break;
+-		case DESC92_RATEMCS13:
++		case DESC_RATEMCS13:
+ 			rate_idx = 13;
+ 			break;
+-		case DESC92_RATEMCS14:
++		case DESC_RATEMCS14:
+ 			rate_idx = 14;
+ 			break;
+-		case DESC92_RATEMCS15:
++		case DESC_RATEMCS15:
+ 			rate_idx = 15;
+ 			break;
+ 		default:
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+index dd5aa08..de6cb6c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+@@ -334,21 +334,21 @@ static struct rtl_hal_cfg rtl92ce_hal_cfg = {
+ 	.maps[RTL_IMR_ROK] = IMR_ROK,
+ 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNINT | IMR_TBDOK | IMR_TBDER),
+ 
+-	.maps[RTL_RC_CCK_RATE1M] = DESC92_RATE1M,
+-	.maps[RTL_RC_CCK_RATE2M] = DESC92_RATE2M,
+-	.maps[RTL_RC_CCK_RATE5_5M] = DESC92_RATE5_5M,
+-	.maps[RTL_RC_CCK_RATE11M] = DESC92_RATE11M,
+-	.maps[RTL_RC_OFDM_RATE6M] = DESC92_RATE6M,
+-	.maps[RTL_RC_OFDM_RATE9M] = DESC92_RATE9M,
+-	.maps[RTL_RC_OFDM_RATE12M] = DESC92_RATE12M,
+-	.maps[RTL_RC_OFDM_RATE18M] = DESC92_RATE18M,
+-	.maps[RTL_RC_OFDM_RATE24M] = DESC92_RATE24M,
+-	.maps[RTL_RC_OFDM_RATE36M] = DESC92_RATE36M,
+-	.maps[RTL_RC_OFDM_RATE48M] = DESC92_RATE48M,
+-	.maps[RTL_RC_OFDM_RATE54M] = DESC92_RATE54M,
+-
+-	.maps[RTL_RC_HT_RATEMCS7] = DESC92_RATEMCS7,
+-	.maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
++	.maps[RTL_RC_CCK_RATE1M] = DESC_RATE1M,
++	.maps[RTL_RC_CCK_RATE2M] = DESC_RATE2M,
++	.maps[RTL_RC_CCK_RATE5_5M] = DESC_RATE5_5M,
++	.maps[RTL_RC_CCK_RATE11M] = DESC_RATE11M,
++	.maps[RTL_RC_OFDM_RATE6M] = DESC_RATE6M,
++	.maps[RTL_RC_OFDM_RATE9M] = DESC_RATE9M,
++	.maps[RTL_RC_OFDM_RATE12M] = DESC_RATE12M,
++	.maps[RTL_RC_OFDM_RATE18M] = DESC_RATE18M,
++	.maps[RTL_RC_OFDM_RATE24M] = DESC_RATE24M,
++	.maps[RTL_RC_OFDM_RATE36M] = DESC_RATE36M,
++	.maps[RTL_RC_OFDM_RATE48M] = DESC_RATE48M,
++	.maps[RTL_RC_OFDM_RATE54M] = DESC_RATE54M,
++
++	.maps[RTL_RC_HT_RATEMCS7] = DESC_RATEMCS7,
++	.maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15,
+ };
+ 
+ static const struct pci_device_id rtl92ce_pci_ids[] = {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+index d25aeeb..685faea 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+@@ -257,8 +257,8 @@ static void _rtl92ce_query_rxphystatus(struct ieee80211_hw *hw,
+ 		pstats->recvsignalpower = rx_pwr_all;
+ 
+ 		/* (3)EVM of HT rate */
+-		if (pstats->is_ht && pstats->rate >= DESC92_RATEMCS8 &&
+-		    pstats->rate <= DESC92_RATEMCS15)
++		if (pstats->is_ht && pstats->rate >= DESC_RATEMCS8 &&
++		    pstats->rate <= DESC_RATEMCS15)
+ 			max_spatial_stream = 2;
+ 		else
+ 			max_spatial_stream = 1;
+@@ -500,7 +500,7 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
+ 		SET_TX_DESC_RTS_BW(pdesc, 0);
+ 		SET_TX_DESC_RTS_SC(pdesc, tcb_desc->rts_sc);
+ 		SET_TX_DESC_RTS_SHORT(pdesc,
+-				      ((tcb_desc->rts_rate <= DESC92_RATE54M) ?
++				      ((tcb_desc->rts_rate <= DESC_RATE54M) ?
+ 				       (tcb_desc->rts_use_shortpreamble ? 1 : 0)
+ 				       : (tcb_desc->rts_use_shortgi ? 1 : 0)));
+ 
+@@ -623,7 +623,7 @@ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw,
+ 	if (firstseg)
+ 		SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN);
+ 
+-	SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE1M);
++	SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
+ 
+ 	SET_TX_DESC_SEQ(pdesc, 0);
+ 
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+index c2d8ec6..133e395 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c
+@@ -880,8 +880,8 @@ static void _rtl92c_query_rxphystatus(struct ieee80211_hw *hw,
+ 		pstats->rxpower = rx_pwr_all;
+ 		pstats->recvsignalpower = rx_pwr_all;
+ 		if (GET_RX_DESC_RX_MCS(pdesc) &&
+-		    GET_RX_DESC_RX_MCS(pdesc) >= DESC92_RATEMCS8 &&
+-		    GET_RX_DESC_RX_MCS(pdesc) <= DESC92_RATEMCS15)
++		    GET_RX_DESC_RX_MCS(pdesc) >= DESC_RATEMCS8 &&
++		    GET_RX_DESC_RX_MCS(pdesc) <= DESC_RATEMCS15)
+ 			max_spatial_stream = 2;
+ 		else
+ 			max_spatial_stream = 1;
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+index e06bafe..90a714c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+@@ -257,20 +257,20 @@ static struct rtl_hal_cfg rtl92cu_hal_cfg = {
+ 	.maps[RTL_IMR_ROK] = IMR_ROK,
+ 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNINT | IMR_TBDOK | IMR_TBDER),
+ 
+-	.maps[RTL_RC_CCK_RATE1M] = DESC92_RATE1M,
+-	.maps[RTL_RC_CCK_RATE2M] = DESC92_RATE2M,
+-	.maps[RTL_RC_CCK_RATE5_5M] = DESC92_RATE5_5M,
+-	.maps[RTL_RC_CCK_RATE11M] = DESC92_RATE11M,
+-	.maps[RTL_RC_OFDM_RATE6M] = DESC92_RATE6M,
+-	.maps[RTL_RC_OFDM_RATE9M] = DESC92_RATE9M,
+-	.maps[RTL_RC_OFDM_RATE12M] = DESC92_RATE12M,
+-	.maps[RTL_RC_OFDM_RATE18M] = DESC92_RATE18M,
+-	.maps[RTL_RC_OFDM_RATE24M] = DESC92_RATE24M,
+-	.maps[RTL_RC_OFDM_RATE36M] = DESC92_RATE36M,
+-	.maps[RTL_RC_OFDM_RATE48M] = DESC92_RATE48M,
+-	.maps[RTL_RC_OFDM_RATE54M] = DESC92_RATE54M,
+-	.maps[RTL_RC_HT_RATEMCS7] = DESC92_RATEMCS7,
+-	.maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
++	.maps[RTL_RC_CCK_RATE1M] = DESC_RATE1M,
++	.maps[RTL_RC_CCK_RATE2M] = DESC_RATE2M,
++	.maps[RTL_RC_CCK_RATE5_5M] = DESC_RATE5_5M,
++	.maps[RTL_RC_CCK_RATE11M] = DESC_RATE11M,
++	.maps[RTL_RC_OFDM_RATE6M] = DESC_RATE6M,
++	.maps[RTL_RC_OFDM_RATE9M] = DESC_RATE9M,
++	.maps[RTL_RC_OFDM_RATE12M] = DESC_RATE12M,
++	.maps[RTL_RC_OFDM_RATE18M] = DESC_RATE18M,
++	.maps[RTL_RC_OFDM_RATE24M] = DESC_RATE24M,
++	.maps[RTL_RC_OFDM_RATE36M] = DESC_RATE36M,
++	.maps[RTL_RC_OFDM_RATE48M] = DESC_RATE48M,
++	.maps[RTL_RC_OFDM_RATE54M] = DESC_RATE54M,
++	.maps[RTL_RC_HT_RATEMCS7] = DESC_RATEMCS7,
++	.maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15,
+ };
+ 
+ #define USB_VENDER_ID_REALTEK		0x0bda
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+index fa30b26..fe29876 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+@@ -543,7 +543,7 @@ void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw,
+ 	SET_TX_DESC_RTS_BW(txdesc, 0);
+ 	SET_TX_DESC_RTS_SC(txdesc, tcb_desc->rts_sc);
+ 	SET_TX_DESC_RTS_SHORT(txdesc,
+-			      ((tcb_desc->rts_rate <= DESC92_RATE54M) ?
++			      ((tcb_desc->rts_rate <= DESC_RATE54M) ?
+ 			       (tcb_desc->rts_use_shortpreamble ? 1 : 0)
+ 			       : (tcb_desc->rts_use_shortgi ? 1 : 0)));
+ 	if (mac->bw_40) {
+@@ -642,7 +642,7 @@ void rtl92cu_fill_fake_txdesc(struct ieee80211_hw *hw, u8 * pDesc,
+ 	}
+ 	SET_TX_DESC_USE_RATE(pDesc, 1); /* use data rate which is set by Sw */
+ 	SET_TX_DESC_OWN(pDesc, 1);
+-	SET_TX_DESC_TX_RATE(pDesc, DESC92_RATE1M);
++	SET_TX_DESC_TX_RATE(pDesc, DESC_RATE1M);
+ 	_rtl_tx_desc_checksum(pDesc);
+ }
+ 
+@@ -658,7 +658,7 @@ void rtl92cu_tx_fill_cmddesc(struct ieee80211_hw *hw,
+ 	memset((void *)pdesc, 0, RTL_TX_HEADER_SIZE);
+ 	if (firstseg)
+ 		SET_TX_DESC_OFFSET(pdesc, RTL_TX_HEADER_SIZE);
+-	SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE1M);
++	SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
+ 	SET_TX_DESC_SEQ(pdesc, 0);
+ 	SET_TX_DESC_LINIP(pdesc, 0);
+ 	SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+index a0aba08..b19d039 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+@@ -337,21 +337,21 @@ static struct rtl_hal_cfg rtl92de_hal_cfg = {
+ 	.maps[RTL_IMR_ROK] = IMR_ROK,
+ 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNINT | IMR_TBDOK | IMR_TBDER),
+ 
+-	.maps[RTL_RC_CCK_RATE1M] = DESC92_RATE1M,
+-	.maps[RTL_RC_CCK_RATE2M] = DESC92_RATE2M,
+-	.maps[RTL_RC_CCK_RATE5_5M] = DESC92_RATE5_5M,
+-	.maps[RTL_RC_CCK_RATE11M] = DESC92_RATE11M,
+-	.maps[RTL_RC_OFDM_RATE6M] = DESC92_RATE6M,
+-	.maps[RTL_RC_OFDM_RATE9M] = DESC92_RATE9M,
+-	.maps[RTL_RC_OFDM_RATE12M] = DESC92_RATE12M,
+-	.maps[RTL_RC_OFDM_RATE18M] = DESC92_RATE18M,
+-	.maps[RTL_RC_OFDM_RATE24M] = DESC92_RATE24M,
+-	.maps[RTL_RC_OFDM_RATE36M] = DESC92_RATE36M,
+-	.maps[RTL_RC_OFDM_RATE48M] = DESC92_RATE48M,
+-	.maps[RTL_RC_OFDM_RATE54M] = DESC92_RATE54M,
+-
+-	.maps[RTL_RC_HT_RATEMCS7] = DESC92_RATEMCS7,
+-	.maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
++	.maps[RTL_RC_CCK_RATE1M] = DESC_RATE1M,
++	.maps[RTL_RC_CCK_RATE2M] = DESC_RATE2M,
++	.maps[RTL_RC_CCK_RATE5_5M] = DESC_RATE5_5M,
++	.maps[RTL_RC_CCK_RATE11M] = DESC_RATE11M,
++	.maps[RTL_RC_OFDM_RATE6M] = DESC_RATE6M,
++	.maps[RTL_RC_OFDM_RATE9M] = DESC_RATE9M,
++	.maps[RTL_RC_OFDM_RATE12M] = DESC_RATE12M,
++	.maps[RTL_RC_OFDM_RATE18M] = DESC_RATE18M,
++	.maps[RTL_RC_OFDM_RATE24M] = DESC_RATE24M,
++	.maps[RTL_RC_OFDM_RATE36M] = DESC_RATE36M,
++	.maps[RTL_RC_OFDM_RATE48M] = DESC_RATE48M,
++	.maps[RTL_RC_OFDM_RATE54M] = DESC_RATE54M,
++
++	.maps[RTL_RC_HT_RATEMCS7] = DESC_RATEMCS7,
++	.maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15,
+ };
+ 
+ static struct pci_device_id rtl92de_pci_ids[] = {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+index 7fbae49..381a4c0 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+@@ -235,8 +235,8 @@ static void _rtl92de_query_rxphystatus(struct ieee80211_hw *hw,
+ 		pstats->rx_pwdb_all = pwdb_all;
+ 		pstats->rxpower = rx_pwr_all;
+ 		pstats->recvsignalpower = rx_pwr_all;
+-		if (pdesc->rxht && pdesc->rxmcs >= DESC92_RATEMCS8 &&
+-		    pdesc->rxmcs <= DESC92_RATEMCS15)
++		if (pdesc->rxht && pdesc->rxmcs >= DESC_RATEMCS8 &&
++		    pdesc->rxmcs <= DESC_RATEMCS15)
+ 			max_spatial_stream = 2;
+ 		else
+ 			max_spatial_stream = 1;
+@@ -611,14 +611,14 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
+ 		}
+ 		/* 5G have no CCK rate */
+ 		if (rtlhal->current_bandtype == BAND_ON_5G)
+-			if (ptcb_desc->hw_rate < DESC92_RATE6M)
+-				ptcb_desc->hw_rate = DESC92_RATE6M;
++			if (ptcb_desc->hw_rate < DESC_RATE6M)
++				ptcb_desc->hw_rate = DESC_RATE6M;
+ 		SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate);
+ 		if (ptcb_desc->use_shortgi || ptcb_desc->use_shortpreamble)
+ 			SET_TX_DESC_DATA_SHORTGI(pdesc, 1);
+ 
+ 		if (rtlhal->macphymode == DUALMAC_DUALPHY &&
+-			ptcb_desc->hw_rate == DESC92_RATEMCS7)
++			ptcb_desc->hw_rate == DESC_RATEMCS7)
+ 			SET_TX_DESC_DATA_SHORTGI(pdesc, 1);
+ 
+ 		if (info->flags & IEEE80211_TX_CTL_AMPDU) {
+@@ -634,13 +634,13 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
+ 		SET_TX_DESC_RTS_STBC(pdesc, ((ptcb_desc->rts_stbc) ? 1 : 0));
+ 		/* 5G have no CCK rate */
+ 		if (rtlhal->current_bandtype == BAND_ON_5G)
+-			if (ptcb_desc->rts_rate < DESC92_RATE6M)
+-				ptcb_desc->rts_rate = DESC92_RATE6M;
++			if (ptcb_desc->rts_rate < DESC_RATE6M)
++				ptcb_desc->rts_rate = DESC_RATE6M;
+ 		SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate);
+ 		SET_TX_DESC_RTS_BW(pdesc, 0);
+ 		SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc);
+ 		SET_TX_DESC_RTS_SHORT(pdesc, ((ptcb_desc->rts_rate <=
+-			DESC92_RATE54M) ?
++			DESC_RATE54M) ?
+ 			(ptcb_desc->rts_use_shortpreamble ? 1 : 0) :
+ 			(ptcb_desc->rts_use_shortgi ? 1 : 0)));
+ 		if (bw_40) {
+@@ -755,9 +755,9 @@ void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw,
+ 	 * The braces are needed no matter what checkpatch says
+ 	 */
+ 	if (rtlhal->current_bandtype == BAND_ON_5G) {
+-		SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE6M);
++		SET_TX_DESC_TX_RATE(pdesc, DESC_RATE6M);
+ 	} else {
+-		SET_TX_DESC_TX_RATE(pdesc, DESC92_RATE1M);
++		SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
+ 	}
+ 	SET_TX_DESC_SEQ(pdesc, 0);
+ 	SET_TX_DESC_LINIP(pdesc, 0);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+index fb46fb9..3ea7367 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+@@ -187,8 +187,8 @@ static void _rtl92ee_query_rxphystatus(struct ieee80211_hw *hw,
+ 		pstatus->recvsignalpower = rx_pwr_all;
+ 
+ 		/* (3)EVM of HT rate */
+-		if (pstatus->rate >= DESC92C_RATEMCS8 &&
+-		    pstatus->rate <= DESC92C_RATEMCS15)
++		if (pstatus->rate >= DESC_RATEMCS8 &&
++		    pstatus->rate <= DESC_RATEMCS15)
+ 			max_spatial_stream = 2;
+ 		else
+ 			max_spatial_stream = 1;
+@@ -742,13 +742,13 @@ void rtl92ee_tx_fill_desc(struct ieee80211_hw *hw,
+ 		} else {
+ 			if (rtlpriv->ra.is_special_data) {
+ 				ptcb_desc->use_driver_rate = true;
+-				SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE11M);
++				SET_TX_DESC_TX_RATE(pdesc, DESC_RATE11M);
+ 			} else {
+ 				ptcb_desc->use_driver_rate = false;
+ 			}
+ 		}
+ 
+-		if (ptcb_desc->hw_rate > DESC92C_RATEMCS0)
++		if (ptcb_desc->hw_rate > DESC_RATEMCS0)
+ 			short_gi = (ptcb_desc->use_shortgi) ? 1 : 0;
+ 		else
+ 			short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0;
+@@ -768,7 +768,7 @@ void rtl92ee_tx_fill_desc(struct ieee80211_hw *hw,
+ 		SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate);
+ 		SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc);
+ 		SET_TX_DESC_RTS_SHORT(pdesc,
+-				((ptcb_desc->rts_rate <= DESC92C_RATE54M) ?
++				((ptcb_desc->rts_rate <= DESC_RATE54M) ?
+ 				 (ptcb_desc->rts_use_shortpreamble ? 1 : 0) :
+ 				 (ptcb_desc->rts_use_shortgi ? 1 : 0)));
+ 
+@@ -879,7 +879,7 @@ void rtl92ee_tx_fill_cmddesc(struct ieee80211_hw *hw,
+ 	if (firstseg)
+ 		SET_TX_DESC_OFFSET(pdesc, txdesc_len);
+ 
+-	SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE1M);
++	SET_TX_DESC_TX_RATE(pdesc, DESC_RATE1M);
+ 
+ 	SET_TX_DESC_SEQ(pdesc, 0);
+ 
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
+index 6f9be1c..45fd9db 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
+@@ -591,10 +591,10 @@ do {								\
+ } while (0)
+ 
+ #define RTL92EE_RX_HAL_IS_CCK_RATE(rxmcs)\
+-	(rxmcs == DESC92C_RATE1M ||\
+-	 rxmcs == DESC92C_RATE2M ||\
+-	 rxmcs == DESC92C_RATE5_5M ||\
+-	 rxmcs == DESC92C_RATE11M)
++	(rxmcs == DESC_RATE1M ||\
++	 rxmcs == DESC_RATE2M ||\
++	 rxmcs == DESC_RATE5_5M ||\
++	 rxmcs == DESC_RATE11M)
+ 
+ #define IS_LITTLE_ENDIAN	1
+ 
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/def.h b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
+index 6e7a70b..ef87c09 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/def.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/def.h
+@@ -450,10 +450,10 @@
+ 	SHIFT_AND_MASK_LE(__pdesc + 24, 0, 32)
+ 
+ #define SE_RX_HAL_IS_CCK_RATE(_pdesc)\
+-	(GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE1M ||	\
+-	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE2M ||	\
+-	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE5_5M ||\
+-	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC92_RATE11M)
++	(GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC_RATE1M ||	\
++	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC_RATE2M ||	\
++	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC_RATE5_5M ||\
++	 GET_RX_STATUS_DESC_RX_MCS(_pdesc) == DESC_RATE11M)
+ 
+ enum rf_optype {
+ 	RF_OP_BY_SW_3WIRE = 0,
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+index fb00386..e1fd27c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+@@ -383,21 +383,21 @@ static struct rtl_hal_cfg rtl92se_hal_cfg = {
+ 	.maps[RTL_IMR_ROK] = IMR_ROK,
+ 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNINT | IMR_TBDOK | IMR_TBDER),
+ 
+-	.maps[RTL_RC_CCK_RATE1M] = DESC92_RATE1M,
+-	.maps[RTL_RC_CCK_RATE2M] = DESC92_RATE2M,
+-	.maps[RTL_RC_CCK_RATE5_5M] = DESC92_RATE5_5M,
+-	.maps[RTL_RC_CCK_RATE11M] = DESC92_RATE11M,
+-	.maps[RTL_RC_OFDM_RATE6M] = DESC92_RATE6M,
+-	.maps[RTL_RC_OFDM_RATE9M] = DESC92_RATE9M,
+-	.maps[RTL_RC_OFDM_RATE12M] = DESC92_RATE12M,
+-	.maps[RTL_RC_OFDM_RATE18M] = DESC92_RATE18M,
+-	.maps[RTL_RC_OFDM_RATE24M] = DESC92_RATE24M,
+-	.maps[RTL_RC_OFDM_RATE36M] = DESC92_RATE36M,
+-	.maps[RTL_RC_OFDM_RATE48M] = DESC92_RATE48M,
+-	.maps[RTL_RC_OFDM_RATE54M] = DESC92_RATE54M,
+-
+-	.maps[RTL_RC_HT_RATEMCS7] = DESC92_RATEMCS7,
+-	.maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
++	.maps[RTL_RC_CCK_RATE1M] = DESC_RATE1M,
++	.maps[RTL_RC_CCK_RATE2M] = DESC_RATE2M,
++	.maps[RTL_RC_CCK_RATE5_5M] = DESC_RATE5_5M,
++	.maps[RTL_RC_CCK_RATE11M] = DESC_RATE11M,
++	.maps[RTL_RC_OFDM_RATE6M] = DESC_RATE6M,
++	.maps[RTL_RC_OFDM_RATE9M] = DESC_RATE9M,
++	.maps[RTL_RC_OFDM_RATE12M] = DESC_RATE12M,
++	.maps[RTL_RC_OFDM_RATE18M] = DESC_RATE18M,
++	.maps[RTL_RC_OFDM_RATE24M] = DESC_RATE24M,
++	.maps[RTL_RC_OFDM_RATE36M] = DESC_RATE36M,
++	.maps[RTL_RC_OFDM_RATE48M] = DESC_RATE48M,
++	.maps[RTL_RC_OFDM_RATE54M] = DESC_RATE54M,
++
++	.maps[RTL_RC_HT_RATEMCS7] = DESC_RATEMCS7,
++	.maps[RTL_RC_HT_RATEMCS15] = DESC_RATEMCS15,
+ };
+ 
+ static struct pci_device_id rtl92se_pci_ids[] = {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+index da053cb..95eebff 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+@@ -191,8 +191,8 @@ static void _rtl92se_query_rxphystatus(struct ieee80211_hw *hw,
+ 		pstats->rxpower = rx_pwr_all;
+ 		pstats->recvsignalpower = rx_pwr_all;
+ 
+-		if (pstats->is_ht && pstats->rate >= DESC92_RATEMCS8 &&
+-		    pstats->rate <= DESC92_RATEMCS15)
++		if (pstats->is_ht && pstats->rate >= DESC_RATEMCS8 &&
++		    pstats->rate <= DESC_RATEMCS15)
+ 			max_spatial_stream = 2;
+ 		else
+ 			max_spatial_stream = 1;
+@@ -393,14 +393,14 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
+ 		SET_TX_DESC_RSVD_MACID(pdesc, reserved_macid);
+ 
+ 		SET_TX_DESC_TXHT(pdesc, ((ptcb_desc->hw_rate >=
+-				 DESC92_RATEMCS0) ? 1 : 0));
++				 DESC_RATEMCS0) ? 1 : 0));
+ 
+ 		if (rtlhal->version == VERSION_8192S_ACUT) {
+-			if (ptcb_desc->hw_rate == DESC92_RATE1M ||
+-			    ptcb_desc->hw_rate  == DESC92_RATE2M ||
+-			    ptcb_desc->hw_rate == DESC92_RATE5_5M ||
+-			    ptcb_desc->hw_rate == DESC92_RATE11M) {
+-				ptcb_desc->hw_rate = DESC92_RATE12M;
++			if (ptcb_desc->hw_rate == DESC_RATE1M ||
++			    ptcb_desc->hw_rate  == DESC_RATE2M ||
++			    ptcb_desc->hw_rate == DESC_RATE5_5M ||
++			    ptcb_desc->hw_rate == DESC_RATE11M) {
++				ptcb_desc->hw_rate = DESC_RATE12M;
+ 			}
+ 		}
+ 
+@@ -429,7 +429,7 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
+ 		SET_TX_DESC_RTS_BANDWIDTH(pdesc, 0);
+ 		SET_TX_DESC_RTS_SUB_CARRIER(pdesc, ptcb_desc->rts_sc);
+ 		SET_TX_DESC_RTS_SHORT(pdesc, ((ptcb_desc->rts_rate <=
+-		       DESC92_RATE54M) ?
++		       DESC_RATE54M) ?
+ 		       (ptcb_desc->rts_use_shortpreamble ? 1 : 0)
+ 		       : (ptcb_desc->rts_use_shortgi ? 1 : 0)));
+ 
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/def.h b/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
+index a730985..53dc522 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
+@@ -374,37 +374,6 @@ enum rtl_desc_qsel {
+ };
+ 
+ enum rtl_desc8821ae_rate {
+-	DESC_RATE1M = 0x00,
+-	DESC_RATE2M = 0x01,
+-	DESC_RATE5_5M = 0x02,
+-	DESC_RATE11M = 0x03,
+-
+-	DESC_RATE6M = 0x04,
+-	DESC_RATE9M = 0x05,
+-	DESC_RATE12M = 0x06,
+-	DESC_RATE18M = 0x07,
+-	DESC_RATE24M = 0x08,
+-	DESC_RATE36M = 0x09,
+-	DESC_RATE48M = 0x0a,
+-	DESC_RATE54M = 0x0b,
+-
+-	DESC_RATEMCS0 = 0x0c,
+-	DESC_RATEMCS1 = 0x0d,
+-	DESC_RATEMCS2 = 0x0e,
+-	DESC_RATEMCS3 = 0x0f,
+-	DESC_RATEMCS4 = 0x10,
+-	DESC_RATEMCS5 = 0x11,
+-	DESC_RATEMCS6 = 0x12,
+-	DESC_RATEMCS7 = 0x13,
+-	DESC_RATEMCS8 = 0x14,
+-	DESC_RATEMCS9 = 0x15,
+-	DESC_RATEMCS10 = 0x16,
+-	DESC_RATEMCS11 = 0x17,
+-	DESC_RATEMCS12 = 0x18,
+-	DESC_RATEMCS13 = 0x19,
+-	DESC_RATEMCS14 = 0x1a,
+-	DESC_RATEMCS15 = 0x1b,
+-
+ 	DESC_RATEVHT1SS_MCS0 = 0x2c,
+ 	DESC_RATEVHT1SS_MCS1 = 0x2d,
+ 	DESC_RATEVHT1SS_MCS2 = 0x2e,
+diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
+index a233b26..26fd960 100644
+--- a/drivers/net/wireless/rtlwifi/wifi.h
++++ b/drivers/net/wireless/rtlwifi/wifi.h
+@@ -331,10 +331,10 @@ enum hardware_type {
+ (IS_HARDWARE_TYPE_8723E(rtlhal) || IS_HARDWARE_TYPE_8723U(rtlhal))
+ 
+ #define RX_HAL_IS_CCK_RATE(rxmcs)			\
+-	((rxmcs) == DESC92_RATE1M ||			\
+-	 (rxmcs) == DESC92_RATE2M ||			\
+-	 (rxmcs) == DESC92_RATE5_5M ||			\
+-	 (rxmcs) == DESC92_RATE11M)
++	((rxmcs) == DESC_RATE1M ||			\
++	 (rxmcs) == DESC_RATE2M ||			\
++	 (rxmcs) == DESC_RATE5_5M ||			\
++	 (rxmcs) == DESC_RATE11M)
+ 
+ enum scan_operation_backup_opt {
+ 	SCAN_OPT_BACKUP = 0,
+@@ -579,38 +579,38 @@ enum rtl_hal_state {
+ };
+ 
+ enum rtl_desc92_rate {
+-	DESC92_RATE1M = 0x00,
+-	DESC92_RATE2M = 0x01,
+-	DESC92_RATE5_5M = 0x02,
+-	DESC92_RATE11M = 0x03,
+-
+-	DESC92_RATE6M = 0x04,
+-	DESC92_RATE9M = 0x05,
+-	DESC92_RATE12M = 0x06,
+-	DESC92_RATE18M = 0x07,
+-	DESC92_RATE24M = 0x08,
+-	DESC92_RATE36M = 0x09,
+-	DESC92_RATE48M = 0x0a,
+-	DESC92_RATE54M = 0x0b,
+-
+-	DESC92_RATEMCS0 = 0x0c,
+-	DESC92_RATEMCS1 = 0x0d,
+-	DESC92_RATEMCS2 = 0x0e,
+-	DESC92_RATEMCS3 = 0x0f,
+-	DESC92_RATEMCS4 = 0x10,
+-	DESC92_RATEMCS5 = 0x11,
+-	DESC92_RATEMCS6 = 0x12,
+-	DESC92_RATEMCS7 = 0x13,
+-	DESC92_RATEMCS8 = 0x14,
+-	DESC92_RATEMCS9 = 0x15,
+-	DESC92_RATEMCS10 = 0x16,
+-	DESC92_RATEMCS11 = 0x17,
+-	DESC92_RATEMCS12 = 0x18,
+-	DESC92_RATEMCS13 = 0x19,
+-	DESC92_RATEMCS14 = 0x1a,
+-	DESC92_RATEMCS15 = 0x1b,
+-	DESC92_RATEMCS15_SG = 0x1c,
+-	DESC92_RATEMCS32 = 0x20,
++	DESC_RATE1M = 0x00,
++	DESC_RATE2M = 0x01,
++	DESC_RATE5_5M = 0x02,
++	DESC_RATE11M = 0x03,
++
++	DESC_RATE6M = 0x04,
++	DESC_RATE9M = 0x05,
++	DESC_RATE12M = 0x06,
++	DESC_RATE18M = 0x07,
++	DESC_RATE24M = 0x08,
++	DESC_RATE36M = 0x09,
++	DESC_RATE48M = 0x0a,
++	DESC_RATE54M = 0x0b,
++
++	DESC_RATEMCS0 = 0x0c,
++	DESC_RATEMCS1 = 0x0d,
++	DESC_RATEMCS2 = 0x0e,
++	DESC_RATEMCS3 = 0x0f,
++	DESC_RATEMCS4 = 0x10,
++	DESC_RATEMCS5 = 0x11,
++	DESC_RATEMCS6 = 0x12,
++	DESC_RATEMCS7 = 0x13,
++	DESC_RATEMCS8 = 0x14,
++	DESC_RATEMCS9 = 0x15,
++	DESC_RATEMCS10 = 0x16,
++	DESC_RATEMCS11 = 0x17,
++	DESC_RATEMCS12 = 0x18,
++	DESC_RATEMCS13 = 0x19,
++	DESC_RATEMCS14 = 0x1a,
++	DESC_RATEMCS15 = 0x1b,
++	DESC_RATEMCS15_SG = 0x1c,
++	DESC_RATEMCS32 = 0x20,
+ };
+ 
+ enum rtl_var_map {
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0030-rtlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch b/package/kernel/mac80211/patches/680-0030-rtlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch
new file mode 100644
index 0000000..bac0aec
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0030-rtlwifi-rtl8821ae-Add-VHT-rate-descriptors.patch
@@ -0,0 +1,85 @@ 
+From 5a0791d0f5511bac894bc753cc68705ed5dea2c4 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:37 -0600
+Subject: [PATCH 30/51] rtlwifi: rtl8821ae: Add VHT rate descriptors
+
+Device RTL8821AE is the first if the rtlwifi devices to implement 802.11ac
+capability. As a result, VHT rate descriptors are needed. In addition, the
+driver is converted to use the descriptors in rtlwifi.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8821ae/def.h | 23 -----------------------
+ drivers/net/wireless/rtlwifi/wifi.h          | 21 +++++++++++++++++++++
+ 2 files changed, 21 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/def.h b/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
+index 53dc522..ee7c208 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/def.h
+@@ -373,29 +373,6 @@ enum rtl_desc_qsel {
+ 	QSLT_CMD = 0x13,
+ };
+ 
+-enum rtl_desc8821ae_rate {
+-	DESC_RATEVHT1SS_MCS0 = 0x2c,
+-	DESC_RATEVHT1SS_MCS1 = 0x2d,
+-	DESC_RATEVHT1SS_MCS2 = 0x2e,
+-	DESC_RATEVHT1SS_MCS3 = 0x2f,
+-	DESC_RATEVHT1SS_MCS4 = 0x30,
+-	DESC_RATEVHT1SS_MCS5 = 0x31,
+-	DESC_RATEVHT1SS_MCS6 = 0x32,
+-	DESC_RATEVHT1SS_MCS7 = 0x33,
+-	DESC_RATEVHT1SS_MCS8 = 0x34,
+-	DESC_RATEVHT1SS_MCS9 = 0x35,
+-	DESC_RATEVHT2SS_MCS0 = 0x36,
+-	DESC_RATEVHT2SS_MCS1 = 0x37,
+-	DESC_RATEVHT2SS_MCS2 = 0x38,
+-	DESC_RATEVHT2SS_MCS3 = 0x39,
+-	DESC_RATEVHT2SS_MCS4 = 0x3a,
+-	DESC_RATEVHT2SS_MCS5 = 0x3b,
+-	DESC_RATEVHT2SS_MCS6 = 0x3c,
+-	DESC_RATEVHT2SS_MCS7 = 0x3d,
+-	DESC_RATEVHT2SS_MCS8 = 0x3e,
+-	DESC_RATEVHT2SS_MCS9 = 0x3f,
+-};
+-
+ enum rx_packet_type {
+ 	NORMAL_RX,
+ 	TX_REPORT1,
+diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
+index 26fd960..7a718fd 100644
+--- a/drivers/net/wireless/rtlwifi/wifi.h
++++ b/drivers/net/wireless/rtlwifi/wifi.h
+@@ -611,6 +611,27 @@ enum rtl_desc92_rate {
+ 	DESC_RATEMCS15 = 0x1b,
+ 	DESC_RATEMCS15_SG = 0x1c,
+ 	DESC_RATEMCS32 = 0x20,
++
++	DESC_RATEVHT1SS_MCS0 = 0x2c,
++	DESC_RATEVHT1SS_MCS1 = 0x2d,
++	DESC_RATEVHT1SS_MCS2 = 0x2e,
++	DESC_RATEVHT1SS_MCS3 = 0x2f,
++	DESC_RATEVHT1SS_MCS4 = 0x30,
++	DESC_RATEVHT1SS_MCS5 = 0x31,
++	DESC_RATEVHT1SS_MCS6 = 0x32,
++	DESC_RATEVHT1SS_MCS7 = 0x33,
++	DESC_RATEVHT1SS_MCS8 = 0x34,
++	DESC_RATEVHT1SS_MCS9 = 0x35,
++	DESC_RATEVHT2SS_MCS0 = 0x36,
++	DESC_RATEVHT2SS_MCS1 = 0x37,
++	DESC_RATEVHT2SS_MCS2 = 0x38,
++	DESC_RATEVHT2SS_MCS3 = 0x39,
++	DESC_RATEVHT2SS_MCS4 = 0x3a,
++	DESC_RATEVHT2SS_MCS5 = 0x3b,
++	DESC_RATEVHT2SS_MCS6 = 0x3c,
++	DESC_RATEVHT2SS_MCS7 = 0x3d,
++	DESC_RATEVHT2SS_MCS8 = 0x3e,
++	DESC_RATEVHT2SS_MCS9 = 0x3f,
+ };
+ 
+ enum rtl_var_map {
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0031-rtlwifi-rtl8192cu-Rework-calls-to-rate-control-routi.patch b/package/kernel/mac80211/patches/680-0031-rtlwifi-rtl8192cu-Rework-calls-to-rate-control-routi.patch
new file mode 100644
index 0000000..690e8df
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0031-rtlwifi-rtl8192cu-Rework-calls-to-rate-control-routi.patch
@@ -0,0 +1,62 @@ 
+From 6a7fd777078f02ba9c14fe1af4c4c3f3a5285a41 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:38 -0600
+Subject: [PATCH 31/51] rtlwifi: rtl8192cu: Rework calls to rate-control
+ routine
+
+The code uses macros to determine the parameters that are passed to the
+rate setting routine. A simpler method is implemented.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+index fe29876..5eccaba 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+@@ -325,6 +325,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
+ 				   && (GET_RX_DESC_FAGGR(pdesc) == 1));
+ 	stats->timestamp_low = GET_RX_DESC_TSFL(pdesc);
+ 	stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc);
++	stats->is_ht = (bool)GET_RX_DESC_RX_HT(pdesc);
+ 	rx_status->freq = hw->conf.chandef.chan->center_freq;
+ 	rx_status->band = hw->conf.chandef.chan->band;
+ 	if (GET_RX_DESC_CRC32(pdesc))
+@@ -338,9 +339,8 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
+ 	rx_status->flag |= RX_FLAG_MACTIME_START;
+ 	if (stats->decrypted)
+ 		rx_status->flag |= RX_FLAG_DECRYPTED;
+-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
+-					(bool)GET_RX_DESC_RX_HT(pdesc),
+-					(u8)GET_RX_DESC_RX_MCS(pdesc));
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
++						   stats->rate);
+ 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
+ 	if (phystatus) {
+ 		p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
+@@ -392,6 +392,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
+ 				   && (GET_RX_DESC_FAGGR(rxdesc) == 1));
+ 	stats.timestamp_low = GET_RX_DESC_TSFL(rxdesc);
+ 	stats.rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(rxdesc);
++	stats.is_ht = (bool)GET_RX_DESC_RX_HT(rxdesc);
+ 	/* TODO: is center_freq changed when doing scan? */
+ 	/* TODO: Shall we add protection or just skip those two step? */
+ 	rx_status->freq = hw->conf.chandef.chan->center_freq;
+@@ -405,9 +406,8 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
+ 	if (GET_RX_DESC_RX_HT(rxdesc))
+ 		rx_status->flag |= RX_FLAG_HT;
+ 	/* Data rate */
+-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
+-					(bool)GET_RX_DESC_RX_HT(rxdesc),
+-					(u8)GET_RX_DESC_RX_MCS(rxdesc));
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats.is_ht,
++						   stats.rate);
+ 	/*  There is a phy status after this rx descriptor. */
+ 	if (GET_RX_DESC_PHY_STATUS(rxdesc)) {
+ 		p_drvinfo = (struct rx_fwinfo_92c *)(rxdesc + RTL_RX_DESC_SIZE);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0032-rtlwifi-rtl8192de-Rework-calls-to-rate-control-routi.patch b/package/kernel/mac80211/patches/680-0032-rtlwifi-rtl8192de-Rework-calls-to-rate-control-routi.patch
new file mode 100644
index 0000000..1e2eba4
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0032-rtlwifi-rtl8192de-Rework-calls-to-rate-control-routi.patch
@@ -0,0 +1,42 @@ 
+From a160ba06c1bde5e0609f7ac475a9650224337933 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:39 -0600
+Subject: [PATCH 32/51] rtlwifi: rtl8192de: Rework calls to rate-control
+ routine
+
+The code uses macros to determine the parameters that are passed to the
+rate setting routine. A simpler method is implemented.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192de/trx.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+index 381a4c0..547c6d0 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+@@ -499,6 +499,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,	struct rtl_stats *stats,
+ 					 && (GET_RX_DESC_FAGGR(pdesc) == 1));
+ 	stats->timestamp_low = GET_RX_DESC_TSFL(pdesc);
+ 	stats->rx_is40Mhzpacket = (bool) GET_RX_DESC_BW(pdesc);
++	stats->is_ht = (bool)GET_RX_DESC_RXHT(pdesc);
+ 	rx_status->freq = hw->conf.chandef.chan->center_freq;
+ 	rx_status->band = hw->conf.chandef.chan->band;
+ 	if (GET_RX_DESC_CRC32(pdesc))
+@@ -512,9 +513,8 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,	struct rtl_stats *stats,
+ 	rx_status->flag |= RX_FLAG_MACTIME_START;
+ 	if (stats->decrypted)
+ 		rx_status->flag |= RX_FLAG_DECRYPTED;
+-	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
+-					(bool)GET_RX_DESC_RXHT(pdesc),
+-					(u8)GET_RX_DESC_RXMCS(pdesc));
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
++						   stats->rate);
+ 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
+ 	if (phystatus) {
+ 		p_drvinfo = (struct rx_fwinfo_92d *)(skb->data +
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0033-rtlwifi-rtl8821ae-Switch-to-use-common-rate-control-.patch b/package/kernel/mac80211/patches/680-0033-rtlwifi-rtl8821ae-Switch-to-use-common-rate-control-.patch
new file mode 100644
index 0000000..20040d7
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0033-rtlwifi-rtl8821ae-Switch-to-use-common-rate-control-.patch
@@ -0,0 +1,498 @@ 
+From fd3cb22ad87fd53eb47dc64fd0cafd665d4124a1 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Thu, 18 Dec 2014 03:05:40 -0600
+Subject: [PATCH 33/51] rtlwifi: rtl8821ae: Switch to use common rate control
+ routine
+
+With this change, all of the drivers now use the common routine. As this
+driver has VHT capability, an additional parameter is needed, thus all the
+drivers had to be modified.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/base.c          |  76 ++++++++-
+ drivers/net/wireless/rtlwifi/base.h          |   4 +-
+ drivers/net/wireless/rtlwifi/rtl8188ee/trx.c |   2 +-
+ drivers/net/wireless/rtlwifi/rtl8192ce/trx.c |   2 +-
+ drivers/net/wireless/rtlwifi/rtl8192cu/trx.c |   4 +-
+ drivers/net/wireless/rtlwifi/rtl8192de/trx.c |   2 +-
+ drivers/net/wireless/rtlwifi/rtl8192ee/trx.c |   2 +-
+ drivers/net/wireless/rtlwifi/rtl8192se/trx.c |   2 +-
+ drivers/net/wireless/rtlwifi/rtl8723ae/trx.c |   2 +-
+ drivers/net/wireless/rtlwifi/rtl8723be/trx.c |   2 +-
+ drivers/net/wireless/rtlwifi/rtl8821ae/trx.c | 232 +--------------------------
+ 11 files changed, 88 insertions(+), 242 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
+index 23fc51e..1d46774 100644
+--- a/drivers/net/wireless/rtlwifi/base.c
++++ b/drivers/net/wireless/rtlwifi/base.c
+@@ -881,12 +881,84 @@ static u8 _rtl_get_highest_n_rate(struct ieee80211_hw *hw,
+  * N rate:
+  * (rx_status->flag & RX_FLAG_HT) = 1,
+  * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
++ *
++ * VHT rates:
++ * DESC_RATEVHT1SS_MCS0-->DESC_RATEVHT1SS_MCS9 ==> idx is 0-->9
++ * DESC_RATEVHT2SS_MCS0-->DESC_RATEVHT2SS_MCS9 ==> idx is 0-->9
+  */
+-int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
+-			 bool isht, u8 desc_rate)
++int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht, bool isvht,
++			 u8 desc_rate)
+ {
+ 	int rate_idx;
+ 
++	if (isvht) {
++		switch (desc_rate) {
++		case DESC_RATEVHT1SS_MCS0:
++			rate_idx = 0;
++			break;
++		case DESC_RATEVHT1SS_MCS1:
++			rate_idx = 1;
++			break;
++		case DESC_RATEVHT1SS_MCS2:
++			rate_idx = 2;
++			break;
++		case DESC_RATEVHT1SS_MCS3:
++			rate_idx = 3;
++			break;
++		case DESC_RATEVHT1SS_MCS4:
++			rate_idx = 4;
++			break;
++		case DESC_RATEVHT1SS_MCS5:
++			rate_idx = 5;
++			break;
++		case DESC_RATEVHT1SS_MCS6:
++			rate_idx = 6;
++			break;
++		case DESC_RATEVHT1SS_MCS7:
++			rate_idx = 7;
++			break;
++		case DESC_RATEVHT1SS_MCS8:
++			rate_idx = 8;
++			break;
++		case DESC_RATEVHT1SS_MCS9:
++			rate_idx = 9;
++			break;
++		case DESC_RATEVHT2SS_MCS0:
++			rate_idx = 0;
++			break;
++		case DESC_RATEVHT2SS_MCS1:
++			rate_idx = 1;
++			break;
++		case DESC_RATEVHT2SS_MCS2:
++			rate_idx = 2;
++			break;
++		case DESC_RATEVHT2SS_MCS3:
++			rate_idx = 3;
++			break;
++		case DESC_RATEVHT2SS_MCS4:
++			rate_idx = 4;
++			break;
++		case DESC_RATEVHT2SS_MCS5:
++			rate_idx = 5;
++			break;
++		case DESC_RATEVHT2SS_MCS6:
++			rate_idx = 6;
++			break;
++		case DESC_RATEVHT2SS_MCS7:
++			rate_idx = 7;
++			break;
++		case DESC_RATEVHT2SS_MCS8:
++			rate_idx = 8;
++			break;
++		case DESC_RATEVHT2SS_MCS9:
++			rate_idx = 9;
++			break;
++		default:
++			rate_idx = 0;
++			break;
++		}
++		return rate_idx;
++	}
+ 	if (false == isht) {
+ 		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
+ 			switch (desc_rate) {
+diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h
+index 936c2bb..c6cb49c 100644
+--- a/drivers/net/wireless/rtlwifi/base.h
++++ b/drivers/net/wireless/rtlwifi/base.h
+@@ -123,8 +123,8 @@ void rtl_watch_dog_timer_callback(unsigned long data);
+ void rtl_deinit_deferred_work(struct ieee80211_hw *hw);
+ 
+ bool rtl_action_proc(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
+-int rtlwifi_rate_mapping(struct ieee80211_hw *hw,
+-			 bool isht, u8 desc_rate);
++int rtlwifi_rate_mapping(struct ieee80211_hw *hw, bool isht,
++			 bool isvht, u8 desc_rate);
+ bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb);
+ u8 rtl_is_special_data(struct ieee80211_hw *hw, struct sk_buff *skb, u8 is_tx);
+ 
+diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
+index d430884..791efbe 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
+@@ -473,7 +473,7 @@ bool rtl88ee_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * Notice: this is diff with windows define
+ 	 */
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
+-						   status->rate);
++						   false, status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+ 	if (phystatus == true) {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+index 685faea..84ddd4d 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+@@ -401,7 +401,7 @@ bool rtl92ce_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * Notice: this is diff with windows define
+ 	 */
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
+-						   stats->rate);
++						   false, stats->rate);
+ 
+ 	rx_status->mactime = stats->timestamp_low;
+ 	if (phystatus) {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+index 5eccaba..cbead00 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c
+@@ -340,7 +340,7 @@ bool rtl92cu_rx_query_desc(struct ieee80211_hw *hw,
+ 	if (stats->decrypted)
+ 		rx_status->flag |= RX_FLAG_DECRYPTED;
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
+-						   stats->rate);
++						   false, stats->rate);
+ 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
+ 	if (phystatus) {
+ 		p_drvinfo = (struct rx_fwinfo_92c *)(skb->data +
+@@ -407,7 +407,7 @@ static void _rtl_rx_process(struct ieee80211_hw *hw, struct sk_buff *skb)
+ 		rx_status->flag |= RX_FLAG_HT;
+ 	/* Data rate */
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats.is_ht,
+-						   stats.rate);
++						   false, stats.rate);
+ 	/*  There is a phy status after this rx descriptor. */
+ 	if (GET_RX_DESC_PHY_STATUS(rxdesc)) {
+ 		p_drvinfo = (struct rx_fwinfo_92c *)(rxdesc + RTL_RX_DESC_SIZE);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+index 547c6d0..1feaa62 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+@@ -514,7 +514,7 @@ bool rtl92de_rx_query_desc(struct ieee80211_hw *hw,	struct rtl_stats *stats,
+ 	if (stats->decrypted)
+ 		rx_status->flag |= RX_FLAG_DECRYPTED;
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
+-						   stats->rate);
++						   false, stats->rate);
+ 	rx_status->mactime = GET_RX_DESC_TSFL(pdesc);
+ 	if (phystatus) {
+ 		p_drvinfo = (struct rx_fwinfo_92d *)(skb->data +
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+index 3ea7367..51806ac 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+@@ -419,7 +419,7 @@ bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * Notice: this is diff with windows define
+ 	 */
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
+-						   status->rate);
++						   false, status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+ 	if (phystatus) {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+index 95eebff..125b29b 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+@@ -319,7 +319,7 @@ bool rtl92se_rx_query_desc(struct ieee80211_hw *hw, struct rtl_stats *stats,
+ 	}
+ 
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, stats->is_ht,
+-						   stats->rate);
++						   false, stats->rate);
+ 
+ 	rx_status->mactime = stats->timestamp_low;
+ 	if (phystatus) {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
+index 662a094..2f7c144 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
+@@ -346,7 +346,7 @@ bool rtl8723e_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * Notice: this is diff with windows define
+ 	 */
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
+-						   status->rate);
++						   false, status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+ 	if (phystatus == true) {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
+index cb23bed..338ec9a 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/trx.c
+@@ -401,7 +401,7 @@ bool rtl8723be_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * are use (RX_FLAG_HT)
+ 	 */
+ 	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
+-						      status->rate);
++						   false, status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+ 	if (phystatus) {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
+index 383b86b..72af4b9 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/trx.c
+@@ -48,232 +48,6 @@ static u8 _rtl8821ae_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue)
+ 	return skb->priority;
+ }
+ 
+-/* mac80211's rate_idx is like this:
+- *
+- * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ
+- *
+- * B/G rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC_RATE1M-->DESC_RATE54M ==> idx is 0-->11,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
+- *
+- * 5G band:rx_status->band == IEEE80211_BAND_5GHZ
+- * A rate:
+- * (rx_status->flag & RX_FLAG_HT) = 0,
+- * DESC_RATE6M-->DESC_RATE54M ==> idx is 0-->7,
+- *
+- * N rate:
+- * (rx_status->flag & RX_FLAG_HT) = 1,
+- * DESC_RATEMCS0-->DESC_RATEMCS15 ==> idx is 0-->15
+- */
+-static int _rtl8821ae_rate_mapping(struct ieee80211_hw *hw,
+-				   bool isht, bool isvht, u8 desc_rate)
+-{
+-	int rate_idx;
+-
+-	if (!isht) {
+-		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) {
+-			switch (desc_rate) {
+-			case DESC_RATE1M:
+-				rate_idx = 0;
+-				break;
+-			case DESC_RATE2M:
+-				rate_idx = 1;
+-				break;
+-			case DESC_RATE5_5M:
+-				rate_idx = 2;
+-				break;
+-			case DESC_RATE11M:
+-				rate_idx = 3;
+-				break;
+-			case DESC_RATE6M:
+-				rate_idx = 4;
+-				break;
+-			case DESC_RATE9M:
+-				rate_idx = 5;
+-				break;
+-			case DESC_RATE12M:
+-				rate_idx = 6;
+-				break;
+-			case DESC_RATE18M:
+-				rate_idx = 7;
+-				break;
+-			case DESC_RATE24M:
+-				rate_idx = 8;
+-				break;
+-			case DESC_RATE36M:
+-				rate_idx = 9;
+-				break;
+-			case DESC_RATE48M:
+-				rate_idx = 10;
+-				break;
+-			case DESC_RATE54M:
+-				rate_idx = 11;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		} else {
+-			switch (desc_rate) {
+-			case DESC_RATE6M:
+-				rate_idx = 0;
+-				break;
+-			case DESC_RATE9M:
+-				rate_idx = 1;
+-				break;
+-			case DESC_RATE12M:
+-				rate_idx = 2;
+-				break;
+-			case DESC_RATE18M:
+-				rate_idx = 3;
+-				break;
+-			case DESC_RATE24M:
+-				rate_idx = 4;
+-				break;
+-			case DESC_RATE36M:
+-				rate_idx = 5;
+-				break;
+-			case DESC_RATE48M:
+-				rate_idx = 6;
+-				break;
+-			case DESC_RATE54M:
+-				rate_idx = 7;
+-				break;
+-			default:
+-				rate_idx = 0;
+-				break;
+-			}
+-		}
+-	} else {
+-		switch (desc_rate) {
+-		case DESC_RATEMCS0:
+-			rate_idx = 0;
+-			break;
+-		case DESC_RATEMCS1:
+-			rate_idx = 1;
+-			break;
+-		case DESC_RATEMCS2:
+-			rate_idx = 2;
+-			break;
+-		case DESC_RATEMCS3:
+-			rate_idx = 3;
+-			break;
+-		case DESC_RATEMCS4:
+-			rate_idx = 4;
+-			break;
+-		case DESC_RATEMCS5:
+-			rate_idx = 5;
+-			break;
+-		case DESC_RATEMCS6:
+-			rate_idx = 6;
+-			break;
+-		case DESC_RATEMCS7:
+-			rate_idx = 7;
+-			break;
+-		case DESC_RATEMCS8:
+-			rate_idx = 8;
+-			break;
+-		case DESC_RATEMCS9:
+-			rate_idx = 9;
+-			break;
+-		case DESC_RATEMCS10:
+-			rate_idx = 10;
+-			break;
+-		case DESC_RATEMCS11:
+-			rate_idx = 11;
+-			break;
+-		case DESC_RATEMCS12:
+-			rate_idx = 12;
+-			break;
+-		case DESC_RATEMCS13:
+-			rate_idx = 13;
+-			break;
+-		case DESC_RATEMCS14:
+-			rate_idx = 14;
+-			break;
+-		case DESC_RATEMCS15:
+-			rate_idx = 15;
+-			break;
+-		default:
+-			rate_idx = 0;
+-			break;
+-		}
+-	}
+-
+-	if (isvht) {
+-		switch (desc_rate) {
+-		case DESC_RATEVHT1SS_MCS0:
+-			rate_idx = 0;
+-			break;
+-		case DESC_RATEVHT1SS_MCS1:
+-			rate_idx = 1;
+-			break;
+-		case DESC_RATEVHT1SS_MCS2:
+-			rate_idx = 2;
+-			break;
+-		case DESC_RATEVHT1SS_MCS3:
+-			rate_idx = 3;
+-			break;
+-		case DESC_RATEVHT1SS_MCS4:
+-			rate_idx = 4;
+-			break;
+-		case DESC_RATEVHT1SS_MCS5:
+-			rate_idx = 5;
+-			break;
+-		case DESC_RATEVHT1SS_MCS6:
+-			rate_idx = 6;
+-			break;
+-		case DESC_RATEVHT1SS_MCS7:
+-			rate_idx = 7;
+-			break;
+-		case DESC_RATEVHT1SS_MCS8:
+-			rate_idx = 8;
+-			break;
+-		case DESC_RATEVHT1SS_MCS9:
+-			rate_idx = 9;
+-			break;
+-		case DESC_RATEVHT2SS_MCS0:
+-			rate_idx = 0;
+-			break;
+-		case DESC_RATEVHT2SS_MCS1:
+-			rate_idx = 1;
+-			break;
+-		case DESC_RATEVHT2SS_MCS2:
+-			rate_idx = 2;
+-			break;
+-		case DESC_RATEVHT2SS_MCS3:
+-			rate_idx = 3;
+-			break;
+-		case DESC_RATEVHT2SS_MCS4:
+-			rate_idx = 4;
+-			break;
+-		case DESC_RATEVHT2SS_MCS5:
+-			rate_idx = 5;
+-			break;
+-		case DESC_RATEVHT2SS_MCS6:
+-			rate_idx = 6;
+-			break;
+-		case DESC_RATEVHT2SS_MCS7:
+-			rate_idx = 7;
+-			break;
+-		case DESC_RATEVHT2SS_MCS8:
+-			rate_idx = 8;
+-			break;
+-		case DESC_RATEVHT2SS_MCS9:
+-			rate_idx = 9;
+-			break;
+-		default:
+-			rate_idx = 0;
+-			break;
+-		}
+-	}
+-	return rate_idx;
+-}
+-
+ static u16 odm_cfo(char value)
+ {
+ 	int ret_val;
+@@ -766,9 +540,9 @@ bool rtl8821ae_rx_query_desc(struct ieee80211_hw *hw,
+ 	 * supported rates or MCS index if HT rates
+ 	 * are use (RX_FLAG_HT)
+ 	 */
+-	rx_status->rate_idx =
+-	  _rtl8821ae_rate_mapping(hw, status->is_ht,
+-				  status->is_vht, status->rate);
++	rx_status->rate_idx = rtlwifi_rate_mapping(hw, status->is_ht,
++						   status->is_vht,
++						   status->rate);
+ 
+ 	rx_status->mactime = status->timestamp_low;
+ 	if (phystatus) {
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0034-rtlwifi-rtl8192ee-trx.c-Remove-unused-function.patch b/package/kernel/mac80211/patches/680-0034-rtlwifi-rtl8192ee-trx.c-Remove-unused-function.patch
new file mode 100644
index 0000000..3050a93
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0034-rtlwifi-rtl8192ee-trx.c-Remove-unused-function.patch
@@ -0,0 +1,64 @@ 
+From 9898b77536b8569be2704964d3c519ef070e4a27 Mon Sep 17 00:00:00 2001
+From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
+Date: Sat, 20 Dec 2014 13:48:14 +0100
+Subject: [PATCH 34/51] rtlwifi: rtl8192ee: trx.c: Remove unused function
+
+Remove the function rtl92ee_get_available_desc() that is not used anywhere.
+
+This was partially found by using a static code analysis program called cppcheck.
+
+Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ee/trx.c | 21 ---------------------
+ drivers/net/wireless/rtlwifi/rtl8192ee/trx.h |  1 -
+ 2 files changed, 22 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+index 51806ac..55d1da5 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.c
+@@ -551,27 +551,6 @@ static u16 get_desc_addr_fr_q_idx(u16 queue_index)
+ 	return desc_address;
+ }
+ 
+-void rtl92ee_get_available_desc(struct ieee80211_hw *hw, u8 q_idx)
+-{
+-	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	u16 point_diff = 0;
+-	u16 current_tx_read_point = 0, current_tx_write_point = 0;
+-	u32 tmp_4byte;
+-
+-	tmp_4byte = rtl_read_dword(rtlpriv,
+-				   get_desc_addr_fr_q_idx(q_idx));
+-	current_tx_read_point = (u16)((tmp_4byte >> 16) & 0x0fff);
+-	current_tx_write_point = (u16)((tmp_4byte) & 0x0fff);
+-
+-	point_diff = ((current_tx_read_point > current_tx_write_point) ?
+-		      (current_tx_read_point - current_tx_write_point) :
+-		      (TX_DESC_NUM_92E - current_tx_write_point +
+-		       current_tx_read_point));
+-
+-	rtlpci->tx_ring[q_idx].avl_desc = point_diff;
+-}
+-
+ void rtl92ee_pre_fill_tx_bd_desc(struct ieee80211_hw *hw,
+ 				 u8 *tx_bd_desc, u8 *desc, u8 queue_index,
+ 				 struct sk_buff *skb, dma_addr_t addr)
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
+index 45fd9db..48504c2 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/trx.h
+@@ -829,7 +829,6 @@ void rtl92ee_rx_check_dma_ok(struct ieee80211_hw *hw, u8 *header_desc,
+ 			     u8 queue_index);
+ u16	rtl92ee_rx_desc_buff_remained_cnt(struct ieee80211_hw *hw,
+ 					  u8 queue_index);
+-void rtl92ee_get_available_desc(struct ieee80211_hw *hw, u8 queue_index);
+ void rtl92ee_pre_fill_tx_bd_desc(struct ieee80211_hw *hw,
+ 				 u8 *tx_bd_desc, u8 *desc, u8 queue_index,
+ 				 struct sk_buff *skb, dma_addr_t addr);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0035-rtlwifi-rtl8723be-phy.c-Remove-unused-function.patch b/package/kernel/mac80211/patches/680-0035-rtlwifi-rtl8723be-phy.c-Remove-unused-function.patch
new file mode 100644
index 0000000..4d5b1a4
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0035-rtlwifi-rtl8723be-phy.c-Remove-unused-function.patch
@@ -0,0 +1,69 @@ 
+From b30b2e0f3dbcde630b911bdc8fda8ae8300fff6a Mon Sep 17 00:00:00 2001
+From: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
+Date: Sat, 20 Dec 2014 23:59:18 +0100
+Subject: [PATCH 35/51] rtlwifi: rtl8723be: phy.c: Remove unused function
+
+Remove the function rtl8723be_phy_get_txpower_level() that is not used anywhere.
+
+This was partially found by using a static code analysis program called cppcheck.
+
+Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8723be/phy.c | 25 -------------------------
+ drivers/net/wireless/rtlwifi/rtl8723be/phy.h |  2 --
+ 2 files changed, 27 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/phy.c b/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
+index 20dcc25..b7b73cb 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/phy.c
+@@ -874,31 +874,6 @@ void rtl8723be_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw)
+ 		  ROFDM0_RXDETECTOR3, rtlphy->framesync);
+ }
+ 
+-void rtl8723be_phy_get_txpower_level(struct ieee80211_hw *hw, long *powerlevel)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	struct rtl_phy *rtlphy = &rtlpriv->phy;
+-	u8 txpwr_level;
+-	long txpwr_dbm;
+-
+-	txpwr_level = rtlphy->cur_cck_txpwridx;
+-	txpwr_dbm = rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_B,
+-						 txpwr_level);
+-	txpwr_level = rtlphy->cur_ofdm24g_txpwridx;
+-	if (rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_G, txpwr_level) >
+-	    txpwr_dbm)
+-		txpwr_dbm =
+-		    rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_G,
+-						 txpwr_level);
+-	txpwr_level = rtlphy->cur_ofdm24g_txpwridx;
+-	if (rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_N_24G,
+-					 txpwr_level) > txpwr_dbm)
+-		txpwr_dbm =
+-		    rtl8723_phy_txpwr_idx_to_dbm(hw, WIRELESS_MODE_N_24G,
+-						 txpwr_level);
+-	*powerlevel = txpwr_dbm;
+-}
+-
+ static u8 _rtl8723be_phy_get_ratesection_intxpower_byrate(enum radio_path path,
+ 							  u8 rate)
+ {
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/phy.h b/drivers/net/wireless/rtlwifi/rtl8723be/phy.h
+index 6339738..9021d47 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/phy.h
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/phy.h
+@@ -114,8 +114,6 @@ bool rtl8723be_phy_mac_config(struct ieee80211_hw *hw);
+ bool rtl8723be_phy_bb_config(struct ieee80211_hw *hw);
+ bool rtl8723be_phy_rf_config(struct ieee80211_hw *hw);
+ void rtl8723be_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw);
+-void rtl8723be_phy_get_txpower_level(struct ieee80211_hw *hw,
+-				     long *powerlevel);
+ void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw,
+ 				     u8 channel);
+ void rtl8723be_phy_scan_operation_backup(struct ieee80211_hw *hw,
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0036-rtlwifi-Fix-error-when-accessing-unmapped-memory-in-.patch b/package/kernel/mac80211/patches/680-0036-rtlwifi-Fix-error-when-accessing-unmapped-memory-in-.patch
new file mode 100644
index 0000000..59bdbfe
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0036-rtlwifi-Fix-error-when-accessing-unmapped-memory-in-.patch
@@ -0,0 +1,126 @@ 
+From e9538cf4f90713eca71b1d6a74b4eae1d445c664 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 30 Dec 2014 21:33:07 -0600
+Subject: [PATCH 36/51] rtlwifi: Fix error when accessing unmapped memory in
+ skb
+
+These drivers use 9100-byte receive buffers, thus allocating an skb requires
+an O(3) memory allocation. Under heavy memory loads and fragmentation, such
+a request can fail. Previous versions of the driver have dropped the packet
+and reused the old buffer; however, the new version introduced a bug in that
+it released the old buffer before trying to allocate a new one. The previous
+method is implemented here. The skb is unmapped before any attempt is made to
+allocate another.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Cc: Stable <stable@vger.kernel.org>  [v3.18]
+Reported-by: Eric Biggers <ebiggers3@gmail.com>
+Cc: Eric Biggers <ebiggers3@gmail.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/pci.c | 32 ++++++++++++++++++++++++--------
+ 1 file changed, 24 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
+index 846a2e6..c70efb9 100644
+--- a/drivers/net/wireless/rtlwifi/pci.c
++++ b/drivers/net/wireless/rtlwifi/pci.c
+@@ -666,7 +666,8 @@ tx_status_ok:
+ }
+ 
+ static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw,
+-				    u8 *entry, int rxring_idx, int desc_idx)
++				    struct sk_buff *new_skb, u8 *entry,
++				    int rxring_idx, int desc_idx)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+ 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
+@@ -674,11 +675,15 @@ static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw,
+ 	u8 tmp_one = 1;
+ 	struct sk_buff *skb;
+ 
++	if (likely(new_skb)) {
++		skb = new_skb;
++		goto remap;
++	}
+ 	skb = dev_alloc_skb(rtlpci->rxbuffersize);
+ 	if (!skb)
+ 		return 0;
+-	rtlpci->rx_ring[rxring_idx].rx_buf[desc_idx] = skb;
+ 
++remap:
+ 	/* just set skb->cb to mapping addr for pci_unmap_single use */
+ 	*((dma_addr_t *)skb->cb) =
+ 		pci_map_single(rtlpci->pdev, skb_tail_pointer(skb),
+@@ -686,6 +691,7 @@ static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw,
+ 	bufferaddress = *((dma_addr_t *)skb->cb);
+ 	if (pci_dma_mapping_error(rtlpci->pdev, bufferaddress))
+ 		return 0;
++	rtlpci->rx_ring[rxring_idx].rx_buf[desc_idx] = skb;
+ 	if (rtlpriv->use_new_trx_flow) {
+ 		rtlpriv->cfg->ops->set_desc(hw, (u8 *)entry, false,
+ 					    HW_DESC_RX_PREPARE,
+@@ -781,6 +787,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
+ 		/*rx pkt */
+ 		struct sk_buff *skb = rtlpci->rx_ring[rxring_idx].rx_buf[
+ 				      rtlpci->rx_ring[rxring_idx].idx];
++		struct sk_buff *new_skb;
+ 
+ 		if (rtlpriv->use_new_trx_flow) {
+ 			rx_remained_cnt =
+@@ -807,6 +814,13 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
+ 		pci_unmap_single(rtlpci->pdev, *((dma_addr_t *)skb->cb),
+ 				 rtlpci->rxbuffersize, PCI_DMA_FROMDEVICE);
+ 
++		/* get a new skb - if fail, old one will be reused */
++		new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
++		if (unlikely(!new_skb)) {
++			pr_err("Allocation of new skb failed in %s\n",
++			       __func__);
++			goto no_new;
++		}
+ 		if (rtlpriv->use_new_trx_flow) {
+ 			buffer_desc =
+ 			  &rtlpci->rx_ring[rxring_idx].buffer_desc
+@@ -911,14 +925,16 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
+ 			schedule_work(&rtlpriv->works.lps_change_work);
+ 		}
+ end:
++		skb = new_skb;
++no_new:
+ 		if (rtlpriv->use_new_trx_flow) {
+-			_rtl_pci_init_one_rxdesc(hw, (u8 *)buffer_desc,
++			_rtl_pci_init_one_rxdesc(hw, skb, (u8 *)buffer_desc,
+ 						 rxring_idx,
+-					       rtlpci->rx_ring[rxring_idx].idx);
++						 rtlpci->rx_ring[rxring_idx].idx);
+ 		} else {
+-			_rtl_pci_init_one_rxdesc(hw, (u8 *)pdesc, rxring_idx,
++			_rtl_pci_init_one_rxdesc(hw, skb, (u8 *)pdesc,
++						 rxring_idx,
+ 						 rtlpci->rx_ring[rxring_idx].idx);
+-
+ 			if (rtlpci->rx_ring[rxring_idx].idx ==
+ 			    rtlpci->rxringcount - 1)
+ 				rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc,
+@@ -1307,7 +1323,7 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx)
+ 		rtlpci->rx_ring[rxring_idx].idx = 0;
+ 		for (i = 0; i < rtlpci->rxringcount; i++) {
+ 			entry = &rtlpci->rx_ring[rxring_idx].buffer_desc[i];
+-			if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry,
++			if (!_rtl_pci_init_one_rxdesc(hw, NULL, (u8 *)entry,
+ 						      rxring_idx, i))
+ 				return -ENOMEM;
+ 		}
+@@ -1332,7 +1348,7 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw, int rxring_idx)
+ 
+ 		for (i = 0; i < rtlpci->rxringcount; i++) {
+ 			entry = &rtlpci->rx_ring[rxring_idx].desc[i];
+-			if (!_rtl_pci_init_one_rxdesc(hw, (u8 *)entry,
++			if (!_rtl_pci_init_one_rxdesc(hw, NULL, (u8 *)entry,
+ 						      rxring_idx, i))
+ 				return -ENOMEM;
+ 		}
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0037-rtlwifi-Unify-variable-naming-for-all-drivers.patch b/package/kernel/mac80211/patches/680-0037-rtlwifi-Unify-variable-naming-for-all-drivers.patch
new file mode 100644
index 0000000..107aa0a
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0037-rtlwifi-Unify-variable-naming-for-all-drivers.patch
@@ -0,0 +1,300 @@ 
+From 1f6969fb230b79debcdf8ec3614162b553664396 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:02 -0600
+Subject: [PATCH 37/51] rtlwifi: Unify variable naming for all drivers
+
+Some drivers refer to a particular quantity in the driver's private
+are by one name, while others use a different name. These differences
+are removed.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c |  2 +-
+ drivers/net/wireless/rtlwifi/rtl8192ee/dm.c       | 26 ++++++++++----------
+ drivers/net/wireless/rtlwifi/rtl8723be/dm.c       | 26 ++++++++++----------
+ drivers/net/wireless/rtlwifi/rtl8821ae/dm.c       | 30 +++++++++++------------
+ drivers/net/wireless/rtlwifi/wifi.h               |  2 --
+ 5 files changed, 42 insertions(+), 44 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+index f6cb5ae..c3aad76 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+@@ -221,7 +221,7 @@ static void rtl92c_dm_diginit(struct ieee80211_hw *hw)
+ 	dm_digtable->forbidden_igi = DM_DIG_MIN;
+ 	dm_digtable->large_fa_hit = 0;
+ 	dm_digtable->recover_cnt = 0;
+-	dm_digtable->dig_dynamic_min  = 0x25;
++	dm_digtable->dig_min_0  = 0x25;
+ }
+ 
+ static u8 rtl92c_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
+index 77deedf..2fa4c45 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
+@@ -172,8 +172,8 @@ static void rtl92ee_dm_diginit(struct ieee80211_hw *hw)
+ 	dm_dig->forbidden_igi = DM_DIG_MIN;
+ 	dm_dig->large_fa_hit = 0;
+ 	dm_dig->recover_cnt = 0;
+-	dm_dig->dig_dynamic_min = DM_DIG_MIN;
+-	dm_dig->dig_dynamic_min_1 = DM_DIG_MIN;
++	dm_dig->dig_min_0 = DM_DIG_MIN;
++	dm_dig->dig_min_1 = DM_DIG_MIN;
+ 	dm_dig->media_connect_0 = false;
+ 	dm_dig->media_connect_1 = false;
+ 	rtlpriv->dm.dm_initialgain_enable = true;
+@@ -298,7 +298,7 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+ 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
+ 	struct dig_t *dm_dig = &rtlpriv->dm_digtable;
+-	u8 dig_dynamic_min , dig_maxofmin;
++	u8 dig_min_0, dig_maxofmin;
+ 	bool bfirstconnect , bfirstdisconnect;
+ 	u8 dm_dig_max, dm_dig_min;
+ 	u8 current_igi = dm_dig->cur_igvalue;
+@@ -308,7 +308,7 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
+ 	if (mac->act_scanning)
+ 		return;
+ 
+-	dig_dynamic_min = dm_dig->dig_dynamic_min;
++	dig_min_0 = dm_dig->dig_min_0;
+ 	bfirstconnect = (mac->link_state >= MAC80211_LINKED) &&
+ 			!dm_dig->media_connect_0;
+ 	bfirstdisconnect = (mac->link_state < MAC80211_LINKED) &&
+@@ -329,19 +329,19 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
+ 		if (rtlpriv->dm.one_entry_only) {
+ 			offset = 0;
+ 			if (dm_dig->rssi_val_min - offset < dm_dig_min)
+-				dig_dynamic_min = dm_dig_min;
++				dig_min_0 = dm_dig_min;
+ 			else if (dm_dig->rssi_val_min - offset >
+ 				 dig_maxofmin)
+-				dig_dynamic_min = dig_maxofmin;
++				dig_min_0 = dig_maxofmin;
+ 			else
+-				dig_dynamic_min = dm_dig->rssi_val_min - offset;
++				dig_min_0 = dm_dig->rssi_val_min - offset;
+ 		} else {
+-			dig_dynamic_min = dm_dig_min;
++			dig_min_0 = dm_dig_min;
+ 		}
+ 
+ 	} else {
+ 		dm_dig->rx_gain_max = dm_dig_max;
+-		dig_dynamic_min = dm_dig_min;
++		dig_min_0 = dm_dig_min;
+ 		RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "no link\n");
+ 	}
+ 
+@@ -368,10 +368,10 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
+ 		} else {
+ 			if (dm_dig->large_fa_hit < 3) {
+ 				if ((dm_dig->forbidden_igi - 1) <
+-				    dig_dynamic_min) {
+-					dm_dig->forbidden_igi = dig_dynamic_min;
++				    dig_min_0) {
++					dm_dig->forbidden_igi = dig_min_0;
+ 					dm_dig->rx_gain_min =
+-								dig_dynamic_min;
++								dig_min_0;
+ 				} else {
+ 					dm_dig->forbidden_igi--;
+ 					dm_dig->rx_gain_min =
+@@ -430,7 +430,7 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)
+ 	rtl92ee_dm_write_dig(hw , current_igi);
+ 	dm_dig->media_connect_0 = ((mac->link_state >= MAC80211_LINKED) ?
+ 				   true : false);
+-	dm_dig->dig_dynamic_min = dig_dynamic_min;
++	dm_dig->dig_min_0 = dig_min_0;
+ }
+ 
+ void rtl92ee_dm_write_cck_cca_thres(struct ieee80211_hw *hw, u8 cur_thres)
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
+index dd7eb43..b92c521e 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
+@@ -232,8 +232,8 @@ static void rtl8723be_dm_diginit(struct ieee80211_hw *hw)
+ 	dm_digtable->forbidden_igi = DM_DIG_MIN;
+ 	dm_digtable->large_fa_hit = 0;
+ 	dm_digtable->recover_cnt = 0;
+-	dm_digtable->dig_dynamic_min = DM_DIG_MIN;
+-	dm_digtable->dig_dynamic_min_1 = DM_DIG_MIN;
++	dm_digtable->dig_min_0 = DM_DIG_MIN;
++	dm_digtable->dig_min_1 = DM_DIG_MIN;
+ 	dm_digtable->media_connect_0 = false;
+ 	dm_digtable->media_connect_1 = false;
+ 	rtlpriv->dm.dm_initialgain_enable = true;
+@@ -424,7 +424,7 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+ 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
+ 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
+-	u8 dig_dynamic_min, dig_maxofmin;
++	u8 dig_min_0, dig_maxofmin;
+ 	bool bfirstconnect, bfirstdisconnect;
+ 	u8 dm_dig_max, dm_dig_min;
+ 	u8 current_igi = dm_digtable->cur_igvalue;
+@@ -434,7 +434,7 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
+ 	if (mac->act_scanning)
+ 		return;
+ 
+-	dig_dynamic_min = dm_digtable->dig_dynamic_min;
++	dig_min_0 = dm_digtable->dig_min_0;
+ 	bfirstconnect = (mac->link_state >= MAC80211_LINKED) &&
+ 			!dm_digtable->media_connect_0;
+ 	bfirstdisconnect = (mac->link_state < MAC80211_LINKED) &&
+@@ -456,20 +456,20 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
+ 		if (rtlpriv->dm.one_entry_only) {
+ 			offset = 12;
+ 			if (dm_digtable->rssi_val_min - offset < dm_dig_min)
+-				dig_dynamic_min = dm_dig_min;
++				dig_min_0 = dm_dig_min;
+ 			else if (dm_digtable->rssi_val_min - offset >
+ 							dig_maxofmin)
+-				dig_dynamic_min = dig_maxofmin;
++				dig_min_0 = dig_maxofmin;
+ 			else
+-				dig_dynamic_min =
++				dig_min_0 =
+ 					dm_digtable->rssi_val_min - offset;
+ 		} else {
+-			dig_dynamic_min = dm_dig_min;
++			dig_min_0 = dm_dig_min;
+ 		}
+ 
+ 	} else {
+ 		dm_digtable->rx_gain_max = dm_dig_max;
+-		dig_dynamic_min = dm_dig_min;
++		dig_min_0 = dm_dig_min;
+ 		RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, "no link\n");
+ 	}
+ 
+@@ -497,11 +497,11 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
+ 		} else {
+ 			if (dm_digtable->large_fa_hit < 3) {
+ 				if ((dm_digtable->forbidden_igi - 1) <
+-				     dig_dynamic_min) {
++				     dig_min_0) {
+ 					dm_digtable->forbidden_igi =
+-							dig_dynamic_min;
++							dig_min_0;
+ 					dm_digtable->rx_gain_min =
+-							dig_dynamic_min;
++							dig_min_0;
+ 				} else {
+ 					dm_digtable->forbidden_igi--;
+ 					dm_digtable->rx_gain_min =
+@@ -552,7 +552,7 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)
+ 	rtl8723be_dm_write_dig(hw, current_igi);
+ 	dm_digtable->media_connect_0 =
+ 		((mac->link_state >= MAC80211_LINKED) ? true : false);
+-	dm_digtable->dig_dynamic_min = dig_dynamic_min;
++	dm_digtable->dig_min_0 = dig_min_0;
+ }
+ 
+ static void rtl8723be_dm_false_alarm_counter_statistics(
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+index ba30b0d..8b0bfb2 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+@@ -539,8 +539,8 @@ static void rtl8821ae_dm_diginit(struct ieee80211_hw *hw)
+ 	dm_digtable->forbidden_igi = DM_DIG_MIN;
+ 	dm_digtable->large_fa_hit = 0;
+ 	dm_digtable->recover_cnt = 0;
+-	dm_digtable->dig_dynamic_min = DM_DIG_MIN;
+-	dm_digtable->dig_dynamic_min_1 = DM_DIG_MIN;
++	dm_digtable->dig_min_0 = DM_DIG_MIN;
++	dm_digtable->dig_min_1 = DM_DIG_MIN;
+ 	dm_digtable->media_connect_0 = false;
+ 	dm_digtable->media_connect_1 = false;
+ 	rtlpriv->dm.dm_initialgain_enable = true;
+@@ -822,7 +822,7 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
+ 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
+ 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
+ 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
+-	u8 dig_dynamic_min;
++	u8 dig_min_0;
+ 	u8 dig_max_of_min;
+ 	bool first_connect, first_disconnect;
+ 	u8 dm_dig_max, dm_dig_min, offset;
+@@ -837,7 +837,7 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
+ 	}
+ 
+ 	/*add by Neil Chen to avoid PSD is processing*/
+-	dig_dynamic_min = dm_digtable->dig_dynamic_min;
++	dig_min_0 = dm_digtable->dig_min_0;
+ 	first_connect = (mac->link_state >= MAC80211_LINKED) &&
+ 			(!dm_digtable->media_connect_0);
+ 	first_disconnect = (mac->link_state < MAC80211_LINKED) &&
+@@ -876,23 +876,23 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
+ 			offset = 0;
+ 
+ 			if (dm_digtable->rssi_val_min - offset < dm_dig_min)
+-				dig_dynamic_min = dm_dig_min;
++				dig_min_0 = dm_dig_min;
+ 			else if (dm_digtable->rssi_val_min -
+ 				offset > dig_max_of_min)
+-				dig_dynamic_min = dig_max_of_min;
++				dig_min_0 = dig_max_of_min;
+ 			else
+-				dig_dynamic_min =
++				dig_min_0 =
+ 					dm_digtable->rssi_val_min - offset;
+ 
+ 			RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
+-				 "bOneEntryOnly=TRUE, dig_dynamic_min=0x%x\n",
+-				 dig_dynamic_min);
++				 "bOneEntryOnly=TRUE, dig_min_0=0x%x\n",
++				 dig_min_0);
+ 		} else {
+-			dig_dynamic_min = dm_dig_min;
++			dig_min_0 = dm_dig_min;
+ 		}
+ 	} else {
+ 		dm_digtable->rx_gain_max = dm_dig_max;
+-		dig_dynamic_min = dm_dig_min;
++		dig_min_0 = dm_dig_min;
+ 		RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
+ 			 "No Link\n");
+ 	}
+@@ -925,11 +925,11 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
+ 		} else {
+ 			if (dm_digtable->large_fa_hit < 3) {
+ 				if ((dm_digtable->forbidden_igi - 1) <
+-				    dig_dynamic_min) {
++				    dig_min_0) {
+ 					dm_digtable->forbidden_igi =
+-						dig_dynamic_min;
++						dig_min_0;
+ 					dm_digtable->rx_gain_min =
+-						dig_dynamic_min;
++						dig_min_0;
+ 					RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
+ 						 "Normal Case: At Lower Bound\n");
+ 				} else {
+@@ -1024,7 +1024,7 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
+ 	rtl8821ae_dm_write_dig(hw, current_igi);
+ 	dm_digtable->media_connect_0 =
+ 		((mac->link_state >= MAC80211_LINKED) ? true : false);
+-	dm_digtable->dig_dynamic_min = dig_dynamic_min;
++	dm_digtable->dig_min_0 = dig_min_0;
+ }
+ 
+ static void rtl8821ae_dm_common_info_self_update(struct ieee80211_hw *hw)
+diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
+index 7a718fd..b53d9dd 100644
+--- a/drivers/net/wireless/rtlwifi/wifi.h
++++ b/drivers/net/wireless/rtlwifi/wifi.h
+@@ -2412,8 +2412,6 @@ struct dig_t {
+ 	u8 pre_ccastate;
+ 	u8 cur_ccasate;
+ 	u8 large_fa_hit;
+-	u8 dig_dynamic_min;
+-	u8 dig_dynamic_min_1;
+ 	u8 forbidden_igi;
+ 	u8 dig_state;
+ 	u8 dig_highpwrstate;
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0038-rtlwifi-rtl8723be-Improve-modinfo-output.patch b/package/kernel/mac80211/patches/680-0038-rtlwifi-rtl8723be-Improve-modinfo-output.patch
new file mode 100644
index 0000000..fede8ad
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0038-rtlwifi-rtl8723be-Improve-modinfo-output.patch
@@ -0,0 +1,40 @@ 
+From 3f0c1cfa735a12dbe24c583d2ab833d348745856 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:03 -0600
+Subject: [PATCH 38/51] rtlwifi: rtl8723be: Improve modinfo output
+
+The description of the power-save variables for this driver is not as
+clear as for the others. The wording is changed to match the others.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8723be/sw.c | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/sw.c b/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
+index 223eb42..1017f02 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
+@@ -387,12 +387,14 @@ module_param_named(swlps, rtl8723be_mod_params.swctrl_lps, bool, 0444);
+ module_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444);
+ module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog,
+ 		   bool, 0444);
+-MODULE_PARM_DESC(swenc, "using hardware crypto (default 0 [hardware])\n");
+-MODULE_PARM_DESC(ips, "using no link power save (default 1 is open)\n");
+-MODULE_PARM_DESC(fwlps, "using linked fw control power save (default 1 is open)\n");
++MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
++MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
++MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
++MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n");
+ MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 0)\n");
+ MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)");
+-MODULE_PARM_DESC(disable_watchdog, "Set to 1 to disable the watchdog (default 0)\n");
++MODULE_PARM_DESC(disable_watchdog,
++		 "Set to 1 to disable the watchdog (default 0)\n");
+ 
+ static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
+ 
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0039-rtlwifi-Create-new-routine-to-initialize-the-DM-tabl.patch b/package/kernel/mac80211/patches/680-0039-rtlwifi-Create-new-routine-to-initialize-the-DM-tabl.patch
new file mode 100644
index 0000000..edc0b40
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0039-rtlwifi-Create-new-routine-to-initialize-the-DM-tabl.patch
@@ -0,0 +1,607 @@ 
+From 6f8214b6905741ac5c58958a35257e8103645c90 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:04 -0600
+Subject: [PATCH 39/51] rtlwifi: Create new routine to initialize the DM tables
+
+Each of the drivers contains a routine that initializes the dm_digtable
+member of the driver's private area. As a first step toward reducing the
+size of the drivers, a copy of this driver is created in rtlwifi, and the
+definitions of the parameters are moved there.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/core.c               | 34 +++++++++++++++++++++++
+ drivers/net/wireless/rtlwifi/core.h               | 24 ++++++++++++++++
+ drivers/net/wireless/rtlwifi/rtl8188ee/dm.c       |  1 +
+ drivers/net/wireless/rtlwifi/rtl8188ee/dm.h       | 22 ---------------
+ drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c |  1 +
+ drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h | 22 ---------------
+ drivers/net/wireless/rtlwifi/rtl8192ce/dm.c       |  1 +
+ drivers/net/wireless/rtlwifi/rtl8192ce/dm.h       | 13 ---------
+ drivers/net/wireless/rtlwifi/rtl8192de/dm.c       |  1 +
+ drivers/net/wireless/rtlwifi/rtl8192de/dm.h       | 22 ---------------
+ drivers/net/wireless/rtlwifi/rtl8192ee/dm.c       |  1 +
+ drivers/net/wireless/rtlwifi/rtl8192ee/dm.h       | 13 ---------
+ drivers/net/wireless/rtlwifi/rtl8192se/dm.c       |  1 +
+ drivers/net/wireless/rtlwifi/rtl8192se/dm.h       | 19 -------------
+ drivers/net/wireless/rtlwifi/rtl8723ae/dm.c       |  1 +
+ drivers/net/wireless/rtlwifi/rtl8723ae/dm.h       | 22 ---------------
+ drivers/net/wireless/rtlwifi/rtl8723be/dm.c       |  1 +
+ drivers/net/wireless/rtlwifi/rtl8723be/dm.h       | 22 ---------------
+ drivers/net/wireless/rtlwifi/rtl8821ae/dm.c       |  1 +
+ drivers/net/wireless/rtlwifi/rtl8821ae/dm.h       | 16 -----------
+ 20 files changed, 67 insertions(+), 171 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
+index deab852..5aa3ab3 100644
+--- a/drivers/net/wireless/rtlwifi/core.c
++++ b/drivers/net/wireless/rtlwifi/core.c
+@@ -1871,3 +1871,37 @@ bool rtl_btc_status_false(void)
+ 	return false;
+ }
+ EXPORT_SYMBOL_GPL(rtl_btc_status_false);
++
++void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
++{
++	struct rtl_priv *rtlpriv = rtl_priv(hw);
++	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
++
++	dm_digtable->dig_enable_flag = true;
++	dm_digtable->cur_igvalue = cur_igvalue;
++	dm_digtable->pre_igvalue = 0;
++	dm_digtable->cur_sta_cstate = DIG_STA_DISCONNECT;
++	dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
++	dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
++	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
++	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
++	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
++	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
++	dm_digtable->rx_gain_max = DM_DIG_MAX;
++	dm_digtable->rx_gain_min = DM_DIG_MIN;
++	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
++	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
++	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
++	dm_digtable->pre_cck_cca_thres = 0xff;
++	dm_digtable->cur_cck_cca_thres = 0x83;
++	dm_digtable->forbidden_igi = DM_DIG_MIN;
++	dm_digtable->large_fa_hit = 0;
++	dm_digtable->recover_cnt = 0;
++	dm_digtable->dig_min_0 = 0x25;
++	dm_digtable->dig_min_1 = 0x25;
++	dm_digtable->media_connect_0 = false;
++	dm_digtable->media_connect_1 = false;
++	rtlpriv->dm.dm_initialgain_enable = true;
++	dm_digtable->bt30_cur_igi = 0x32;
++}
++EXPORT_SYMBOL(rtl_dm_diginit);
+diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
+index 8c87eb5..c0a0317 100644
+--- a/drivers/net/wireless/rtlwifi/core.h
++++ b/drivers/net/wireless/rtlwifi/core.h
+@@ -35,6 +35,29 @@
+ 
+ #define RTL_SUPPORTED_CTRL_FILTER	0xFF
+ 
++#define DM_DIG_THRESH_HIGH		40
++#define DM_DIG_THRESH_LOW		35
++#define DM_FALSEALARM_THRESH_LOW	400
++#define DM_FALSEALARM_THRESH_HIGH	1000
++
++#define DM_DIG_MAX			0x3e
++#define DM_DIG_MIN			0x1e
++#define DM_DIG_BACKOFF_MAX		12
++#define DM_DIG_BACKOFF_MIN		-4
++#define DM_DIG_BACKOFF_DEFAULT		10
++
++enum dm_dig_connect_e {
++	DIG_STA_DISCONNECT,
++	DIG_STA_CONNECT,
++	DIG_STA_BEFORE_CONNECT,
++	DIG_MULTISTA_DISCONNECT,
++	DIG_MULTISTA_CONNECT,
++	DIG_AP_DISCONNECT,
++	DIG_AP_CONNECT,
++	DIG_AP_ADD_STATION,
++	DIG_CONNECT_MAX
++};
++
+ extern const struct ieee80211_ops rtl_ops;
+ void rtl_fw_cb(const struct firmware *firmware, void *context);
+ void rtl_wowlan_fw_cb(const struct firmware *firmware, void *context);
+@@ -44,5 +67,6 @@ void rtl_rfreg_delay(struct ieee80211_hw *hw, enum radio_path rfpath, u32 addr,
+ void rtl_bb_delay(struct ieee80211_hw *hw, u32 addr, u32 data);
+ bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb);
+ bool rtl_btc_status_false(void);
++void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igval);
+ 
+ #endif
+diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
+index 2aa34d9..7ebf6e0 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
+@@ -26,6 +26,7 @@
+ #include "../wifi.h"
+ #include "../base.h"
+ #include "../pci.h"
++#include "../core.h"
+ #include "reg.h"
+ #include "def.h"
+ #include "phy.h"
+diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
+index 64f1f3ea..6217b7c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
+@@ -186,15 +186,6 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW				25
+ #define BW_AUTO_SWITCH_LOW_HIGH				30
+ 
+-#define DM_DIG_THRESH_HIGH				40
+-#define DM_DIG_THRESH_LOW				35
+-
+-#define DM_FALSEALARM_THRESH_LOW			400
+-#define DM_FALSEALARM_THRESH_HIGH			1000
+-
+-#define DM_DIG_MAX					0x3e
+-#define DM_DIG_MIN					0x1e
+-
+ #define DM_DIG_MAX_AP					0x32
+ #define DM_DIG_MIN_AP					0x20
+ 
+@@ -204,10 +195,6 @@
+ #define DM_DIG_FA_TH1					0x300
+ #define DM_DIG_FA_TH2					0x400
+ 
+-#define DM_DIG_BACKOFF_MAX				12
+-#define DM_DIG_BACKOFF_MIN				-4
+-#define DM_DIG_BACKOFF_DEFAULT				10
+-
+ #define RXPATHSELECTION_SS_TH_W				30
+ #define RXPATHSELECTION_DIFF_TH				18
+ 
+@@ -296,15 +283,6 @@ enum dm_dig_ext_port_alg_e {
+ 	DIG_EXT_PORT_STAGE_MAX = 4,
+ };
+ 
+-enum dm_dig_connect_e {
+-	DIG_STA_DISCONNECT = 0,
+-	DIG_STA_CONNECT = 1,
+-	DIG_STA_BEFORE_CONNECT = 2,
+-	DIG_MULTISTA_DISCONNECT = 3,
+-	DIG_MULTISTA_CONNECT = 4,
+-	DIG_CONNECT_MAX
+-};
+-
+ enum pwr_track_control_method {
+ 	BBSWING,
+ 	TXAGC
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+index c3aad76..dabe18f 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+@@ -32,6 +32,7 @@
+ #include "phy_common.h"
+ #include "../pci.h"
+ #include "../base.h"
++#include "../core.h"
+ 
+ #define BT_RSSI_STATE_NORMAL_POWER	BIT_OFFSET_LEN_MASK_32(0, 1)
+ #define BT_RSSI_STATE_AMDPU_OFF		BIT_OFFSET_LEN_MASK_32(1, 1)
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
+index 4f232a0..55ebffd 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
+@@ -47,25 +47,12 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW			25
+ #define BW_AUTO_SWITCH_LOW_HIGH			30
+ 
+-#define DM_DIG_THRESH_HIGH			40
+-#define DM_DIG_THRESH_LOW			35
+-
+-#define DM_FALSEALARM_THRESH_LOW		400
+-#define DM_FALSEALARM_THRESH_HIGH		1000
+-
+-#define DM_DIG_MAX				0x3e
+-#define DM_DIG_MIN				0x1e
+-
+ #define DM_DIG_FA_UPPER				0x32
+ #define DM_DIG_FA_LOWER				0x20
+ #define DM_DIG_FA_TH0				0x20
+ #define DM_DIG_FA_TH1				0x100
+ #define DM_DIG_FA_TH2				0x200
+ 
+-#define DM_DIG_BACKOFF_MAX			12
+-#define DM_DIG_BACKOFF_MIN			-4
+-#define DM_DIG_BACKOFF_DEFAULT			10
+-
+ #define RXPATHSELECTION_SS_TH_lOW		30
+ #define RXPATHSELECTION_DIFF_TH			18
+ 
+@@ -157,15 +144,6 @@ enum dm_dig_ext_port_alg_e {
+ 	DIG_EXT_PORT_STAGE_MAX = 4,
+ };
+ 
+-enum dm_dig_connect_e {
+-	DIG_STA_DISCONNECT = 0,
+-	DIG_STA_CONNECT = 1,
+-	DIG_STA_BEFORE_CONNECT = 2,
+-	DIG_MULTISTA_DISCONNECT = 3,
+-	DIG_MULTISTA_CONNECT = 4,
+-	DIG_CONNECT_MAX
+-};
+-
+ void rtl92c_dm_init(struct ieee80211_hw *hw);
+ void rtl92c_dm_watchdog(struct ieee80211_hw *hw);
+ void rtl92c_dm_write_dig(struct ieee80211_hw *hw);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
+index 74f9c08..09898cf 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.c
+@@ -30,6 +30,7 @@
+ #include "../wifi.h"
+ #include "../base.h"
+ #include "../pci.h"
++#include "../core.h"
+ #include "reg.h"
+ #include "def.h"
+ #include "phy.h"
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
+index 9c5311c..38ba707 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192ce/dm.h
+@@ -42,25 +42,12 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW			25
+ #define BW_AUTO_SWITCH_LOW_HIGH			30
+ 
+-#define DM_DIG_THRESH_HIGH			40
+-#define DM_DIG_THRESH_LOW			35
+-
+-#define DM_FALSEALARM_THRESH_LOW		400
+-#define DM_FALSEALARM_THRESH_HIGH		1000
+-
+-#define DM_DIG_MAX				0x3e
+-#define DM_DIG_MIN				0x1e
+-
+ #define DM_DIG_FA_UPPER				0x32
+ #define DM_DIG_FA_LOWER				0x20
+ #define DM_DIG_FA_TH0				0x20
+ #define DM_DIG_FA_TH1				0x100
+ #define DM_DIG_FA_TH2				0x200
+ 
+-#define DM_DIG_BACKOFF_MAX			12
+-#define DM_DIG_BACKOFF_MIN			-4
+-#define DM_DIG_BACKOFF_DEFAULT			10
+-
+ #define RXPATHSELECTION_SS_TH_lOW		30
+ #define RXPATHSELECTION_DIFF_TH			18
+ 
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
+index 304c443..75643ab 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
+@@ -29,6 +29,7 @@
+ 
+ #include "../wifi.h"
+ #include "../base.h"
++#include "../core.h"
+ #include "reg.h"
+ #include "def.h"
+ #include "phy.h"
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
+index 3fea0c1..d21b3bc 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
+@@ -42,25 +42,12 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW			25
+ #define BW_AUTO_SWITCH_LOW_HIGH			30
+ 
+-#define DM_DIG_THRESH_HIGH			40
+-#define DM_DIG_THRESH_LOW			35
+-
+-#define DM_FALSEALARM_THRESH_LOW		400
+-#define DM_FALSEALARM_THRESH_HIGH		1000
+-
+-#define DM_DIG_MAX				0x3e
+-#define DM_DIG_MIN				0x1c
+-
+ #define DM_DIG_FA_UPPER				0x32
+ #define DM_DIG_FA_LOWER				0x20
+ #define DM_DIG_FA_TH0				0x100
+ #define DM_DIG_FA_TH1				0x400
+ #define DM_DIG_FA_TH2				0x600
+ 
+-#define DM_DIG_BACKOFF_MAX			12
+-#define DM_DIG_BACKOFF_MIN			-4
+-#define DM_DIG_BACKOFF_DEFAULT			10
+-
+ #define RXPATHSELECTION_SS_TH_lOW		30
+ #define RXPATHSELECTION_DIFF_TH			18
+ 
+@@ -142,15 +129,6 @@ enum dm_dig_ext_port_alg {
+ 	DIG_EXT_PORT_STAGE_MAX = 4,
+ };
+ 
+-enum dm_dig_connect {
+-	DIG_STA_DISCONNECT = 0,
+-	DIG_STA_CONNECT = 1,
+-	DIG_STA_BEFORE_CONNECT = 2,
+-	DIG_MULTISTA_DISCONNECT = 3,
+-	DIG_MULTISTA_CONNECT = 4,
+-	DIG_CONNECT_MAX
+-};
+-
+ void rtl92d_dm_init(struct ieee80211_hw *hw);
+ void rtl92d_dm_watchdog(struct ieee80211_hw *hw);
+ void rtl92d_dm_init_edca_turbo(struct ieee80211_hw *hw);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
+index 2fa4c45..70e58d1 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
+@@ -26,6 +26,7 @@
+ #include "../wifi.h"
+ #include "../base.h"
+ #include "../pci.h"
++#include "../core.h"
+ #include "reg.h"
+ #include "def.h"
+ #include "phy.h"
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
+index 881db7d..4880e19 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
+@@ -189,15 +189,6 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW			25
+ #define BW_AUTO_SWITCH_LOW_HIGH			30
+ 
+-#define DM_DIG_THRESH_HIGH			40
+-#define DM_DIG_THRESH_LOW			35
+-
+-#define DM_FALSEALARM_THRESH_LOW		400
+-#define DM_FALSEALARM_THRESH_HIGH		1000
+-
+-#define DM_DIG_MAX				0x3e
+-#define DM_DIG_MIN				0x1e
+-
+ #define DM_DIG_MAX_AP				0x32
+ #define DM_DIG_MIN_AP				0x20
+ 
+@@ -207,10 +198,6 @@
+ #define DM_DIG_FA_TH1				0x300
+ #define DM_DIG_FA_TH2				0x400
+ 
+-#define DM_DIG_BACKOFF_MAX			12
+-#define DM_DIG_BACKOFF_MIN			-4
+-#define DM_DIG_BACKOFF_DEFAULT			10
+-
+ #define RXPATHSELECTION_SS_TH_LOW		30
+ #define RXPATHSELECTION_DIFF_TH			18
+ 
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
+index b3a2d5e..6cac70b 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
+@@ -29,6 +29,7 @@
+ 
+ #include "../wifi.h"
+ #include "../base.h"
++#include "../core.h"
+ #include "reg.h"
+ #include "def.h"
+ #include "phy.h"
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
+index 2e9052c..7d778d3 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
+@@ -54,16 +54,6 @@ enum dm_dig_sta {
+ 	DM_STA_DIG_MAX
+ };
+ 
+-enum dm_dig_connect {
+-	DIG_STA_DISCONNECT = 0,
+-	DIG_STA_CONNECT = 1,
+-	DIG_STA_BEFORE_CONNECT = 2,
+-	DIG_AP_DISCONNECT = 3,
+-	DIG_AP_CONNECT = 4,
+-	DIG_AP_ADD_STATION = 5,
+-	DIG_CONNECT_MAX
+-};
+-
+ enum dm_dig_ext_port_alg {
+ 	DIG_EXT_PORT_STAGE_0 = 0,
+ 	DIG_EXT_PORT_STAGE_1 = 1,
+@@ -99,22 +89,13 @@ enum dm_ratr_sta {
+ #define	TX_POWER_NEAR_FIELD_THRESH_LVL2	74
+ #define	TX_POWER_NEAR_FIELD_THRESH_LVL1	67
+ 
+-#define DM_DIG_THRESH_HIGH		40
+-#define DM_DIG_THRESH_LOW		35
+-#define	DM_FALSEALARM_THRESH_LOW	40
+-#define	DM_FALSEALARM_THRESH_HIGH	1000
+ #define	DM_DIG_HIGH_PWR_THRESH_HIGH	75
+ #define	DM_DIG_HIGH_PWR_THRESH_LOW	70
+ #define	DM_DIG_BACKOFF			12
+-#define	DM_DIG_MAX			0x3e
+-#define	DM_DIG_MIN			0x1c
+ #define	DM_DIG_MIN_Netcore		0x12
+-#define	DM_DIG_BACKOFF_MAX		12
+-#define	DM_DIG_BACKOFF_MIN		-4
+ 
+ void rtl92s_dm_watchdog(struct ieee80211_hw *hw);
+ void rtl92s_dm_init(struct ieee80211_hw *hw);
+ void rtl92s_dm_init_edca_turbo(struct ieee80211_hw *hw);
+ 
+ #endif
+-
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
+index a0e8692..80f4c54 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
+@@ -26,6 +26,7 @@
+ #include "../wifi.h"
+ #include "../base.h"
+ #include "../pci.h"
++#include "../core.h"
+ #include "reg.h"
+ #include "def.h"
+ #include "phy.h"
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
+index 6fa0feb..c54024e 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
+@@ -42,25 +42,12 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW			25
+ #define BW_AUTO_SWITCH_LOW_HIGH			30
+ 
+-#define DM_DIG_THRESH_HIGH			40
+-#define DM_DIG_THRESH_LOW			35
+-
+-#define DM_FALSEALARM_THRESH_LOW		400
+-#define DM_FALSEALARM_THRESH_HIGH		1000
+-
+-#define DM_DIG_MAX				0x3e
+-#define DM_DIG_MIN				0x1e
+-
+ #define DM_DIG_FA_UPPER				0x32
+ #define DM_DIG_FA_LOWER				0x20
+ #define DM_DIG_FA_TH0				0x20
+ #define DM_DIG_FA_TH1				0x100
+ #define DM_DIG_FA_TH2				0x200
+ 
+-#define DM_DIG_BACKOFF_MAX			12
+-#define DM_DIG_BACKOFF_MIN			-4
+-#define DM_DIG_BACKOFF_DEFAULT			10
+-
+ #define RXPATHSELECTION_SS_TH_LOW		30
+ #define RXPATHSELECTION_DIFF_TH			18
+ 
+@@ -142,15 +129,6 @@ enum dm_dig_ext_port_alg_e {
+ 	DIG_EXT_PORT_STAGE_MAX = 4,
+ };
+ 
+-enum dm_dig_connect_e {
+-	DIG_STA_DISCONNECT = 0,
+-	DIG_STA_CONNECT = 1,
+-	DIG_STA_BEFORE_CONNECT = 2,
+-	DIG_MULTISTA_DISCONNECT = 3,
+-	DIG_MULTISTA_CONNECT = 4,
+-	DIG_CONNECT_MAX
+-};
+-
+ #define BT_RSSI_STATE_NORMAL_POWER      BIT_OFFSET_LEN_MASK_32(0, 1)
+ #define BT_RSSI_STATE_AMDPU_OFF         BIT_OFFSET_LEN_MASK_32(1, 1)
+ #define BT_RSSI_STATE_SPECIAL_LOW       BIT_OFFSET_LEN_MASK_32(2, 1)
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
+index b92c521e..ddf45d9 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
+@@ -26,6 +26,7 @@
+ #include "../wifi.h"
+ #include "../base.h"
+ #include "../pci.h"
++#include "../core.h"
+ #include "reg.h"
+ #include "def.h"
+ #include "phy.h"
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
+index e4c0e8a..f3e47ab 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
+@@ -180,15 +180,6 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW			25
+ #define BW_AUTO_SWITCH_LOW_HIGH			30
+ 
+-#define DM_DIG_THRESH_HIGH			40
+-#define DM_DIG_THRESH_LOW			35
+-
+-#define DM_FALSEALARM_THRESH_LOW		400
+-#define DM_FALSEALARM_THRESH_HIGH		1000
+-
+-#define DM_DIG_MAX				0x3e
+-#define DM_DIG_MIN				0x1e
+-
+ #define DM_DIG_MAX_AP				0x32
+ #define DM_DIG_MIN_AP				0x20
+ 
+@@ -198,10 +189,6 @@
+ #define DM_DIG_FA_TH1				0x300
+ #define DM_DIG_FA_TH2				0x400
+ 
+-#define DM_DIG_BACKOFF_MAX			12
+-#define DM_DIG_BACKOFF_MIN			-4
+-#define DM_DIG_BACKOFF_DEFAULT			10
+-
+ #define RXPATHSELECTION_SS_TH_LOW		30
+ #define RXPATHSELECTION_DIFF_TH			18
+ 
+@@ -260,15 +247,6 @@ enum dm_dig_ext_port_alg_e {
+ 	DIG_EXT_PORT_STAGE_MAX	= 4,
+ };
+ 
+-enum dm_dig_connect_e {
+-	DIG_STA_DISCONNECT	= 0,
+-	DIG_STA_CONNECT		= 1,
+-	DIG_STA_BEFORE_CONNECT	= 2,
+-	DIG_MULTISTA_DISCONNECT	= 3,
+-	DIG_MULTISTA_CONNECT	= 4,
+-	DIG_CONNECT_MAX
+-};
+-
+ enum pwr_track_control_method {
+ 	BBSWING,
+ 	TXAGC
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+index 8b0bfb2..4af4613 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+@@ -26,6 +26,7 @@
+ #include "../wifi.h"
+ #include "../base.h"
+ #include "../pci.h"
++#include "../core.h"
+ #include "reg.h"
+ #include "def.h"
+ #include "phy.h"
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
+index 9dd40dd..f311887 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
+@@ -187,9 +187,6 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW		25
+ #define BW_AUTO_SWITCH_LOW_HIGH		30
+ 
+-#define DM_DIG_THRESH_HIGH			40
+-#define DM_DIG_THRESH_LOW			35
+-
+ #define DM_FALSEALARM_THRESH_LOW	400
+ #define DM_FALSEALARM_THRESH_HIGH	1000
+ 
+@@ -205,10 +202,6 @@
+ #define DM_DIG_FA_TH1				0x300
+ #define DM_DIG_FA_TH2				0x400
+ 
+-#define DM_DIG_BACKOFF_MAX			12
+-#define DM_DIG_BACKOFF_MIN			-4
+-#define DM_DIG_BACKOFF_DEFAULT		10
+-
+ #define RXPATHSELECTION_SS_TH_LOW	30
+ #define RXPATHSELECTION_DIFF_TH		18
+ 
+@@ -296,15 +289,6 @@ enum dm_dig_ext_port_alg_e {
+ 	DIG_EXT_PORT_STAGE_MAX = 4,
+ };
+ 
+-enum dm_dig_connect_e {
+-	DIG_STA_DISCONNECT = 0,
+-	DIG_STA_CONNECT = 1,
+-	DIG_STA_BEFORE_CONNECT = 2,
+-	DIG_MULTISTA_DISCONNECT = 3,
+-	DIG_MULTISTA_CONNECT = 4,
+-	DIG_CONNECT_MAX
+-};
+-
+ enum pwr_track_control_method {
+ 	BBSWING,
+ 	TXAGC,
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0040-rtlwifi-rtl8188ee-Convert-driver-to-use-the-common-D.patch b/package/kernel/mac80211/patches/680-0040-rtlwifi-rtl8188ee-Convert-driver-to-use-the-common-D.patch
new file mode 100644
index 0000000..f89e2c3
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0040-rtlwifi-rtl8188ee-Convert-driver-to-use-the-common-D.patch
@@ -0,0 +1,73 @@ 
+From b5d4478dc35e0cd9ef482d22aba069a19fe04a04 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:05 -0600
+Subject: [PATCH 40/51] rtlwifi: rtl8188ee: Convert driver to use the common DM
+ table init routine
+
+The previous patch created a routine in rtlwifi to initialize dm_digtable.
+Driver rtl8188ee is converted to use that routine.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8188ee/dm.c | 35 ++---------------------------
+ 1 file changed, 2 insertions(+), 33 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
+index 7ebf6e0..d930c1f 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.c
+@@ -342,38 +342,6 @@ static void dm_tx_pwr_track_set_pwr(struct ieee80211_hw *hw,
+ 	}
+ }
+ 
+-static void rtl88e_dm_diginit(struct ieee80211_hw *hw)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	struct dig_t *dm_dig = &rtlpriv->dm_digtable;
+-
+-	dm_dig->dig_enable_flag = true;
+-	dm_dig->cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
+-	dm_dig->pre_igvalue = 0;
+-	dm_dig->cur_sta_cstate = DIG_STA_DISCONNECT;
+-	dm_dig->presta_cstate = DIG_STA_DISCONNECT;
+-	dm_dig->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
+-	dm_dig->rssi_lowthresh = DM_DIG_THRESH_LOW;
+-	dm_dig->rssi_highthresh = DM_DIG_THRESH_HIGH;
+-	dm_dig->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
+-	dm_dig->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
+-	dm_dig->rx_gain_max = DM_DIG_MAX;
+-	dm_dig->rx_gain_min = DM_DIG_MIN;
+-	dm_dig->back_val = DM_DIG_BACKOFF_DEFAULT;
+-	dm_dig->back_range_max = DM_DIG_BACKOFF_MAX;
+-	dm_dig->back_range_min = DM_DIG_BACKOFF_MIN;
+-	dm_dig->pre_cck_cca_thres = 0xff;
+-	dm_dig->cur_cck_cca_thres = 0x83;
+-	dm_dig->forbidden_igi = DM_DIG_MIN;
+-	dm_dig->large_fa_hit = 0;
+-	dm_dig->recover_cnt = 0;
+-	dm_dig->dig_min_0 = 0x25;
+-	dm_dig->dig_min_1 = 0x25;
+-	dm_dig->media_connect_0 = false;
+-	dm_dig->media_connect_1 = false;
+-	rtlpriv->dm.dm_initialgain_enable = true;
+-}
+-
+ static u8 rtl88e_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+@@ -1797,9 +1765,10 @@ static void rtl88e_dm_antenna_diversity(struct ieee80211_hw *hw)
+ void rtl88e_dm_init(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
++	u32 cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
+ 
+ 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
+-	rtl88e_dm_diginit(hw);
++	rtl_dm_diginit(hw, cur_igvalue);
+ 	rtl88e_dm_init_dynamic_txpower(hw);
+ 	rtl88e_dm_init_edca_turbo(hw);
+ 	rtl88e_dm_init_rate_adaptive_mask(hw);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0041-rtlwifi-rtl8192c-common-Convert-driver-to-use-common.patch b/package/kernel/mac80211/patches/680-0041-rtlwifi-rtl8192c-common-Convert-driver-to-use-common.patch
new file mode 100644
index 0000000..b51dbcb
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0041-rtlwifi-rtl8192c-common-Convert-driver-to-use-common.patch
@@ -0,0 +1,411 @@ 
+From 3424a00fd559debf402559c226d9b1d895b94a5f Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:06 -0600
+Subject: [PATCH 41/51] rtlwifi: rtl8192c-common: Convert driver to use common
+ DM table initialization
+
+These changes convert both rtl8192ce and rtl8192cu to use the new routine.
+Some additional definitions are needed in the core, thus several of the
+headers for other drivers are affected, but no other executable code is
+changed.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/core.c               |  3 ++
+ drivers/net/wireless/rtlwifi/core.h               | 16 +++++++++
+ drivers/net/wireless/rtlwifi/rtl8188ee/dm.h       | 16 ---------
+ drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 44 ++++-------------------
+ drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h | 16 ---------
+ drivers/net/wireless/rtlwifi/rtl8192de/dm.h       | 16 ---------
+ drivers/net/wireless/rtlwifi/rtl8192se/dm.h       |  8 -----
+ drivers/net/wireless/rtlwifi/rtl8723ae/dm.c       | 14 ++++----
+ drivers/net/wireless/rtlwifi/rtl8723ae/dm.h       | 16 ---------
+ drivers/net/wireless/rtlwifi/rtl8723be/dm.h       |  8 -----
+ drivers/net/wireless/rtlwifi/rtl8821ae/dm.h       | 16 ---------
+ 11 files changed, 33 insertions(+), 140 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
+index 5aa3ab3..eb20316 100644
+--- a/drivers/net/wireless/rtlwifi/core.c
++++ b/drivers/net/wireless/rtlwifi/core.c
+@@ -1878,6 +1878,7 @@ void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
+ 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
+ 
+ 	dm_digtable->dig_enable_flag = true;
++	dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
+ 	dm_digtable->cur_igvalue = cur_igvalue;
+ 	dm_digtable->pre_igvalue = 0;
+ 	dm_digtable->cur_sta_cstate = DIG_STA_DISCONNECT;
+@@ -1903,5 +1904,7 @@ void rtl_dm_diginit(struct ieee80211_hw *hw, u32 cur_igvalue)
+ 	dm_digtable->media_connect_1 = false;
+ 	rtlpriv->dm.dm_initialgain_enable = true;
+ 	dm_digtable->bt30_cur_igi = 0x32;
++	dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
++	dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LOWRSSI;
+ }
+ EXPORT_SYMBOL(rtl_dm_diginit);
+diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
+index c0a0317..1cde356 100644
+--- a/drivers/net/wireless/rtlwifi/core.h
++++ b/drivers/net/wireless/rtlwifi/core.h
+@@ -46,6 +46,22 @@
+ #define DM_DIG_BACKOFF_MIN		-4
+ #define DM_DIG_BACKOFF_DEFAULT		10
+ 
++enum cck_packet_detection_threshold {
++	CCK_PD_STAGE_LOWRSSI = 0,
++	CCK_PD_STAGE_HIGHRSSI = 1,
++	CCK_FA_STAGE_LOW = 2,
++	CCK_FA_STAGE_HIGH = 3,
++	CCK_PD_STAGE_MAX = 4,
++};
++
++enum dm_dig_ext_port_alg_e {
++	DIG_EXT_PORT_STAGE_0 = 0,
++	DIG_EXT_PORT_STAGE_1 = 1,
++	DIG_EXT_PORT_STAGE_2 = 2,
++	DIG_EXT_PORT_STAGE_3 = 3,
++	DIG_EXT_PORT_STAGE_MAX = 4,
++};
++
+ enum dm_dig_connect_e {
+ 	DIG_STA_DISCONNECT,
+ 	DIG_STA_CONNECT,
+diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
+index 6217b7c..51ad3f9 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
+@@ -249,14 +249,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
+ 	DIG_OP_TYPE_MAX
+ };
+ 
+-enum tag_cck_packet_detection_threshold_type_definition {
+-	CCK_PD_STAGE_LOWRSSI = 0,
+-	CCK_PD_STAGE_HIGHRSSI = 1,
+-	CCK_FA_STAGE_LOW = 2,
+-	CCK_FA_STAGE_HIGH = 3,
+-	CCK_PD_STAGE_MAX = 4,
+-};
+-
+ enum dm_1r_cca_e {
+ 	CCA_1R = 0,
+ 	CCA_2R = 1,
+@@ -275,14 +267,6 @@ enum dm_sw_ant_switch_e {
+ 	ANS_ANTENNA_MAX = 3,
+ };
+ 
+-enum dm_dig_ext_port_alg_e {
+-	DIG_EXT_PORT_STAGE_0 = 0,
+-	DIG_EXT_PORT_STAGE_1 = 1,
+-	DIG_EXT_PORT_STAGE_2 = 2,
+-	DIG_EXT_PORT_STAGE_3 = 3,
+-	DIG_EXT_PORT_STAGE_MAX = 4,
+-};
+-
+ enum pwr_track_control_method {
+ 	BBSWING,
+ 	TXAGC
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+index dabe18f..f5ee67c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
+@@ -195,36 +195,6 @@ void dm_savepowerindex(struct ieee80211_hw *hw)
+ }
+ EXPORT_SYMBOL_GPL(dm_savepowerindex);
+ 
+-static void rtl92c_dm_diginit(struct ieee80211_hw *hw)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
+-
+-	dm_digtable->dig_enable_flag = true;
+-	dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
+-	dm_digtable->cur_igvalue = 0x20;
+-	dm_digtable->pre_igvalue = 0x0;
+-	dm_digtable->cursta_cstate = DIG_STA_DISCONNECT;
+-	dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
+-	dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
+-	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
+-	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
+-	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
+-	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
+-	dm_digtable->rx_gain_max = DM_DIG_MAX;
+-	dm_digtable->rx_gain_min = DM_DIG_MIN;
+-	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
+-	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
+-	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
+-	dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
+-	dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_LowRssi;
+-
+-	dm_digtable->forbidden_igi = DM_DIG_MIN;
+-	dm_digtable->large_fa_hit = 0;
+-	dm_digtable->recover_cnt = 0;
+-	dm_digtable->dig_min_0  = 0x25;
+-}
+-
+ static u8 rtl92c_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+@@ -508,27 +478,27 @@ static void rtl92c_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
+ 		if (dm_digtable->rssi_val_min > 100)
+ 			dm_digtable->rssi_val_min = 100;
+ 
+-		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LowRssi) {
++		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LOWRSSI) {
+ 			if (dm_digtable->rssi_val_min <= 25)
+ 				dm_digtable->cur_cck_pd_state =
+-				    CCK_PD_STAGE_LowRssi;
++				    CCK_PD_STAGE_LOWRSSI;
+ 			else
+ 				dm_digtable->cur_cck_pd_state =
+-				    CCK_PD_STAGE_HighRssi;
++				    CCK_PD_STAGE_HIGHRSSI;
+ 		} else {
+ 			if (dm_digtable->rssi_val_min <= 20)
+ 				dm_digtable->cur_cck_pd_state =
+-				    CCK_PD_STAGE_LowRssi;
++				    CCK_PD_STAGE_LOWRSSI;
+ 			else
+ 				dm_digtable->cur_cck_pd_state =
+-				    CCK_PD_STAGE_HighRssi;
++				    CCK_PD_STAGE_HIGHRSSI;
+ 		}
+ 	} else {
+ 		dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
+ 	}
+ 
+ 	if (dm_digtable->pre_cck_pd_state != dm_digtable->cur_cck_pd_state) {
+-		if ((dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LowRssi) ||
++		if ((dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI) ||
+ 		    (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_MAX))
+ 			rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0x83);
+ 		else
+@@ -1375,7 +1345,7 @@ void rtl92c_dm_init(struct ieee80211_hw *hw)
+ 	rtlpriv->dm.undec_sm_pwdb = -1;
+ 	rtlpriv->dm.undec_sm_cck = -1;
+ 	rtlpriv->dm.dm_initialgain_enable = true;
+-	rtl92c_dm_diginit(hw);
++	rtl_dm_diginit(hw, 0x20);
+ 
+ 	rtlpriv->dm.dm_flag |= HAL_DM_HIPWR_DISABLE;
+ 	rtl92c_dm_init_dynamic_txpower(hw);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
+index 55ebffd..4422e31 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.h
+@@ -110,14 +110,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
+ 	DIG_OP_TYPE_MAX
+ };
+ 
+-enum tag_cck_packet_detection_threshold_type_definition {
+-	CCK_PD_STAGE_LowRssi = 0,
+-	CCK_PD_STAGE_HighRssi = 1,
+-	CCK_FA_STAGE_Low = 2,
+-	CCK_FA_STAGE_High = 3,
+-	CCK_PD_STAGE_MAX = 4,
+-};
+-
+ enum dm_1r_cca_e {
+ 	CCA_1R = 0,
+ 	CCA_2R = 1,
+@@ -136,14 +128,6 @@ enum dm_sw_ant_switch_e {
+ 	ANS_ANTENNA_MAX = 3,
+ };
+ 
+-enum dm_dig_ext_port_alg_e {
+-	DIG_EXT_PORT_STAGE_0 = 0,
+-	DIG_EXT_PORT_STAGE_1 = 1,
+-	DIG_EXT_PORT_STAGE_2 = 2,
+-	DIG_EXT_PORT_STAGE_3 = 3,
+-	DIG_EXT_PORT_STAGE_MAX = 4,
+-};
+-
+ void rtl92c_dm_init(struct ieee80211_hw *hw);
+ void rtl92c_dm_watchdog(struct ieee80211_hw *hw);
+ void rtl92c_dm_write_dig(struct ieee80211_hw *hw);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
+index d21b3bc..f2d318c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.h
+@@ -95,14 +95,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
+ 	DIG_OP_TYPE_MAX
+ };
+ 
+-enum tag_cck_packet_detection_threshold_type_definition {
+-	CCK_PD_STAGE_LOWRSSI = 0,
+-	CCK_PD_STAGE_HIGHRSSI = 1,
+-	CCK_FA_STAGE_LOW = 2,
+-	CCK_FA_STAGE_HIGH = 3,
+-	CCK_PD_STAGE_MAX = 4,
+-};
+-
+ enum dm_1r_cca {
+ 	CCA_1R = 0,
+ 	CCA_2R = 1,
+@@ -121,14 +113,6 @@ enum dm_sw_ant_switch {
+ 	ANS_ANTENNA_MAX = 3,
+ };
+ 
+-enum dm_dig_ext_port_alg {
+-	DIG_EXT_PORT_STAGE_0 = 0,
+-	DIG_EXT_PORT_STAGE_1 = 1,
+-	DIG_EXT_PORT_STAGE_2 = 2,
+-	DIG_EXT_PORT_STAGE_3 = 3,
+-	DIG_EXT_PORT_STAGE_MAX = 4,
+-};
+-
+ void rtl92d_dm_init(struct ieee80211_hw *hw);
+ void rtl92d_dm_watchdog(struct ieee80211_hw *hw);
+ void rtl92d_dm_init_edca_turbo(struct ieee80211_hw *hw);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
+index 7d778d3..be07d81 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
+@@ -54,14 +54,6 @@ enum dm_dig_sta {
+ 	DM_STA_DIG_MAX
+ };
+ 
+-enum dm_dig_ext_port_alg {
+-	DIG_EXT_PORT_STAGE_0 = 0,
+-	DIG_EXT_PORT_STAGE_1 = 1,
+-	DIG_EXT_PORT_STAGE_2 = 2,
+-	DIG_EXT_PORT_STAGE_3 = 3,
+-	DIG_EXT_PORT_STAGE_MAX = 4,
+-};
+-
+ enum dm_ratr_sta {
+ 	DM_RATR_STA_HIGH = 0,
+ 	DM_RATR_STA_MIDDLEHIGH = 1,
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
+index 80f4c54..8bd124c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
+@@ -396,30 +396,30 @@ static void rtl8723e_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
+ 	if (dm_digtable->cursta_cstate == DIG_STA_CONNECT) {
+ 		dm_digtable->rssi_val_min = rtl8723e_dm_initial_gain_min_pwdb(hw);
+ 
+-		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LowRssi) {
++		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LOWRSSI) {
+ 			if (dm_digtable->rssi_val_min <= 25)
+ 				dm_digtable->cur_cck_pd_state =
+-				    CCK_PD_STAGE_LowRssi;
++				    CCK_PD_STAGE_LOWRSSI;
+ 			else
+ 				dm_digtable->cur_cck_pd_state =
+-				    CCK_PD_STAGE_HighRssi;
++				    CCK_PD_STAGE_HIGHRSSI;
+ 		} else {
+ 			if (dm_digtable->rssi_val_min <= 20)
+ 				dm_digtable->cur_cck_pd_state =
+-				    CCK_PD_STAGE_LowRssi;
++				    CCK_PD_STAGE_LOWRSSI;
+ 			else
+ 				dm_digtable->cur_cck_pd_state =
+-				    CCK_PD_STAGE_HighRssi;
++				    CCK_PD_STAGE_HIGHRSSI;
+ 		}
+ 	} else {
+ 		dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
+ 	}
+ 
+ 	if (dm_digtable->pre_cck_pd_state != dm_digtable->cur_cck_pd_state) {
+-		if (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LowRssi) {
++		if (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI) {
+ 			if (rtlpriv->falsealm_cnt.cnt_cck_fail > 800)
+ 				dm_digtable->cur_cck_fa_state =
+-				    CCK_FA_STAGE_High;
++				    CCK_FA_STAGE_HIGH;
+ 			else
+ 				dm_digtable->cur_cck_fa_state =
+ 				    CCK_FA_STAGE_LOW;
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
+index c54024e..5711105 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
+@@ -95,14 +95,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
+ 	DIG_OP_TYPE_MAX
+ };
+ 
+-enum tag_cck_packet_detection_threshold_type_definition {
+-	CCK_PD_STAGE_LowRssi = 0,
+-	CCK_PD_STAGE_HighRssi = 1,
+-	CCK_FA_STAGE_LOW = 2,
+-	CCK_FA_STAGE_High = 3,
+-	CCK_PD_STAGE_MAX = 4,
+-};
+-
+ enum dm_1r_cca_e {
+ 	CCA_1R = 0,
+ 	CCA_2R = 1,
+@@ -121,14 +113,6 @@ enum dm_sw_ant_switch_e {
+ 	ANS_ANTENNA_MAX = 3,
+ };
+ 
+-enum dm_dig_ext_port_alg_e {
+-	DIG_EXT_PORT_STAGE_0 = 0,
+-	DIG_EXT_PORT_STAGE_1 = 1,
+-	DIG_EXT_PORT_STAGE_2 = 2,
+-	DIG_EXT_PORT_STAGE_3 = 3,
+-	DIG_EXT_PORT_STAGE_MAX = 4,
+-};
+-
+ #define BT_RSSI_STATE_NORMAL_POWER      BIT_OFFSET_LEN_MASK_32(0, 1)
+ #define BT_RSSI_STATE_AMDPU_OFF         BIT_OFFSET_LEN_MASK_32(1, 1)
+ #define BT_RSSI_STATE_SPECIAL_LOW       BIT_OFFSET_LEN_MASK_32(2, 1)
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
+index f3e47ab..533b4f2 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
+@@ -239,14 +239,6 @@ enum dm_sw_ant_switch_e {
+ 	ANS_ANTENNA_MAX	= 3,
+ };
+ 
+-enum dm_dig_ext_port_alg_e {
+-	DIG_EXT_PORT_STAGE_0	= 0,
+-	DIG_EXT_PORT_STAGE_1	= 1,
+-	DIG_EXT_PORT_STAGE_2	= 2,
+-	DIG_EXT_PORT_STAGE_3	= 3,
+-	DIG_EXT_PORT_STAGE_MAX	= 4,
+-};
+-
+ enum pwr_track_control_method {
+ 	BBSWING,
+ 	TXAGC
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
+index f311887..5516557 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
+@@ -255,14 +255,6 @@ enum tag_dynamic_init_gain_operation_type_definition {
+ 	DIG_OP_TYPE_MAX
+ };
+ 
+-enum tag_cck_packet_detection_threshold_type_definition {
+-	CCK_PD_STAGE_LOWRSSI = 0,
+-	CCK_PD_STAGE_HIGHRSSI = 1,
+-	CCK_FA_STAGE_LOW = 2,
+-	CCK_FA_STAGE_HIGH = 3,
+-	CCK_PD_STAGE_MAX = 4,
+-};
+-
+ enum dm_1r_cca_e {
+ 	CCA_1R = 0,
+ 	CCA_2R = 1,
+@@ -281,14 +273,6 @@ enum dm_sw_ant_switch_e {
+ 	ANS_ANTENNA_MAX = 3,
+ };
+ 
+-enum dm_dig_ext_port_alg_e {
+-	DIG_EXT_PORT_STAGE_0 = 0,
+-	DIG_EXT_PORT_STAGE_1 = 1,
+-	DIG_EXT_PORT_STAGE_2 = 2,
+-	DIG_EXT_PORT_STAGE_3 = 3,
+-	DIG_EXT_PORT_STAGE_MAX = 4,
+-};
+-
+ enum pwr_track_control_method {
+ 	BBSWING,
+ 	TXAGC,
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0042-rtlwifi-rtl8192de-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0042-rtlwifi-rtl8192de-Convert-driver-to-use-common-DM-ta.patch
new file mode 100644
index 0000000..7b45006
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0042-rtlwifi-rtl8192de-Convert-driver-to-use-common-DM-ta.patch
@@ -0,0 +1,68 @@ 
+From 8b17c1f3a5e058952177339d0310f27a4fb42c13 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:07 -0600
+Subject: [PATCH 42/51] rtlwifi: rtl8192de: Convert driver to use common DM
+ table initialization
+
+This patch converts driver rtl8192de to use the common routine to
+initialize dm_digtable.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192de/dm.c | 32 +++--------------------------
+ 1 file changed, 3 insertions(+), 29 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
+index 75643ab..a1be5a6 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
+@@ -156,34 +156,6 @@ static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
+ 	{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}     /* 32, -16.0dB */
+ };
+ 
+-static void rtl92d_dm_diginit(struct ieee80211_hw *hw)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	struct dig_t *de_digtable = &rtlpriv->dm_digtable;
+-
+-	de_digtable->dig_enable_flag = true;
+-	de_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
+-	de_digtable->cur_igvalue = 0x20;
+-	de_digtable->pre_igvalue = 0x0;
+-	de_digtable->cursta_cstate = DIG_STA_DISCONNECT;
+-	de_digtable->presta_cstate = DIG_STA_DISCONNECT;
+-	de_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
+-	de_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
+-	de_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
+-	de_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
+-	de_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
+-	de_digtable->rx_gain_max = DM_DIG_FA_UPPER;
+-	de_digtable->rx_gain_min = DM_DIG_FA_LOWER;
+-	de_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
+-	de_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
+-	de_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
+-	de_digtable->pre_cck_pd_state = CCK_PD_STAGE_LOWRSSI;
+-	de_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
+-	de_digtable->large_fa_hit = 0;
+-	de_digtable->recover_cnt = 0;
+-	de_digtable->forbidden_igi = DM_DIG_FA_LOWER;
+-}
+-
+ static void rtl92d_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw)
+ {
+ 	u32 ret_value;
+@@ -1306,7 +1278,9 @@ void rtl92d_dm_init(struct ieee80211_hw *hw)
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+ 
+ 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
+-	rtl92d_dm_diginit(hw);
++	rtl_dm_diginit(hw, 0x20);
++	rtlpriv->dm_digtable.rx_gain_max = DM_DIG_FA_UPPER;
++	rtlpriv->dm_digtable.rx_gain_min = DM_DIG_FA_LOWER;
+ 	rtl92d_dm_init_dynamic_txpower(hw);
+ 	rtl92d_dm_init_edca_turbo(hw);
+ 	rtl92d_dm_init_rate_adaptive_mask(hw);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0043-rtlwifi-rtl8192ee-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0043-rtlwifi-rtl8192ee-Convert-driver-to-use-common-DM-ta.patch
new file mode 100644
index 0000000..b522d52
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0043-rtlwifi-rtl8192ee-Convert-driver-to-use-common-DM-ta.patch
@@ -0,0 +1,71 @@ 
+From 153cb55731b68ddf7b0ebaa55536b56d766b47e6 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:08 -0600
+Subject: [PATCH 43/51] rtlwifi: rtl8192ee: Convert driver to use common DM
+ table initialization
+
+Convert driver rtl8192ee to use the common routine to initialize
+dm_digtable.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192ee/dm.c | 32 ++---------------------------
+ 1 file changed, 2 insertions(+), 30 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
+index 70e58d1..459f3d0 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.c
+@@ -152,35 +152,6 @@ static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
+ 	{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}  /* 32, -16.0dB */
+ };
+ 
+-static void rtl92ee_dm_diginit(struct ieee80211_hw *hw)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	struct dig_t *dm_dig = &rtlpriv->dm_digtable;
+-
+-	dm_dig->cur_igvalue = rtl_get_bbreg(hw, DM_REG_IGI_A_11N,
+-					    DM_BIT_IGI_11N);
+-	dm_dig->rssi_lowthresh = DM_DIG_THRESH_LOW;
+-	dm_dig->rssi_highthresh = DM_DIG_THRESH_HIGH;
+-	dm_dig->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
+-	dm_dig->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
+-	dm_dig->rx_gain_max = DM_DIG_MAX;
+-	dm_dig->rx_gain_min = DM_DIG_MIN;
+-	dm_dig->back_val = DM_DIG_BACKOFF_DEFAULT;
+-	dm_dig->back_range_max = DM_DIG_BACKOFF_MAX;
+-	dm_dig->back_range_min = DM_DIG_BACKOFF_MIN;
+-	dm_dig->pre_cck_cca_thres = 0xff;
+-	dm_dig->cur_cck_cca_thres = 0x83;
+-	dm_dig->forbidden_igi = DM_DIG_MIN;
+-	dm_dig->large_fa_hit = 0;
+-	dm_dig->recover_cnt = 0;
+-	dm_dig->dig_min_0 = DM_DIG_MIN;
+-	dm_dig->dig_min_1 = DM_DIG_MIN;
+-	dm_dig->media_connect_0 = false;
+-	dm_dig->media_connect_1 = false;
+-	rtlpriv->dm.dm_initialgain_enable = true;
+-	dm_dig->bt30_cur_igi = 0x32;
+-}
+-
+ static void rtl92ee_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw)
+ {
+ 	u32 ret_value;
+@@ -1089,10 +1060,11 @@ static void rtl92ee_dm_init_dynamic_atc_switch(struct ieee80211_hw *hw)
+ void rtl92ee_dm_init(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
++	u32 cur_igvalue = rtl_get_bbreg(hw, DM_REG_IGI_A_11N, DM_BIT_IGI_11N);
+ 
+ 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
+ 
+-	rtl92ee_dm_diginit(hw);
++	rtl_dm_diginit(hw, cur_igvalue);
+ 	rtl92ee_dm_init_rate_adaptive_mask(hw);
+ 	rtl92ee_dm_init_primary_cca_check(hw);
+ 	rtl92ee_dm_init_edca_turbo(hw);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0044-rtlwifi-rtl8723ae-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0044-rtlwifi-rtl8723ae-Convert-driver-to-use-common-DM-ta.patch
new file mode 100644
index 0000000..2f29e77
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0044-rtlwifi-rtl8723ae-Convert-driver-to-use-common-DM-ta.patch
@@ -0,0 +1,62 @@ 
+From 3592c54b6c8e85a1713515f463379c6a97bf8009 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:09 -0600
+Subject: [PATCH 44/51] rtlwifi: rtl8723ae: Convert driver to use common DM
+ table initialization
+
+Convert driver rtl8723ae to use common routine rtl_dm_diginit().
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8723ae/dm.c | 27 +--------------------------
+ 1 file changed, 1 insertion(+), 26 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
+index 8bd124c..4c1c96c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
+@@ -147,31 +147,6 @@ static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
+ 	{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}
+ };
+ 
+-static void rtl8723e_dm_diginit(struct ieee80211_hw *hw)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
+-
+-	dm_digtable->dig_enable_flag = true;
+-	dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
+-	dm_digtable->cur_igvalue = 0x20;
+-	dm_digtable->pre_igvalue = 0x0;
+-	dm_digtable->cursta_cstate = DIG_STA_DISCONNECT;
+-	dm_digtable->presta_cstate = DIG_STA_DISCONNECT;
+-	dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT;
+-	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
+-	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
+-	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
+-	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
+-	dm_digtable->rx_gain_max = DM_DIG_MAX;
+-	dm_digtable->rx_gain_min = DM_DIG_MIN;
+-	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
+-	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
+-	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
+-	dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX;
+-	dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
+-}
+-
+ static u8 rtl8723e_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+@@ -819,7 +794,7 @@ void rtl8723e_dm_init(struct ieee80211_hw *hw)
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+ 
+ 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
+-	rtl8723e_dm_diginit(hw);
++	rtl_dm_diginit(hw, 0x20);
+ 	rtl8723_dm_init_dynamic_txpower(hw);
+ 	rtl8723_dm_init_edca_turbo(hw);
+ 	rtl8723e_dm_init_rate_adaptive_mask(hw);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0045-rtlwifi-rtl8723be-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0045-rtlwifi-rtl8723be-Convert-driver-to-use-common-DM-ta.patch
new file mode 100644
index 0000000..8c5e5ff
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0045-rtlwifi-rtl8723be-Convert-driver-to-use-common-DM-ta.patch
@@ -0,0 +1,69 @@ 
+From ac2f0baefab920a3f9117993eb1455b40b265ab5 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:10 -0600
+Subject: [PATCH 45/51] rtlwifi: rtl8723be: Convert driver to use common DM
+ table initialization
+
+Convert driver rtl8723be to use routine rtl_dm_diginit().
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8723be/dm.c | 32 ++---------------------------
+ 1 file changed, 2 insertions(+), 30 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
+index ddf45d9..2367e8f 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.c
+@@ -212,35 +212,6 @@ void rtl8723be_dm_txpower_track_adjust(struct ieee80211_hw *hw, u8 type,
+ 		(pwr_val << 16) | (pwr_val << 24);
+ }
+ 
+-static void rtl8723be_dm_diginit(struct ieee80211_hw *hw)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
+-
+-	dm_digtable->dig_enable_flag = true;
+-	dm_digtable->cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
+-	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
+-	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
+-	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
+-	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
+-	dm_digtable->rx_gain_max = DM_DIG_MAX;
+-	dm_digtable->rx_gain_min = DM_DIG_MIN;
+-	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
+-	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
+-	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
+-	dm_digtable->pre_cck_cca_thres = 0xff;
+-	dm_digtable->cur_cck_cca_thres = 0x83;
+-	dm_digtable->forbidden_igi = DM_DIG_MIN;
+-	dm_digtable->large_fa_hit = 0;
+-	dm_digtable->recover_cnt = 0;
+-	dm_digtable->dig_min_0 = DM_DIG_MIN;
+-	dm_digtable->dig_min_1 = DM_DIG_MIN;
+-	dm_digtable->media_connect_0 = false;
+-	dm_digtable->media_connect_1 = false;
+-	rtlpriv->dm.dm_initialgain_enable = true;
+-	dm_digtable->bt30_cur_igi = 0x32;
+-}
+-
+ void rtl8723be_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+@@ -294,9 +265,10 @@ static void rtl8723be_dm_init_dynamic_atc_switch(struct ieee80211_hw *hw)
+ void rtl8723be_dm_init(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
++	u32 cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
+ 
+ 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
+-	rtl8723be_dm_diginit(hw);
++	rtl_dm_diginit(hw, cur_igvalue);
+ 	rtl8723be_dm_init_rate_adaptive_mask(hw);
+ 	rtl8723_dm_init_edca_turbo(hw);
+ 	rtl8723_dm_init_dynamic_bb_powersaving(hw);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0046-rtlwifi-rtl8821ae-Convert-driver-to-use-common-DM-ta.patch b/package/kernel/mac80211/patches/680-0046-rtlwifi-rtl8821ae-Convert-driver-to-use-common-DM-ta.patch
new file mode 100644
index 0000000..7c49dcb
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0046-rtlwifi-rtl8821ae-Convert-driver-to-use-common-DM-ta.patch
@@ -0,0 +1,73 @@ 
+From 9259ee79208a95aa20a9824717a9f22b0a52cccd Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:11 -0600
+Subject: [PATCH 46/51] rtlwifi: rtl8821ae: Convert driver to use common DM
+ table initialization
+
+Convert driver to use routine rtl_dm_diginit().
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8821ae/dm.c | 31 ++---------------------------
+ 1 file changed, 2 insertions(+), 29 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+index 4af4613..0b2082d 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+@@ -520,34 +520,6 @@ void rtl8821ae_dm_initialize_txpower_tracking_thermalmeter(
+ 	}
+ }
+ 
+-static void rtl8821ae_dm_diginit(struct ieee80211_hw *hw)
+-{
+-	struct rtl_priv *rtlpriv = rtl_priv(hw);
+-	struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
+-
+-	dm_digtable->cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
+-	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW;
+-	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH;
+-	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW;
+-	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH;
+-	dm_digtable->rx_gain_max = DM_DIG_MAX;
+-	dm_digtable->rx_gain_min = DM_DIG_MIN;
+-	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
+-	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX;
+-	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN;
+-	dm_digtable->pre_cck_cca_thres = 0xff;
+-	dm_digtable->cur_cck_cca_thres = 0x83;
+-	dm_digtable->forbidden_igi = DM_DIG_MIN;
+-	dm_digtable->large_fa_hit = 0;
+-	dm_digtable->recover_cnt = 0;
+-	dm_digtable->dig_min_0 = DM_DIG_MIN;
+-	dm_digtable->dig_min_1 = DM_DIG_MIN;
+-	dm_digtable->media_connect_0 = false;
+-	dm_digtable->media_connect_1 = false;
+-	rtlpriv->dm.dm_initialgain_enable = true;
+-	dm_digtable->bt30_cur_igi = 0x32;
+-}
+-
+ void rtl8821ae_dm_init_edca_turbo(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+@@ -607,6 +579,7 @@ void rtl8821ae_dm_init(struct ieee80211_hw *hw)
+ {
+ 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+ 	struct rtl_phy *rtlphy = &rtlpriv->phy;
++	u32 cur_igvalue = rtl_get_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f);
+ 
+ 	spin_lock(&rtlpriv->locks.iqk_lock);
+ 	rtlphy->lck_inprogress = false;
+@@ -614,7 +587,7 @@ void rtl8821ae_dm_init(struct ieee80211_hw *hw)
+ 
+ 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
+ 	rtl8821ae_dm_common_info_self_init(hw);
+-	rtl8821ae_dm_diginit(hw);
++	rtl_dm_diginit(hw, cur_igvalue);
+ 	rtl8821ae_dm_init_rate_adaptive_mask(hw);
+ 	rtl8821ae_dm_init_edca_turbo(hw);
+ 	rtl8821ae_dm_initialize_txpower_tracking_thermalmeter(hw);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0047-rtlwifi-Move-macro-definitions-to-core.patch b/package/kernel/mac80211/patches/680-0047-rtlwifi-Move-macro-definitions-to-core.patch
new file mode 100644
index 0000000..faf34c1
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0047-rtlwifi-Move-macro-definitions-to-core.patch
@@ -0,0 +1,140 @@ 
+From ed0fb7eb2b2d27a07610b75d1f3a68cc22716347 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Tue, 6 Jan 2015 09:58:12 -0600
+Subject: [PATCH 47/51] rtlwifi: Move macro definitions to core
+
+Several of the drivers still were defining their own copies of various
+macros. These are all moved into the core.
+
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/core.h         | 1 +
+ drivers/net/wireless/rtlwifi/rtl8188ee/dm.h | 3 ---
+ drivers/net/wireless/rtlwifi/rtl8192ee/dm.h | 3 ---
+ drivers/net/wireless/rtlwifi/rtl8192se/dm.c | 6 +++---
+ drivers/net/wireless/rtlwifi/rtl8192se/dm.h | 1 -
+ drivers/net/wireless/rtlwifi/rtl8723be/dm.h | 3 ---
+ drivers/net/wireless/rtlwifi/rtl8821ae/dm.h | 9 ---------
+ 7 files changed, 4 insertions(+), 22 deletions(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/core.h b/drivers/net/wireless/rtlwifi/core.h
+index 1cde356..7b64e34 100644
+--- a/drivers/net/wireless/rtlwifi/core.h
++++ b/drivers/net/wireless/rtlwifi/core.h
+@@ -42,6 +42,7 @@
+ 
+ #define DM_DIG_MAX			0x3e
+ #define DM_DIG_MIN			0x1e
++#define DM_DIG_MAX_AP			0x32
+ #define DM_DIG_BACKOFF_MAX		12
+ #define DM_DIG_BACKOFF_MIN		-4
+ #define DM_DIG_BACKOFF_DEFAULT		10
+diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
+index 51ad3f9..071ccee 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8188ee/dm.h
+@@ -186,9 +186,6 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW				25
+ #define BW_AUTO_SWITCH_LOW_HIGH				30
+ 
+-#define DM_DIG_MAX_AP					0x32
+-#define DM_DIG_MIN_AP					0x20
+-
+ #define DM_DIG_FA_UPPER					0x3e
+ #define DM_DIG_FA_LOWER					0x1e
+ #define DM_DIG_FA_TH0					0x200
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
+index 4880e19..107d5a4 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192ee/dm.h
+@@ -189,9 +189,6 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW			25
+ #define BW_AUTO_SWITCH_LOW_HIGH			30
+ 
+-#define DM_DIG_MAX_AP				0x32
+-#define DM_DIG_MIN_AP				0x20
+-
+ #define DM_DIG_FA_UPPER				0x3e
+ #define DM_DIG_FA_LOWER				0x1e
+ #define DM_DIG_FA_TH0				0x200
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
+index 6cac70b..575980b 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.c
+@@ -470,7 +470,7 @@ static void _rtl92s_dm_initial_gain_sta_beforeconnect(struct ieee80211_hw *hw)
+ 			if (digtable->backoff_enable_flag)
+ 				rtl92s_backoff_enable_flag(hw);
+ 			else
+-				digtable->back_val = DM_DIG_BACKOFF;
++				digtable->back_val = DM_DIG_BACKOFF_MAX;
+ 
+ 			if ((digtable->rssi_val + 10 - digtable->back_val) >
+ 				digtable->rx_gain_max)
+@@ -504,7 +504,7 @@ static void _rtl92s_dm_initial_gain_sta_beforeconnect(struct ieee80211_hw *hw)
+ 		digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
+ 		rtl92s_phy_set_fw_cmd(hw, FW_CMD_DIG_ENABLE);
+ 
+-		digtable->back_val = DM_DIG_BACKOFF;
++		digtable->back_val = DM_DIG_BACKOFF_MAX;
+ 		digtable->cur_igvalue = rtlpriv->phy.default_initialgain[0];
+ 		digtable->pre_igvalue = 0;
+ 		return;
+@@ -692,7 +692,7 @@ static void _rtl92s_dm_init_dig(struct ieee80211_hw *hw)
+ 
+ 	/* for dig debug rssi value */
+ 	digtable->rssi_val = 50;
+-	digtable->back_val = DM_DIG_BACKOFF;
++	digtable->back_val = DM_DIG_BACKOFF_MAX;
+ 	digtable->rx_gain_max = DM_DIG_MAX;
+ 
+ 	digtable->rx_gain_min = DM_DIG_MIN;
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
+index be07d81..de6ac79 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8192se/dm.h
+@@ -83,7 +83,6 @@ enum dm_ratr_sta {
+ 
+ #define	DM_DIG_HIGH_PWR_THRESH_HIGH	75
+ #define	DM_DIG_HIGH_PWR_THRESH_LOW	70
+-#define	DM_DIG_BACKOFF			12
+ #define	DM_DIG_MIN_Netcore		0x12
+ 
+ void rtl92s_dm_watchdog(struct ieee80211_hw *hw);
+diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
+index 533b4f2..f752a2c 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8723be/dm.h
+@@ -180,9 +180,6 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW			25
+ #define BW_AUTO_SWITCH_LOW_HIGH			30
+ 
+-#define DM_DIG_MAX_AP				0x32
+-#define DM_DIG_MIN_AP				0x20
+-
+ #define DM_DIG_FA_UPPER				0x3e
+ #define DM_DIG_FA_LOWER				0x1e
+ #define DM_DIG_FA_TH0				0x200
+diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
+index 5516557..625a6bb 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
++++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.h
+@@ -187,15 +187,6 @@
+ #define BW_AUTO_SWITCH_HIGH_LOW		25
+ #define BW_AUTO_SWITCH_LOW_HIGH		30
+ 
+-#define DM_FALSEALARM_THRESH_LOW	400
+-#define DM_FALSEALARM_THRESH_HIGH	1000
+-
+-#define DM_DIG_MAX					0x3e
+-#define DM_DIG_MIN					0x1e
+-
+-#define DM_DIG_MAX_AP				0x32
+-#define DM_DIG_MIN_AP				0x20
+-
+ #define DM_DIG_FA_UPPER				0x3e
+ #define DM_DIG_FA_LOWER				0x1e
+ #define DM_DIG_FA_TH0				200
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0048-rtlwifi-rtl8192de-remove-redundant-else-if-check.patch b/package/kernel/mac80211/patches/680-0048-rtlwifi-rtl8192de-remove-redundant-else-if-check.patch
new file mode 100644
index 0000000..9457e6d
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0048-rtlwifi-rtl8192de-remove-redundant-else-if-check.patch
@@ -0,0 +1,46 @@ 
+From 59b23ebd7fd0af3facd174e96ee4dbc1494fa215 Mon Sep 17 00:00:00 2001
+From: Colin Ian King <colin.king@canonical.com>
+Date: Tue, 13 Jan 2015 14:07:34 +0000
+Subject: [PATCH 48/51] rtlwifi/rtl8192de: remove redundant else if check
+
+The else if check condition checks for the opposite of the
+if check, hence the else if check is redundant and can be
+replaced with a simple else:
+
+if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) {
+	..
+} else if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY) {
+	..
+}
+
+replaced with:
+
+if (rtlpriv->rtlhal.macphymode == SINGLEMAC_SINGLEPHY) {
+	..
+} else {
+	..
+}
+
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192de/hw.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
+index 280c3da..01bcc2d 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
+@@ -546,7 +546,7 @@ static bool _rtl92de_llt_table_init(struct ieee80211_hw *hw)
+ 		txpktbuf_bndy = 246;
+ 		value8 = 0;
+ 		value32 = 0x80bf0d29;
+-	} else if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY) {
++	} else {
+ 		maxPage = 127;
+ 		txpktbuf_bndy = 123;
+ 		value8 = 0;
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0049-rtlwifi-add-support-to-send-beacon-frame.patch b/package/kernel/mac80211/patches/680-0049-rtlwifi-add-support-to-send-beacon-frame.patch
new file mode 100644
index 0000000..d7e8abe
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0049-rtlwifi-add-support-to-send-beacon-frame.patch
@@ -0,0 +1,47 @@ 
+From 33511b157bbcebaef853cc1811992b664a2e5862 Mon Sep 17 00:00:00 2001
+From: Taehee Yoo <ap420073@gmail.com>
+Date: Wed, 21 Jan 2015 16:58:19 +0900
+Subject: [PATCH 49/51] rtlwifi: add support to send beacon frame.
+
+In AP mode, beacon frame is necessary to keep connection.
+this patch adds a sending beacon frame routine in initialization routine.
+
+Signed-off-by: Taehee Yoo <ap420073@gmail.com>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/core.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/drivers/net/wireless/rtlwifi/core.c b/drivers/net/wireless/rtlwifi/core.c
+index eb20316..a31a127 100644
+--- a/drivers/net/wireless/rtlwifi/core.c
++++ b/drivers/net/wireless/rtlwifi/core.c
+@@ -1010,6 +1010,16 @@ static int rtl_op_conf_tx(struct ieee80211_hw *hw,
+ 	return 0;
+ }
+ 
++static void send_beacon_frame(struct ieee80211_hw *hw,
++			      struct ieee80211_vif *vif)
++{
++	struct rtl_priv *rtlpriv = rtl_priv(hw);
++	struct sk_buff *skb = ieee80211_beacon_get(hw, vif);
++
++	if (skb)
++		rtlpriv->intf_ops->adapter_tx(hw, NULL, skb, NULL);
++}
++
+ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
+ 				    struct ieee80211_vif *vif,
+ 				    struct ieee80211_bss_conf *bss_conf,
+@@ -1040,6 +1050,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
+ 
+ 				if (rtlpriv->cfg->ops->linked_set_reg)
+ 					rtlpriv->cfg->ops->linked_set_reg(hw);
++				send_beacon_frame(hw, vif);
+ 			}
+ 		}
+ 		if ((changed & BSS_CHANGED_BEACON_ENABLED &&
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0050-rtl8192cu-fix-the-mesh-beaconing.patch b/package/kernel/mac80211/patches/680-0050-rtl8192cu-fix-the-mesh-beaconing.patch
new file mode 100644
index 0000000..8254fde
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0050-rtl8192cu-fix-the-mesh-beaconing.patch
@@ -0,0 +1,31 @@ 
+From 0b70dc273c13da02241b5b9e76fca5a714bd2965 Mon Sep 17 00:00:00 2001
+From: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
+Date: Fri, 23 Jan 2015 16:59:24 +0800
+Subject: [PATCH 50/51] rtl8192cu: fix the mesh beaconing
+
+Patch "rtlwifi: add support to send beacon frame" allows
+the beaconing of rtl8192cu. But mesh beaconing is not
+working. Fix this.
+
+Signed-off-by: Chun-Yeow Yeoh <yeohchunyeow@gmail.com>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+index 5513217..e5a7c4f 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+@@ -1509,6 +1509,7 @@ void rtl92cu_set_beacon_related_registers(struct ieee80211_hw *hw)
+ 	/* TODO: Modify later (Find the right parameters)
+ 	 * NOTE: Fix test chip's bug (about contention windows's randomness) */
+ 	if ((mac->opmode == NL80211_IFTYPE_ADHOC) ||
++	    (mac->opmode == NL80211_IFTYPE_MESH_POINT) ||
+ 	    (mac->opmode == NL80211_IFTYPE_AP)) {
+ 		rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_CCK, 0x50);
+ 		rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_OFDM, 0x50);
+-- 
+2.2.2
+
diff --git a/package/kernel/mac80211/patches/680-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch b/package/kernel/mac80211/patches/680-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch
new file mode 100644
index 0000000..35074be
--- /dev/null
+++ b/package/kernel/mac80211/patches/680-0051-rtlwifi-rtl8192cu-Set-fw_ready-flag.patch
@@ -0,0 +1,38 @@ 
+From 314112e0023acddaae1b43d549bc03be29a146ce Mon Sep 17 00:00:00 2001
+From: Taehee Yoo <ap420073@gmail.com>
+Date: Sat, 24 Jan 2015 20:55:40 +0900
+Subject: [PATCH 51/51] rtlwifi: rtl8192cu: Set fw_ready flag
+
+After rtl8192cu download firmware routine, set fw_ready flag.
+
+Signed-off-by: Taehee Yoo <ap420073@gmail.com>
+Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+index e5a7c4f..fe4b699 100644
+--- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
++++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
+@@ -1000,6 +1000,7 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw)
+ 	local_save_flags(flags);
+ 	local_irq_enable();
+ 
++	rtlhal->fw_ready = false;
+ 	rtlhal->hw_type = HARDWARE_TYPE_RTL8192CU;
+ 	err = _rtl92cu_init_mac(hw);
+ 	if (err) {
+@@ -1013,6 +1014,8 @@ int rtl92cu_hw_init(struct ieee80211_hw *hw)
+ 		err = 1;
+ 		goto exit;
+ 	}
++
++	rtlhal->fw_ready = true;
+ 	rtlhal->last_hmeboxnum = 0; /* h2c */
+ 	_rtl92cu_phy_param_tab_init(hw);
+ 	rtl92cu_phy_mac_config(hw);
+-- 
+2.2.2
+