From 13232bc0b8d03fd7da997fb2abca12fa95ac5df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ertu=C4=9Frul=20Erata?= Date: Fri, 27 Jan 2017 15:52:53 +0300 Subject: [PATCH] kernel-4.9.6 patches and config --- .../kernel/files/configs/kernel-x86_64-config | 187 +- .../kernel/files/patches/linux/patch-4.9.6.xz | Bin 0 -> 209552 bytes .../patches/mageia/3rd-3rdparty-merge.patch | 18 +- .../mageia/3rd-rtl8723bs-4.7-buildfix.patch | 178 - .../mageia/3rd-rtl8723bs-4.8-buildfix.patch | 19 - .../files/patches/mageia/3rd-rtl8723bs.patch | 40625 ++++++++-------- ...i-do-not-warn-if-_BQC-does-not-exist.patch | 39 + .../block-Turn-into-BFQ-v8r6-for-4.9.0.patch | 9106 ++++ ...rly-Queue-Merge-EQM-to-BFQ-v7r11-for.patch | 1101 + ...onfig-build-bits-for-BFQ-v7r11-4.5.0.patch | 103 + ...e-the-BFQ-v7r11-I-O-sched-for-4.5.0.patch} | 6543 +-- ...x-Intel-PTT-hw-bug-during-idle-state.patch | 115 + ...crb-implement-runtime-pm-for-tpm_crb.patch | 134 + ...tpm_crb-implement-tpm-crb-idle-state.patch | 111 + ...open-code-the-crb_init-into-acpi_add.patch | 75 + ...odular.patch => fs-aufs-4.9-modular.patch} | 162 +- .../{fs-aufs-4.8.patch => fs-aufs-4.9.patch} | 1189 +- ...terator-to-first-record-for-zero-off.patch | 44 + ...sableLSQCROPERFforOCL-KBL-workaround.patch | 97 + ...-workarounds-for-A0-and-B0-revisions.patch | 127 + ...skl-drop-workarounds-for-D0-revision.patch | 86 + ...skl-drop-workarounds-for-E0-revision.patch | 59 + .../files/patches/mageia/gpu-drm-mach64.patch | 14 +- .../net-netfilter-psd-fix-redefines.patch | 85 + ...ix-incorrect-event-channel-deduction.patch | 29 + ...el-oops-introduced-with-commit-e4965.patch | 37 + ...ession-caused-by-commit-d86e64768859.patch | 429 - ...v_kfree_skb_irq-instead-of-kfree_skb.patch | 34 + .../files/patches/mageia/nvmepatch1-V4.patch | 111 - .../files/patches/mageia/nvmepatch2-V4.patch | 107 - .../files/patches/mageia/nvmepatch3-V4.patch | 264 - kernel/kernel/files/patches/mageia/series | 60 +- ...vt-switch-with-video-1366x768-option.patch | 71 + ...on-skl-when-the-plane-is-not-visible.patch | 49 + ...th-1s-delay-if-we-have-delayed-event.patch | 55 + ...ev-color-map-copying-bounds-checking.patch | 82 + ...ous-registers-for-short-regset-write.patch | 32 + ...-fixdep-parsing-wait-for-last-target.patch | 51 + ...-fixdep-compilation-at-the-start-of-.patch | 237 + ...perf-build-related-variables-under-n.patch | 49 + ...st-Makefile-remove-powerpc-reference.patch | 4 +- kernel/kernel/pspec.xml | 62 +- 42 files changed, 34566 insertions(+), 27414 deletions(-) create mode 100644 kernel/kernel/files/patches/linux/patch-4.9.6.xz delete mode 100644 kernel/kernel/files/patches/mageia/3rd-rtl8723bs-4.7-buildfix.patch delete mode 100644 kernel/kernel/files/patches/mageia/3rd-rtl8723bs-4.8-buildfix.patch create mode 100644 kernel/kernel/files/patches/mageia/acpi-do-not-warn-if-_BQC-does-not-exist.patch create mode 100644 kernel/kernel/files/patches/mageia/block-Turn-into-BFQ-v8r6-for-4.9.0.patch create mode 100644 kernel/kernel/files/patches/mageia/block-bfq-add-Early-Queue-Merge-EQM-to-BFQ-v7r11-for.patch create mode 100644 kernel/kernel/files/patches/mageia/block-cgroups-kconfig-build-bits-for-BFQ-v7r11-4.5.0.patch rename kernel/kernel/files/patches/mageia/{linux-BFQ-v8r4.patch => block-introduce-the-BFQ-v7r11-I-O-sched-for-4.5.0.patch} (54%) create mode 100644 kernel/kernel/files/patches/mageia/char-tmp-tpm_crb-fix-Intel-PTT-hw-bug-during-idle-state.patch create mode 100644 kernel/kernel/files/patches/mageia/char-tmp-tpm_crb-implement-runtime-pm-for-tpm_crb.patch create mode 100644 kernel/kernel/files/patches/mageia/char-tpm-tpm_crb-implement-tpm-crb-idle-state.patch create mode 100644 kernel/kernel/files/patches/mageia/char-tpm-tpm_crb-open-code-the-crb_init-into-acpi_add.patch rename kernel/kernel/files/patches/mageia/{fs-aufs-4.8-modular.patch => fs-aufs-4.9-modular.patch} (61%) rename kernel/kernel/files/patches/mageia/{fs-aufs-4.8.patch => fs-aufs-4.9.patch} (97%) create mode 100644 kernel/kernel/files/patches/mageia/fs-seq_file-reset-iterator-to-first-record-for-zero-off.patch create mode 100644 kernel/kernel/files/patches/mageia/gpu-drm-i915-Remove-WaDisableLSQCROPERFforOCL-KBL-workaround.patch create mode 100644 kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-A0-and-B0-revisions.patch create mode 100644 kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-D0-revision.patch create mode 100644 kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-E0-revision.patch create mode 100644 kernel/kernel/files/patches/mageia/net-netfilter-psd-fix-redefines.patch create mode 100644 kernel/kernel/files/patches/mageia/net-wireless-brcmfmac-fix-incorrect-event-channel-deduction.patch create mode 100644 kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Fix-kernel-oops-introduced-with-commit-e4965.patch delete mode 100644 kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Fix-regression-caused-by-commit-d86e64768859.patch create mode 100644 kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Use-dev_kfree_skb_irq-instead-of-kfree_skb.patch delete mode 100644 kernel/kernel/files/patches/mageia/nvmepatch1-V4.patch delete mode 100644 kernel/kernel/files/patches/mageia/nvmepatch2-V4.patch delete mode 100644 kernel/kernel/files/patches/mageia/nvmepatch3-V4.patch create mode 100644 kernel/kernel/files/patches/mageia/stable-drm-fix-broken-vt-switch-with-video-1366x768-option.patch create mode 100644 kernel/kernel/files/patches/mageia/stable-drm-i915-ignore-bogus-plane-coordinates-on-skl-when-the-plane-is-not-visible.patch create mode 100644 kernel/kernel/files/patches/mageia/stable-drm-schedule-the-output_poll_work-with-1s-delay-if-we-have-delayed-event.patch create mode 100644 kernel/kernel/files/patches/mageia/stable-fbdev-color-map-copying-bounds-checking.patch create mode 100644 kernel/kernel/files/patches/mageia/stable-tile-ptrace-preserve-previous-registers-for-short-regset-write.patch create mode 100644 kernel/kernel/files/patches/mageia/tools-build-Make-fixdep-parsing-wait-for-last-target.patch create mode 100644 kernel/kernel/files/patches/mageia/tools-perf-tools-Force-fixdep-compilation-at-the-start-of-.patch create mode 100644 kernel/kernel/files/patches/mageia/tools-perf-tools-Move-perf-build-related-variables-under-n.patch diff --git a/kernel/kernel/files/configs/kernel-x86_64-config b/kernel/kernel/files/configs/kernel-x86_64-config index 8b5d1389..724d16e5 100644 --- a/kernel/kernel/files/configs/kernel-x86_64-config +++ b/kernel/kernel/files/configs/kernel-x86_64-config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86_64 4.8.13 Kernel Configuration +# Linux/x86_64 4.9.6 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y @@ -46,6 +46,7 @@ CONFIG_PGTABLE_LEVELS=4 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" CONFIG_IRQ_WORK=y CONFIG_BUILDTIME_EXTABLE_SORT=y +CONFIG_THREAD_INFO_IN_TASK=y # # General setup @@ -311,6 +312,8 @@ CONFIG_HAVE_STACK_VALIDATION=y CONFIG_OLD_SIGSUSPEND3=y CONFIG_COMPAT_OLD_SIGACTION=y # CONFIG_CPU_NO_EFFICIENT_FFS is not set +CONFIG_HAVE_ARCH_VMAP_STACK=y +CONFIG_VMAP_STACK=y # # GCOV-based kernel profiling @@ -361,6 +364,7 @@ CONFIG_EFI_PARTITION=y # CONFIG_SYSV68_PARTITION is not set CONFIG_CMDLINE_PARTITION=y CONFIG_BLOCK_COMPAT=y +CONFIG_BLK_MQ_PCI=y # # IO Schedulers @@ -409,6 +413,7 @@ CONFIG_X86_EXTENDED_PLATFORM=y # CONFIG_X86_UV is not set # CONFIG_X86_GOLDFISH is not set # CONFIG_X86_INTEL_MID is not set +# CONFIG_MLX_PLATFORM is not set # CONFIG_X86_INTEL_LPSS is not set CONFIG_X86_AMD_PLATFORM_DEVICE=y CONFIG_IOSF_MBI=m @@ -622,7 +627,6 @@ CONFIG_PM_DEBUG=y # CONFIG_PM_ADVANCED_DEBUG is not set CONFIG_PM_TEST_SUSPEND=y CONFIG_PM_SLEEP_DEBUG=y -# CONFIG_DPM_WATCHDOG is not set CONFIG_PM_TRACE=y CONFIG_PM_TRACE_RTC=y CONFIG_PM_CLK=y @@ -677,6 +681,7 @@ CONFIG_ACPI_APEI_MEMORY_FAILURE=y # CONFIG_ACPI_APEI_EINJ is not set # CONFIG_ACPI_APEI_ERST_DEBUG is not set CONFIG_DPTF_POWER=m +CONFIG_ACPI_WATCHDOG=y CONFIG_ACPI_EXTLOG=m # CONFIG_PMIC_OPREGION is not set CONFIG_ACPI_CONFIGFS=m @@ -755,6 +760,7 @@ CONFIG_PCIEASPM_DEFAULT=y # CONFIG_PCIEASPM_PERFORMANCE is not set CONFIG_PCIE_PME=y # CONFIG_PCIE_DPC is not set +# CONFIG_PCIE_PTM is not set CONFIG_PCI_BUS_ADDR_T_64BIT=y CONFIG_PCI_MSI=y CONFIG_PCI_MSI_IRQ_DOMAIN=y @@ -778,6 +784,7 @@ CONFIG_HOTPLUG_PCI_SHPC=m # PCI host controller drivers # # CONFIG_PCIE_DW_PLAT is not set +# CONFIG_VMD is not set CONFIG_ISA_DMA_API=y CONFIG_AMD_NB=y CONFIG_PCCARD=y @@ -820,7 +827,6 @@ CONFIG_SYSVIPC_COMPAT=y CONFIG_KEYS_COMPAT=y CONFIG_X86_DEV_DMA_OPS=y CONFIG_PMC_ATOM=y -# CONFIG_VMD is not set CONFIG_NET=y CONFIG_COMPAT_NETLINK_MESSAGES=y CONFIG_NET_INGRESS=y @@ -893,6 +899,7 @@ CONFIG_TCP_CONG_YEAH=m CONFIG_TCP_CONG_ILLINOIS=m # CONFIG_TCP_CONG_DCTCP is not set # CONFIG_TCP_CONG_CDG is not set +# CONFIG_TCP_CONG_BBR is not set CONFIG_DEFAULT_CUBIC=y # CONFIG_DEFAULT_RENO is not set CONFIG_DEFAULT_TCP_CONG="cubic" @@ -986,9 +993,10 @@ CONFIG_NF_TABLES_INET=m # CONFIG_NF_TABLES_NETDEV is not set CONFIG_NFT_EXTHDR=m CONFIG_NFT_META=m +# CONFIG_NFT_NUMGEN is not set CONFIG_NFT_CT=m -CONFIG_NFT_RBTREE=m -CONFIG_NFT_HASH=m +# CONFIG_NFT_SET_RBTREE is not set +# CONFIG_NFT_SET_HASH is not set CONFIG_NFT_COUNTER=m CONFIG_NFT_LOG=m CONFIG_NFT_LIMIT=m @@ -996,9 +1004,11 @@ CONFIG_NFT_LIMIT=m # CONFIG_NFT_REDIR is not set CONFIG_NFT_NAT=m CONFIG_NFT_QUEUE=m +# CONFIG_NFT_QUOTA is not set CONFIG_NFT_REJECT=m CONFIG_NFT_REJECT_INET=m CONFIG_NFT_COMPAT=m +CONFIG_NFT_HASH=m CONFIG_NETFILTER_XTABLES=y # @@ -1152,7 +1162,6 @@ CONFIG_IP_VS_PE_SIP=m # CONFIG_NF_DEFRAG_IPV4=m CONFIG_NF_CONNTRACK_IPV4=m -# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set CONFIG_NF_TABLES_IPV4=m CONFIG_NFT_CHAIN_ROUTE_IPV4=m CONFIG_NFT_REJECT_IPV4=m @@ -1403,7 +1412,9 @@ CONFIG_NET_ACT_CSUM=m # CONFIG_NET_ACT_VLAN is not set CONFIG_NET_ACT_BPF=m CONFIG_NET_ACT_CONNMARK=m +# CONFIG_NET_ACT_SKBMOD is not set # CONFIG_NET_ACT_IFE is not set +# CONFIG_NET_ACT_TUNNEL_KEY is not set CONFIG_NET_CLS_IND=y CONFIG_NET_SCH_FIFO=y CONFIG_DCB=y @@ -1414,6 +1425,7 @@ CONFIG_BATMAN_ADV_BLA=y CONFIG_BATMAN_ADV_DAT=y # CONFIG_BATMAN_ADV_NC is not set # CONFIG_BATMAN_ADV_MCAST is not set +CONFIG_BATMAN_ADV_DEBUGFS=y # CONFIG_BATMAN_ADV_DEBUG is not set CONFIG_OPENVSWITCH=m CONFIG_OPENVSWITCH_GRE=m @@ -1562,6 +1574,7 @@ CONFIG_BT_HCIUART_INTEL=y CONFIG_BT_HCIUART_BCM=y CONFIG_BT_HCIUART_QCA=y # CONFIG_BT_HCIUART_AG6XX is not set +# CONFIG_BT_HCIUART_MRVL is not set CONFIG_BT_HCIBCM203X=m CONFIG_BT_HCIBPA10X=m CONFIG_BT_HCIBFUSB=m @@ -1576,6 +1589,7 @@ CONFIG_BT_ATH3K=m CONFIG_BT_WILINK=m # CONFIG_AF_RXRPC is not set # CONFIG_AF_KCM is not set +# CONFIG_STREAM_PARSER is not set CONFIG_FIB_RULES=y CONFIG_WIRELESS=y CONFIG_WIRELESS_EXT=y @@ -1859,7 +1873,6 @@ CONFIG_SENSORS_APDS990X=m # CONFIG_HMC6352 is not set # CONFIG_DS1682 is not set CONFIG_VMWARE_BALLOON=m -# CONFIG_BMP085_I2C is not set # CONFIG_USB_SWITCH_FSA9480 is not set # CONFIG_SRAM is not set # CONFIG_PANEL is not set @@ -2015,6 +2028,7 @@ CONFIG_SCSI_MPT3SAS=m CONFIG_SCSI_MPT2SAS_MAX_SGE=128 CONFIG_SCSI_MPT3SAS_MAX_SGE=128 CONFIG_SCSI_MPT2SAS=m +# CONFIG_SCSI_SMARTPQI is not set CONFIG_SCSI_UFSHCD=m CONFIG_SCSI_UFSHCD_PCI=m CONFIG_SCSI_UFS_DWC_TC_PCI=m @@ -2256,7 +2270,6 @@ CONFIG_NET_TEAM_MODE_ACTIVEBACKUP=m CONFIG_NET_TEAM_MODE_LOADBALANCE=m CONFIG_MACVLAN=m CONFIG_MACVTAP=m -CONFIG_IPVLAN=m CONFIG_VXLAN=m CONFIG_GENEVE=m # CONFIG_GTP is not set @@ -2315,6 +2328,8 @@ CONFIG_NET_VENDOR_ALTEON=y CONFIG_ACENIC=m # CONFIG_ACENIC_OMIT_TIGON_I is not set CONFIG_ALTERA_TSE=m +CONFIG_NET_VENDOR_AMAZON=y +CONFIG_ENA_ETHERNET=m CONFIG_NET_VENDOR_AMD=y CONFIG_AMD8111_ETH=m CONFIG_PCNET32=m @@ -2348,6 +2363,7 @@ CONFIG_NET_VENDOR_CAVIUM=y # CONFIG_THUNDER_NIC_PF is not set # CONFIG_THUNDER_NIC_VF is not set # CONFIG_THUNDER_NIC_BGX is not set +CONFIG_THUNDER_NIC_RGX=m # CONFIG_LIQUIDIO is not set CONFIG_NET_VENDOR_CHELSIO=y CONFIG_CHELSIO_T1=m @@ -2461,9 +2477,12 @@ CONFIG_QLCNIC_HWMON=y CONFIG_QLGE=m CONFIG_NETXEN_NIC=m CONFIG_QED=m +CONFIG_QED_LL2=y CONFIG_QED_SRIOV=y CONFIG_QEDE=m +CONFIG_QED_RDMA=y CONFIG_NET_VENDOR_QUALCOMM=y +CONFIG_QCOM_EMAC=m CONFIG_NET_VENDOR_REALTEK=y CONFIG_ATP=m CONFIG_8139CP=m @@ -2529,41 +2548,47 @@ CONFIG_PCMCIA_XIRC2PS=m CONFIG_PHYLIB=y CONFIG_SWPHY=y +# +# MDIO bus device drivers +# +# CONFIG_MDIO_BCM_UNIMAC is not set +CONFIG_MDIO_BITBANG=m +CONFIG_MDIO_CAVIUM=m +CONFIG_MDIO_GPIO=m +CONFIG_MDIO_OCTEON=m +CONFIG_MDIO_THUNDER=m + # # MII PHY device drivers # +CONFIG_AMD_PHY=m CONFIG_AQUANTIA_PHY=m CONFIG_AT803X_PHY=m -CONFIG_AMD_PHY=m -CONFIG_MARVELL_PHY=m -CONFIG_DAVICOM_PHY=m -CONFIG_QSEMI_PHY=m -CONFIG_LXT_PHY=m -CONFIG_CICADA_PHY=m -CONFIG_VITESSE_PHY=m -CONFIG_TERANETICS_PHY=m -CONFIG_SMSC_PHY=m -CONFIG_BCM_NET_PHYLIB=m -CONFIG_BROADCOM_PHY=m CONFIG_BCM7XXX_PHY=m CONFIG_BCM87XX_PHY=m -CONFIG_ICPLUS_PHY=m -CONFIG_REALTEK_PHY=m -CONFIG_NATIONAL_PHY=m -CONFIG_STE10XP=m -CONFIG_LSI_ET1011C_PHY=m -CONFIG_MICREL_PHY=m +CONFIG_BCM_NET_PHYLIB=m +CONFIG_BROADCOM_PHY=m +CONFIG_CICADA_PHY=m +CONFIG_DAVICOM_PHY=m CONFIG_DP83848_PHY=m # CONFIG_DP83867_PHY is not set -CONFIG_MICROCHIP_PHY=m CONFIG_FIXED_PHY=y -CONFIG_MDIO_BITBANG=m -CONFIG_MDIO_GPIO=m -CONFIG_MDIO_CAVIUM=m -CONFIG_MDIO_OCTEON=m -# CONFIG_MDIO_THUNDER is not set -# CONFIG_MDIO_BCM_UNIMAC is not set +CONFIG_ICPLUS_PHY=m CONFIG_INTEL_XWAY_PHY=m +CONFIG_LSI_ET1011C_PHY=m +CONFIG_LXT_PHY=m +CONFIG_MARVELL_PHY=m +CONFIG_MICREL_PHY=m +CONFIG_MICROCHIP_PHY=m +CONFIG_MICROSEMI_PHY=m +CONFIG_NATIONAL_PHY=m +CONFIG_QSEMI_PHY=m +CONFIG_REALTEK_PHY=m +CONFIG_SMSC_PHY=m +CONFIG_STE10XP=m +CONFIG_TERANETICS_PHY=m +CONFIG_VITESSE_PHY=m +CONFIG_XILINX_GMII2RGMII=m # CONFIG_PLIP is not set CONFIG_PPP=m CONFIG_PPP_BSDCOMP=m @@ -3109,6 +3134,7 @@ CONFIG_TOUCHSCREEN_PROPERTIES=y CONFIG_TOUCHSCREEN_AD7879=m CONFIG_TOUCHSCREEN_AD7879_I2C=m CONFIG_TOUCHSCREEN_ATMEL_MXT=m +CONFIG_TOUCHSCREEN_ATMEL_MXT_T37=y CONFIG_TOUCHSCREEN_AUO_PIXCIR=m CONFIG_TOUCHSCREEN_BU21013=m CONFIG_TOUCHSCREEN_CY8CTMG110=m @@ -3120,11 +3146,11 @@ CONFIG_TOUCHSCREEN_DYNAPRO=m CONFIG_TOUCHSCREEN_HAMPSHIRE=m CONFIG_TOUCHSCREEN_EETI=m # CONFIG_TOUCHSCREEN_EGALAX_SERIAL is not set -CONFIG_TOUCHSCREEN_FT6236=m CONFIG_TOUCHSCREEN_FUJITSU=m # CONFIG_TOUCHSCREEN_GOODIX is not set CONFIG_TOUCHSCREEN_ILI210X=m CONFIG_TOUCHSCREEN_GUNZE=m +CONFIG_TOUCHSCREEN_EKTF2127=m # CONFIG_TOUCHSCREEN_ELAN is not set CONFIG_TOUCHSCREEN_ELO=m CONFIG_TOUCHSCREEN_WACOM_W8001=m @@ -3192,6 +3218,7 @@ CONFIG_INPUT_APANEL=m CONFIG_INPUT_GP2A=m CONFIG_INPUT_GPIO_BEEPER=m CONFIG_INPUT_GPIO_TILT_POLLED=m +CONFIG_INPUT_GPIO_DECODER=m CONFIG_INPUT_ATLAS_BTNS=m CONFIG_INPUT_ATI_REMOTE2=m CONFIG_INPUT_KEYSPAN_REMOTE=m @@ -3292,6 +3319,7 @@ CONFIG_SERIAL_8250_RSA=y # CONFIG_SERIAL_8250_FSL is not set CONFIG_SERIAL_8250_DW=m # CONFIG_SERIAL_8250_RT288X is not set +CONFIG_SERIAL_8250_LPSS=y CONFIG_SERIAL_8250_MID=y # CONFIG_SERIAL_8250_MOXA is not set @@ -3504,7 +3532,6 @@ CONFIG_PINCTRL_INTEL=m CONFIG_PINCTRL_BROXTON=m CONFIG_PINCTRL_SUNRISEPOINT=m CONFIG_GPIOLIB=y -CONFIG_GPIO_DEVRES=y CONFIG_GPIO_ACPI=y CONFIG_GPIOLIB_IRQCHIP=y CONFIG_GPIO_SYSFS=y @@ -3519,6 +3546,7 @@ CONFIG_GPIO_DWAPB=m CONFIG_GPIO_GENERIC_PLATFORM=y CONFIG_GPIO_ICH=m CONFIG_GPIO_LYNXPOINT=m +CONFIG_GPIO_MOCKUP=m CONFIG_GPIO_VX855=m # CONFIG_GPIO_ZX is not set @@ -3539,11 +3567,13 @@ CONFIG_GPIO_MAX732X=m CONFIG_GPIO_PCA953X=m CONFIG_GPIO_PCF857X=m # CONFIG_GPIO_TPIC2810 is not set +CONFIG_GPIO_TS4900=m # # MFD GPIO expanders # CONFIG_GPIO_LP3943=m +CONFIG_GPIO_LP873X=m # CONFIG_GPIO_TPS65218 is not set CONFIG_GPIO_UCB1400=m @@ -3592,6 +3622,8 @@ CONFIG_W1_SLAVE_DS2780=m CONFIG_W1_SLAVE_DS2781=m CONFIG_W1_SLAVE_DS28E04=m CONFIG_W1_SLAVE_BQ27000=m +CONFIG_POWER_AVS=y +# CONFIG_POWER_RESET is not set CONFIG_POWER_SUPPLY=y # CONFIG_POWER_SUPPLY_DEBUG is not set # CONFIG_PDA_POWER is not set @@ -3618,8 +3650,6 @@ CONFIG_CHARGER_BQ24735=m CONFIG_CHARGER_SMB347=m CONFIG_BATTERY_GAUGE_LTC2941=m # CONFIG_CHARGER_RT9455 is not set -# CONFIG_POWER_RESET is not set -CONFIG_POWER_AVS=y CONFIG_HWMON=y CONFIG_HWMON_VID=m # CONFIG_HWMON_DEBUG_CHIP is not set @@ -3810,6 +3840,7 @@ CONFIG_WATCHDOG_CORE=y # Watchdog Device Drivers # CONFIG_SOFT_WATCHDOG=m +CONFIG_WDAT_WDT=m # CONFIG_XILINX_WATCHDOG is not set # CONFIG_ZIIRAVE_WATCHDOG is not set CONFIG_CADENCE_WATCHDOG=m @@ -3863,6 +3894,15 @@ CONFIG_WDTPCI=m # USB-based Watchdog Cards # CONFIG_USBPCWATCHDOG=m + +# +# Watchdog Pretimeout Governors +# +CONFIG_WATCHDOG_PRETIMEOUT_GOV=y +# CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_NOOP is not set +CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC=y +CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP=m +CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC=y CONFIG_SSB_POSSIBLE=y # @@ -3909,6 +3949,7 @@ CONFIG_MFD_CROS_EC_I2C=m # CONFIG_MFD_DA9063 is not set # CONFIG_MFD_DA9150 is not set # CONFIG_MFD_DLN2 is not set +CONFIG_MFD_EXYNOS_LPASS=m # CONFIG_MFD_MC13XXX_I2C is not set # CONFIG_HTC_PASIC3 is not set CONFIG_MFD_INTEL_QUARK_I2C_GPIO=m @@ -3947,6 +3988,7 @@ CONFIG_TPS65010=m # CONFIG_TPS6507X is not set # CONFIG_MFD_TPS65086 is not set # CONFIG_MFD_TPS65217 is not set +CONFIG_MFD_TI_LP873X=m CONFIG_MFD_TPS65218=m # CONFIG_MFD_TPS65912_I2C is not set CONFIG_MFD_WL1273_CORE=m @@ -3974,6 +4016,7 @@ CONFIG_VIDEO_V4L2_SUBDEV_API=y CONFIG_VIDEO_V4L2=m # CONFIG_VIDEO_ADV_DEBUG is not set # CONFIG_VIDEO_FIXED_MINOR_RANGES is not set +CONFIG_VIDEO_PCI_SKELETON=m CONFIG_VIDEO_TUNER=m CONFIG_V4L2_MEM2MEM_DEV=m # CONFIG_V4L2_FLASH_LED_CLASS is not set @@ -4126,6 +4169,7 @@ CONFIG_VIDEO_TM6000_DVB=m # CONFIG_DVB_USB=m # CONFIG_DVB_USB_DEBUG is not set +CONFIG_DVB_USB_DIB3000MC=m CONFIG_DVB_USB_A800=m CONFIG_DVB_USB_DIBUSB_MB=m # CONFIG_DVB_USB_DIBUSB_MB_FAULTY is not set @@ -4192,6 +4236,7 @@ CONFIG_MEDIA_PCI_SUPPORT=y # CONFIG_VIDEO_MEYE=m CONFIG_VIDEO_SOLO6X10=m +CONFIG_VIDEO_TW5864=m # CONFIG_VIDEO_TW68 is not set # CONFIG_VIDEO_TW686X is not set CONFIG_VIDEO_ZORAN=m @@ -4321,7 +4366,7 @@ CONFIG_SMS_SIANO_RC=y # CONFIG_SMS_SIANO_DEBUGFS is not set # -# Media ancillary drivers (tuners, sensors, i2c, frontends) +# Media ancillary drivers (tuners, sensors, i2c, spi, frontends) # CONFIG_MEDIA_SUBDRV_AUTOSELECT=y CONFIG_MEDIA_ATTACH=y @@ -4513,6 +4558,7 @@ CONFIG_DVB_RTL2832=m CONFIG_DVB_RTL2832_SDR=m CONFIG_DVB_SI2168=m # CONFIG_DVB_AS102_FE is not set +CONFIG_DVB_GP8PSK_FE=m # # DVB-C (cable) frontends @@ -4607,8 +4653,6 @@ CONFIG_DRM_TTM=m CONFIG_DRM_I2C_CH7006=m CONFIG_DRM_I2C_SIL164=m CONFIG_DRM_I2C_NXP_TDA998X=m -CONFIG_DRM_TDFX=m -CONFIG_DRM_R128=m CONFIG_DRM_RADEON=m CONFIG_DRM_RADEON_USERPTR=y # CONFIG_DRM_AMDGPU is not set @@ -4620,15 +4664,10 @@ CONFIG_DRM_NOUVEAU=m CONFIG_NOUVEAU_DEBUG=5 CONFIG_NOUVEAU_DEBUG_DEFAULT=3 CONFIG_DRM_NOUVEAU_BACKLIGHT=y -CONFIG_DRM_I810=m CONFIG_DRM_I915=m CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT=y CONFIG_DRM_I915_USERPTR=y CONFIG_DRM_I915_GVT=y -CONFIG_DRM_MGA=m -CONFIG_DRM_SIS=m -CONFIG_DRM_VIA=m -CONFIG_DRM_SAVAGE=m CONFIG_DRM_VGEM=m CONFIG_DRM_VMWGFX=m CONFIG_DRM_VMWGFX_FBCON=y @@ -4654,6 +4693,7 @@ CONFIG_DRM_BRIDGE=y # # CONFIG_DRM_ANALOGIX_ANX78XX is not set # CONFIG_HSA_AMD is not set +# CONFIG_DRM_LEGACY is not set # # Frame buffer Devices @@ -5064,6 +5104,11 @@ CONFIG_USB_HIDDEV=y # I2C HID support # CONFIG_I2C_HID=m + +# +# Intel ISH HID support +# +CONFIG_INTEL_ISH_HID=m CONFIG_USB_OHCI_LITTLE_ENDIAN=y CONFIG_USB_SUPPORT=y CONFIG_USB_COMMON=y @@ -5080,7 +5125,7 @@ CONFIG_USB_OTG=y # CONFIG_USB_OTG_WHITELIST is not set # CONFIG_USB_OTG_BLACKLIST_HUB is not set CONFIG_USB_OTG_FSM=m -# CONFIG_USB_ULPI_BUS is not set +CONFIG_USB_LEDS_TRIGGER_USBPORT=m CONFIG_USB_MON=y CONFIG_USB_WUSB=m CONFIG_USB_WUSB_CBAF=m @@ -5274,6 +5319,7 @@ CONFIG_USB_ISIGHTFW=m CONFIG_USB_YUREX=m CONFIG_USB_EZUSB_FX2=m CONFIG_USB_HSIC_USB3503=m +CONFIG_USB_HSIC_USB4604=m # CONFIG_USB_LINK_LAYER_TEST is not set CONFIG_USB_CHAOSKEY=m # CONFIG_UCSI is not set @@ -5292,6 +5338,7 @@ CONFIG_USB_GPIO_VBUS=m CONFIG_USB_ISP1301=m # CONFIG_USB_GADGET is not set # CONFIG_USB_LED_TRIG is not set +# CONFIG_USB_ULPI_BUS is not set CONFIG_UWB=m CONFIG_UWB_HWA=m CONFIG_UWB_WHCI=m @@ -5381,6 +5428,7 @@ CONFIG_LEDS_LM355x=m # LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM) # CONFIG_LEDS_BLINKM=m +CONFIG_LEDS_MLXCPLD=m # # LED Triggers @@ -5438,6 +5486,7 @@ CONFIG_INFINIBAND_HFI1=m CONFIG_HFI1_DEBUG_SDMA_ORDER=y CONFIG_HFI1_VERBS_31BIT_PSN=y CONFIG_SDMA_VERBOSITY=y +CONFIG_INFINIBAND_QEDR=m CONFIG_EDAC_ATOMIC_SCRUB=y CONFIG_EDAC_SUPPORT=y CONFIG_EDAC=y @@ -5485,6 +5534,7 @@ CONFIG_RTC_DRV_ABB5ZES3=m CONFIG_RTC_DRV_ABX80X=m CONFIG_RTC_DRV_DS1307=m CONFIG_RTC_DRV_DS1307_HWMON=y +# CONFIG_RTC_DRV_DS1307_CENTURY is not set CONFIG_RTC_DRV_DS1374=m # CONFIG_RTC_DRV_DS1374_WDT is not set CONFIG_RTC_DRV_DS1672=m @@ -5492,7 +5542,6 @@ CONFIG_RTC_DRV_MAX6900=m CONFIG_RTC_DRV_RS5C372=m CONFIG_RTC_DRV_ISL1208=m CONFIG_RTC_DRV_ISL12022=m -CONFIG_RTC_DRV_ISL12057=m CONFIG_RTC_DRV_X1205=m CONFIG_RTC_DRV_PCF8523=m CONFIG_RTC_DRV_PCF85063=m @@ -5571,6 +5620,7 @@ CONFIG_INTEL_IOATDMA=m CONFIG_INTEL_MIC_X100_DMA=m # CONFIG_QCOM_HIDMA_MGMT is not set # CONFIG_QCOM_HIDMA is not set +CONFIG_DW_DMAC_CORE=y # CONFIG_DW_DMAC is not set # CONFIG_DW_DMAC_PCI is not set CONFIG_HSU_DMA=y @@ -5593,6 +5643,7 @@ CONFIG_KS0108_PORT=0x378 CONFIG_KS0108_DELAY=2 CONFIG_CFAG12864B=m CONFIG_CFAG12864B_RATE=20 +# CONFIG_IMG_ASCII_LCD is not set CONFIG_UIO=m CONFIG_UIO_CIF=m # CONFIG_UIO_PDRV_GENIRQ is not set @@ -5670,9 +5721,6 @@ CONFIG_STAGING=y CONFIG_R8712U=m CONFIG_R8188EU=m CONFIG_88EU_AP_MODE=y -CONFIG_R8723AU=m -CONFIG_8723AU_AP_MODE=y -CONFIG_8723AU_BT_COEXIST=y CONFIG_RTS5208=m # CONFIG_VT6655 is not set # CONFIG_VT6656 is not set @@ -5687,7 +5735,6 @@ CONFIG_STAGING_MEDIA=y CONFIG_I2C_BCM2048=m # CONFIG_MEDIA_CEC is not set # CONFIG_DVB_CXD2099 is not set -# CONFIG_VIDEO_TW686X_KH is not set CONFIG_LIRC_STAGING=y CONFIG_LIRC_BT829=m CONFIG_LIRC_IMON=m @@ -5729,6 +5776,24 @@ CONFIG_HDM_USB=m # Old ISDN4Linux (deprecated) # CONFIG_KS7010=m +CONFIG_GREYBUS=m +CONFIG_GREYBUS_ES2=m +CONFIG_GREYBUS_AUDIO=m +CONFIG_GREYBUS_BOOTROM=m +CONFIG_GREYBUS_HID=m +CONFIG_GREYBUS_LIGHT=m +CONFIG_GREYBUS_LOG=m +CONFIG_GREYBUS_LOOPBACK=m +CONFIG_GREYBUS_POWER=m +CONFIG_GREYBUS_RAW=m +CONFIG_GREYBUS_VIBRATOR=m +CONFIG_GREYBUS_BRIDGED_PHY=m +CONFIG_GREYBUS_GPIO=m +CONFIG_GREYBUS_I2C=m +CONFIG_GREYBUS_PWM=m +CONFIG_GREYBUS_SDIO=m +CONFIG_GREYBUS_UART=m +CONFIG_GREYBUS_USB=m CONFIG_X86_PLATFORM_DEVICES=y CONFIG_ACER_WMI=m CONFIG_ACERHDF=m @@ -5811,7 +5876,6 @@ CONFIG_COMMON_CLK_CDCE706=m CONFIG_COMMON_CLK_PWM=m # CONFIG_COMMON_CLK_PXA is not set # CONFIG_COMMON_CLK_PIC32 is not set -# CONFIG_SUNXI_CCU is not set # # Hardware Spinlock drivers @@ -5902,7 +5966,16 @@ CONFIG_PWM_PCA9685=m CONFIG_ARM_GIC_MAX_NR=1 # CONFIG_IPACK_BUS is not set CONFIG_RESET_CONTROLLER=y +# CONFIG_RESET_ATH79 is not set +# CONFIG_RESET_BERLIN is not set +# CONFIG_RESET_LPC18XX is not set +# CONFIG_RESET_MESON is not set +# CONFIG_RESET_PISTACHIO is not set +# CONFIG_RESET_SOCFPGA is not set +# CONFIG_RESET_STM32 is not set +# CONFIG_RESET_SUNXI is not set CONFIG_TI_SYSCON_RESET=m +# CONFIG_RESET_ZYNQ is not set # CONFIG_FMC is not set # @@ -5951,7 +6024,6 @@ CONFIG_INTEL_TH_PTI=m # FPGA Configuration Support # CONFIG_FPGA=m -CONFIG_FPGA_MGR_ZYNQ_FPGA=m # # Firmware Drivers @@ -5989,6 +6061,7 @@ CONFIG_EFI_RUNTIME_MAP=y CONFIG_EFI_RUNTIME_WRAPPERS=y CONFIG_EFI_BOOTLOADER_CONTROL=m CONFIG_EFI_CAPSULE_LOADER=m +CONFIG_EFI_TEST=m CONFIG_UEFI_CPER=y # @@ -6127,6 +6200,7 @@ CONFIG_TMPFS_POSIX_ACL=y CONFIG_TMPFS_XATTR=y CONFIG_HUGETLBFS=y CONFIG_HUGETLB_PAGE=y +CONFIG_ARCH_HAS_GIGANTIC_PAGE=y CONFIG_CONFIGFS_FS=y CONFIG_EFIVAR_FS=y CONFIG_MISC_FILESYSTEMS=y @@ -6405,7 +6479,6 @@ CONFIG_USER_STACKTRACE_SUPPORT=y CONFIG_NOP_TRACER=y CONFIG_HAVE_FUNCTION_TRACER=y CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y -CONFIG_HAVE_FUNCTION_GRAPH_FP_TEST=y CONFIG_HAVE_DYNAMIC_FTRACE=y CONFIG_HAVE_DYNAMIC_FTRACE_WITH_REGS=y CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y @@ -6426,6 +6499,7 @@ CONFIG_FUNCTION_TRACER=y CONFIG_FUNCTION_GRAPH_TRACER=y # CONFIG_IRQSOFF_TRACER is not set CONFIG_SCHED_TRACER=y +# CONFIG_HWLAT_TRACER is not set CONFIG_FTRACE_SYSCALLS=y CONFIG_TRACER_SNAPSHOT=y CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y @@ -6465,7 +6539,6 @@ CONFIG_TEST_PRINTF=m # CONFIG_TEST_RHASHTABLE is not set # CONFIG_TEST_HASH is not set # CONFIG_PROVIDE_OHCI1394_DMA_INIT is not set -# CONFIG_BUILD_DOCSRC is not set # CONFIG_DMA_API_DEBUG is not set # CONFIG_TEST_LKM is not set # CONFIG_TEST_USER_COPY is not set @@ -6477,6 +6550,7 @@ CONFIG_TEST_STATIC_KEYS=m # CONFIG_SAMPLES is not set CONFIG_HAVE_ARCH_KGDB=y CONFIG_ARCH_HAS_UBSAN_SANITIZE_ALL=y +# CONFIG_ARCH_WANTS_UBSAN_NO_NULL is not set # CONFIG_UBSAN is not set CONFIG_ARCH_HAS_DEVMEM_IS_ALLOWED=y CONFIG_STRICT_DEVMEM=y @@ -6733,6 +6807,7 @@ CONFIG_CRYPTO_DEV_QAT_DH895xCC=m CONFIG_CRYPTO_DEV_QAT_DH895xCCVF=m # CONFIG_CRYPTO_DEV_QAT_C3XXXVF is not set # CONFIG_CRYPTO_DEV_QAT_C62XVF is not set +CONFIG_CRYPTO_DEV_CHELSIO=m # CONFIG_ASYMMETRIC_KEY_TYPE is not set # @@ -6838,7 +6913,6 @@ CONFIG_DQL=y CONFIG_GLOB=y # CONFIG_GLOB_SELFTEST is not set CONFIG_NLATTR=y -CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y CONFIG_LRU_CACHE=m CONFIG_CLZ_TAB=y CONFIG_CORDIC=m @@ -6856,11 +6930,12 @@ CONFIG_SG_POOL=y CONFIG_ARCH_HAS_SG_CHAIN=y CONFIG_ARCH_HAS_PMEM_API=y CONFIG_ARCH_HAS_MMIO_FLUSH=y +CONFIG_SBITMAP=y # # Unofficial 3rd party kernel additions # CONFIG_NDISWRAPPER=m +CONFIG_VIAHSS=m CONFIG_RTL8723BS=m CONFIG_WLAN_SDIO=y -CONFIG_VIAHSS=m diff --git a/kernel/kernel/files/patches/linux/patch-4.9.6.xz b/kernel/kernel/files/patches/linux/patch-4.9.6.xz new file mode 100644 index 0000000000000000000000000000000000000000..2a9954797925ec73a93480c6de8777447e870f2d GIT binary patch literal 209552 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 K000001X)@NdH3P~ literal 0 HcmV?d00001 diff --git a/kernel/kernel/files/patches/mageia/3rd-3rdparty-merge.patch b/kernel/kernel/files/patches/mageia/3rd-3rdparty-merge.patch index b2ab8c08..72c6c8b0 100644 --- a/kernel/kernel/files/patches/mageia/3rd-3rdparty-merge.patch +++ b/kernel/kernel/files/patches/mageia/3rd-3rdparty-merge.patch @@ -83,10 +83,10 @@ diff -Nurp linux-4.2.2/Makefile linux-4.2.2-3rd/Makefile net-y := net/ libs-y := lib/ core-y := usr/ -diff -Nurp linux-4.6/scripts/kconfig/Makefile linux-4.6-3rd/scripts/kconfig/Makefile ---- linux-4.6/scripts/kconfig/Makefile -+++ linux-4.6-3rd/scripts/kconfig/Makefile -@@ -18,26 +18,26 @@ endif +diff -Nurp linux-4.9/scripts/kconfig/Makefile linux-4.9-3rd/scripts/kconfig/Makefile +--- linux-4.9/scripts/kconfig/Makefile ++++ linux-4.9-3rd/scripts/kconfig/Makefile +@@ -18,28 +18,28 @@ endif # We need this, in case the user has it in its environment unexport CONFIG_ @@ -113,6 +113,8 @@ diff -Nurp linux-4.6/scripts/kconfig/Makefile linux-4.6-3rd/scripts/kconfig/Make -silentoldconfig: $(obj)/conf +silentoldconfig: $(obj)/conf 3rdparty/Makefile $(Q)mkdir -p include/config include/generated + $(Q)test -e include/generated/autoksyms.h || \ + touch include/generated/autoksyms.h $< $(silent) --$@ $(Kconfig) -localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf @@ -120,7 +122,7 @@ diff -Nurp linux-4.6/scripts/kconfig/Makefile linux-4.6-3rd/scripts/kconfig/Make $(Q)mkdir -p include/config include/generated $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config $(Q)if [ -f .config ]; then \ -@@ -80,7 +80,7 @@ simple-targets := oldconfig allnoconfig +@@ -82,7 +82,7 @@ simple-targets := oldconfig allnoconfig alldefconfig randconfig listnewconfig olddefconfig PHONY += $(simple-targets) @@ -129,7 +131,7 @@ diff -Nurp linux-4.6/scripts/kconfig/Makefile linux-4.6-3rd/scripts/kconfig/Make $< $(silent) --$@ $(Kconfig) PHONY += oldnoconfig savedefconfig defconfig -@@ -88,12 +88,12 @@ PHONY += oldnoconfig savedefconfig defco +@@ -90,12 +90,12 @@ PHONY += oldnoconfig savedefconfig defco # oldnoconfig is an alias of olddefconfig, because people already are dependent # on its behavior (sets new symbols to their default value but not 'n') with the # counter-intuitive name. @@ -145,7 +147,7 @@ diff -Nurp linux-4.6/scripts/kconfig/Makefile linux-4.6-3rd/scripts/kconfig/Make ifeq ($(KBUILD_DEFCONFIG),) $< $(silent) --defconfig $(Kconfig) else -@@ -106,26 +106,26 @@ else +@@ -108,26 +108,26 @@ else endif endif @@ -177,7 +179,7 @@ diff -Nurp linux-4.6/scripts/kconfig/Makefile linux-4.6-3rd/scripts/kconfig/Make $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config # Help text used by make help -@@ -188,6 +188,9 @@ gconf-objs := gconf.o zconf.tab.o +@@ -190,6 +190,9 @@ gconf-objs := gconf.o zconf.tab.o hostprogs-y := conf nconf mconf kxgettext qconf gconf diff --git a/kernel/kernel/files/patches/mageia/3rd-rtl8723bs-4.7-buildfix.patch b/kernel/kernel/files/patches/mageia/3rd-rtl8723bs-4.7-buildfix.patch deleted file mode 100644 index cbab5aae..00000000 --- a/kernel/kernel/files/patches/mageia/3rd-rtl8723bs-4.7-buildfix.patch +++ /dev/null @@ -1,178 +0,0 @@ - -Fix building with kernel-4.7 series. - -Signed-off-by: Thomas Backlund - - 3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c | 32 ++++++++++++++--------------- - 3rdparty/rtl8723bs/os_dep/wifi_regd.c | 6 ++--- - 2 files changed, 19 insertions(+), 19 deletions(-) - -diff -urp linux/3rdparty/rtl8723bs.orig/os_dep/ioctl_cfg80211.c linux/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c ---- linux/3rdparty/rtl8723bs.orig/os_dep/ioctl_cfg80211.c 2016-07-04 20:00:13.000000000 +0300 -+++ linux/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c 2016-07-04 20:37:45.054379270 +0300 -@@ -44,7 +44,7 @@ static const u32 rtw_cipher_suites[] = { - } - - #define CHAN2G(_channel, _freq, _flags) { \ -- .band = IEEE80211_BAND_2GHZ, \ -+ .band = NL80211_BAND_2GHZ, \ - .center_freq = (_freq), \ - .hw_value = (_channel), \ - .flags = (_flags), \ -@@ -120,13 +120,13 @@ static void rtw_2g_rates_init(struct iee - } - - static struct ieee80211_supported_band *rtw_spt_band_alloc( -- enum ieee80211_band band -+ enum nl80211_band band - ) - { - struct ieee80211_supported_band *spt_band = NULL; - int n_channels, n_bitrates; - -- if (band == IEEE80211_BAND_2GHZ) -+ if (band == NL80211_BAND_2GHZ) - { - n_channels = RTW_2G_CHANNELS_NUM; - n_bitrates = RTW_G_RATES_NUM; -@@ -150,7 +150,7 @@ static struct ieee80211_supported_band * - spt_band->n_channels = n_channels; - spt_band->n_bitrates = n_bitrates; - -- if (band == IEEE80211_BAND_2GHZ) -+ if (band == NL80211_BAND_2GHZ) - { - rtw_2g_channels_init(spt_band->channels); - rtw_2g_rates_init(spt_band->bitrates); -@@ -170,7 +170,7 @@ static void rtw_spt_band_free(struct iee - if (!spt_band) - return; - -- if (spt_band->band == IEEE80211_BAND_2GHZ) -+ if (spt_band->band == NL80211_BAND_2GHZ) - { - size = sizeof(struct ieee80211_supported_band) - + sizeof(struct ieee80211_channel)*RTW_2G_CHANNELS_NUM -@@ -232,7 +232,7 @@ static int rtw_ieee80211_channel_to_freq - { - /* see 802.11 17.3.8.3.2 and Annex J - * there are overlapping channel numbers in 5GHz and 2GHz bands */ -- if (band == IEEE80211_BAND_2GHZ) { -+ if (band == NL80211_BAND_2GHZ) { - if (chan == 14) - return 2484; - else if (chan < 14) -@@ -336,7 +336,7 @@ struct cfg80211_bss *rtw_cfg80211_inform - - - channel = pnetwork->network.Configuration.DSConfig; -- freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); -+ freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ); - - notify_channel = ieee80211_get_channel(wiphy, freq); - -@@ -420,7 +420,7 @@ int rtw_cfg80211_check_bss(struct adapte - if (!(pnetwork) || !(padapter->rtw_wdev)) - return false; - -- freq = rtw_ieee80211_channel_to_frequency(pnetwork->Configuration.DSConfig, IEEE80211_BAND_2GHZ); -+ freq = rtw_ieee80211_channel_to_frequency(pnetwork->Configuration.DSConfig, NL80211_BAND_2GHZ); - - notify_channel = ieee80211_get_channel(padapter->rtw_wdev->wiphy, freq); - bss = cfg80211_get_bss(padapter->rtw_wdev->wiphy, notify_channel, -@@ -542,7 +542,7 @@ check_bss: - u32 freq; - u16 channel = cur_network->network.Configuration.DSConfig; - -- freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); -+ freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ); - - notify_channel = ieee80211_get_channel(wiphy, freq); - -@@ -3064,7 +3064,7 @@ void rtw_cfg80211_rx_action(struct adapt - else - DBG_871X("RTW_Rx:category(%u), action(%u)\n", category, action); - -- freq = rtw_ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); -+ freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ); - - rtw_cfg80211_rx_mgmt(adapter, freq, 0, frame, frame_len, GFP_ATOMIC); - } -@@ -3311,7 +3311,7 @@ static int cfg80211_rtw_sched_scan_stop( - } - #endif /* CONFIG_PNO_SUPPORT */ - --static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum ieee80211_band band, u8 rf_type) -+static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum nl80211_band band, u8 rf_type) - { - - #define MAX_BIT_RATE_40MHZ_MCS15 300 /* Mbps */ -@@ -3335,7 +3335,7 @@ static void rtw_cfg80211_init_ht_capab(s - ht_cap->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; - - /* -- *hw->wiphy->bands[IEEE80211_BAND_2GHZ] -+ *hw->wiphy->bands[NL80211_BAND_2GHZ] - *base on ant_num - *rx_mask: RX mask - *if rx_ant = 1 rx_mask[0]= 0xff;==>MCS0-MCS7 -@@ -3379,9 +3379,9 @@ void rtw_cfg80211_init_wiphy(struct adap - DBG_8192C("%s:rf_type =%d\n", __func__, rf_type); - - { -- bands = wiphy->bands[IEEE80211_BAND_2GHZ]; -+ bands = wiphy->bands[NL80211_BAND_2GHZ]; - if (bands) -- rtw_cfg80211_init_ht_capab(&bands->ht_cap, IEEE80211_BAND_2GHZ, rf_type); -+ rtw_cfg80211_init_ht_capab(&bands->ht_cap, NL80211_BAND_2GHZ, rf_type); - } - - /* init regulary domain */ -@@ -3417,7 +3417,7 @@ static void rtw_cfg80211_preinit_wiphy(s - wiphy->n_cipher_suites = ARRAY_SIZE(rtw_cipher_suites); - - /* if (padapter->registrypriv.wireless_mode & WIRELESS_11G) */ -- wiphy->bands[IEEE80211_BAND_2GHZ] = rtw_spt_band_alloc(IEEE80211_BAND_2GHZ); -+ wiphy->bands[NL80211_BAND_2GHZ] = rtw_spt_band_alloc(NL80211_BAND_2GHZ); - - wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; - wiphy->flags |= WIPHY_FLAG_OFFCHAN_TX | WIPHY_FLAG_HAVE_AP_SME; -@@ -3564,7 +3564,7 @@ void rtw_wdev_free(struct wireless_dev * - if (!wdev) - return; - -- rtw_spt_band_free(wdev->wiphy->bands[IEEE80211_BAND_2GHZ]); -+ rtw_spt_band_free(wdev->wiphy->bands[NL80211_BAND_2GHZ]); - - wiphy_free(wdev->wiphy); - -diff -urp linux/3rdparty/rtl8723bs.orig/os_dep/wifi_regd.c linux/3rdparty/rtl8723bs/os_dep/wifi_regd.c ---- linux/3rdparty/rtl8723bs.orig/os_dep/wifi_regd.c 2016-07-04 20:00:13.000000000 +0300 -+++ linux/3rdparty/rtl8723bs/os_dep/wifi_regd.c 2016-07-04 20:35:31.427278665 +0300 -@@ -105,7 +105,7 @@ static int rtw_ieee80211_channel_to_freq - /* see 802.11 17.3.8.3.2 and Annex J - * there are overlapping channel numbers in 5GHz and 2GHz bands */ - -- /* IEEE80211_BAND_2GHZ */ -+ /* NL80211_BAND_2GHZ */ - if (chan == 14) - return 2484; - else if (chan < 14) -@@ -128,7 +128,7 @@ static void _rtw_reg_apply_flags(struct - u32 freq; - - /* all channels disable */ -- for (i = 0; i < IEEE80211_NUM_BANDS; i++) { -+ for (i = 0; i < NUM_NL80211_BANDS; i++) { - sband = wiphy->bands[i]; - - if (sband) { -@@ -146,7 +146,7 @@ static void _rtw_reg_apply_flags(struct - channel = channel_set[i].ChannelNum; - freq = - rtw_ieee80211_channel_to_frequency(channel, -- IEEE80211_BAND_2GHZ); -+ NL80211_BAND_2GHZ); - - ch = ieee80211_get_channel(wiphy, freq); - if (ch) { diff --git a/kernel/kernel/files/patches/mageia/3rd-rtl8723bs-4.8-buildfix.patch b/kernel/kernel/files/patches/mageia/3rd-rtl8723bs-4.8-buildfix.patch deleted file mode 100644 index fa695774..00000000 --- a/kernel/kernel/files/patches/mageia/3rd-rtl8723bs-4.8-buildfix.patch +++ /dev/null @@ -1,19 +0,0 @@ - -Adjust for cfg80211_scan_done() changes in kernel 4.8 - -Signed-off-by: Thomas Backlund - ---- linux/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c.orig -+++ linux/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c -@@ -1413,7 +1413,10 @@ void rtw_cfg80211_indicate_scan_done(str - } - else - { -- cfg80211_scan_done(pwdev_priv->scan_request, aborted); -+ struct cfg80211_scan_info info = { -+ .aborted = aborted, -+ }; -+ cfg80211_scan_done(pwdev_priv->scan_request, &info); - } - - pwdev_priv->scan_request = NULL; diff --git a/kernel/kernel/files/patches/mageia/3rd-rtl8723bs.patch b/kernel/kernel/files/patches/mageia/3rd-rtl8723bs.patch index 5e355dd0..58379a12 100644 --- a/kernel/kernel/files/patches/mageia/3rd-rtl8723bs.patch +++ b/kernel/kernel/files/patches/mageia/3rd-rtl8723bs.patch @@ -3,111 +3,112 @@ From https://github.com/hadess/rtl8723bs Tpomost commit: -commit 9750337e13af3e3870fabd5c3dd9d170bd0953e4 -Author: Larry Finger -Date: Mon Nov 9 12:00:56 2015 -0600 +commit b3def82d8cbd0e7011bfaa6b70cd74725863e833 +Merge: aae04af 20822be +Author: lwfinger +Date: Thu Nov 3 10:33:33 2016 -0500 - rtl8723bs: Remove extraneous variable - - Signed-off-by: Larry Finger + Merge pull request #110 from colin4124/patch-1 + + Add usage guide Signed-off-by: Thomas Backlund 3rdparty/rtl8723bs/Kconfig | 11 - 3rdparty/rtl8723bs/Makefile | 250 - 3rdparty/rtl8723bs/core/rtw_ap.c | 2479 +++++++ - 3rdparty/rtl8723bs/core/rtw_btcoex.c | 253 - 3rdparty/rtl8723bs/core/rtw_cmd.c | 2322 ++++++ - 3rdparty/rtl8723bs/core/rtw_debug.c | 1477 ++++ - 3rdparty/rtl8723bs/core/rtw_eeprom.c | 375 + - 3rdparty/rtl8723bs/core/rtw_efuse.c | 654 + - 3rdparty/rtl8723bs/core/rtw_ieee80211.c | 1488 ++++ + 3rdparty/rtl8723bs/Makefile | 251 + 3rdparty/rtl8723bs/core/rtw_ap.c | 2684 ++++++++ + 3rdparty/rtl8723bs/core/rtw_btcoex.c | 243 + 3rdparty/rtl8723bs/core/rtw_cmd.c | 2244 +++++++ + 3rdparty/rtl8723bs/core/rtw_debug.c | 1453 ++++ + 3rdparty/rtl8723bs/core/rtw_eeprom.c | 369 + + 3rdparty/rtl8723bs/core/rtw_efuse.c | 635 ++ + 3rdparty/rtl8723bs/core/rtw_ieee80211.c | 1433 ++++ 3rdparty/rtl8723bs/core/rtw_io.c | 203 - 3rdparty/rtl8723bs/core/rtw_ioctl_set.c | 736 ++ - 3rdparty/rtl8723bs/core/rtw_mlme.c | 3331 +++++++++ - 3rdparty/rtl8723bs/core/rtw_mlme_ext.c | 7376 ++++++++++++++++++++++ + 3rdparty/rtl8723bs/core/rtw_ioctl_set.c | 696 ++ + 3rdparty/rtl8723bs/core/rtw_mlme.c | 3155 ++++++++++ + 3rdparty/rtl8723bs/core/rtw_mlme_ext.c | 6940 ++++++++++++++++++++++ 3rdparty/rtl8723bs/core/rtw_odm.c | 195 - 3rdparty/rtl8723bs/core/rtw_pwrctrl.c | 1521 ++++ - 3rdparty/rtl8723bs/core/rtw_recv.c | 2931 ++++++++ - 3rdparty/rtl8723bs/core/rtw_rf.c | 66 - 3rdparty/rtl8723bs/core/rtw_security.c | 2486 +++++++ - 3rdparty/rtl8723bs/core/rtw_sta_mgt.c | 646 + - 3rdparty/rtl8723bs/core/rtw_wlan_util.c | 2542 +++++++ - 3rdparty/rtl8723bs/core/rtw_xmit.c | 3263 +++++++++ - 3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c | 115 + 3rdparty/rtl8723bs/core/rtw_pwrctrl.c | 1421 ++++ + 3rdparty/rtl8723bs/core/rtw_recv.c | 2693 ++++++++ + 3rdparty/rtl8723bs/core/rtw_rf.c | 64 + 3rdparty/rtl8723bs/core/rtw_security.c | 2448 +++++++ + 3rdparty/rtl8723bs/core/rtw_sta_mgt.c | 641 ++ + 3rdparty/rtl8723bs/core/rtw_wlan_util.c | 2328 +++++++ + 3rdparty/rtl8723bs/core/rtw_xmit.c | 3100 +++++++++ + 3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c | 138 3rdparty/rtl8723bs/hal/Hal8723BReg.h | 442 + - 3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c | 3547 ++++++++++ - 3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h | 243 - 3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c | 4077 ++++++++++++ - 3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h | 205 - 3rdparty/rtl8723bs/hal/HalBtcOutSrc.h | 706 ++ - 3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c | 612 + + 3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c | 3779 +++++++++++ + 3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h | 193 + 3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c | 3729 +++++++++++ + 3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h | 155 + 3rdparty/rtl8723bs/hal/HalBtcOutSrc.h | 565 + + 3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c | 643 ++ 3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h | 48 - 3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c | 275 + 3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c | 302 3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h | 28 - 3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c | 638 + + 3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c | 799 ++ 3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h | 49 - 3rdparty/rtl8723bs/hal/HalPhyRf.c | 394 + - 3rdparty/rtl8723bs/hal/HalPhyRf.h | 75 - 3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c | 2171 ++++++ - 3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h | 100 - 3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c | 166 + 3rdparty/rtl8723bs/hal/HalPhyRf.c | 662 ++ + 3rdparty/rtl8723bs/hal/HalPhyRf.h | 63 + 3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c | 2091 ++++++ + 3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h | 83 + 3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c | 205 3rdparty/rtl8723bs/hal/Mp_Precomp.h | 33 - 3rdparty/rtl8723bs/hal/hal_btcoex.c | 1754 +++++ - 3rdparty/rtl8723bs/hal/hal_com.c | 1464 ++++ - 3rdparty/rtl8723bs/hal/hal_com_phycfg.c | 3582 ++++++++++ - 3rdparty/rtl8723bs/hal/hal_intf.c | 478 + - 3rdparty/rtl8723bs/hal/hal_phy.c | 272 - 3rdparty/rtl8723bs/hal/hal_sdio.c | 106 - 3rdparty/rtl8723bs/hal/odm.c | 1630 ++++ - 3rdparty/rtl8723bs/hal/odm.h | 1558 ++++ - 3rdparty/rtl8723bs/hal/odm_AntDiv.c | 74 + 3rdparty/rtl8723bs/hal/hal_btcoex.c | 1720 +++++ + 3rdparty/rtl8723bs/hal/hal_com.c | 1753 +++++ + 3rdparty/rtl8723bs/hal/hal_com_phycfg.c | 3288 ++++++++++ + 3rdparty/rtl8723bs/hal/hal_intf.c | 474 + + 3rdparty/rtl8723bs/hal/hal_phy.c | 224 + 3rdparty/rtl8723bs/hal/hal_sdio.c | 115 + 3rdparty/rtl8723bs/hal/odm.c | 1446 ++++ + 3rdparty/rtl8723bs/hal/odm.h | 1465 ++++ + 3rdparty/rtl8723bs/hal/odm_AntDiv.c | 70 3rdparty/rtl8723bs/hal/odm_AntDiv.h | 38 - 3rdparty/rtl8723bs/hal/odm_CfoTracking.c | 275 - 3rdparty/rtl8723bs/hal/odm_CfoTracking.h | 48 - 3rdparty/rtl8723bs/hal/odm_DIG.c | 1104 +++ - 3rdparty/rtl8723bs/hal/odm_DIG.h | 263 - 3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c | 107 - 3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h | 46 - 3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c | 32 - 3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h | 40 - 3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c | 187 - 3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h | 41 - 3rdparty/rtl8723bs/hal/odm_HWConfig.c | 608 + - 3rdparty/rtl8723bs/hal/odm_HWConfig.h | 179 - 3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c | 172 - 3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h | 44 - 3rdparty/rtl8723bs/hal/odm_PathDiv.c | 34 + 3rdparty/rtl8723bs/hal/odm_CfoTracking.c | 338 + + 3rdparty/rtl8723bs/hal/odm_CfoTracking.h | 47 + 3rdparty/rtl8723bs/hal/odm_DIG.c | 1221 +++ + 3rdparty/rtl8723bs/hal/odm_DIG.h | 195 + 3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c | 89 + 3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h | 39 + 3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c | 30 + 3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h | 37 + 3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c | 186 + 3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h | 31 + 3rdparty/rtl8723bs/hal/odm_HWConfig.c | 535 + + 3rdparty/rtl8723bs/hal/odm_HWConfig.h | 162 + 3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c | 175 + 3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h | 47 + 3rdparty/rtl8723bs/hal/odm_PathDiv.c | 42 3rdparty/rtl8723bs/hal/odm_PathDiv.h | 29 - 3rdparty/rtl8723bs/hal/odm_RTL8723B.c | 49 + 3rdparty/rtl8723bs/hal/odm_RTL8723B.c | 45 3rdparty/rtl8723bs/hal/odm_RTL8723B.h | 22 - 3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c | 189 - 3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h | 80 + 3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c | 257 + 3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h | 65 3rdparty/rtl8723bs/hal/odm_RegDefine11N.h | 172 3rdparty/rtl8723bs/hal/odm_debug.c | 52 - 3rdparty/rtl8723bs/hal/odm_debug.h | 154 - 3rdparty/rtl8723bs/hal/odm_interface.h | 60 + 3rdparty/rtl8723bs/hal/odm_debug.h | 165 + 3rdparty/rtl8723bs/hal/odm_interface.h | 59 3rdparty/rtl8723bs/hal/odm_precomp.h | 60 3rdparty/rtl8723bs/hal/odm_reg.h | 103 3rdparty/rtl8723bs/hal/odm_types.h | 102 - 3rdparty/rtl8723bs/hal/rtl8723b_cmd.c | 2412 +++++++ - 3rdparty/rtl8723bs/hal/rtl8723b_dm.c | 314 - 3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c | 4844 ++++++++++++++ - 3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c | 1070 +++ - 3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c | 241 - 3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c | 87 - 3rdparty/rtl8723bs/hal/rtl8723bs_recv.c | 528 + - 3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c | 652 + - 3rdparty/rtl8723bs/hal/sdio_halinit.c | 1959 +++++ - 3rdparty/rtl8723bs/hal/sdio_ops.c | 1262 +++ + 3rdparty/rtl8723bs/hal/rtl8723b_cmd.c | 2358 +++++++ + 3rdparty/rtl8723bs/hal/rtl8723b_dm.c | 300 + 3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c | 4546 ++++++++++++++ + 3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c | 1060 +++ + 3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c | 230 + 3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c | 86 + 3rdparty/rtl8723bs/hal/rtl8723bs_recv.c | 490 + + 3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c | 686 ++ + 3rdparty/rtl8723bs/hal/sdio_halinit.c | 1928 ++++++ + 3rdparty/rtl8723bs/hal/sdio_ops.c | 1296 ++++ 3rdparty/rtl8723bs/include/Hal8192CPhyReg.h | 1126 +++ 3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h | 128 3rdparty/rtl8723bs/include/Hal8723BPhyReg.h | 77 3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h | 232 3rdparty/rtl8723bs/include/HalPwrSeqCmd.h | 132 3rdparty/rtl8723bs/include/HalVerDef.h | 127 - 3rdparty/rtl8723bs/include/autoconf.h | 67 + 3rdparty/rtl8723bs/include/autoconf.h | 71 3rdparty/rtl8723bs/include/basic_types.h | 209 3rdparty/rtl8723bs/include/cmd_osdep.h | 26 3rdparty/rtl8723bs/include/drv_conf.h | 37 @@ -146,7 +147,7 @@ Signed-off-by: Thomas Backlund 3rdparty/rtl8723bs/include/rtw_br_ext.h | 63 3rdparty/rtl8723bs/include/rtw_btcoex.h | 64 3rdparty/rtl8723bs/include/rtw_byteorder.h | 24 - 3rdparty/rtl8723bs/include/rtw_cmd.h | 980 ++ + 3rdparty/rtl8723bs/include/rtw_cmd.h | 980 +++ 3rdparty/rtl8723bs/include/rtw_debug.h | 355 + 3rdparty/rtl8723bs/include/rtw_eeprom.h | 128 3rdparty/rtl8723bs/include/rtw_efuse.h | 132 @@ -165,7 +166,7 @@ Signed-off-by: Thomas Backlund 3rdparty/rtl8723bs/include/rtw_rf.h | 159 3rdparty/rtl8723bs/include/rtw_security.h | 440 + 3rdparty/rtl8723bs/include/rtw_version.h | 2 - 3rdparty/rtl8723bs/include/rtw_wifi_regd.h | 28 + 3rdparty/rtl8723bs/include/rtw_wifi_regd.h | 35 3rdparty/rtl8723bs/include/rtw_xmit.h | 528 + 3rdparty/rtl8723bs/include/sdio_hal.h | 28 3rdparty/rtl8723bs/include/sdio_ops.h | 49 @@ -175,24 +176,24 @@ Signed-off-by: Thomas Backlund 3rdparty/rtl8723bs/include/wifi.h | 1158 +++ 3rdparty/rtl8723bs/include/wlan_bssdef.h | 278 3rdparty/rtl8723bs/include/xmit_osdep.h | 54 - 3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c | 3599 ++++++++++ - 3rdparty/rtl8723bs/os_dep/ioctl_linux.c | 5820 +++++++++++++++++ + 3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c | 3608 +++++++++++ + 3rdparty/rtl8723bs/os_dep/ioctl_linux.c | 5820 ++++++++++++++++++ 3rdparty/rtl8723bs/os_dep/mlme_linux.c | 206 - 3rdparty/rtl8723bs/os_dep/os_intfs.c | 1916 +++++ + 3rdparty/rtl8723bs/os_dep/os_intfs.c | 1916 ++++++ 3rdparty/rtl8723bs/os_dep/osdep_service.c | 481 + 3rdparty/rtl8723bs/os_dep/recv_linux.c | 366 + 3rdparty/rtl8723bs/os_dep/rtw_proc.c | 786 ++ 3rdparty/rtl8723bs/os_dep/rtw_proc.h | 45 - 3rdparty/rtl8723bs/os_dep/sdio_intf.c | 725 ++ + 3rdparty/rtl8723bs/os_dep/sdio_intf.c | 727 ++ 3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c | 599 + - 3rdparty/rtl8723bs/os_dep/wifi_regd.c | 218 + 3rdparty/rtl8723bs/os_dep/wifi_regd.c | 164 3rdparty/rtl8723bs/os_dep/xmit_linux.c | 298 - 173 files changed, 111507 insertions(+) + 173 files changed, 109461 insertions(+) -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_ap.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_ap.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,2479 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_ap.c linux/3rdparty/rtl8723bs/core/rtw_ap.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_ap.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_ap.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,2684 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -271,46 +272,59 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + /* update TIM IE */ + /* if (pstapriv->tim_bitmap) */ -+ if (true) -+ { ++ if (true) { ++ + u8 *p, *dst_ie, *premainder_ie = NULL, *pbackup_remainder_ie = NULL; + __le16 tim_bitmap_le; + uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; + + tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); + -+ p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); -+ if (p != NULL && tim_ielen>0) -+ { ++ p = rtw_get_ie( ++ pie + _FIXED_IE_LENGTH_, ++ _TIM_IE_, ++ &tim_ielen, ++ pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_ ++ ); ++ if (p != NULL && tim_ielen > 0) { ++ + tim_ielen += 2; + + premainder_ie = p+tim_ielen; + -+ tim_ie_offset = (sint)(p -pie); ++ tim_ie_offset = (sint)(p - pie); + + remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen; + + /* append TIM IE from dst_ie offset */ + dst_ie = p; -+ } -+ else -+ { ++ } else{ ++ ++ + tim_ielen = 0; + + /* calucate head_len */ + offset = _FIXED_IE_LENGTH_; + + /* get ssid_ie len */ -+ p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SSID_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); ++ p = rtw_get_ie( ++ pie + _BEACON_IE_OFFSET_, ++ _SSID_IE_, ++ &tmp_len, ++ (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_) ++ ); + if (p != NULL) + offset += tmp_len+2; + + /* get supported rates len */ -+ p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); ++ p = rtw_get_ie( ++ pie + _BEACON_IE_OFFSET_, ++ _SUPPORTEDRATES_IE_, &tmp_len, ++ (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_) ++ ); + if (p != NULL) -+ { + offset += tmp_len+2; -+ } ++ + + /* DS Parameter Set IE, len =3 */ + offset += 3; @@ -325,8 +339,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + + -+ if (remainder_ielen>0) -+ { ++ if (remainder_ielen > 0) { ++ + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie && premainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); @@ -349,8 +363,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + else + *dst_ie++ = 0; + -+ if (tim_ielen ==4) -+ { ++ if (tim_ielen == 4) { ++ + __le16 pvb; + + if (pstapriv->tim_bitmap&0xff00) @@ -360,16 +374,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + *dst_ie++ = le16_to_cpu(pvb); + -+ } -+ else if (tim_ielen ==5) -+ { ++ } else if (tim_ielen == 5) { ++ ++ + memcpy(dst_ie, &tim_bitmap_le, 2); -+ dst_ie+=2; ++ dst_ie += 2; + } + + /* copy remainder IE */ -+ if (pbackup_remainder_ie) -+ { ++ if (pbackup_remainder_ie) { ++ + memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + kfree(pbackup_remainder_ie); @@ -385,7 +399,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar +u8 chk_sta_is_alive(struct sta_info *psta) +{ + #ifdef DBG_EXPIRATION_CHK -+ DBG_871X("sta:"MAC_FMT", rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, %s%ssq_len:%u\n" ++ DBG_871X( ++ "sta:"MAC_FMT", rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, %s%ssq_len:%u\n" + , MAC_ARG(psta->hwaddr) + , psta->rssi_stat.UndecoratedSmoothedPWDB + /* STA_RX_PKTS_ARG(psta) */ @@ -425,22 +440,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + , FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->auth_list_cnt); + } + #endif -+ while (phead != plist) -+ { ++ while (phead != plist) { ++ + psta = LIST_CONTAINOR(plist, struct sta_info, auth_list); + + plist = get_next(plist); + -+ if (psta->expire_to>0) -+ { ++ if (psta->expire_to > 0) { ++ + psta->expire_to--; -+ if (psta->expire_to == 0) -+ { ++ if (psta->expire_to == 0) { ++ + list_del_init(&psta->auth_list); + pstapriv->auth_list_cnt--; + -+ DBG_871X("auth expire %02X%02X%02X%02X%02X%02X\n", -+ psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5]); ++ DBG_871X( ++ "auth expire %02X%02X%02X%02X%02X%02X\n", ++ psta->hwaddr[0], ++ psta->hwaddr[1], ++ psta->hwaddr[2], ++ psta->hwaddr[3], ++ psta->hwaddr[4], ++ psta->hwaddr[5] ++ ); + + spin_unlock_bh(&pstapriv->auth_list_lock); + @@ -468,8 +490,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + , FUNC_NDEV_ARG(padapter->pnetdev), pstapriv->asoc_list_cnt); + } + #endif -+ while (phead != plist) -+ { ++ while (phead != plist) { ++ + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + plist = get_next(plist); +#ifdef CONFIG_AUTO_AP_MODE @@ -485,12 +507,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + psta->expire_to--; + } + -+ if (psta->expire_to == 0) -+ { ++ if (psta->expire_to == 0) { ++ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + -+ if (padapter->registrypriv.wifi_spec == 1) -+ { ++ if (padapter->registrypriv.wifi_spec == 1) { ++ + psta->expire_to = pstapriv->expire_to; + continue; + } @@ -515,26 +537,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + int stainfo_offset; + + stainfo_offset = rtw_stainfo_offset(pstapriv, psta); -+ if (stainfo_offset_valid(stainfo_offset)) { ++ if (stainfo_offset_valid(stainfo_offset)) + chk_alive_list[chk_alive_num++] = stainfo_offset; -+ } ++ + + continue; + } + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; -+ DBG_871X("asoc expire "MAC_FMT", state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state); ++ DBG_871X( ++ "asoc expire "MAC_FMT", state = 0x%x\n", ++ MAC_ARG(psta->hwaddr), ++ psta->state ++ ); + updated = ap_free_sta(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING); -+ } -+ else -+ { ++ } else{ ++ ++ + /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ + if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt) -+ && padapter->xmitpriv.free_xmitframe_cnt < ((NR_XMITFRAME/pstapriv->asoc_list_cnt)/2) ++ && padapter->xmitpriv.free_xmitframe_cnt < (( ++ NR_XMITFRAME/pstapriv->asoc_list_cnt ++ )/2) + ) { -+ DBG_871X("%s sta:"MAC_FMT", sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__ -+ , MAC_ARG(psta->hwaddr) -+ , psta->sleepq_len, padapter->xmitpriv.free_xmitframe_cnt, pstapriv->asoc_list_cnt); ++ DBG_871X( ++ "%s sta:"MAC_FMT", sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", ++ __func__, ++ MAC_ARG(psta->hwaddr), ++ psta->sleepq_len, ++ padapter->xmitpriv.free_xmitframe_cnt, ++ pstapriv->asoc_list_cnt ++ ); + wakeup_sta_to_xmit(padapter, psta); + } + } @@ -557,7 +590,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + int ret = _FAIL; + + psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]); -+ if (!(psta->state &_FW_LINKED)) ++ if (!(psta->state & _FW_LINKED)) + continue; + + if (psta->state & WIFI_SLEEP_STATE) @@ -566,24 +599,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + ret = issue_nulldata(padapter, psta->hwaddr, 0, 3, 50); + + psta->keep_alive_trycnt++; -+ if (ret == _SUCCESS) -+ { -+ DBG_871X("asoc check, sta(" MAC_FMT ") is alive\n", MAC_ARG(psta->hwaddr)); ++ if (ret == _SUCCESS) { ++ ++ DBG_871X( ++ "asoc check, sta(" MAC_FMT ") is alive\n", ++ MAC_ARG(psta->hwaddr) ++ ); + psta->expire_to = pstapriv->expire_to; + psta->keep_alive_trycnt = 0; + continue; -+ } -+ else if (psta->keep_alive_trycnt <= 3) -+ { -+ DBG_871X("ack check for asoc expire, keep_alive_trycnt =%d\n", psta->keep_alive_trycnt); ++ } else if (psta->keep_alive_trycnt <= 3) { ++ ++ ++ DBG_871X( ++ "ack check for asoc expire, keep_alive_trycnt =%d\n", ++ psta->keep_alive_trycnt ++ ); + psta->expire_to = 1; + continue; + } + + psta->keep_alive_trycnt = 0; -+ DBG_871X("asoc expire "MAC_FMT", state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state); ++ DBG_871X( ++ "asoc expire "MAC_FMT", state = 0x%x\n", ++ MAC_ARG(psta->hwaddr), ++ psta->state ++ ); + spin_lock_bh(&pstapriv->asoc_list_lock); -+ if (list_empty(&psta->asoc_list) ==false) { ++ if (list_empty(&psta->asoc_list) == false) { + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING); @@ -592,7 +635,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + } + -+ if (backup_oper_channel>0) /* back to the original operation channel */ ++ if (backup_oper_channel > 0) /* back to the original operation channel */ + SelectChannel(padapter, backup_oper_channel); +} + @@ -604,7 +647,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + unsigned char sta_band = 0, shortGIrate = false; + unsigned int tx_ra_bitmap = 0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); -+ struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; ++ struct wlan_bssid_ex ++ *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + + if (!psta) + return; @@ -620,7 +664,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + if (pcur_network->Configuration.DSConfig > 14) { + + if (tx_ra_bitmap & 0xffff000) -+ sta_band |= WIRELESS_11_5N ; ++ sta_band |= WIRELESS_11_5N; + + if (tx_ra_bitmap & 0xff0) + sta_band |= WIRELESS_11A; @@ -638,8 +682,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + psta->wireless_mode = sta_band; + psta->raid = rtw_hal_networktype_to_raid(padapter, psta); + -+ if (psta->aid < NUM_STA) -+ { ++ if (psta->aid < NUM_STA) { ++ + u8 arg[4] = {0}; + + arg[0] = psta->mac_id; @@ -648,12 +692,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + arg[3] = psta->init_rate; + + DBG_871X("%s => mac_id:%d , raid:%d , shortGIrate =%d, bitmap = 0x%x\n", -+ __func__ , psta->mac_id, psta->raid , shortGIrate, tx_ra_bitmap); ++ __func__, psta->mac_id, psta->raid, shortGIrate, tx_ra_bitmap); + + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, rssi_level); -+ } -+ else -+ { ++ } else{ ++ ++ + DBG_871X("station aid %d exceed the max number\n", psta->aid); + } + @@ -667,11 +711,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; ++ struct wlan_bssid_ex ++ *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct sta_info *psta = rtw_get_bcmc_stainfo(padapter); + -+ if (psta) -+ { ++ if (psta) { ++ + psta->aid = 0;/* default set to 0 */ + /* psta->mac_id = psta->aid+4; */ + psta->mac_id = psta->aid + 1;/* mac_id = 1 for bc/mc stainfo */ @@ -683,17 +728,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + psta->ieee8021x_blocked = 0; + -+ memset((void*)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); ++ memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + /* psta->dot118021XPrivacy = _NO_PRIVACY_;//!!! remove it, because it has been set before this. */ + + /* prepare for add_RATid */ + supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->SupportedRates); -+ network_type = rtw_check_network_type((u8 *)&pcur_network->SupportedRates, supportRateNum, pcur_network->Configuration.DSConfig); ++ network_type = rtw_check_network_type( ++ (u8 *)&pcur_network->SupportedRates, ++ supportRateNum, ++ pcur_network->Configuration.DSConfig ++ ); + if (IsSupportedTxCCK(network_type)) { + network_type = WIRELESS_11B; -+ } -+ else if (network_type == WIRELESS_INVALID) { /* error handling */ ++ } else if (network_type == WIRELESS_INVALID) { /* error handling */ ++ + if (pcur_network->Configuration.DSConfig > 14) + network_type = WIRELESS_11A; + else @@ -720,7 +769,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + arg[3] = psta->init_rate; + + DBG_871X("%s => mac_id:%d , raid:%d , bitmap = 0x%x\n", -+ __func__ , psta->mac_id, psta->raid , tx_ra_bitmap); ++ __func__, psta->mac_id, psta->raid, tx_ra_bitmap); + + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, 0); + } @@ -731,9 +780,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + psta->state = _FW_LINKED; + spin_unlock_bh(&psta->lock); + -+ } -+ else -+ { ++ } else{ ++ ++ + DBG_871X("add_RATid_bmc_sta error!\n"); + } + @@ -757,16 +806,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + /* set intf_tag to if1 */ + /* psta->intf_tag = 0; */ + -+ DBG_871X("%s\n", __func__); ++ DBG_871X("%s\n", __func__); + + /* psta->mac_id = psta->aid+4; */ + /* psta->mac_id = psta->aid+1;//alloc macid when call rtw_alloc_stainfo(), */ -+ /* release macid when call rtw_free_stainfo() */ ++ /* release macid when call rtw_free_stainfo() */ + + /* ap mode */ + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + -+ if (psecuritypriv->dot11AuthAlgrthm ==dot11AuthAlgrthm_8021X) ++ if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->ieee8021x_blocked = true; + else + psta->ieee8021x_blocked = false; @@ -778,40 +827,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + VCS_update(padapter, psta); + + /* HT related cap */ -+ if (phtpriv_sta->ht_option) -+ { ++ if (phtpriv_sta->ht_option) { ++ + /* check if sta supports rx ampdu */ + phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; + -+ phtpriv_sta->rx_ampdu_min_spacing = (phtpriv_sta->ht_cap.ampdu_params_info&IEEE80211_HT_CAP_AMPDU_DENSITY)>>2; ++ phtpriv_sta->rx_ampdu_min_spacing = ( ++ phtpriv_sta->ht_cap.ampdu_params_info&IEEE80211_HT_CAP_AMPDU_DENSITY ++ )>>2; + + /* bwmode */ -+ if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH)) -+ { ++ if (( ++ phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info ++ ) & cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH)) + psta->bw_mode = CHANNEL_WIDTH_40; -+ } + else -+ { + psta->bw_mode = CHANNEL_WIDTH_20; -+ } + + if (pmlmeext->cur_bwmode < psta->bw_mode) -+ { + psta->bw_mode = pmlmeext->cur_bwmode; -+ } + + phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; + + + /* check if sta support s Short GI 20M */ -+ if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SGI_20)) -+ { ++ if (( ++ phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info ++ ) & cpu_to_le16(IEEE80211_HT_CAP_SGI_20)) + phtpriv_sta->sgi_20m = true; -+ } + + /* check if sta support s Short GI 40M */ -+ if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SGI_40)) -+ { ++ if (( ++ phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info ++ ) & cpu_to_le16(IEEE80211_HT_CAP_SGI_40)) { ++ + if (psta->bw_mode == CHANNEL_WIDTH_40) /* according to psta->bw_mode */ + phtpriv_sta->sgi_40m = true; + else @@ -822,22 +871,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + /* B0 Config LDPC Coding Capability */ + if (TEST_FLAG(phtpriv_ap->ldpc_cap, LDPC_HT_ENABLE_TX) && -+ GET_HT_CAPABILITY_ELE_LDPC_CAP((u8 *)(&phtpriv_sta->ht_cap))) -+ { ++ GET_HT_CAPABILITY_ELE_LDPC_CAP((u8 *)(&phtpriv_sta->ht_cap))) { ++ + SET_FLAG(cur_ldpc_cap, (LDPC_HT_ENABLE_TX | LDPC_HT_CAP_TX)); + DBG_871X("Enable HT Tx LDPC for STA(%d)\n", psta->aid); + } + + /* B7 B8 B9 Config STBC setting */ + if (TEST_FLAG(phtpriv_ap->stbc_cap, STBC_HT_ENABLE_TX) && -+ GET_HT_CAPABILITY_ELE_RX_STBC((u8 *)(&phtpriv_sta->ht_cap))) -+ { ++ GET_HT_CAPABILITY_ELE_RX_STBC((u8 *)(&phtpriv_sta->ht_cap))) { ++ + SET_FLAG(cur_stbc_cap, (STBC_HT_ENABLE_TX | STBC_HT_CAP_TX)); + DBG_871X("Enable HT Tx STBC for STA(%d)\n", psta->aid); + } -+ } -+ else -+ { ++ } else{ ++ ++ + phtpriv_sta->ampdu_enable = false; + + phtpriv_sta->sgi_20m = false; @@ -862,7 +911,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + /* todo: init other variables */ + -+ memset((void*)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); ++ memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + + /* add ratid */ @@ -879,7 +928,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar +static void update_ap_info(struct adapter *padapter, struct sta_info *psta) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); -+ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; ++ struct wlan_bssid_ex ++ *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; + @@ -889,26 +939,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + memcpy(psta->bssrateset, pnetwork->SupportedRates, psta->bssratelen); + + /* HT related cap */ -+ if (phtpriv_ap->ht_option) -+ { ++ if (phtpriv_ap->ht_option) { ++ + /* check if sta supports rx ampdu */ + /* phtpriv_ap->ampdu_enable = phtpriv_ap->ampdu_enable; */ + + /* check if sta support s Short GI 20M */ + if ((phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SGI_20)) -+ { + phtpriv_ap->sgi_20m = true; -+ } ++ + /* check if sta support s Short GI 40M */ + if ((phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SGI_40)) -+ { + phtpriv_ap->sgi_40m = true; -+ } ++ + + psta->qos_option = true; -+ } -+ else -+ { ++ } else{ ++ ++ + phtpriv_ap->ampdu_enable = false; + + phtpriv_ap->sgi_20m = false; @@ -926,8 +974,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + +static void update_hw_ht_param(struct adapter *padapter) +{ -+ unsigned char max_AMPDU_len; -+ unsigned char min_MPDU_spacing; ++ unsigned char max_AMPDU_len; ++ unsigned char min_MPDU_spacing; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + @@ -941,16 +989,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + */ + max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03; + -+ min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; ++ min_MPDU_spacing = ( ++ pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c ++ ) >> 2; + -+ rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); ++ rtw_hal_set_hwreg( ++ padapter, ++ HW_VAR_AMPDU_MIN_SPACE, ++ (u8 *)(&min_MPDU_spacing) ++ ); + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + + /* */ + /* Config SM Power Save setting */ + /* */ -+ pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & 0x0C) >> 2; ++ pmlmeinfo->SM_PS = (le16_to_cpu( ++ pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info ++ ) & 0x0C) >> 2; + if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) + DBG_871X("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); + @@ -970,8 +1026,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + int ie_len; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); -+ struct security_priv* psecuritypriv =&(padapter->securitypriv); -+ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; ++ struct security_priv *psecuritypriv = &(padapter->securitypriv); ++ struct wlan_bssid_ex ++ *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network); @@ -989,18 +1046,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + /* check if there is wps ie, */ + /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */ + /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */ -+ if (NULL == rtw_get_wps_ie(pnetwork->IEs+_FIXED_IE_LENGTH_, pnetwork->IELength-_FIXED_IE_LENGTH_, NULL, NULL)) -+ { ++ if (NULL == rtw_get_wps_ie( ++ pnetwork->IEs+_FIXED_IE_LENGTH_, ++ pnetwork->IELength-_FIXED_IE_LENGTH_, ++ NULL, ++ NULL ++ )) + pmlmeext->bstart_bss = true; -+ } ++ + + /* todo: update wmm, ht cap */ + /* pmlmeinfo->WMM_enable; */ + /* pmlmeinfo->HT_enable; */ + if (pmlmepriv->qospriv.qos_option) + pmlmeinfo->WMM_enable = true; -+ if (pmlmepriv->htpriv.ht_option) -+ { ++ if (pmlmepriv->htpriv.ht_option) { ++ + pmlmeinfo->WMM_enable = true; + pmlmeinfo->HT_enable = true; + /* pmlmeinfo->HT_info_enable = true; */ @@ -1009,10 +1070,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + update_hw_ht_param(padapter); + } + -+ if (pmlmepriv->cur_network.join_res != true) /* setting only at first time */ -+ { ++ if (pmlmepriv->cur_network.join_res != true) { /* setting only at first time */ ++ + /* WEP Key will be set before this function, do not clear CAM. */ -+ if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)) ++ if ( ++ (psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && ++ (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_) ++ ) + flush_all_cam_entry(padapter); /* clear CAM */ + } + @@ -1034,7 +1098,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); + + /* Set Security */ -+ val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf; ++ val8 = ( ++ psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X ++ ) ? 0xcc : 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* Beacon Control related register */ @@ -1042,8 +1108,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + rtw_hal_set_hwreg(padapter, HW_VAR_DO_IQK, NULL); + -+ if (pmlmepriv->cur_network.join_res != true) /* setting only at first time */ -+ { ++ if (pmlmepriv->cur_network.join_res != true) { /* setting only at first time */ ++ + /* u32 initialgain; */ + + /* initialgain = 0x1e; */ @@ -1061,9 +1127,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + + /* set channel, bwmode */ -+ p = rtw_get_ie((pnetwork->IEs + sizeof(struct ndis_802_11_fix_ie)), _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie))); -+ if (p && ie_len) -+ { ++ p = rtw_get_ie( ++ (pnetwork->IEs + sizeof(struct ndis_802_11_fix_ie)), ++ _HT_ADD_INFO_IE_, ++ &ie_len, ++ (pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie)) ++ ); ++ if (p && ie_len) { ++ + pht_info = (struct HT_info_element *)(p+2); + + if (cur_channel > 14) { @@ -1074,27 +1145,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + cbw40_enable = 1; + } + -+ if ((cbw40_enable) && (pht_info->infos[0] & BIT(2))) -+ { ++ if ((cbw40_enable) && (pht_info->infos[0] & BIT(2))) { ++ + /* switch to the 40M Hz mode */ + /* pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; */ + cur_bwmode = CHANNEL_WIDTH_40; -+ switch (pht_info->infos[0] & 0x3) -+ { -+ case 1: -+ /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; */ -+ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; -+ break; ++ switch (pht_info->infos[0] & 0x3) { + -+ case 3: -+ /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; */ -+ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; -+ break; ++ case 1: ++ /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; */ ++ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; ++ break; + -+ default: -+ /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; */ -+ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; -+ break; ++ case 3: ++ /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; */ ++ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; ++ break; ++ ++ default: ++ /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; */ ++ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; ++ break; + } + + } @@ -1102,7 +1173,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); -+ DBG_871X("CH =%d, BW =%d, offset =%d\n", cur_channel, cur_bwmode, cur_ch_offset); ++ DBG_871X( ++ "CH =%d, BW =%d, offset =%d\n", ++ cur_channel, ++ cur_bwmode, ++ cur_ch_offset ++ ); + pmlmeext->cur_channel = cur_channel; + pmlmeext->cur_bwmode = cur_bwmode; + pmlmeext->cur_ch_offset = cur_ch_offset; @@ -1119,19 +1195,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); + + /* udpate capability after cur_wireless_mode updated */ -+ update_capinfo(padapter, rtw_get_capability((struct wlan_bssid_ex *)pnetwork)); ++ update_capinfo( ++ padapter, ++ rtw_get_capability((struct wlan_bssid_ex *)pnetwork) ++ ); + + -+ if (true == pmlmeext->bstart_bss) -+ { ++ if (true == pmlmeext->bstart_bss) { ++ + update_beacon(padapter, _TIM_IE_, NULL, true); + +#ifndef CONFIG_INTERRUPT_BASED_TXBCN /* other case will tx beacon when bcn interrupt coming in. */ + /* issue beacon frame */ + if (send_beacon(padapter) == _FAIL) -+ { + DBG_871X("issue_beacon, fail!\n"); -+ } ++ +#endif /* CONFIG_INTERRUPT_BASED_TXBCN */ + + } @@ -1151,7 +1229,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + u8 *pHT_caps_ie = NULL; + u8 *pHT_info_ie = NULL; + struct sta_info *psta = NULL; -+ u16 cap, ht_cap =false; ++ u16 cap, ht_cap = false; + uint ie_len = 0; + int group_cipher, pairwise_cipher; + u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX]; @@ -1161,7 +1239,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); -+ struct wlan_bssid_ex *pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; ++ struct wlan_bssid_ex ++ *pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + u8 *ie = pbss_network->IEs; + + /* SSID */ @@ -1181,7 +1260,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + return _FAIL; + + -+ if (len>MAX_IE_SZ) ++ if (len > MAX_IE_SZ) + return _FAIL; + + pbss_network->IELength = len; @@ -1191,7 +1270,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + memcpy(ie, pbuf, pbss_network->IELength); + + -+ if (pbss_network->InfrastructureMode!=Ndis802_11APMode) ++ if (pbss_network->InfrastructureMode != Ndis802_11APMode) + return _FAIL; + + pbss_network->Rssi = 0; @@ -1209,9 +1288,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + cap = RTW_GET_LE16(ie); + + /* SSID */ -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->IELength -_BEACON_IE_OFFSET_)); -+ if (p && ie_len>0) -+ { ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _SSID_IE_, ++ &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_) ++ ); ++ if (p && ie_len > 0) { ++ + memset(&pbss_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len); + pbss_network->Ssid.SsidLength = ie_len; @@ -1220,8 +1304,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + /* chnnel */ + channel = 0; + pbss_network->Configuration.Length = 0; -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); -+ if (p && ie_len>0) ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _DSSET_IE_, &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_) ++ ); ++ if (p && ie_len > 0) + channel = *(p + 2); + + pbss_network->Configuration.DSConfig = channel; @@ -1229,17 +1317,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); + /* get supported rates */ -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); -+ if (p != NULL) -+ { ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _SUPPORTEDRATES_IE_, ++ &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_) ++ ); ++ if (p != NULL) { ++ + memcpy(supportRate, p+2, ie_len); + supportRateNum = ie_len; + } + + /* get ext_supported rates */ -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); -+ if (p != NULL) -+ { ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _EXT_SUPPORTEDRATES_IE_, ++ &ie_len, ++ pbss_network->IELength - _BEACON_IE_OFFSET_ ++ ); ++ if (p != NULL) { ++ + memcpy(supportRate+supportRateNum, p+2, ie_len); + supportRateNum += ie_len; + @@ -1251,11 +1349,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + + /* parsing ERP_IE */ -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); -+ if (p && ie_len>0) -+ { ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _ERPINFO_IE_, ++ &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_) ++ ); ++ if (p && ie_len > 0) + ERP_IE_handler(padapter, (struct ndis_80211_var_ie *)p); -+ } + + /* update privacy/security */ + if (cap & BIT(4)) @@ -1269,11 +1370,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + group_cipher = 0; pairwise_cipher = 0; + psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; + psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); -+ if (p && ie_len>0) -+ { -+ if (rtw_parse_wpa2_ie(p, ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) -+ { ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _RSN_IE_2_, ++ &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_) ++ ); ++ if (p && ie_len > 0) { ++ ++ if (rtw_parse_wpa2_ie( ++ p, ++ ie_len+2, ++ &group_cipher, ++ &pairwise_cipher, ++ NULL ++ ) == _SUCCESS) { ++ + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + + psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ @@ -1290,13 +1402,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + group_cipher = 0; pairwise_cipher = 0; + psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; + psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; -+ for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) -+ { -+ p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); -+ if ((p) && (!memcmp(p+2, OUI1, 4))) -+ { -+ if (rtw_parse_wpa_ie(p, ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) -+ { ++ for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) { ++ ++ p = rtw_get_ie( ++ p, ++ _SSN_IE_1_, ++ &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)) ++ ); ++ if ((p) && (!memcmp(p+2, OUI1, 4))) { ++ ++ if (rtw_parse_wpa_ie( ++ p, ++ ie_len+2, ++ &group_cipher, ++ &pairwise_cipher, ++ NULL ++ ) == _SUCCESS) { ++ + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + + psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ @@ -1312,22 +1435,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + + if ((p == NULL) || (ie_len == 0)) -+ { + break; -+ } ++ + + } + + /* wmm */ + ie_len = 0; + pmlmepriv->qospriv.qos_option = 0; -+ if (pregistrypriv->wmm_enable) -+ { -+ for (p = ie + _BEACON_IE_OFFSET_; ;p += (ie_len + 2)) -+ { -+ p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); -+ if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) -+ { ++ if (pregistrypriv->wmm_enable) { ++ ++ for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) { ++ ++ p = rtw_get_ie( ++ p, ++ _VENDOR_SPECIFIC_IE_, ++ &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)) ++ ); ++ if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { ++ + pmlmepriv->qospriv.qos_option = 1; + + *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ @@ -1342,21 +1469,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + + if ((p == NULL) || (ie_len == 0)) -+ { + break; -+ } ++ + } + } + + /* parsing HT_CAP_IE */ -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); -+ if (p && ie_len>0) -+ { ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _HT_CAPABILITY_IE_, ++ &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_) ++ ); ++ if (p && ie_len > 0) { ++ + u8 rf_type = 0; + u8 max_rx_ampdu_factor = 0; + struct rtw_ieee80211_ht_cap *pht_cap = (struct rtw_ieee80211_ht_cap *)(p+2); + -+ pHT_caps_ie =p; ++ pHT_caps_ie = p; + + ht_cap = true; + network_type |= WIRELESS_11_24N; @@ -1370,38 +1501,43 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + pht_cap->cap_info &= cpu_to_le16(~(IEEE80211_HT_CAP_SGI_40)); + + if (!TEST_FLAG(pmlmepriv->htpriv.ldpc_cap, LDPC_HT_ENABLE_RX)) -+ { + pht_cap->cap_info &= cpu_to_le16(~(IEEE80211_HT_CAP_LDPC_CODING)); -+ } ++ + + if (!TEST_FLAG(pmlmepriv->htpriv.stbc_cap, STBC_HT_ENABLE_TX)) -+ { + pht_cap->cap_info &= cpu_to_le16(~(IEEE80211_HT_CAP_TX_STBC)); -+ } ++ + + if (!TEST_FLAG(pmlmepriv->htpriv.stbc_cap, STBC_HT_ENABLE_RX)) -+ { + pht_cap->cap_info &= cpu_to_le16(~(IEEE80211_HT_CAP_RX_STBC_3R)); -+ } + -+ pht_cap->ampdu_params_info &= ~(IEEE80211_HT_CAP_AMPDU_FACTOR|IEEE80211_HT_CAP_AMPDU_DENSITY); ++ ++ pht_cap->ampdu_params_info &= ~( ++ IEEE80211_HT_CAP_AMPDU_FACTOR|IEEE80211_HT_CAP_AMPDU_DENSITY ++ ); + + if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || -+ (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) -+ { ++ (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) { ++ + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); -+ } -+ else -+ { ++ } else{ ++ ++ + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + } + -+ rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); -+ pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & max_rx_ampdu_factor); /* set Max Rx AMPDU size to 64K */ ++ rtw_hal_get_def_var( ++ padapter, ++ HW_VAR_MAX_RX_AMPDU_FACTOR, ++ &max_rx_ampdu_factor ++ ); ++ pht_cap->ampdu_params_info |= ( ++ IEEE80211_HT_CAP_AMPDU_FACTOR & max_rx_ampdu_factor ++ ); /* set Max Rx AMPDU size to 64K */ + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); -+ if (rf_type == RF_1T1R) -+ { ++ if (rf_type == RF_1T1R) { ++ + pht_cap->supp_mcs_set[0] = 0xff; + pht_cap->supp_mcs_set[1] = 0x0; + } @@ -1411,29 +1547,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + + /* parsing HT_INFO_IE */ -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); -+ if (p && ie_len>0) -+ { -+ pHT_info_ie =p; -+ } ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _HT_ADD_INFO_IE_, ++ &ie_len, ++ (pbss_network->IELength - _BEACON_IE_OFFSET_) ++ ); ++ if (p && ie_len > 0) ++ pHT_info_ie = p; + -+ switch (network_type) -+ { -+ case WIRELESS_11B: -+ pbss_network->NetworkTypeInUse = Ndis802_11DS; -+ break; -+ case WIRELESS_11G: -+ case WIRELESS_11BG: -+ case WIRELESS_11G_24N: -+ case WIRELESS_11BG_24N: -+ pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; -+ break; -+ case WIRELESS_11A: -+ pbss_network->NetworkTypeInUse = Ndis802_11OFDM5; -+ break; -+ default : -+ pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; -+ break; ++ ++ switch (network_type) { ++ ++ case WIRELESS_11B: ++ pbss_network->NetworkTypeInUse = Ndis802_11DS; ++ break; ++ case WIRELESS_11G: ++ case WIRELESS_11BG: ++ case WIRELESS_11G_24N: ++ case WIRELESS_11BG_24N: ++ pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; ++ break; ++ case WIRELESS_11A: ++ pbss_network->NetworkTypeInUse = Ndis802_11OFDM5; ++ break; ++ default: ++ pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; ++ break; + } + + pmlmepriv->cur_network.network_type = network_type; @@ -1441,29 +1581,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + pmlmepriv->htpriv.ht_option = false; + + if ((psecuritypriv->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || -+ (psecuritypriv->wpa_pairwise_cipher&WPA_CIPHER_TKIP)) -+ { ++ (psecuritypriv->wpa_pairwise_cipher&WPA_CIPHER_TKIP)) { ++ + /* todo: */ + /* ht_cap = false; */ + } + + /* ht_cap */ -+ if (pregistrypriv->ht_enable && ht_cap ==true) -+ { ++ if (pregistrypriv->ht_enable && ht_cap == true) { ++ + pmlmepriv->htpriv.ht_option = true; + pmlmepriv->qospriv.qos_option = 1; + + if (pregistrypriv->ampdu_enable == 1) -+ { + pmlmepriv->htpriv.ampdu_enable = true; -+ } ++ + + HT_caps_handler(padapter, (struct ndis_80211_var_ie *)pHT_caps_ie); + + HT_info_handler(padapter, (struct ndis_80211_var_ie *)pHT_info_ie); + } + -+ pbss_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pbss_network); ++ pbss_network->Length = get_wlan_bssid_ex_sz( ++ (struct wlan_bssid_ex *)pbss_network ++ ); + + /* issue beacon to start bss network */ + /* start_bss_network(padapter, (u8 *)pbss_network); */ @@ -1472,13 +1613,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + /* alloc sta_info for ap itself */ + psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); -+ if (!psta) -+ { ++ if (!psta) { ++ + psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); + if (psta == NULL) -+ { + return _FAIL; -+ } ++ + } + + /* update AP's sta info */ @@ -1514,9 +1654,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + struct rtw_wlan_acl_node *paclnode; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; -+ struct __queue *pacl_node_q =&pacl_list->acl_node_q; ++ struct __queue *pacl_node_q = &pacl_list->acl_node_q; + -+ DBG_871X("%s(acl_num =%d) =" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr)); ++ DBG_871X( ++ "%s(acl_num =%d) =" MAC_FMT "\n", ++ __func__, ++ pacl_list->num, ++ MAC_ARG(addr) ++ ); + + if ((NUM_ACL-1) < pacl_list->num) + return (-1); @@ -1527,15 +1672,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + -+ while (phead != plist) -+ { ++ while (phead != plist) { ++ + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + -+ if (!memcmp(paclnode->addr, addr, ETH_ALEN)) -+ { -+ if (paclnode->valid == true) -+ { ++ if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { ++ ++ if (paclnode->valid == true) { ++ + added = true; + DBG_871X("%s, sta has been added\n", __func__); + break; @@ -1552,12 +1697,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + spin_lock_bh(&(pacl_node_q->lock)); + -+ for (i = 0; i< NUM_ACL; i++) -+ { ++ for (i = 0; i < NUM_ACL; i++) { ++ + paclnode = &pacl_list->aclnode[i]; + -+ if (paclnode->valid == false) -+ { ++ if (paclnode->valid == false) { ++ + INIT_LIST_HEAD(&paclnode->list); + + memcpy(paclnode->addr, addr, ETH_ALEN); @@ -1586,25 +1731,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + struct rtw_wlan_acl_node *paclnode; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; -+ struct __queue *pacl_node_q =&pacl_list->acl_node_q; ++ struct __queue *pacl_node_q = &pacl_list->acl_node_q; + u8 baddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* Baddr is used for clearing acl_list */ + -+ DBG_871X("%s(acl_num =%d) =" MAC_FMT "\n", __func__, pacl_list->num, MAC_ARG(addr)); ++ DBG_871X( ++ "%s(acl_num =%d) =" MAC_FMT "\n", ++ __func__, ++ pacl_list->num, ++ MAC_ARG(addr) ++ ); + + spin_lock_bh(&(pacl_node_q->lock)); + + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + -+ while (phead != plist) -+ { ++ while (phead != plist) { ++ + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + -+ if (!memcmp(paclnode->addr, addr, ETH_ALEN) || !memcmp(baddr, addr, ETH_ALEN)) -+ { -+ if (paclnode->valid == true) -+ { ++ if ( ++ !memcmp(paclnode->addr, addr, ETH_ALEN) || ++ !memcmp(baddr, addr, ETH_ALEN) ++ ) { ++ ++ if (paclnode->valid == true) { ++ + paclnode->valid = false; + + list_del_init(&paclnode->list); @@ -1624,18 +1777,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + +u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta) +{ -+ struct cmd_obj* ph2c; ++ struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ psetstakey_para = (struct set_stakey_parm*)rtw_zmalloc(sizeof(struct set_stakey_parm)); ++ psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc( ++ sizeof(struct set_stakey_parm) ++ ); + if (psetstakey_para == NULL) { + kfree((u8 *) ph2c); + res = _FAIL; @@ -1660,22 +1815,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + +} + -+static int rtw_ap_set_key(struct adapter *padapter, u8 *key, u8 alg, int keyid, u8 set_tx) ++static int rtw_ap_set_key( ++ struct adapter *padapter, ++ u8 *key, ++ u8 alg, ++ int keyid, ++ u8 set_tx ++) +{ + u8 keylen; -+ struct cmd_obj* pcmd; ++ struct cmd_obj *pcmd; + struct setkey_parm *psetkeyparm; -+ struct cmd_priv *pcmdpriv =&(padapter->cmdpriv); ++ struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + int res = _SUCCESS; + + /* DBG_871X("%s\n", __func__); */ + -+ pcmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + goto exit; + } -+ psetkeyparm =(struct setkey_parm*)rtw_zmalloc(sizeof(struct setkey_parm)); ++ psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + if (psetkeyparm == NULL) { + kfree((unsigned char *)pcmd); + res = _FAIL; @@ -1684,7 +1845,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + memset(psetkeyparm, 0, sizeof(struct setkey_parm)); + -+ psetkeyparm->keyid =(u8)keyid; ++ psetkeyparm->keyid = (u8)keyid; + if (is_wep_enc(alg)) + padapter->securitypriv.key_mask |= BIT(psetkeyparm->keyid); + @@ -1692,19 +1853,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + psetkeyparm->set_tx = set_tx; + -+ switch (alg) -+ { -+ case _WEP40_: -+ keylen = 5; -+ break; -+ case _WEP104_: -+ keylen = 13; -+ break; -+ case _TKIP_: -+ case _TKIP_WTMIC_: -+ case _AES_: -+ default: -+ keylen = 16; ++ switch (alg) { ++ ++ case _WEP40_: ++ keylen = 5; ++ break; ++ case _WEP104_: ++ keylen = 13; ++ break; ++ case _TKIP_: ++ case _TKIP_WTMIC_: ++ case _AES_: ++ default: ++ keylen = 16; + } + + memcpy(&(psetkeyparm->key[0]), key, keylen); @@ -1732,20 +1893,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + return rtw_ap_set_key(padapter, key, alg, keyid, 1); +} + -+int rtw_ap_set_wep_key(struct adapter *padapter, u8 *key, u8 keylen, int keyid, u8 set_tx) ++int rtw_ap_set_wep_key( ++ struct adapter *padapter, ++ u8 *key, ++ u8 keylen, ++ int keyid, ++ u8 set_tx ++) +{ + u8 alg; + -+ switch (keylen) -+ { -+ case 5: -+ alg = _WEP40_; -+ break; -+ case 13: -+ alg = _WEP104_; -+ break; -+ default: -+ alg = _NO_PRIVACY_; ++ switch (keylen) { ++ ++ case 5: ++ alg = _WEP40_; ++ break; ++ case 13: ++ alg = _WEP104_; ++ break; ++ default: ++ alg = _NO_PRIVACY_; + } + + DBG_871X("%s\n", __func__); @@ -1774,15 +1941,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + return; + + /* parsing ERP_IE */ -+ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); -+ if (p && len>0) -+ { -+ struct ndis_80211_var_ie * pIE = (struct ndis_80211_var_ie *)p; ++ p = rtw_get_ie( ++ ie + _BEACON_IE_OFFSET_, ++ _ERPINFO_IE_, ++ &len, ++ (pnetwork->IELength - _BEACON_IE_OFFSET_) ++ ); ++ if (p && len > 0) { ++ ++ struct ndis_80211_var_ie *pIE = (struct ndis_80211_var_ie *)p; + + if (pmlmepriv->num_sta_non_erp == 1) + pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION; + else -+ pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION); ++ pIE->data[0] &= ~( ++ RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION ++ ); + + if (pmlmepriv->num_sta_no_short_preamble > 0) + pIE->data[0] |= RTW_ERP_INFO_BARKER_PREAMBLE_MODE; @@ -1826,7 +2000,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + +static void update_bcn_wps_ie(struct adapter *padapter) +{ -+ u8 *pwps_ie = NULL, *pwps_ie_src, *premainder_ie, *pbackup_remainder_ie = NULL; ++ u8 *pwps_ie = NULL; ++ u8 *pwps_ie_src; ++ u8 *premainder_ie; ++ u8 *pbackup_remainder_ie = NULL; ++ + uint wps_ielen = 0, wps_offset, remainder_ielen; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); @@ -1838,7 +2016,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + DBG_871X("%s\n", __func__); + -+ pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); ++ pwps_ie = rtw_get_wps_ie( ++ ie+_FIXED_IE_LENGTH_, ++ ielen-_FIXED_IE_LENGTH_, ++ NULL, ++ &wps_ielen ++ ); + + if (pwps_ie == NULL || wps_ielen == 0) + return; @@ -1853,16 +2036,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + remainder_ielen = ielen - wps_offset - wps_ielen; + -+ if (remainder_ielen>0) -+ { ++ if (remainder_ielen > 0) { ++ + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ -+ if ((wps_offset+wps_ielen+2+remainder_ielen)<=MAX_IE_SZ) -+ { ++ if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { ++ + memcpy(pwps_ie, pwps_ie_src, wps_ielen+2); + pwps_ie += (wps_ielen+2); + @@ -1878,10 +2061,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + /* deal with the case without set_tx_beacon_cmd() in update_beacon() */ +#if defined(CONFIG_INTERRUPT_BASED_TXBCN) -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { ++ + u8 sr = 0; -+ rtw_get_wps_attr_content(pwps_ie_src, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); ++ ++ rtw_get_wps_attr_content( ++ pwps_ie_src, ++ wps_ielen, ++ WPS_ATTR_SELECTED_REGISTRAR, ++ (u8 *)(&sr), ++ NULL ++ ); + + if (sr) { + set_fwstate(pmlmepriv, WIFI_UNDER_WPS); @@ -1896,30 +2086,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + +} + -+static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8*oui) ++static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) +{ + DBG_871X("%s\n", __func__); + + if (!memcmp(RTW_WPA_OUI, oui, 4)) -+ { + update_bcn_wpa_ie(padapter); -+ } ++ + else if (!memcmp(WMM_OUI, oui, 4)) -+ { + update_bcn_wmm_ie(padapter); -+ } ++ + else if (!memcmp(WPS_OUI, oui, 4)) -+ { + update_bcn_wps_ie(padapter); -+ } ++ + else if (!memcmp(P2P_OUI, oui, 4)) -+ { + update_bcn_p2p_ie(padapter); -+ } ++ + else -+ { + DBG_871X("unknown OUI type!\n"); -+ } ++ + + +} @@ -1944,52 +2129,52 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + spin_lock_bh(&pmlmepriv->bcn_update_lock); + -+ switch (ie_id) -+ { -+ case 0xFF: ++ switch (ie_id) { + -+ update_bcn_fixed_ie(padapter);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ ++ case 0xFF: + -+ break; ++ update_bcn_fixed_ie(padapter);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ + -+ case _TIM_IE_: ++ break; + -+ update_BCNTIM(padapter); ++ case _TIM_IE_: + -+ break; ++ update_BCNTIM(padapter); + -+ case _ERPINFO_IE_: ++ break; + -+ update_bcn_erpinfo_ie(padapter); ++ case _ERPINFO_IE_: + -+ break; ++ update_bcn_erpinfo_ie(padapter); + -+ case _HT_CAPABILITY_IE_: ++ break; + -+ update_bcn_htcap_ie(padapter); ++ case _HT_CAPABILITY_IE_: + -+ break; ++ update_bcn_htcap_ie(padapter); + -+ case _RSN_IE_2_: ++ break; + -+ update_bcn_rsn_ie(padapter); ++ case _RSN_IE_2_: + -+ break; ++ update_bcn_rsn_ie(padapter); + -+ case _HT_ADD_INFO_IE_: ++ break; + -+ update_bcn_htinfo_ie(padapter); ++ case _HT_ADD_INFO_IE_: + -+ break; ++ update_bcn_htinfo_ie(padapter); + -+ case _VENDOR_SPECIFIC_IE_: ++ break; + -+ update_bcn_vendor_spec_ie(padapter, oui); ++ case _VENDOR_SPECIFIC_IE_: + -+ break; ++ update_bcn_vendor_spec_ie(padapter, oui); + -+ default: -+ break; ++ break; ++ ++ default: ++ break; + } + + pmlmepriv->update_bcn = true; @@ -1997,8 +2182,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + spin_unlock_bh(&pmlmepriv->bcn_update_lock); + +#ifndef CONFIG_INTERRUPT_BASED_TXBCN -+ if (tx) -+ { ++ if (tx) { ++ + /* send_beacon(padapter);//send_beacon must execute on TSR level */ + set_tx_beacon_cmd(padapter); + } @@ -2029,7 +2214,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + return 0; + + /* if (!iface->conf->ieee80211n || iface->conf->ht_op_mode_fixed) */ -+ /* return 0; */ ++ /* return 0; */ + + DBG_871X("%s current operation mode = 0x%X\n", + __func__, pmlmepriv->ht_op_mode); @@ -2067,8 +2252,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + if (pmlmepriv->num_sta_no_ht || + (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) + new_op_mode = OP_MODE_MIXED; -+ else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) -+ && pmlmepriv->num_sta_ht_20mhz) ++ else if ( ++ (le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) ++ && pmlmepriv->num_sta_ht_20mhz) + new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; + else if (pmlmepriv->olbc_ht) + new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; @@ -2092,8 +2278,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar +void associated_clients_update(struct adapter *padapter, u8 updated) +{ + /* update associcated stations cap. */ -+ if (updated == true) -+ { ++ if (updated == true) { ++ + struct list_head *phead, *plist; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; @@ -2104,8 +2290,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + plist = get_next(phead); + + /* check asoc_queue */ -+ while (phead != plist) -+ { ++ while (phead != plist) { ++ + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + + plist = get_next(plist); @@ -2126,34 +2312,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + -+ if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) -+ { -+ if (!psta->no_short_preamble_set) -+ { ++ if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) { ++ ++ if (!psta->no_short_preamble_set) { ++ + psta->no_short_preamble_set = 1; + + pmlmepriv->num_sta_no_short_preamble++; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && -+ (pmlmepriv->num_sta_no_short_preamble == 1)) -+ { ++ (pmlmepriv->num_sta_no_short_preamble == 1)) { ++ + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + + } -+ } -+ else -+ { -+ if (psta->no_short_preamble_set) -+ { ++ } else{ ++ ++ ++ if (psta->no_short_preamble_set) { ++ + psta->no_short_preamble_set = 0; + + pmlmepriv->num_sta_no_short_preamble--; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && -+ (pmlmepriv->num_sta_no_short_preamble == 0)) -+ { ++ (pmlmepriv->num_sta_no_short_preamble == 0)) { ++ + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } @@ -2161,32 +2347,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + } + -+ if (psta->flags & WLAN_STA_NONERP) -+ { -+ if (!psta->nonerp_set) -+ { ++ if (psta->flags & WLAN_STA_NONERP) { ++ ++ if (!psta->nonerp_set) { ++ + psta->nonerp_set = 1; + + pmlmepriv->num_sta_non_erp++; + -+ if (pmlmepriv->num_sta_non_erp == 1) -+ { ++ if (pmlmepriv->num_sta_non_erp == 1) { ++ + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } + } + -+ } -+ else -+ { -+ if (psta->nonerp_set) -+ { ++ } else{ ++ ++ ++ if (psta->nonerp_set) { ++ + psta->nonerp_set = 0; + + pmlmepriv->num_sta_non_erp--; + -+ if (pmlmepriv->num_sta_non_erp == 0) -+ { ++ if (pmlmepriv->num_sta_non_erp == 0) { ++ + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } @@ -2195,42 +2381,42 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + + -+ if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) -+ { -+ if (!psta->no_short_slot_time_set) -+ { ++ if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) { ++ ++ if (!psta->no_short_slot_time_set) { ++ + psta->no_short_slot_time_set = 1; + + pmlmepriv->num_sta_no_short_slot_time++; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && -+ (pmlmepriv->num_sta_no_short_slot_time == 1)) -+ { ++ (pmlmepriv->num_sta_no_short_slot_time == 1)) { ++ + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + + } -+ } -+ else -+ { -+ if (psta->no_short_slot_time_set) -+ { ++ } else{ ++ ++ ++ if (psta->no_short_slot_time_set) { ++ + psta->no_short_slot_time_set = 0; + + pmlmepriv->num_sta_no_short_slot_time--; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && -+ (pmlmepriv->num_sta_no_short_slot_time == 0)) -+ { ++ (pmlmepriv->num_sta_no_short_slot_time == 0)) { ++ + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } + -+ if (psta->flags & WLAN_STA_HT) -+ { ++ if (psta->flags & WLAN_STA_HT) { ++ + u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info); + + DBG_871X("HT: STA " MAC_FMT " HT Capabilities " @@ -2263,9 +2449,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + pmlmepriv->num_sta_ht_20mhz); + } + -+ } -+ else -+ { ++ } else{ ++ ++ + if (!psta->no_ht_set) { + psta->no_ht_set = 1; + pmlmepriv->num_sta_no_ht++; @@ -2278,8 +2464,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + } + } + -+ if (rtw_ht_operation_update(padapter) > 0) -+ { ++ if (rtw_ht_operation_update(padapter) > 0) { ++ + update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); + update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + } @@ -2304,8 +2490,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + psta->no_short_preamble_set = 0; + pmlmepriv->num_sta_no_short_preamble--; + if (pmlmeext->cur_wireless_mode > WIRELESS_11B -+ && pmlmepriv->num_sta_no_short_preamble == 0) -+ { ++ && pmlmepriv->num_sta_no_short_preamble == 0){ ++ + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } @@ -2314,8 +2500,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + if (psta->nonerp_set) { + psta->nonerp_set = 0; + pmlmepriv->num_sta_non_erp--; -+ if (pmlmepriv->num_sta_non_erp == 0) -+ { ++ if (pmlmepriv->num_sta_non_erp == 0) { ++ + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } @@ -2325,8 +2511,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + psta->no_short_slot_time_set = 0; + pmlmepriv->num_sta_no_short_slot_time--; + if (pmlmeext->cur_wireless_mode > WIRELESS_11B -+ && pmlmepriv->num_sta_no_short_slot_time == 0) -+ { ++ && pmlmepriv->num_sta_no_short_slot_time == 0){ ++ + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } @@ -2347,8 +2533,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + pmlmepriv->num_sta_ht_20mhz--; + } + -+ if (rtw_ht_operation_update(padapter) > 0) -+ { ++ if (rtw_ht_operation_update(padapter) > 0) { ++ + update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); + update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + } @@ -2362,15 +2548,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + +} + -+u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, bool active, u16 reason) ++u8 ap_free_sta( ++ struct adapter *padapter, ++ struct sta_info *psta, ++ bool active, ++ u16 reason ++) +{ + u8 beacon_updated = false; + + if (!psta) + return beacon_updated; + -+ if (active == true) -+ { ++ if (active == true) { ++ + /* tear down Rx AMPDU */ + send_delba(padapter, 0, psta->hwaddr);/* recipient */ + @@ -2428,8 +2619,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + plist = get_next(phead); + + /* free sta asoc_queue */ -+ while (phead != plist) -+ { ++ while (phead != plist) { ++ + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + + plist = get_next(plist); @@ -2469,13 +2660,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + psta->qos_option = 0; + + /* update 802.11n ht cap. */ -+ if (WLAN_STA_HT&flags) -+ { ++ if (WLAN_STA_HT&flags) { ++ + psta->htpriv.ht_option = true; + psta->qos_option = 1; -+ } -+ else -+ { ++ } else{ ++ ++ + psta->htpriv.ht_option = false; + } + @@ -2493,8 +2684,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ if (psta->state & _FW_LINKED) -+ { ++ if (psta->state & _FW_LINKED) { ++ + pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; + + /* add ratid */ @@ -2506,9 +2697,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar +{ + struct mlme_priv *mlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -+ struct sta_priv * pstapriv = &padapter->stapriv; ++ struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *psta; -+ struct security_priv* psecuritypriv =&(padapter->securitypriv); ++ struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct list_head *phead, *plist; + u8 chk_alive_num = 0; + char chk_alive_list[NUM_STA]; @@ -2516,15 +2707,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + rtw_setopmode_cmd(padapter, Ndis802_11APMode, false); + -+ set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); ++ set_channel_bwmode( ++ padapter, ++ pmlmeext->cur_channel, ++ pmlmeext->cur_ch_offset, ++ pmlmeext->cur_bwmode ++ ); + + start_bss_network(padapter, (u8 *)&mlmepriv->cur_network.network); + + if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || -+ (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) -+ { ++ (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { ++ + /* restore group key, WEP keys is restored in ips_leave() */ -+ rtw_set_key(padapter, psecuritypriv, psecuritypriv->dot118021XGrpKeyid, 0, false); ++ rtw_set_key( ++ padapter, ++ psecuritypriv, ++ psecuritypriv->dot118021XGrpKeyid, ++ 0, ++ false ++ ); + } + + spin_lock_bh(&pstapriv->asoc_list_lock); @@ -2539,9 +2741,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + plist = get_next(plist); + + stainfo_offset = rtw_stainfo_offset(pstapriv, psta); -+ if (stainfo_offset_valid(stainfo_offset)) { ++ if (stainfo_offset_valid(stainfo_offset)) + chk_alive_list[chk_alive_num++] = stainfo_offset; -+ } ++ + } + + spin_unlock_bh(&pstapriv->asoc_list_lock); @@ -2551,14 +2753,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + if (psta == NULL) { + DBG_871X(FUNC_ADPT_FMT" sta_info is null\n", FUNC_ADPT_ARG(padapter)); -+ } else if (psta->state &_FW_LINKED) { ++ } else if (psta->state & _FW_LINKED) { + rtw_sta_media_status_rpt(padapter, psta, 1); + Update_RA_Entry(padapter, psta); + /* pairwise key */ + /* per sta pairwise key and settings */ + if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || -+ (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) -+ { ++ (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { ++ + rtw_setstakey_cmd(padapter, psta, true, false); + } + } @@ -2595,7 +2797,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + pmlmepriv->ht_op_mode = 0; + -+ for (i = 0; ista_aid[i] = NULL; + + pmlmepriv->wps_beacon_ie = NULL; @@ -2626,13 +2828,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; -+ struct __queue *pacl_node_q =&pacl_list->acl_node_q; ++ struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + pmlmepriv->update_bcn = false; + pmlmeext->bstart_bss = false; + + /* reset and init security priv , this can refine with rtw_reset_securitypriv */ -+ memset((unsigned char *)&padapter->securitypriv, 0, sizeof (struct security_priv)); ++ memset( ++ (unsigned char *)&padapter->securitypriv, ++ 0, ++ sizeof(struct security_priv) ++ ); + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; + @@ -2640,13 +2846,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + spin_lock_bh(&(pacl_node_q->lock)); + phead = get_list_head(pacl_node_q); + plist = get_next(phead); -+ while (phead != plist) -+ { ++ while (phead != plist) { ++ + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + -+ if (paclnode->valid == true) -+ { ++ if (paclnode->valid == true) { ++ + paclnode->valid = false; + + list_del_init(&paclnode->list); @@ -2672,10 +2878,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ap.c linux-4.3-rtl8723bs/3rdpar + + rtw_btcoex_MediaStatusNotify(padapter, 0); /* disconnect */ +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_btcoex.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_btcoex.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_btcoex.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_btcoex.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,253 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_btcoex.c linux/3rdparty/rtl8723bs/core/rtw_btcoex.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_btcoex.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_btcoex.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,243 @@ +/****************************************************************************** + * + * Copyright(c) 2013 Realtek Corporation. All rights reserved. @@ -2734,8 +2940,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_btcoex.c linux-4.3-rtl8723bs/3r +void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus) +{ + if ((RT_MEDIA_CONNECT == mediaStatus) -+ && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)) -+ { ++ && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)) { + rtw_hal_set_hwreg(padapter, HW_VAR_DL_RSVD_PAGE, NULL); + } + @@ -2764,16 +2969,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_btcoex.c linux-4.3-rtl8723bs/3r + +void rtw_btcoex_HaltNotify(struct adapter *padapter) +{ -+ if (false == padapter->bup) -+ { ++ if (false == padapter->bup) { + DBG_871X(FUNC_ADPT_FMT ": bup =%d Skip!\n", + FUNC_ADPT_ARG(padapter), padapter->bup); + + return; + } + -+ if (true == padapter->bSurpriseRemoved) -+ { ++ if (true == padapter->bSurpriseRemoved) { + DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n", + FUNC_ADPT_ARG(padapter), padapter->bSurpriseRemoved); + @@ -2804,12 +3007,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_btcoex.c linux-4.3-rtl8723bs/3r + +void rtw_btcoex_SetManualControl(struct adapter *padapter, u8 manual) +{ -+ if (true == manual) -+ { ++ if (true == manual) { + hal_btcoex_SetManualControl(padapter, true); -+ } -+ else -+ { ++ } else{ + hal_btcoex_SetManualControl(padapter, false); + } +} @@ -2890,14 +3090,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_btcoex.c linux-4.3-rtl8723bs/3r + pmlmeinfo = &padapter->mlmeextpriv.mlmext_info; + psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv)); + -+ if (true == enable) -+ { ++ if (true == enable) { + pmlmeinfo->bAcceptAddbaReq = false; + if (psta) + send_delba(padapter, 0, psta->hwaddr); -+ } -+ else -+ { ++ } else{ + pmlmeinfo->bAcceptAddbaReq = true; + } +} @@ -2922,17 +3119,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_btcoex.c linux-4.3-rtl8723bs/3r + + pwrpriv = adapter_to_pwrctl(padapter); + -+ if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) -+ { ++ if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { + rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "BTCOEX"); + LPS_RF_ON_check(padapter, 100); + pwrpriv->bpower_saving = false; + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_cmd.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_cmd.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,2322 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_cmd.c linux/3rdparty/rtl8723bs/core/rtw_cmd.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_cmd.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_cmd.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,2244 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -2953,8 +3149,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +#include +#include + -+static struct _cmd_callback rtw_cmd_callback[] = -+{ ++static struct _cmd_callback rtw_cmd_callback[] = { + {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ + {GEN_CMD_CODE(_Write_MACREG), NULL}, + {GEN_CMD_CODE(_Read_BBREG), &rtw_getbbrfreg_cmdrsp_callback}, @@ -2997,7 +3192,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + {GEN_CMD_CODE(_SetPwrMode), NULL}, + {GEN_CMD_CODE(_JoinbssRpt), NULL}, + {GEN_CMD_CODE(_SetRaTable), NULL}, -+ {GEN_CMD_CODE(_GetRaTable) , NULL}, ++ {GEN_CMD_CODE(_GetRaTable), NULL}, + + {GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/ + {GEN_CMD_CODE(_GetDTMReport), NULL}, @@ -3045,25 +3240,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct joinbss_parm), join_cmd_hdl) /*14*/ -+ GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl) -+ GEN_MLME_EXT_HANDLER(sizeof (struct createbss_parm), createbss_hdl) -+ GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl) -+ GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), sitesurvey_cmd_hdl) /*18*/ -+ GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl) -+ GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl) /*20*/ -+ GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl) -+ GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct del_assocsta_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct setstapwrstate_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct setbasicrate_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct getbasicrate_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct setdatarate_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct getdatarate_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct setphyinfo_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct getphyinfo_parm), NULL) /*30*/ -+ GEN_MLME_EXT_HANDLER(sizeof (struct setphy_parm), NULL) -+ GEN_MLME_EXT_HANDLER(sizeof (struct getphy_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct joinbss_parm), join_cmd_hdl) /*14*/ ++ GEN_MLME_EXT_HANDLER(sizeof(struct disconnect_parm), disconnect_hdl) ++ GEN_MLME_EXT_HANDLER(sizeof(struct createbss_parm), createbss_hdl) ++ GEN_MLME_EXT_HANDLER(sizeof(struct setopmode_parm), setopmode_hdl) ++ GEN_MLME_EXT_HANDLER(sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl) /*18*/ ++ GEN_MLME_EXT_HANDLER(sizeof(struct setauth_parm), setauth_hdl) ++ GEN_MLME_EXT_HANDLER(sizeof(struct setkey_parm), setkey_hdl) /*20*/ ++ GEN_MLME_EXT_HANDLER(sizeof(struct set_stakey_parm), set_stakey_hdl) ++ GEN_MLME_EXT_HANDLER(sizeof(struct set_assocsta_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct del_assocsta_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct setstapwrstate_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct setbasicrate_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct getbasicrate_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct setdatarate_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct getdatarate_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct setphyinfo_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct getphyinfo_parm), NULL) /*30*/ ++ GEN_MLME_EXT_HANDLER(sizeof(struct setphy_parm), NULL) ++ GEN_MLME_EXT_HANDLER(sizeof(struct getphy_parm), NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) @@ -3106,7 +3301,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +No irqsave is necessary. +*/ + -+sint _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) ++sint _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) +{ + sint res = _SUCCESS; + @@ -3162,7 +3357,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + return res; +} + -+void _rtw_free_evt_priv (struct evt_priv *pevtpriv) ++void _rtw_free_evt_priv(struct evt_priv *pevtpriv) +{ + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+_rtw_free_evt_priv\n")); + @@ -3171,9 +3366,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + msleep(10); + + while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { -+ void *c2h; -+ if ((c2h = rtw_cbuf_pop(pevtpriv->c2h_queue)) != NULL -+ && c2h != (void *)pevtpriv) { ++ void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue); ++ if (c2h != NULL && c2h != (void *)pevtpriv) { + kfree(c2h); + } + } @@ -3182,7 +3376,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-_rtw_free_evt_priv\n")); +} + -+void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) ++void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) +{ + if (pcmdpriv) { + if (pcmdpriv->cmd_allocated_buf) @@ -3233,8 +3427,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + spin_lock_irqsave(&queue->lock, irqL); + if (list_empty(&(queue->queue))) + obj = NULL; -+ else -+ { ++ else{ + obj = LIST_CONTAINOR(get_next(&(queue->queue)), struct cmd_obj, list); + list_del_init(&obj->list); + } @@ -3249,11 +3442,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +{ + u32 res; + -+ res = _rtw_init_cmd_priv (pcmdpriv); ++ res = _rtw_init_cmd_priv(pcmdpriv); + return res; +} + -+u32 rtw_init_evt_priv (struct evt_priv *pevtpriv) ++u32 rtw_init_evt_priv(struct evt_priv *pevtpriv) +{ + int res; + @@ -3261,13 +3454,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + return res; +} + -+void rtw_free_evt_priv (struct evt_priv *pevtpriv) ++void rtw_free_evt_priv(struct evt_priv *pevtpriv) +{ + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_evt_priv\n")); + _rtw_free_evt_priv(pevtpriv); +} + -+void rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) ++void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) +{ + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv\n")); + _rtw_free_cmd_priv(pcmdpriv); @@ -3281,10 +3474,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan)) + bAllow = true; + -+ if ((pcmdpriv->padapter->hw_init_completed ==false && bAllow == false) ++ if ((pcmdpriv->padapter->hw_init_completed == false && bAllow == false) + || atomic_read(&(pcmdpriv->cmdthd_running)) == false /* com_thread not running */ -+ ) -+ { ++ ) { + /* DBG_871X("%s:%s: drop cmdcode:%u, hw_init_completed:%u, cmdthd_running:%u\n", caller_func, __func__, */ + /* cmd_obj->cmdcode, */ + /* pcmdpriv->padapter->hw_init_completed, */ @@ -3309,7 +3501,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + cmd_obj->padapter = padapter; + -+ if (_FAIL == (res =rtw_cmd_filter(pcmdpriv, cmd_obj))) { ++ res = rtw_cmd_filter(pcmdpriv, cmd_obj); ++ if (_FAIL == res) { + rtw_free_cmd_obj(cmd_obj); + goto exit; + } @@ -3334,21 +3527,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +void rtw_free_cmd_obj(struct cmd_obj *pcmd) +{ -+ if ((pcmd->cmdcode!= _JoinBss_CMD_) && -+ (pcmd->cmdcode!= _CreateBss_CMD_)) { ++ if ((pcmd->cmdcode != _JoinBss_CMD_) && ++ (pcmd->cmdcode != _CreateBss_CMD_)) { + /* free parmbuf in cmd_obj */ -+ kfree((unsigned char*)pcmd->parmbuf); ++ kfree((unsigned char *)pcmd->parmbuf); + } + -+ if (pcmd->rsp!= NULL) { -+ if (pcmd->rspsz!= 0) { ++ if (pcmd->rsp != NULL) { ++ if (pcmd->rspsz != 0) { + /* free rsp in cmd_obj */ -+ kfree((unsigned char*)pcmd->rsp); ++ kfree((unsigned char *)pcmd->rsp); + } + } + + /* free cmd_obj */ -+ kfree((unsigned char*)pcmd); ++ kfree((unsigned char *)pcmd); +} + + @@ -3356,8 +3549,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +{ + if (adapter->cmdThread && + atomic_read(&(adapter->cmdpriv.cmdthd_running)) == true && -+ adapter->cmdpriv.stop_req == 0) -+ { ++ adapter->cmdpriv.stop_req == 0) { + adapter->cmdpriv.stop_req = 1; + up(&adapter->cmdpriv.cmd_queue_sema); + down(&adapter->cmdpriv.terminate_cmdthread_sema); @@ -3388,15 +3580,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n")); + -+ while (1) -+ { ++ while (1) { + if (down_interruptible(&pcmdpriv->cmd_queue_sema)) { + DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" down_interruptible(&pcmdpriv->cmd_queue_sema) return != 0, break\n", FUNC_ADPT_ARG(padapter)); + break; + } + -+ if ((padapter->bDriverStopped == true)||(padapter->bSurpriseRemoved == true)) -+ { ++ if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) { + DBG_871X_LEVEL(_drv_always_, "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n", + __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__); + break; @@ -3407,36 +3597,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + break; + } + -+ if (list_empty(&(pcmdpriv->cmd_queue.queue))) -+ { ++ if (list_empty(&(pcmdpriv->cmd_queue.queue))) { + /* DBG_871X("%s: cmd queue is empty!\n", __func__); */ + continue; + } + -+ if (rtw_register_cmd_alive(padapter) != _SUCCESS) -+ { ++ if (rtw_register_cmd_alive(padapter) != _SUCCESS) { + RT_TRACE(_module_hal_xmit_c_, _drv_notice_, + ("%s: wait to leave LPS_LCLK\n", __func__)); + continue; + } + +_next: -+ if ((padapter->bDriverStopped == true)||(padapter->bSurpriseRemoved == true)) -+ { ++ if ((padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true)) { + DBG_871X_LEVEL(_drv_always_, "%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n", + __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__); + break; + } + -+ if (!(pcmd = rtw_dequeue_cmd(pcmdpriv))) { ++ pcmd = rtw_dequeue_cmd(pcmdpriv); ++ if (!pcmd) { + rtw_unregister_cmd_alive(padapter); + continue; + } + + cmd_start_time = jiffies; + -+ if (_FAIL == rtw_cmd_filter(pcmdpriv, pcmd)) -+ { ++ if (_FAIL == rtw_cmd_filter(pcmdpriv, pcmd)) { + pcmd->res = H2C_DROPPED; + goto post_process; + } @@ -3447,20 +3634,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); + -+ if (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) -+ { ++ if (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) { + cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; + -+ if (cmd_hdl) -+ { ++ if (cmd_hdl) { + ret = cmd_hdl(pcmd->padapter, pcmdbuf); + pcmd->res = ret; + } + + pcmdpriv->cmd_seq++; -+ } -+ else -+ { ++ } else{ + pcmd->res = H2C_PARAMETERS_ERROR; + } + @@ -3481,8 +3664,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + mutex_unlock(&(pcmd->padapter->cmdpriv.sctx_mutex)); + } + -+ if ((cmd_process_time = jiffies_to_msecs(jiffies - cmd_start_time)) > 1000) -+ { ++ cmd_process_time = jiffies_to_msecs(jiffies - cmd_start_time); ++ if (cmd_process_time > 1000) { + if (pcmd->cmdcode == GEN_CMD_CODE(_Set_Drv_Extra)) { + DBG_871X(ADPT_FMT" cmd =%d process_time =%lu > 1 sec\n", + ADPT_ARG(pcmd->padapter), pcmd->cmdcode, cmd_process_time); @@ -3499,22 +3682,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + } + + /* call callback function for post-processed */ -+ if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) -+ { ++ if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) { + pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; -+ if (pcmd_callback == NULL) -+ { ++ if (pcmd_callback == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode)); + rtw_free_cmd_obj(pcmd); -+ } -+ else -+ { ++ } else{ + /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */ + pcmd_callback(pcmd->padapter, pcmd);/* need conider that free cmd_obj in rtw_cmd_callback */ + } -+ } -+ else -+ { ++ } else{ + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("%s: cmdcode = 0x%x callback not defined!\n", __func__, pcmd->cmdcode)); + rtw_free_cmd_obj(pcmd); + } @@ -3526,7 +3703,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + } + + /* free all cmd_obj resources */ -+ do{ ++ do { + pcmd = rtw_dequeue_cmd(pcmdpriv); + if (pcmd == NULL) { + rtw_unregister_cmd_alive(padapter); @@ -3543,7 +3720,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + } + + rtw_free_cmd_obj(pcmd); -+ }while (1); ++ } while (1); + + up(&pcmdpriv->terminate_cmdthread_sema); + atomic_set(&(pcmdpriv->cmdthd_running), false); @@ -3569,13 +3746,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); + } + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + return _FAIL; + -+ psurveyPara = (struct sitesurvey_parm*)rtw_zmalloc(sizeof(struct sitesurvey_parm)); ++ psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + if (psurveyPara == NULL) { -+ kfree((unsigned char*) ph2c); ++ kfree((unsigned char *) ph2c); + return _FAIL; + } + @@ -3591,7 +3768,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + /* prepare ssid list */ + if (ssid) { + int i; -+ for (i = 0; issid[i], &ssid[i], sizeof(struct ndis_802_11_ssid)); + psurveyPara->ssid_num++; @@ -3605,7 +3782,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + /* prepare channel list */ + if (ch) { + int i; -+ for (i = 0; ich[i], &ch[i], sizeof(struct rtw_ieee80211_channel)); + psurveyPara->ch_num++; @@ -3632,18 +3809,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) +{ -+ struct cmd_obj* ph2c; -+ struct setdatarate_parm*pbsetdataratepara; -+ struct cmd_priv* pcmdpriv = &padapter->cmdpriv; ++ struct cmd_obj *ph2c; ++ struct setdatarate_parm *pbsetdataratepara; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pbsetdataratepara = (struct setdatarate_parm*)rtw_zmalloc(sizeof(struct setdatarate_parm)); ++ pbsetdataratepara = (struct setdatarate_parm *)rtw_zmalloc(sizeof(struct setdatarate_parm)); + if (pbsetdataratepara == NULL) { + kfree((u8 *) ph2c); + res = _FAIL; @@ -3662,14 +3839,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + /* rtw_free_cmd_obj(pcmd); */ -+ kfree((unsigned char*) pcmd->parmbuf); -+ kfree((unsigned char*) pcmd); ++ kfree((unsigned char *) pcmd->parmbuf); ++ kfree((unsigned char *) pcmd); +} + +u8 rtw_createbss_cmd(struct adapter *padapter) +{ -+ struct cmd_obj* pcmd; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_obj *pcmd; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; + u8 res = _SUCCESS; @@ -3680,7 +3857,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); + } + -+ pcmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + goto exit; @@ -3689,7 +3866,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + INIT_LIST_HEAD(&pcmd->list); + pcmd->cmdcode = _CreateBss_CMD_; + pcmd->parmbuf = (unsigned char *)pdev_network; -+ pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex*)pdev_network); ++ pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + @@ -3703,8 +3880,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +u8 rtw_startbss_cmd(struct adapter *padapter, int flags) +{ -+ struct cmd_obj* pcmd; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_obj *pcmd; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct submit_ctx sctx; + u8 res = _SUCCESS; + @@ -3713,7 +3890,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + start_bss_network(padapter, (u8 *)&(padapter->mlmepriv.cur_network.network)); + } else { + /* need enqueue, prepare cmd_obj and enqueue */ -+ pcmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + goto exit; @@ -3747,16 +3924,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + return res; +} + -+u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network* pnetwork) ++u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) +{ + u8 *auth, res = _SUCCESS; + uint t_len = 0; + struct wlan_bssid_ex *psecnetwork; + struct cmd_obj *pcmd; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + enum NDIS_802_11_NETWORK_INFRASTRUCTURE ndis_network_mode = pnetwork->network.InfrastructureMode; @@ -3771,7 +3948,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid)); + } + -+ pcmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); @@ -3782,29 +3959,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + + /* for hidden ap to set fw_state here */ -+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) != true) -+ { -+ switch (ndis_network_mode) -+ { -+ case Ndis802_11IBSS: -+ set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); -+ break; ++ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) != true) { ++ switch (ndis_network_mode) { ++ case Ndis802_11IBSS: ++ set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); ++ break; + -+ case Ndis802_11Infrastructure: -+ set_fwstate(pmlmepriv, WIFI_STATION_STATE); -+ break; ++ case Ndis802_11Infrastructure: ++ set_fwstate(pmlmepriv, WIFI_STATION_STATE); ++ break; + -+ case Ndis802_11APMode: -+ case Ndis802_11AutoUnknown: -+ case Ndis802_11InfrastructureMax: -+ break; ++ case Ndis802_11APMode: ++ case Ndis802_11AutoUnknown: ++ case Ndis802_11InfrastructureMax: ++ break; + + } + } + -+ psecnetwork =(struct wlan_bssid_ex *)&psecuritypriv->sec_bss; -+ if (psecnetwork == NULL) -+ { ++ psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; ++ if (psecnetwork == NULL) { + if (pcmd != NULL) + kfree((unsigned char *)pcmd); + @@ -3819,8 +3993,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network)); + -+ auth =&psecuritypriv->authenticator_ie[0]; -+ psecuritypriv->authenticator_ie[0]=(unsigned char)psecnetwork->IELength; ++ auth = &psecuritypriv->authenticator_ie[0]; ++ psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; + + if ((psecnetwork->IELength-12) < (256-1)) { + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); @@ -3834,9 +4008,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + /* If not, we have to copy the connecting AP's MAC address to it so that */ + /* the driver just has the bssid information for PMKIDList searching. */ + -+ if (pmlmepriv->assoc_by_bssid == false) -+ { -+ memcpy(&pmlmepriv->assoc_bssid[ 0 ], &pnetwork->network.MacAddress[ 0 ], ETH_ALEN); ++ if (pmlmepriv->assoc_by_bssid == false) { ++ memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0], ETH_ALEN); + } + + psecnetwork->IELength = rtw_restruct_sec_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength); @@ -3844,32 +4017,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + pqospriv->qos_option = 0; + -+ if (pregistrypriv->wmm_enable) -+ { ++ if (pregistrypriv->wmm_enable) { + tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength, psecnetwork->IELength); + -+ if (psecnetwork->IELength != tmp_len) -+ { ++ if (psecnetwork->IELength != tmp_len) { + psecnetwork->IELength = tmp_len; + pqospriv->qos_option = 1; /* There is WMM IE in this corresp. beacon */ -+ } -+ else -+ { ++ } else{ + pqospriv->qos_option = 0;/* There is no WMM IE in this corresp. beacon */ + } + } + + phtpriv->ht_option = false; + ptmp = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &tmp_len, pnetwork->network.IELength-12); -+ if (pregistrypriv->ht_enable && ptmp && tmp_len>0) -+ { ++ if (pregistrypriv->ht_enable && ptmp && tmp_len > 0) { + /* Added by Albert 2010/06/23 */ + /* For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */ + /* Especially for Realtek 8192u SoftAP. */ + if ((padapter->securitypriv.dot11PrivacyAlgrthm != _WEP40_) && + (padapter->securitypriv.dot11PrivacyAlgrthm != _WEP104_) && -+ (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) -+ { ++ (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) { + rtw_ht_use_default_setting(padapter); + + rtw_build_wmm_ie_ht(padapter, &psecnetwork->IEs[12], &psecnetwork->IELength); @@ -3939,13 +4106,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype, bool enqueue) +{ -+ struct cmd_obj*ph2c; -+ struct setopmode_parm* psetop; ++ struct cmd_obj *ph2c; ++ struct setopmode_parm *psetop; + + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ psetop = (struct setopmode_parm*)rtw_zmalloc(sizeof(struct setopmode_parm)); ++ psetop = (struct setopmode_parm *)rtw_zmalloc(sizeof(struct setopmode_parm)); + + if (psetop == NULL) { + res = _FAIL; @@ -3954,7 +4121,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + psetop->mode = (u8)networktype; + + if (enqueue) { -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + kfree((u8 *)psetop); + res = _FAIL; @@ -3963,8 +4130,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); + res = rtw_enqueue_cmd(pcmdpriv, ph2c); -+ } -+ else { ++ } else{ + setopmode_hdl(padapter, (u8 *)psetop); + kfree((u8 *)psetop); + } @@ -3974,16 +4140,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_key, bool enqueue) +{ -+ struct cmd_obj* ph2c; ++ struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct set_stakey_rsp *psetstakey_rsp = NULL; + + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u8 res = _SUCCESS; + -+ psetstakey_para = (struct set_stakey_parm*)rtw_zmalloc(sizeof(struct set_stakey_parm)); ++ psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + if (psetstakey_para == NULL) { + res = _FAIL; + goto exit; @@ -3992,31 +4158,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { -+ psetstakey_para->algorithm =(unsigned char) psecuritypriv->dot11PrivacyAlgrthm; ++ psetstakey_para->algorithm = (unsigned char) psecuritypriv->dot11PrivacyAlgrthm; + } else { + GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false); + } + + if (unicast_key == true) { + memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16); -+ } -+ else { ++ } else{ + memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16); -+ } ++ } + + /* jeff: set this becasue at least sw key is ready */ -+ padapter->securitypriv.busetkipkey =true; ++ padapter->securitypriv.busetkipkey = true; + -+ if (enqueue) -+ { -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (enqueue) { ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + kfree((u8 *) psetstakey_para); + res = _FAIL; + goto exit; + } + -+ psetstakey_rsp = (struct set_stakey_rsp*)rtw_zmalloc(sizeof(struct set_stakey_rsp)); ++ psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + if (psetstakey_rsp == NULL) { + kfree((u8 *) ph2c); + kfree((u8 *) psetstakey_para); @@ -4028,8 +4192,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + ph2c->rsp = (u8 *) psetstakey_rsp; + ph2c->rspsz = sizeof(struct set_stakey_rsp); + res = rtw_enqueue_cmd(pcmdpriv, ph2c); -+ } -+ else { ++ } else{ + set_stakey_hdl(padapter, (u8 *)psetstakey_para); + kfree((u8 *) psetstakey_para); + } @@ -4039,37 +4202,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueue) +{ -+ struct cmd_obj* ph2c; ++ struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct set_stakey_rsp *psetstakey_rsp = NULL; + s16 cam_id = 0; + u8 res = _SUCCESS; + -+ if (!enqueue) -+ { ++ if (!enqueue) { + while ((cam_id = rtw_camid_search(padapter, sta->hwaddr, -1)) >= 0) { + DBG_871X_LEVEL(_drv_always_, "clear key for addr:"MAC_FMT", camid:%d\n", MAC_ARG(sta->hwaddr), cam_id); + clear_cam_entry(padapter, cam_id); + rtw_camid_free(padapter, cam_id); + } -+ } -+ else -+ { -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ } else{ ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ psetstakey_para = (struct set_stakey_parm*)rtw_zmalloc(sizeof(struct set_stakey_parm)); ++ psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + if (psetstakey_para == NULL) { + kfree((u8 *) ph2c); + res = _FAIL; + goto exit; + } + -+ psetstakey_rsp = (struct set_stakey_rsp*)rtw_zmalloc(sizeof(struct set_stakey_rsp)); ++ psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + if (psetstakey_rsp == NULL) { + kfree((u8 *) ph2c); + kfree((u8 *) psetstakey_para); @@ -4096,18 +4256,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) +{ + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; -+ struct cmd_obj* ph2c; ++ struct cmd_obj *ph2c; + struct addBaReq_parm *paddbareq_parm; + + u8 res = _SUCCESS; + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ paddbareq_parm = (struct addBaReq_parm*)rtw_zmalloc(sizeof(struct addBaReq_parm)); ++ paddbareq_parm = (struct addBaReq_parm *)rtw_zmalloc(sizeof(struct addBaReq_parm)); + if (paddbareq_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; @@ -4130,18 +4290,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +/* add for CONFIG_IEEE80211W, none 11w can use it */ +u8 rtw_reset_securitypriv_cmd(struct adapter *padapter) +{ -+ struct cmd_obj* ph2c; ++ struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; @@ -4165,18 +4325,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +u8 rtw_free_assoc_resources_cmd(struct adapter *padapter) +{ -+ struct cmd_obj* ph2c; ++ struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; @@ -4200,19 +4360,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) +{ -+ struct cmd_obj* ph2c; ++ struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + /* only primary padapter does this cmd */ -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; @@ -4235,7 +4395,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconfig) +{ -+ struct cmd_obj*pcmdobj; ++ struct cmd_obj *pcmdobj; + struct SetChannelPlan_param *setChannelPlan_param; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + @@ -4244,8 +4404,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_chplan_cmd\n")); + + /* check if allow software config */ -+ if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter) == true) -+ { ++ if (swconfig && rtw_hal_is_disable_sw_channel_plan(padapter) == true) { + res = _FAIL; + goto exit; + } @@ -4262,12 +4421,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + res = _FAIL; + goto exit; + } -+ setChannelPlan_param->channel_plan =chplan; ++ setChannelPlan_param->channel_plan = chplan; + -+ if (enqueue) -+ { ++ if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ -+ pcmdobj = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmdobj == NULL) { + kfree((u8 *)setChannelPlan_param); + res = _FAIL; @@ -4276,11 +4434,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelPlan_param, GEN_CMD_CODE(_SetChannelPlan)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); -+ } -+ else -+ { ++ } else{ + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ -+ if (H2C_SUCCESS !=set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param)) ++ if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param)) + res = _FAIL; + + kfree((u8 *)setChannelPlan_param); @@ -4314,8 +4470,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + pdvobjpriv->traffic_stat.last_tx_bytes = pdvobjpriv->traffic_stat.tx_bytes; + pdvobjpriv->traffic_stat.last_rx_bytes = pdvobjpriv->traffic_stat.rx_bytes; + -+ pdvobjpriv->traffic_stat.cur_tx_tp = (u32)(pdvobjpriv->traffic_stat.cur_tx_bytes *8/2/1024/1024); -+ pdvobjpriv->traffic_stat.cur_rx_tp = (u32)(pdvobjpriv->traffic_stat.cur_rx_bytes *8/2/1024/1024); ++ pdvobjpriv->traffic_stat.cur_tx_tp = (u32)(pdvobjpriv->traffic_stat.cur_tx_bytes * 8/2/1024/1024); ++ pdvobjpriv->traffic_stat.cur_rx_tp = (u32)(pdvobjpriv->traffic_stat.cur_rx_bytes * 8/2/1024/1024); +} + +u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer) @@ -4329,7 +4485,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + -+ RT_LINK_DETECT_T * link_detect = &pmlmepriv->LinkDetectInfo; ++ RT_LINK_DETECT_T *link_detect = &pmlmepriv->LinkDetectInfo; + + collect_traffic_statistics(padapter); + @@ -4337,15 +4493,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + /* Determine if our traffic is busy now */ + /* */ + if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) -+ /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) -+ { ++ /*&& !MgntInitAdapterInProgress(pMgntInfo)*/) { + /* if we raise bBusyTraffic in last watchdog, using lower threshold. */ + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) + BusyThreshold = BusyThresholdLow; + + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > BusyThreshold || -+ pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold) -+ { ++ pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > BusyThreshold) { + bBusyTraffic = true; + + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) @@ -4356,8 +4510,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + /* Higher Tx/Rx data. */ + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 || -+ pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) -+ { ++ pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) { + bHigherBusyTraffic = true; + + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) @@ -4384,13 +4537,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + /* check traffic for powersaving. */ + if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) || -+ (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) -+ { ++ (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) { + /* DBG_871X("(-)Tx = %d, Rx = %d\n", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */ + bEnterPS = false; + -+ if (bBusyTraffic == true) -+ { ++ if (bBusyTraffic == true) { + if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount <= 4) + pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 4; + @@ -4398,18 +4549,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + /* DBG_871X("Set TrafficTransitionCount to %d\n", pmlmepriv->LinkDetectInfo.TrafficTransitionCount); */ + -+ if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount > 30/*TrafficTransitionLevel*/) -+ { ++ if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount > 30/*TrafficTransitionLevel*/) { + pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 30; + } + } -+ } -+ else -+ { ++ } else{ + /* DBG_871X("(+)Tx = %d, Rx = %d\n", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */ + -+ if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount>=2) -+ pmlmepriv->LinkDetectInfo.TrafficTransitionCount -=2; ++ if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount >= 2) ++ pmlmepriv->LinkDetectInfo.TrafficTransitionCount -= 2; + else + pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 0; + @@ -4427,7 +4575,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + else + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_TRAFFIC_BUSY, 1); + } -+ } else { ++ } else{ + struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); + int n_assoc_iface = 0; + @@ -4457,8 +4605,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + struct mlme_priv *pmlmepriv; + pmlmepriv = &(padapter->mlmepriv); + -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + expire_timeout_chk(padapter); + } + @@ -4495,56 +4642,53 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + u8 mstatus; + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) -+ || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) -+ { ++ || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + return; + } + -+ switch (lps_ctrl_type) -+ { -+ case LPS_CTRL_SCAN: -+ /* DBG_871X("LPS_CTRL_SCAN\n"); */ -+ rtw_btcoex_ScanNotify(padapter, true); ++ switch (lps_ctrl_type) { ++ case LPS_CTRL_SCAN: ++ /* DBG_871X("LPS_CTRL_SCAN\n"); */ ++ rtw_btcoex_ScanNotify(padapter, true); + -+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) -+ { -+ /* connect */ -+ LPS_Leave(padapter, "LPS_CTRL_SCAN"); -+ } -+ break; -+ case LPS_CTRL_JOINBSS: -+ /* DBG_871X("LPS_CTRL_JOINBSS\n"); */ -+ LPS_Leave(padapter, "LPS_CTRL_JOINBSS"); -+ break; -+ case LPS_CTRL_CONNECT: -+ /* DBG_871X("LPS_CTRL_CONNECT\n"); */ -+ mstatus = 1;/* connect */ -+ /* Reset LPS Setting */ -+ pwrpriv->LpsIdleCount = 0; -+ rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); -+ rtw_btcoex_MediaStatusNotify(padapter, mstatus); -+ break; -+ case LPS_CTRL_DISCONNECT: -+ /* DBG_871X("LPS_CTRL_DISCONNECT\n"); */ -+ mstatus = 0;/* disconnect */ -+ rtw_btcoex_MediaStatusNotify(padapter, mstatus); -+ LPS_Leave(padapter, "LPS_CTRL_DISCONNECT"); -+ rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); -+ break; -+ case LPS_CTRL_SPECIAL_PACKET: -+ /* DBG_871X("LPS_CTRL_SPECIAL_PACKET\n"); */ -+ pwrpriv->DelayLPSLastTimeStamp = jiffies; -+ rtw_btcoex_SpecialPacketNotify(padapter, PACKET_DHCP); -+ LPS_Leave(padapter, "LPS_CTRL_SPECIAL_PACKET"); -+ break; -+ case LPS_CTRL_LEAVE: -+ /* DBG_871X("LPS_CTRL_LEAVE\n"); */ -+ LPS_Leave(padapter, "LPS_CTRL_LEAVE"); -+ break; -+ case LPS_CTRL_TRAFFIC_BUSY: -+ LPS_Leave(padapter, "LPS_CTRL_TRAFFIC_BUSY"); -+ default: -+ break; ++ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { ++ /* connect */ ++ LPS_Leave(padapter, "LPS_CTRL_SCAN"); ++ } ++ break; ++ case LPS_CTRL_JOINBSS: ++ /* DBG_871X("LPS_CTRL_JOINBSS\n"); */ ++ LPS_Leave(padapter, "LPS_CTRL_JOINBSS"); ++ break; ++ case LPS_CTRL_CONNECT: ++ /* DBG_871X("LPS_CTRL_CONNECT\n"); */ ++ mstatus = 1;/* connect */ ++ /* Reset LPS Setting */ ++ pwrpriv->LpsIdleCount = 0; ++ rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); ++ rtw_btcoex_MediaStatusNotify(padapter, mstatus); ++ break; ++ case LPS_CTRL_DISCONNECT: ++ /* DBG_871X("LPS_CTRL_DISCONNECT\n"); */ ++ mstatus = 0;/* disconnect */ ++ rtw_btcoex_MediaStatusNotify(padapter, mstatus); ++ LPS_Leave(padapter, "LPS_CTRL_DISCONNECT"); ++ rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); ++ break; ++ case LPS_CTRL_SPECIAL_PACKET: ++ /* DBG_871X("LPS_CTRL_SPECIAL_PACKET\n"); */ ++ pwrpriv->DelayLPSLastTimeStamp = jiffies; ++ rtw_btcoex_SpecialPacketNotify(padapter, PACKET_DHCP); ++ LPS_Leave(padapter, "LPS_CTRL_SPECIAL_PACKET"); ++ break; ++ case LPS_CTRL_LEAVE: ++ /* DBG_871X("LPS_CTRL_LEAVE\n"); */ ++ LPS_Leave(padapter, "LPS_CTRL_LEAVE"); ++ break; ++ case LPS_CTRL_TRAFFIC_BUSY: ++ LPS_Leave(padapter, "LPS_CTRL_TRAFFIC_BUSY"); ++ default: ++ break; + } +} + @@ -4559,15 +4703,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + /* if (!pwrctrlpriv->bLeisurePs) */ + /* return res; */ + -+ if (enqueue) -+ { -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (enqueue) { ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; @@ -4582,9 +4725,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); -+ } -+ else -+ { ++ } else{ + lps_ctrl_wk_hdl(padapter, lps_ctrl_type); + } + @@ -4605,13 +4746,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + u8 res = _SUCCESS; + + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; @@ -4645,16 +4786,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + down(&pwrpriv->lock); + -+ if (pwrpriv->dtim!=dtim) -+ { ++ if (pwrpriv->dtim != dtim) { + DBG_871X("change DTIM from %d to %d, bFwCurrentInPSMode =%d, ps_mode =%d\n", pwrpriv->dtim, dtim, + pwrpriv->bFwCurrentInPSMode, pwrpriv->pwr_mode); + + pwrpriv->dtim = dtim; + } + -+ if ((pwrpriv->bFwCurrentInPSMode ==true) && (pwrpriv->pwr_mode > PS_MODE_ACTIVE)) -+ { ++ if ((pwrpriv->bFwCurrentInPSMode == true) && (pwrpriv->pwr_mode > PS_MODE_ACTIVE)) { + u8 ps_mode = pwrpriv->pwr_mode; + + /* DBG_871X("change DTIM from %d to %d, ps_mode =%d\n", pwrpriv->dtim, dtim, ps_mode); */ @@ -4680,13 +4819,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + u8 res = _SUCCESS; + + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; @@ -4731,13 +4870,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ ppscmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ppscmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ppscmd == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((unsigned char *)ppscmd); + res = _FAIL; @@ -4769,16 +4908,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty); + -+ while (false == empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) -+ { ++ while (false == empty && jiffies_to_msecs(jiffies - start) < g_wait_hiq_empty) { + msleep(100); + rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &empty); + } + -+ if (psta_bmc->sleepq_len == 0) -+ { -+ if (empty == _SUCCESS) -+ { ++ if (psta_bmc->sleepq_len == 0) { ++ if (empty == _SUCCESS) { + bool update_tim = false; + + if (pstapriv->tim_bitmap & BIT(0)) @@ -4789,9 +4925,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + if (update_tim == true) + update_beacon(padapter, _TIM_IE_, NULL, true); -+ } -+ else /* re check again */ -+ { ++ } else{/* re check again */ + rtw_chk_hi_queue_cmd(padapter); + } + @@ -4806,13 +4940,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; @@ -4895,7 +5029,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + buf[1] = 0; + else if (cmd_idx == BTINFO_BT_AUTO_RPT) + buf[1] = 2; -+ rtw_btcoex_BtInfoNotify(adapter , len+1, &buf[1]); ++ rtw_btcoex_BtInfoNotify(adapter, len+1, &buf[1]); +} + +u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length) @@ -4905,13 +5039,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((u8 *)ph2c); + res = _FAIL; @@ -4940,13 +5074,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + -+ ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); ++ pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree((u8 *)ph2c); + res = _FAIL; @@ -4977,14 +5111,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + evtpriv->c2h_wk_alive = true; + + while (!rtw_cbuf_empty(evtpriv->c2h_queue)) { -+ if ((c2h_evt = (u8 *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) { ++ c2h_evt = (u8 *)rtw_cbuf_pop(evtpriv->c2h_queue); ++ if (c2h_evt != NULL) { + /* This C2H event is read, clear it */ + c2h_evt_clear(adapter); -+ } else if ((c2h_evt = (u8 *)rtw_malloc(16)) != NULL) { -+ /* This C2H event is not read, read & clear now */ -+ if (rtw_hal_c2h_evt_read(adapter, c2h_evt) != _SUCCESS) { -+ kfree(c2h_evt); -+ continue; ++ } else{ ++ c2h_evt = (u8 *)rtw_malloc(16); ++ if (c2h_evt != NULL) { ++ /* This C2H event is not read, read & clear now */ ++ if (rtw_hal_c2h_evt_read(adapter, c2h_evt) != _SUCCESS) { ++ kfree(c2h_evt); ++ continue; ++ } + } + } + @@ -5001,7 +5139,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + /* Handle CCX report here */ + rtw_hal_c2h_handler(adapter, c2h_evt); + kfree(c2h_evt); -+ } else { ++ } else{ + /* Enqueue into cmd_thread for others */ + rtw_c2h_wk_cmd(adapter, c2h_evt); + } @@ -5017,72 +5155,68 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + if (!pbuf) + return H2C_PARAMETERS_ERROR; + -+ pdrvextra_cmd = (struct drvextra_cmd_parm*)pbuf; ++ pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf; + -+ switch (pdrvextra_cmd->ec_id) -+ { -+ case DYNAMIC_CHK_WK_CID:/* only primary padapter go to this cmd, but execute dynamic_chk_wk_hdl() for two interfaces */ -+ dynamic_chk_wk_hdl(padapter); -+ break; -+ case POWER_SAVING_CTRL_WK_CID: -+ power_saving_wk_hdl(padapter); -+ break; -+ case LPS_CTRL_WK_CID: -+ lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type); -+ break; -+ case DM_IN_LPS_WK_CID: -+ rtw_dm_in_lps_hdl(padapter); -+ break; -+ case LPS_CHANGE_DTIM_CID: -+ rtw_lps_change_dtim_hdl(padapter, (u8)pdrvextra_cmd->type); -+ break; -+ case CHECK_HIQ_WK_CID: -+ rtw_chk_hi_queue_hdl(padapter); -+ break; ++ switch (pdrvextra_cmd->ec_id) { ++ case DYNAMIC_CHK_WK_CID:/* only primary padapter go to this cmd, but execute dynamic_chk_wk_hdl() for two interfaces */ ++ dynamic_chk_wk_hdl(padapter); ++ break; ++ case POWER_SAVING_CTRL_WK_CID: ++ power_saving_wk_hdl(padapter); ++ break; ++ case LPS_CTRL_WK_CID: ++ lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type); ++ break; ++ case DM_IN_LPS_WK_CID: ++ rtw_dm_in_lps_hdl(padapter); ++ break; ++ case LPS_CHANGE_DTIM_CID: ++ rtw_lps_change_dtim_hdl(padapter, (u8)pdrvextra_cmd->type); ++ break; ++ case CHECK_HIQ_WK_CID: ++ rtw_chk_hi_queue_hdl(padapter); ++ break; +#ifdef CONFIG_INTEL_WIDI -+ case INTEl_WIDI_WK_CID: -+ intel_widi_wk_hdl(padapter, pdrvextra_cmd->type, pdrvextra_cmd->pbuf); -+ break; ++ case INTEl_WIDI_WK_CID: ++ intel_widi_wk_hdl(padapter, pdrvextra_cmd->type, pdrvextra_cmd->pbuf); ++ break; +#endif /* CONFIG_INTEL_WIDI */ -+ /* add for CONFIG_IEEE80211W, none 11w can use it */ -+ case RESET_SECURITYPRIV: -+ reset_securitypriv_hdl(padapter); -+ break; -+ case FREE_ASSOC_RESOURCES: -+ free_assoc_resources_hdl(padapter); -+ break; -+ case C2H_WK_CID: -+ rtw_hal_set_hwreg_with_buf(padapter, HW_VAR_C2H_HANDLE, pdrvextra_cmd->pbuf, pdrvextra_cmd->size); -+ break; -+ case DM_RA_MSK_WK_CID: -+ rtw_dm_ra_mask_hdl(padapter, (struct sta_info *)pdrvextra_cmd->pbuf); -+ break; -+ case BTINFO_WK_CID: -+ rtw_btinfo_hdl(padapter , pdrvextra_cmd->pbuf, pdrvextra_cmd->size); -+ break; -+ default: -+ break; ++ /* add for CONFIG_IEEE80211W, none 11w can use it */ ++ case RESET_SECURITYPRIV: ++ reset_securitypriv_hdl(padapter); ++ break; ++ case FREE_ASSOC_RESOURCES: ++ free_assoc_resources_hdl(padapter); ++ break; ++ case C2H_WK_CID: ++ rtw_hal_set_hwreg_with_buf(padapter, HW_VAR_C2H_HANDLE, pdrvextra_cmd->pbuf, pdrvextra_cmd->size); ++ break; ++ case DM_RA_MSK_WK_CID: ++ rtw_dm_ra_mask_hdl(padapter, (struct sta_info *)pdrvextra_cmd->pbuf); ++ break; ++ case BTINFO_WK_CID: ++ rtw_btinfo_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->size); ++ break; ++ default: ++ break; + } + -+ if (pdrvextra_cmd->pbuf && pdrvextra_cmd->size>0) -+ { ++ if (pdrvextra_cmd->pbuf && pdrvextra_cmd->size > 0) { + kfree(pdrvextra_cmd->pbuf); + } + + return H2C_SUCCESS; +} + -+void rtw_survey_cmd_callback(struct adapter *padapter , struct cmd_obj *pcmd) ++void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + -+ if (pcmd->res == H2C_DROPPED) -+ { ++ if (pcmd->res == H2C_DROPPED) { + /* TODO: cancel timer and do timeout handler directly... */ + /* need to make timeout handlerOS independent */ + _set_timer(&pmlmepriv->scan_to_timer, 1); -+ } -+ else if (pcmd->res != H2C_SUCCESS) { ++ } else if (pcmd->res != H2C_SUCCESS) { + _set_timer(&pmlmepriv->scan_to_timer, 1); + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n.")); + } @@ -5095,8 +5229,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + -+ if (pcmd->res != H2C_SUCCESS) -+ { ++ if (pcmd->res != H2C_SUCCESS) { + spin_lock_bh(&pmlmepriv->lock); + set_fwstate(pmlmepriv, _FW_LINKED); + spin_unlock_bh(&pmlmepriv->lock); @@ -5112,14 +5245,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + -+ if (pcmd->res == H2C_DROPPED) -+ { ++ if (pcmd->res == H2C_DROPPED) { + /* TODO: cancel timer and do timeout handler directly... */ + /* need to make timeout handlerOS independent */ + _set_timer(&pmlmepriv->assoc_timer, 1); -+ } -+ else if (pcmd->res != H2C_SUCCESS) -+ { ++ } else if (pcmd->res != H2C_SUCCESS) { + _set_timer(&pmlmepriv->assoc_timer, 1); + } + @@ -5138,8 +5268,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + if (pcmd->parmbuf == NULL) + goto exit; + -+ if ((pcmd->res != H2C_SUCCESS)) -+ { ++ if ((pcmd->res != H2C_SUCCESS)) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: rtw_createbss_cmd_callback Fail ************\n\n.")); + _set_timer(&pmlmepriv->assoc_timer, 1); + } @@ -5149,38 +5278,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + spin_lock_bh(&pmlmepriv->lock); + + -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); -+ if (!psta) -+ { -+ psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); -+ if (psta == NULL) -+ { -+ RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when createbss_cmd_callback\n")); -+ goto createbss_cmd_fail ; -+ } ++ if (!psta) { ++ psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); ++ if (psta == NULL) { ++ RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when createbss_cmd_callback\n")); ++ goto createbss_cmd_fail; ++ } + } + + rtw_indicate_connect(padapter); -+ } -+ else -+ { ++ } else{ + pwlan = _rtw_alloc_network(pmlmepriv); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); -+ if (pwlan == NULL) -+ { ++ if (pwlan == NULL) { + pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue); -+ if (pwlan == NULL) -+ { ++ if (pwlan == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n Error: can't get pwlan in rtw_joinbss_event_callback\n")); + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + goto createbss_cmd_fail; + } + pwlan->last_scanned = jiffies; -+ } -+ else -+ { ++ } else{ + list_add_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); + } + @@ -5212,15 +5332,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + + + -+void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter , struct cmd_obj *pcmd) ++void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + -+ struct sta_priv * pstapriv = &padapter->stapriv; -+ struct set_stakey_rsp* psetstakey_rsp = (struct set_stakey_rsp*) (pcmd->rsp); -+ struct sta_info*psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); ++ struct sta_priv *pstapriv = &padapter->stapriv; ++ struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *) (pcmd->rsp); ++ struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); + -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: rtw_setstaKey_cmdrsp_callback => can't get sta_info\n\n")); + goto exit; + } @@ -5230,14 +5349,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa + +void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ -+ struct sta_priv * pstapriv = &padapter->stapriv; ++ struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -+ struct set_assocsta_parm* passocsta_parm = (struct set_assocsta_parm*)(pcmd->parmbuf); -+ struct set_assocsta_rsp* passocsta_rsp = (struct set_assocsta_rsp*) (pcmd->rsp); -+ struct sta_info*psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); ++ struct set_assocsta_parm *passocsta_parm = (struct set_assocsta_parm *)(pcmd->parmbuf); ++ struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *) (pcmd->rsp); ++ struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); + -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n\n")); + goto exit; + } @@ -5255,10 +5373,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_cmd.c linux-4.3-rtl8723bs/3rdpa +exit: + rtw_free_cmd_obj(pcmd); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_debug.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_debug.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1477 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_debug.c linux/3rdparty/rtl8723bs/core/rtw_debug.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_debug.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_debug.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1453 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -5331,8 +5449,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd +{ + int i; + -+ for (i = 0x0;i<= 0xff;i++) -+ { ++ for (i = 0x0; i <= 0xff; i++) { + if (i%16 == 0) + DBG_871X_SEL_NL(sel, "0x%02x ", i); + @@ -5340,7 +5457,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + + if (i%16 == 15) + DBG_871X_SEL(sel, "\n"); -+ else if (i%8 ==7) ++ else if (i%8 == 7) + DBG_871X_SEL(sel, "\t"); + } +} @@ -5351,8 +5468,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + + DBG_871X_SEL_NL(sel, "======= MAC REG =======\n"); + -+ for (i = 0x0;i<0x800;i+=4) -+ { ++ for (i = 0x0; i < 0x800; i += 4) { + if (j%4 == 1) + DBG_871X_SEL_NL(sel, "0x%03x", i); + DBG_871X_SEL(sel, " 0x%08x ", rtw_read32(adapter, i)); @@ -5366,8 +5482,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + int i, j = 1; + + DBG_871X_SEL_NL(sel, "======= BB REG =======\n"); -+ for (i = 0x800;i<0x1000;i+=4) -+ { ++ for (i = 0x800; i < 0x1000 ; i += 4) { + if (j%4 == 1) + DBG_871X_SEL_NL(sel, "0x%03x", i); + DBG_871X_SEL(sel, " 0x%08x ", rtw_read32(adapter, i)); @@ -5384,16 +5499,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + u8 path_nums = 0; + + rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); -+ if ((RF_1T2R == rf_type) ||(RF_1T1R ==rf_type)) ++ if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) + path_nums = 1; + else + path_nums = 2; + + DBG_871X_SEL_NL(sel, "======= RF REG =======\n"); + -+ for (path = 0;pathwep_sw_enc_cnt_bc , sec->wep_sw_enc_cnt_mc, sec->wep_sw_enc_cnt_uc); ++ , sec->wep_sw_enc_cnt_bc, sec->wep_sw_enc_cnt_mc, sec->wep_sw_enc_cnt_uc); + DBG_871X_SEL_NL(m, "wep_sw_dec_cnt =%llu, %llu, %llu\n" -+ , sec->wep_sw_dec_cnt_bc , sec->wep_sw_dec_cnt_mc, sec->wep_sw_dec_cnt_uc); ++ , sec->wep_sw_dec_cnt_bc, sec->wep_sw_dec_cnt_mc, sec->wep_sw_dec_cnt_uc); + + DBG_871X_SEL_NL(m, "tkip_sw_enc_cnt =%llu, %llu, %llu\n" -+ , sec->tkip_sw_enc_cnt_bc , sec->tkip_sw_enc_cnt_mc, sec->tkip_sw_enc_cnt_uc); ++ , sec->tkip_sw_enc_cnt_bc, sec->tkip_sw_enc_cnt_mc, sec->tkip_sw_enc_cnt_uc); + DBG_871X_SEL_NL(m, "tkip_sw_dec_cnt =%llu, %llu, %llu\n" -+ , sec->tkip_sw_dec_cnt_bc , sec->tkip_sw_dec_cnt_mc, sec->tkip_sw_dec_cnt_uc); ++ , sec->tkip_sw_dec_cnt_bc, sec->tkip_sw_dec_cnt_mc, sec->tkip_sw_dec_cnt_uc); + + DBG_871X_SEL_NL(m, "aes_sw_enc_cnt =%llu, %llu, %llu\n" -+ , sec->aes_sw_enc_cnt_bc , sec->aes_sw_enc_cnt_mc, sec->aes_sw_enc_cnt_uc); ++ , sec->aes_sw_enc_cnt_bc, sec->aes_sw_enc_cnt_mc, sec->aes_sw_enc_cnt_uc); + DBG_871X_SEL_NL(m, "aes_sw_dec_cnt =%llu, %llu, %llu\n" -+ , sec->aes_sw_dec_cnt_bc , sec->aes_sw_dec_cnt_mc, sec->aes_sw_dec_cnt_uc); ++ , sec->aes_sw_dec_cnt_bc, sec->aes_sw_dec_cnt_mc, sec->aes_sw_dec_cnt_uc); +#endif /* DBG_SW_SEC_CNT */ + + return 0; @@ -5725,25 +5836,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + return 0; + } + -+ DBG_871X_SEL_NL(m, "%5s %-17s %3s %-3s %-4s %-4s %5s %s\n","index", "bssid", "ch", "RSSI", "SdBm", "Noise", "age", "ssid"); -+ while (1) -+ { ++ DBG_871X_SEL_NL(m, "%5s %-17s %3s %-3s %-4s %-4s %5s %s\n", "index", "bssid", "ch", "RSSI", "SdBm", "Noise", "age", "ssid"); ++ while (1) { + if (phead == plist) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); -+ if (!pnetwork) ++ ++ if (!pnetwork) + break; + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true && + is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) { -+ notify_signal = translate_percentage_to_dbm(padapter->recvpriv.signal_strength);//dbm ++ notify_signal = translate_percentage_to_dbm(padapter->recvpriv.signal_strength);/*dbm*/ + } else { -+ notify_signal = translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength);//dbm ++ notify_signal = translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength);/*dbm*/ + } + + #if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR) -+ rtw_hal_get_odm_var(padapter, HAL_ODM_NOISE_MONITOR,&(pnetwork->network.Configuration.DSConfig), &(notify_noise)); ++ rtw_hal_get_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &(pnetwork->network.Configuration.DSConfig), &(notify_noise)); + #endif + + DBG_871X_SEL_NL(m, "%5d "MAC_FMT" %3d %3d %4d %4d %5d %s\n", @@ -5754,7 +5865,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + notify_signal, + notify_noise, + jiffies_to_msecs(jiffies - pnetwork->last_scanned), -+ //translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength), ++ /*translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength),*/ + pnetwork->network.Ssid.Ssid); + plist = get_next(plist); + } @@ -5774,8 +5885,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + struct sta_priv *pstapriv = &padapter->stapriv; + + psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); -+ if (psta) -+ { ++ if (psta) { + int i; + struct recv_reorder_ctrl *preorder_ctrl; + @@ -5790,18 +5900,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + DBG_871X_SEL_NL(m, "agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + DBG_871X_SEL_NL(m, "ldpc_cap = 0x%x, stbc_cap = 0x%x, beamform_cap = 0x%x\n", psta->htpriv.ldpc_cap, psta->htpriv.stbc_cap, psta->htpriv.beamform_cap); + -+ for (i = 0;i<16;i++) -+ { ++ for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; -+ if (preorder_ctrl->enable) -+ { ++ if (preorder_ctrl->enable) { + DBG_871X_SEL_NL(m, "tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq); + } + } + -+ } -+ else -+ { ++ } else{ + DBG_871X_SEL_NL(m, "can't get sta's macaddr, cur_network's macaddr:" MAC_FMT "\n", MAC_ARG(cur_network->network.MacAddress)); + } + @@ -5835,8 +5941,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + DBG_871X_SEL_NL(m, "free_recvframe_cnt =%d\n" + , precvpriv->free_recvframe_cnt); + -+ for (i = 0; i < 4; i++) -+ { ++ for (i = 0; i < 4; i++) { + phwxmit = pxmitpriv->hwxmits + i; + DBG_871X_SEL_NL(m, "%d, hwq.accnt =%d\n", i, phwxmit->accnt); + } @@ -6212,7 +6317,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + return 0; +} + -+#endif // CONFIG_DBG_COUNTER ++#endif /* CONFIG_DBG_COUNTER*/ + +int proc_get_rx_signal(struct seq_file *m, void *v) +{ @@ -6220,7 +6325,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + DBG_871X_SEL_NL(m, "rssi:%d\n", padapter->recvpriv.rssi); -+ //DBG_871X_SEL_NL(m, "rxpwdb:%d\n", padapter->recvpriv.rxpwdb); ++ /*DBG_871X_SEL_NL(m, "rxpwdb:%d\n", padapter->recvpriv.rxpwdb);*/ + DBG_871X_SEL_NL(m, "signal_strength:%u\n", padapter->recvpriv.signal_strength); + DBG_871X_SEL_NL(m, "signal_qual:%u\n", padapter->recvpriv.signal_qual); + DBG_871X_SEL_NL(m, "noise:%d\n", padapter->recvpriv.noise); @@ -6261,13 +6366,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + + is_signal_dbg = is_signal_dbg == 0?0:1; + -+ if (is_signal_dbg && num!=2) ++ if (is_signal_dbg && num != 2) + return count; + -+ signal_strength = signal_strength>100?100:signal_strength; ++ signal_strength = signal_strength > 100?100:signal_strength; + + padapter->recvpriv.is_signal_dbg = is_signal_dbg; -+ padapter->recvpriv.signal_strength_dbg =signal_strength; ++ padapter->recvpriv.signal_strength_dbg = signal_strength; + + if (is_signal_dbg) + DBG_871X("set %s %u\n", "DBG_SIGNAL_STRENGTH", signal_strength); @@ -6306,8 +6411,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + sscanf(tmp, "%d ", &mode); + -+ if (pregpriv && mode >= 0 && mode < 2) -+ { ++ if (pregpriv && mode >= 0 && mode < 2) { + pregpriv->ht_enable = mode; + printk("ht_enable =%d\n", pregpriv->ht_enable); + } @@ -6343,8 +6447,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + sscanf(tmp, "%d ", &mode); + -+ if (pregpriv && mode < 2) -+ { ++ if (pregpriv && mode < 2) { + + pregpriv->bw_mode = mode; + printk("bw_mode =%d\n", mode); @@ -6383,8 +6486,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + + sscanf(tmp, "%d ", &mode); + -+ if (pregpriv && mode < 3) -+ { ++ if (pregpriv && mode < 3) { + pregpriv->ampdu_enable = mode; + printk("ampdu_enable =%d\n", mode); + } @@ -6428,14 +6530,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + + sscanf(tmp, "%d ", &mode); + -+ if (pregpriv && mode >= 0 && mode < 2) -+ { ++ if (pregpriv && mode >= 0 && mode < 2) { + pmlmeinfo->bAcceptAddbaReq = mode; + DBG_871X("pmlmeinfo->bAcceptAddbaReq =%d\n", pmlmeinfo->bAcceptAddbaReq); -+ if (mode == 0) -+ { -+ //tear down Rx AMPDU -+ send_delba(padapter, 0, get_my_bssid(&(pmlmeinfo->network)));// recipient ++ if (mode == 0) { ++ /*tear down Rx AMPDU*/ ++ send_delba(padapter, 0, get_my_bssid(&(pmlmeinfo->network)));/* recipient*/ + } + } + @@ -6543,10 +6643,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + + if (enable) { + DBG_8192C("Linked info Function Enable\n"); -+ padapter->bLinkInfoDump = enable ; ++ padapter->bLinkInfoDump = enable; + } else { + DBG_8192C("Linked info Function Disable\n"); -+ padapter->bLinkInfoDump = 0 ; ++ padapter->bLinkInfoDump = 0; + } + } + return count; @@ -6658,18 +6758,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + + padapter = (struct adapter *)rtw_netdev_priv(dev); + -+// DBG_871X("+" FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); ++/* DBG_871X("+" FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter));*/ + -+ if (NULL == buffer) -+ { ++ if (NULL == buffer) { + DBG_871X(FUNC_ADPT_FMT ": input buffer is NULL!\n", + FUNC_ADPT_ARG(padapter)); + + return -EFAULT; + } + -+ if (count < 1) -+ { ++ if (count < 1) { + DBG_871X(FUNC_ADPT_FMT ": input length is 0!\n", + FUNC_ADPT_ARG(padapter)); + @@ -6680,8 +6778,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + if (num > (sizeof(tmp) - 1)) + num = (sizeof(tmp) - 1); + -+ if (copy_from_user(tmp, buffer, num)) -+ { ++ if (copy_from_user(tmp, buffer, num)) { + DBG_871X(FUNC_ADPT_FMT ": copy buffer from user space FAIL!\n", + FUNC_ADPT_ARG(padapter)); + @@ -6689,15 +6786,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd + } + + num = sscanf(tmp, "%x %x", module, module+1); -+ if (1 == num) -+ { ++ if (1 == num) { + if (0 == module[0]) + memset(module, 0, sizeof(module)); + else + memset(module, 0xFF, sizeof(module)); -+ } -+ else if (2 != num) -+ { ++ } else if (2 != num) { + DBG_871X(FUNC_ADPT_FMT ": input(\"%s\") format incorrect!\n", + FUNC_ADPT_ARG(padapter), tmp); + @@ -6736,10 +6830,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_debug.c linux-4.3-rtl8723bs/3rd +} + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_eeprom.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_eeprom.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,375 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_eeprom.c linux/3rdparty/rtl8723bs/core/rtw_eeprom.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_eeprom.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_eeprom.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,369 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -6760,7 +6854,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r +#include +#include + -+void up_clk(_adapter*padapter, u16 *x) ++void up_clk(_adapter *padapter, u16 *x) +{ +_func_enter_; + *x = *x | _EESK; @@ -6771,7 +6865,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + +} + -+void down_clk(_adapter *padapter, u16 *x ) ++void down_clk(_adapter *padapter, u16 *x) +{ +_func_enter_; + *x = *x & ~_EESK; @@ -6782,11 +6876,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + +void shift_out_bits(_adapter *padapter, u16 data, u16 count) +{ -+ u16 x,mask; ++ u16 x, mask; +_func_enter_; + -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + mask = 0x01 << (count - 1); @@ -6794,13 +6888,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + + x &= ~(_EEDO | _EEDI); + -+ do -+ { ++ do { + x &= ~_EEDI; -+ if(data & mask) ++ if (data & mask) + x |= _EEDI; -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + rtw_write8(padapter, EE_9346CR, (u8)x); @@ -6808,9 +6901,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + up_clk(padapter, &x); + down_clk(padapter, &x); + mask = mask >> 1; -+ } while(mask); -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ } while (mask); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + x &= ~_EEDI; @@ -6819,12 +6912,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r +_func_exit_; +} + -+u16 shift_in_bits (_adapter *padapter) ++u16 shift_in_bits(_adapter *padapter) +{ -+ u16 x,d=0,i; ++ u16 x, d = 0, i; +_func_enter_; -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + x = rtw_read8(padapter, EE_9346CR); @@ -6832,18 +6925,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + x &= ~(_EEDO | _EEDI); + d = 0; + -+ for(i=0; i<16; i++) -+ { ++ for (i = 0; i < 16; i++) { + d = d << 1; + up_clk(padapter, &x); -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + x = rtw_read8(padapter, EE_9346CR); + + x &= ~(_EEDI); -+ if(x & _EEDO) ++ if (x & _EEDO) + d |= 1; + + down_clk(padapter, &x); @@ -6854,14 +6946,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + return d; +} + -+void standby(_adapter *padapter ) ++void standby(_adapter *padapter) +{ + u8 x; +_func_enter_; + x = rtw_read8(padapter, EE_9346CR); + + x &= ~(_EECS | _EESK); -+ rtw_write8(padapter, EE_9346CR,x); ++ rtw_write8(padapter, EE_9346CR, x); + + udelay(CLOCK_RATE); + x |= _EECS; @@ -6870,17 +6962,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r +_func_exit_; +} + -+u16 wait_eeprom_cmd_done(_adapter* padapter) ++u16 wait_eeprom_cmd_done(_adapter *padapter) +{ + u8 x; -+ u16 i,res=false; ++ u16 i, res = false; +_func_enter_; -+ standby(padapter ); -+ for (i=0; i<200; i++) -+ { ++ standby(padapter); ++ for (i = 0; i < 200; i++) { + x = rtw_read8(padapter, EE_9346CR); + if (x & _EEDO) { -+ res=true; ++ res = true; + goto exit; + } + udelay(CLOCK_RATE); @@ -6894,24 +6985,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r +{ + u16 x; +_func_enter_; -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + x = rtw_read8(padapter, EE_9346CR); -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + x &= ~(_EECS | _EEDI); + rtw_write8(padapter, EE_9346CR, (u8)x); -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + up_clk(padapter, &x); -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + down_clk(padapter, &x); @@ -6933,72 +7024,71 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + + shift_out_bits(padapter, EEPROM_EWEN_OPCODE, 5); + -+ if(padapter->EepromAddressSize==8) //CF+ and SDIO ++ if (padapter->EepromAddressSize == 8) /*CF+ and SDIO*/ + shift_out_bits(padapter, 0, 6); -+ else //USB ++ else /*USB*/ + shift_out_bits(padapter, 0, 4); + + standby(padapter); + -+// Commented out by rcnjko, 2004.0 -+// // Erase this particular word. Write the erase opcode and register -+// // number in that order. The opcode is 3bits in length; reg is 6 bits long. -+// shift_out_bits(Adapter, EEPROM_ERASE_OPCODE, 3); -+// shift_out_bits(Adapter, reg, Adapter->EepromAddressSize); -+// -+// if (wait_eeprom_cmd_done(Adapter ) == false) -+// { -+// return; -+// } ++/* Commented out by rcnjko, 2004.0 ++* Erase this particular word. Write the erase opcode and register ++* number in that order. The opcode is 3bits in length; reg is 6 bits long. ++* shift_out_bits(Adapter, EEPROM_ERASE_OPCODE, 3); ++* shift_out_bits(Adapter, reg, Adapter->EepromAddressSize); ++* ++* if (wait_eeprom_cmd_done(Adapter ) == false) ++* { ++* return; ++* } ++*/ + ++ standby(padapter); + -+ standby(padapter ); ++ /* write the new word to the EEPROM*/ + -+ // write the new word to the EEPROM -+ -+ // send the write opcode the EEPORM ++ /* send the write opcode the EEPORM*/ + shift_out_bits(padapter, EEPROM_WRITE_OPCODE, 3); + -+ // select which word in the EEPROM that we are writing to. ++ /* select which word in the EEPROM that we are writing to.*/ + shift_out_bits(padapter, reg, padapter->EepromAddressSize); + -+ // write the data to the selected EEPROM word. ++ /* write the data to the selected EEPROM word.*/ + shift_out_bits(padapter, data, 16); + -+ if (wait_eeprom_cmd_done(padapter ) == false) -+ { ++ if (wait_eeprom_cmd_done(padapter) == false) { + + goto exit; + } + -+ standby(padapter ); ++ standby(padapter); + + shift_out_bits(padapter, EEPROM_EWDS_OPCODE, 5); + shift_out_bits(padapter, reg, 4); + -+ eeprom_clean(padapter ); ++ eeprom_clean(padapter); +exit: +_func_exit_; + return; +} + -+u16 eeprom_read16(_adapter *padapter, u16 reg) //ReadEEprom ++u16 eeprom_read16(_adapter *padapter, u16 reg) /*ReadEEprom*/ +{ + + u16 x; -+ u16 data=0; ++ u16 data = 0; + +_func_enter_; + -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } -+ // select EEPROM, reset bits, set _EECS ++ /* select EEPROM, reset bits, set _EECS*/ + x = rtw_read8(padapter, EE_9346CR); + -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + @@ -7006,12 +7096,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + x |= _EEM1 | _EECS; + rtw_write8(padapter, EE_9346CR, (unsigned char)x); + -+ // write the read opcode and register number in that order -+ // The opcode is 3bits in length, reg is 6 bits long ++ /* write the read opcode and register number in that order*/ ++ /* The opcode is 3bits in length, reg is 6 bits long*/ + shift_out_bits(padapter, EEPROM_READ_OPCODE, 3); + shift_out_bits(padapter, reg, padapter->EepromAddressSize); + -+ // Now read the data (16 bits) in from the selected EEPROM word ++ /* Now read the data (16 bits) in from the selected EEPROM word*/ + data = shift_in_bits(padapter); + + eeprom_clean(padapter); @@ -7025,22 +7115,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + + + -+//From even offset ++/*From even offset*/ +void eeprom_read_sz(_adapter *padapter, u16 reg, u8 *data, u32 sz) +{ + + u16 x, data16; + u32 i; +_func_enter_; -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } -+ // select EEPROM, reset bits, set _EECS ++ /* select EEPROM, reset bits, set _EECS*/ + x = rtw_read8(padapter, EE_9346CR); + -+ if(padapter->bSurpriseRemoved==true) { -+ RT_TRACE(_module_rtl871x_eeprom_c_,_drv_err_,("padapter->bSurpriseRemoved==true")); ++ if (padapter->bSurpriseRemoved == true) { ++ RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); + goto out; + } + @@ -7048,17 +7138,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + x |= _EEM1 | _EECS; + rtw_write8(padapter, EE_9346CR, (unsigned char)x); + -+ // write the read opcode and register number in that order -+ // The opcode is 3bits in length, reg is 6 bits long ++ /* write the read opcode and register number in that order*/ ++ /* The opcode is 3bits in length, reg is 6 bits long*/ + shift_out_bits(padapter, EEPROM_READ_OPCODE, 3); + shift_out_bits(padapter, reg, padapter->EepromAddressSize); + + -+ for(i=0; i>8; ++ data[i+1] = data16 >> 8; + } + + eeprom_clean(padapter); @@ -7070,34 +7159,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r +} + + -+//addr_off : address offset of the entry in eeprom (not the tuple number of eeprom (reg); that is addr_off !=reg) ++/*addr_off : address offset of the entry in eeprom (not the tuple number of eeprom (reg); that is addr_off !=reg)*/ +u8 eeprom_read(_adapter *padapter, u32 addr_off, u8 sz, u8 *rbuf) +{ + u8 quotient, remainder, addr_2align_odd; -+ u16 reg, stmp , i=0, idx = 0; ++ u16 reg, stmp, i = 0, idx = 0; +_func_enter_; + reg = (u16)(addr_off >> 1); + addr_2align_odd = (u8)(addr_off & 0x1); + -+ if(addr_2align_odd) //read that start at high part: e.g 1,3,5,7,9,... -+ { ++ /*read that start at high part: e.g 1,3,5,7,9,...*/ ++ if (addr_2align_odd) { + stmp = eeprom_read16(padapter, reg); -+ rbuf[idx++] = (u8) ((stmp>>8)&0xff); //return hogh-part of the short ++ rbuf[idx++] = (u8) ((stmp>>8)&0xff); /*return hogh-part of the short*/ + reg++; sz--; + } + + quotient = sz >> 1; + remainder = sz & 0x1; + -+ for(i=0 ; i < quotient; i++) -+ { ++ for (i = 0; i < quotient; i++) { + stmp = eeprom_read16(padapter, reg+i); + rbuf[idx++] = (u8) (stmp&0xff); + rbuf[idx++] = (u8) ((stmp>>8)&0xff); + } + + reg = reg+i; -+ if(remainder) { //end of read at lower part of short : 0,2,4,6,... ++ if (remainder) { /*end of read at lower part of short : 0,2,4,6,...*/ + stmp = eeprom_read16(padapter, reg); + rbuf[idx] = (u8)(stmp & 0xff); + } @@ -7115,10 +7203,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_eeprom.c linux-4.3-rtl8723bs/3r + +_func_exit_; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_efuse.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_efuse.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,654 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_efuse.c linux/3rdparty/rtl8723bs/core/rtw_efuse.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_efuse.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_efuse.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,635 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -7144,19 +7232,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd +/*------------------------Define local variable------------------------------*/ +u8 fakeEfuseBank = 0; +u32 fakeEfuseUsedBytes = 0; -+u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE]={0}; -+u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN]={0}; -+u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN]={0}; ++u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE] = {0}; ++u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN] = {0}; ++u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN] = {0}; + +u32 BTEfuseUsedBytes = 0; +u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; -+u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0}; -+u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0}; ++u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; ++u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; + +u32 fakeBTEfuseUsedBytes = 0; +u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; -+u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]={0}; -+u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]={0}; ++u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; ++u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; +/*------------------------Define local variable------------------------------*/ + +/* */ @@ -7168,15 +7256,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd +Efuse_Read1ByteFromFakeContent( + struct adapter *padapter, + u16 Offset, -+ u8 *Value ); ++ u8 *Value); +bool +Efuse_Read1ByteFromFakeContent( + struct adapter *padapter, + u16 Offset, -+ u8 *Value ) ++ u8 *Value) +{ -+ if (Offset >= EFUSE_MAX_HW_SIZE) -+ { ++ if (Offset >= EFUSE_MAX_HW_SIZE) { + return false; + } + /* DbgPrint("Read fake content, offset = %d\n", Offset); */ @@ -7191,21 +7278,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd +Efuse_Write1ByteToFakeContent( + struct adapter *padapter, + u16 Offset, -+ u8 Value ); ++ u8 Value); +bool +Efuse_Write1ByteToFakeContent( + struct adapter *padapter, + u16 Offset, -+ u8 Value ) ++ u8 Value) +{ -+ if (Offset >= EFUSE_MAX_HW_SIZE) -+ { ++ if (Offset >= EFUSE_MAX_HW_SIZE) { + return false; + } + if (fakeEfuseBank == 0) + fakeEfuseContent[Offset] = Value; -+ else -+ { ++ else{ + fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value; + } + return true; @@ -7256,7 +7341,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + *---------------------------------------------------------------------------*/ +u16 +Efuse_GetCurrentSize( -+ struct adapter * padapter, ++ struct adapter *padapter, + u8 efuseType, + bool bPseudoTest) +{ @@ -7272,10 +7357,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd +Efuse_CalculateWordCnts(u8 word_en) +{ + u8 word_cnts = 0; -+ if (!(word_en & BIT(0))) word_cnts++; /* 0 : write enable */ -+ if (!(word_en & BIT(1))) word_cnts++; -+ if (!(word_en & BIT(2))) word_cnts++; -+ if (!(word_en & BIT(3))) word_cnts++; ++ if (!(word_en & BIT(0))) ++ word_cnts++; /* 0 : write enable */ ++ if (!(word_en & BIT(1))) ++ word_cnts++; ++ if (!(word_en & BIT(2))) ++ word_cnts++; ++ if (!(word_en & BIT(3))) ++ word_cnts++; + return word_cnts; +} + @@ -7358,10 +7447,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + u32 k = 0; + u16 contentLen = 0; + -+ EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false); ++ EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false); + -+ if (Address < contentLen) /* E-fuse 512Byte */ -+ { ++ if (Address < contentLen) {/* E-fuse 512Byte */ + /* Write E-fuse Register address bit0~7 */ + temp = Address & 0xFF; + rtw_write8(Adapter, EFUSE_CTRL+1, temp); @@ -7377,23 +7465,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + + /* Wait Write-ready (0x30[31]= 1) */ + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); -+ while (!(Bytetemp & 0x80)) -+ { ++ while (!(Bytetemp & 0x80)) { + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + k++; -+ if (k == 1000) -+ { ++ if (k == 1000) { + k = 0; + break; + } + } -+ data =rtw_read8(Adapter, EFUSE_CTRL); ++ data = rtw_read8(Adapter, EFUSE_CTRL); + return data; -+ } -+ else ++ } else + return 0xFF; + -+}/* EFUSE_Read1Byte */ ++} /* EFUSE_Read1Byte */ + +/* 11/16/2008 MH Read one byte from real Efuse. */ +u8 @@ -7410,8 +7495,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + /* DBG_871X("===> EFUSE_OneByteRead(), addr = %x\n", addr); */ + /* DBG_871X("===> EFUSE_OneByteRead() start, 0x34 = 0x%X\n", rtw_read32(padapter, EFUSE_TEST)); */ + -+ if (bPseudoTest) -+ { ++ if (bPseudoTest) { + bResult = Efuse_Read1ByteFromFakeContent(padapter, addr, data); + return bResult; + } @@ -7419,12 +7503,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + /* <20130121, Kordan> For SMIC EFUSE specificatoin. */ + /* 0x34[11]: SW force PGMEN input of efuse to high. (for the bank selected by 0x34[9:8]) */ + /* PHY_SetMacReg(padapter, 0x34, BIT11, 0); */ -+ rtw_write16(padapter, 0x34, rtw_read16(padapter, 0x34)& (~BIT11)); ++ rtw_write16(padapter, 0x34, rtw_read16(padapter, 0x34) & (~BIT11)); + + /* -----------------e-fuse reg ctrl --------------------------------- */ + /* address */ + rtw_write8(padapter, EFUSE_CTRL+1, (u8)(addr&0xff)); -+ rtw_write8(padapter, EFUSE_CTRL+2, ((u8)((addr>>8) &0x03)) | ++ rtw_write8(padapter, EFUSE_CTRL+2, ((u8)((addr>>8) & 0x03)) | + (rtw_read8(padapter, EFUSE_CTRL+2)&0xFC)); + + /* rtw_write8(padapter, EFUSE_CTRL+3, 0x72); read cmd */ @@ -7432,18 +7516,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + readbyte = rtw_read8(padapter, EFUSE_CTRL+3); + rtw_write8(padapter, EFUSE_CTRL+3, (readbyte & 0x7f)); + -+ while (!(0x80 &rtw_read8(padapter, EFUSE_CTRL+3)) && (tmpidx<1000)) -+ { ++ while (!(0x80 & rtw_read8(padapter, EFUSE_CTRL+3)) && (tmpidx < 1000)) { + mdelay(1); + tmpidx++; + } -+ if (tmpidx<100) -+ { -+ *data =rtw_read8(padapter, EFUSE_CTRL); ++ if (tmpidx < 100) { ++ *data = rtw_read8(padapter, EFUSE_CTRL); + bResult = true; -+ } -+ else -+ { ++ } else{ + *data = 0xff; + bResult = false; + DBG_871X("%s: [ERROR] addr = 0x%x bResult =%d time out 1s !!!\n", __func__, addr, bResult); @@ -7462,14 +7542,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd +bool bPseudoTest) +{ + u8 tmpidx = 0; -+ u8 bResult =false; ++ u8 bResult = false; + u32 efuseValue = 0; + + /* DBG_871X("===> EFUSE_OneByteWrite(), addr = %x data =%x\n", addr, data); */ + /* DBG_871X("===> EFUSE_OneByteWrite() start, 0x34 = 0x%X\n", rtw_read32(padapter, EFUSE_TEST)); */ + -+ if (bPseudoTest) -+ { ++ if (bPseudoTest) { + bResult = Efuse_Write1ByteToFakeContent(padapter, addr, data); + return bResult; + } @@ -7490,20 +7569,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + /* <20130121, Kordan> For SMIC EFUSE specificatoin. */ + /* 0x34[11]: SW force PGMEN input of efuse to high. (for the bank selected by 0x34[9:8]) */ + /* PHY_SetMacReg(padapter, 0x34, BIT11, 1); */ -+ rtw_write16(padapter, 0x34, rtw_read16(padapter, 0x34)| (BIT11)); ++ rtw_write16(padapter, 0x34, rtw_read16(padapter, 0x34) | (BIT11)); + rtw_write32(padapter, EFUSE_CTRL, 0x90600000|((addr<<8 | data))); + -+ while ((0x80 & rtw_read8(padapter, EFUSE_CTRL+3)) && (tmpidx<100)) { ++ while ((0x80 & rtw_read8(padapter, EFUSE_CTRL+3)) && (tmpidx < 100)) { + mdelay(1); + tmpidx++; + } + -+ if (tmpidx<100) -+ { ++ if (tmpidx < 100) { + bResult = true; -+ } -+ else -+ { ++ } else{ + bResult = false; + DBG_871X("%s: [ERROR] addr = 0x%x , efuseValue = 0x%x , bResult =%d time out 1s !!!\n", + __func__, addr, efuseValue, bResult); @@ -7565,23 +7641,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + u8 *sourdata, + u8 *targetdata) +{ -+ if (!(word_en&BIT(0))) -+ { ++ if (!(word_en&BIT(0))) { + targetdata[0] = sourdata[0]; + targetdata[1] = sourdata[1]; + } -+ if (!(word_en&BIT(1))) -+ { ++ if (!(word_en&BIT(1))) { + targetdata[2] = sourdata[2]; + targetdata[3] = sourdata[3]; + } -+ if (!(word_en&BIT(2))) -+ { ++ if (!(word_en&BIT(2))) { + targetdata[4] = sourdata[4]; + targetdata[5] = sourdata[5]; + } -+ if (!(word_en&BIT(3))) -+ { ++ if (!(word_en&BIT(3))) { + targetdata[6] = sourdata[6]; + targetdata[7] = sourdata[7]; + } @@ -7728,18 +7800,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + + EFUSE_GetEfuseDefinition(padapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, bPseudoTest); + -+ if (pEEPROM->bautoload_fail_flag == true) -+ { ++ if (pEEPROM->bautoload_fail_flag == true) { + memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen); -+ } -+ else -+ { ++ } else{ + Efuse_ReadAllMap(padapter, efuseType, pEEPROM->efuse_eeprom_data, bPseudoTest); + } + + /* PlatformMoveMemory((void *)&pHalData->EfuseMap[EFUSE_MODIFY_MAP][0], */ + /* void *)&pHalData->EfuseMap[EFUSE_INIT_MAP][0], mapLen); */ -+}/* EFUSE_ShadowMapUpdate */ ++} /* EFUSE_ShadowMapUpdate */ + + +/*----------------------------------------------------------------------------- @@ -7763,7 +7832,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + struct adapter *padapter, + u8 Type, + u16 Offset, -+ u32 *Value ) ++ u32 *Value) +{ + if (Type == 1) + efuse_ShadowRead1Byte(padapter, Offset, (u8 *)Value); @@ -7772,11 +7841,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_efuse.c linux-4.3-rtl8723bs/3rd + else if (Type == 4) + efuse_ShadowRead4Byte(padapter, Offset, (u32 *)Value); + -+} // EFUSE_ShadowRead -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_ieee80211.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_ieee80211.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1488 @@ ++} /* EFUSE_ShadowRead*/ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux/3rdparty/rtl8723bs/core/rtw_ieee80211.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_ieee80211.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_ieee80211.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1433 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -7822,26 +7891,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs +/* for adhoc-master to generate ie and provide supported-rate to fw */ +/* */ + -+static u8 WIFI_CCKRATES[] = -+{(IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK), -+ (IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK), -+ (IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK), -+ (IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK)}; ++static u8 WIFI_CCKRATES[] = { ++ (IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK), ++ (IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK), ++ (IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK), ++ (IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK) ++}; + -+static u8 WIFI_OFDMRATES[] = -+{(IEEE80211_OFDM_RATE_6MB), -+ (IEEE80211_OFDM_RATE_9MB), -+ (IEEE80211_OFDM_RATE_12MB), -+ (IEEE80211_OFDM_RATE_18MB), -+ (IEEE80211_OFDM_RATE_24MB), -+ IEEE80211_OFDM_RATE_36MB, -+ IEEE80211_OFDM_RATE_48MB, -+ IEEE80211_OFDM_RATE_54MB}; ++static u8 WIFI_OFDMRATES[] = { ++ (IEEE80211_OFDM_RATE_6MB), ++ (IEEE80211_OFDM_RATE_9MB), ++ (IEEE80211_OFDM_RATE_12MB), ++ (IEEE80211_OFDM_RATE_18MB), ++ (IEEE80211_OFDM_RATE_24MB), ++ IEEE80211_OFDM_RATE_36MB, ++ IEEE80211_OFDM_RATE_48MB, ++ IEEE80211_OFDM_RATE_54MB ++}; + + +int rtw_get_bit_value_from_ieee_value(u8 val) +{ -+ unsigned char dot11_rate_table[]={2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0}; /* last element must be zero!! */ ++ unsigned char dot11_rate_table[] = {2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108, 0}; /* last element must be zero!! */ + + int i = 0; + while (dot11_rate_table[i] != 0) { @@ -7856,8 +7927,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs +{ + u32 i = 0; + -+ while (rate[i]!= 0) -+ { ++ while (rate[i] != 0) { + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + return true; @@ -7872,8 +7942,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + u32 i = 0; + + -+ while (rate[i]!= 0) -+ { ++ while (rate[i] != 0) { + if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && + (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + @@ -7888,15 +7957,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + +int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) +{ -+ if (channel > 14) -+ { ++ if (channel > 14) { + if ((rtw_is_cckrates_included(rate)) == true) + return WIRELESS_INVALID; + else + return WIRELESS_11A; -+ } -+ else /* could be pure B, pure G, or B/G */ -+ { ++ } else{ /* could be pure B, pure G, or B/G */ + if ((rtw_is_cckratesonly_included(rate)) == true) + return WIRELESS_11B; + else if ((rtw_is_cckrates_included(rate)) == true) @@ -7952,15 +8018,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + p = pbuf; + i = 0; + *len = 0; -+ while (1) -+ { -+ if (*p == index) -+ { ++ while (1) { ++ if (*p == index) { + *len = *(p + 1); -+ return (p); -+ } -+ else -+ { ++ return p; ++ } else{ + tmp = *(p + 1); + p += (tmp + 2); + i += (tmp + 2); @@ -7992,16 +8054,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + if (ielen) + *ielen = 0; + -+ if (!in_ie || in_len<= 0) ++ if (!in_ie || in_len <= 0) + return target_ie; + + cnt = 0; + -+ while (cntdev_network; -+ u8*ie = pdev_network->IEs; ++ struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; ++ u8 *ie = pdev_network->IEs; + + /* timestamp will be inserted by hardware */ + sz += 8; + ie += sz; + + /* beacon interval : 2bytes */ -+ *(__le16*)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);/* BCN_INTERVAL; */ ++ *(__le16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);/* BCN_INTERVAL; */ + sz += 2; + ie += 2; + + /* capability info */ -+ *(u16*)ie = 0; ++ *(u16 *)ie = 0; + -+ *(__le16*)ie |= cpu_to_le16(cap_IBSS); ++ *(__le16 *)ie |= cpu_to_le16(cap_IBSS); + + if (pregistrypriv->preamble == PREAMBLE_SHORT) -+ *(__le16*)ie |= cpu_to_le16(cap_ShortPremble); ++ *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble); + + if (pdev_network->Privacy) -+ *(__le16*)ie |= cpu_to_le16(cap_Privacy); ++ *(__le16 *)ie |= cpu_to_le16(cap_Privacy); + + sz += 2; + ie += 2; @@ -8149,29 +8205,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz); + + /* supported rates */ -+ if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) -+ { ++ if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) { + if (pdev_network->Configuration.DSConfig > 14) + wireless_mode = WIRELESS_11A_5N; + else + wireless_mode = WIRELESS_11BG_24N; -+ } -+ else -+ { ++ } else{ + wireless_mode = pregistrypriv->wireless_mode; + } + -+ rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode) ; ++ rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode); + + rateLen = rtw_get_rateset_len(pdev_network->SupportedRates); + -+ if (rateLen > 8) -+ { ++ if (rateLen > 8) { + ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz); + /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ -+ } -+ else -+ { ++ } else{ + ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz); + } + @@ -8183,15 +8233,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + + ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); + -+ if (rateLen > 8) -+ { ++ if (rateLen > 8) { + ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); + } + + /* HT Cap. */ -+ if (((pregistrypriv->wireless_mode&WIRELESS_11_5N)||(pregistrypriv->wireless_mode&WIRELESS_11_24N)) -+ && (pregistrypriv->ht_enable ==true)) -+ { ++ if (((pregistrypriv->wireless_mode&WIRELESS_11_5N) || (pregistrypriv->wireless_mode&WIRELESS_11_24N)) ++ && (pregistrypriv->ht_enable == true)) { + /* todo: */ + } + @@ -8211,14 +8259,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + int limit_new = limit; + __le16 le_tmp; + -+ while (1) -+ { ++ while (1) { + pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new); + + if (pbuf) { + + /* check if oui matches... */ -+ if (memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type))) { ++ if (memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type))) { + + goto check_next_ie; + } @@ -8234,8 +8281,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + + return pbuf; + -+ } -+ else { ++ } else{ + + *wpa_ie_len = 0; + return NULL; @@ -8312,8 +8358,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + + + if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || -+ (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) -+ { ++ (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) { + return _FAIL; + } + @@ -8331,9 +8376,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + pos += WPA_SELECTOR_LEN; + left -= WPA_SELECTOR_LEN; + -+ } -+ else if (left > 0) -+ { ++ } else if (left > 0) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); + + return _FAIL; @@ -8341,9 +8384,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + + + /* pairwise_cipher */ -+ if (left >= 2) -+ { -+ /* count = le16_to_cpu(*(u16*)pos); */ ++ if (left >= 2) { ++ /* count = le16_to_cpu(*(u16*)pos); */ + count = RTW_GET_LE16(pos); + pos += 2; + left -= 2; @@ -8354,17 +8396,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + return _FAIL; + } + -+ for (i = 0; i < count; i++) -+ { ++ for (i = 0; i < count; i++) { + *pairwise_cipher |= rtw_get_wpa_cipher_suite(pos); + + pos += WPA_SELECTOR_LEN; + left -= WPA_SELECTOR_LEN; + } + -+ } -+ else if (left == 1) -+ { ++ } else if (left == 1) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); + return _FAIL; + } @@ -8396,8 +8435,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + } + + -+ if ((*rsn_ie!= _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) -+ { ++ if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) { + return _FAIL; + } + @@ -8419,9 +8457,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + } + + /* pairwise_cipher */ -+ if (left >= 2) -+ { -+ /* count = le16_to_cpu(*(u16*)pos); */ ++ if (left >= 2) { ++ /* count = le16_to_cpu(*(u16*)pos); */ + count = RTW_GET_LE16(pos); + pos += 2; + left -= 2; @@ -8432,17 +8469,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + return _FAIL; + } + -+ for (i = 0; i < count; i++) -+ { ++ for (i = 0; i < count; i++) { + *pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos); + + pos += RSN_SELECTOR_LEN; + left -= RSN_SELECTOR_LEN; + } + -+ } -+ else if (left == 1) -+ { ++ } else if (left == 1) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); + + return _FAIL; @@ -8468,29 +8502,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + int len = 0; + u8 authmode, i; + uint cnt; -+ u8 wapi_oui1[4]={0x0, 0x14, 0x72, 0x01}; -+ u8 wapi_oui2[4]={0x0, 0x14, 0x72, 0x02}; ++ u8 wapi_oui1[4] = {0x0, 0x14, 0x72, 0x01}; ++ u8 wapi_oui2[4] = {0x0, 0x14, 0x72, 0x02}; + + if (wapi_len) + *wapi_len = 0; + -+ if (!in_ie || in_len<= 0) ++ if (!in_ie || in_len <= 0) + return len; + + cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); + -+ while (cnt found WPS_IE.....\n"); */ + *wps_ielen = ie_ptr[1]+2; -+ match =true; ++ match = true; + } + return match; +} @@ -8607,22 +8632,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs +{ + uint cnt; + u8 *wpsie_ptr = NULL; -+ u8 eid, wps_oui[4]={0x0, 0x50, 0xf2, 0x04}; ++ u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + if (wps_ielen) + *wps_ielen = 0; + -+ if (!in_ie || in_len<= 0) ++ if (!in_ie || in_len <= 0) + return wpsie_ptr; + + cnt = 0; + -+ while (cnt='0') && (ch<='9')) -+ return ch - '0'; -+ else if ((ch>='a') && (ch<='f')) -+ return ch - 'a' + 10; -+ else if ((ch>='A') && (ch<='F')) -+ return ch - 'A' + 10; -+ else -+ return 0xff; ++ if ((ch >= '0') && (ch <= '9')) ++ return ch - '0'; ++ else if ((ch >= 'a') && (ch <= 'f')) ++ return ch - 'a' + 10; ++ else if ((ch >= 'A') && (ch <= 'F')) ++ return ch - 'A' + 10; ++ else ++ return 0xff; +} + +u8 key_2char2num(u8 hch, u8 lch); +u8 key_2char2num(u8 hch, u8 lch) +{ -+ return ((key_char2num(hch) << 4) | key_char2num(lch)); ++ return ((key_char2num(hch) << 4) | key_char2num(lch)); +} + -+void rtw_macaddr_cfg(u8 *mac_addr) ++void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) +{ + u8 mac[ETH_ALEN]; -+ if (mac_addr == NULL) return; ++ struct device_node *np = dev->of_node; ++ const unsigned char *addr; ++ int len; + -+ if (rtw_initmac) -+ { /* Users specify the mac address */ ++ if (mac_addr == NULL) ++ return; ++ ++ if (rtw_initmac) { /* Users specify the mac address */ + int jj, kk; + -+ for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) -+ { -+ mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk+ 1]); ++ for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) { ++ mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]); + } + memcpy(mac_addr, mac, ETH_ALEN); -+ } -+ else -+ { /* Use the mac address stored in the Efuse */ ++ } else{ /* Use the mac address stored in the Efuse */ + memcpy(mac, mac_addr, ETH_ALEN); + } + -+ if (((mac[0]== 0xff) && (mac[1]== 0xff) && (mac[2]== 0xff) && -+ (mac[3]== 0xff) && (mac[4]== 0xff) && (mac[5]== 0xff)) || -+ ((mac[0]== 0x0) && (mac[1]== 0x0) && (mac[2]== 0x0) && -+ (mac[3]== 0x0) && (mac[4]== 0x0) && (mac[5]== 0x0))) -+ { -+ mac[0] = 0x00; -+ mac[1] = 0xe0; -+ mac[2] = 0x4c; -+ mac[3] = 0x87; -+ mac[4] = 0x00; -+ mac[5] = 0x00; -+ /* use default mac addresss */ -+ memcpy(mac_addr, mac, ETH_ALEN); -+ DBG_871X("MAC Address from efuse error, assign default one !!!\n"); ++ if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) && ++ (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) || ++ ((mac[0] == 0x00) && (mac[1] == 0x00) && (mac[2] == 0x00) && ++ (mac[3] == 0x00) && (mac[4] == 0x00) && (mac[5] == 0x00))) { ++ if (np && ++ (addr = of_get_property(np, "local-mac-address", &len)) && ++ len == ETH_ALEN) { ++ memcpy(mac_addr, addr, ETH_ALEN); ++ } else { ++ mac[0] = 0x00; ++ mac[1] = 0xe0; ++ mac[2] = 0x4c; ++ mac[3] = 0x87; ++ mac[4] = 0x00; ++ mac[5] = 0x00; ++ /* use default mac addresss */ ++ memcpy(mac_addr, mac, ETH_ALEN); ++ DBG_871X("MAC Address from efuse error, assign default one !!!\n"); ++ } + } + + DBG_871X("rtw_macaddr_cfg MAC Address = "MAC_FMT"\n", MAC_ARG(mac_addr)); @@ -9047,7 +9068,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + int ret = _FAIL; + pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + -+ if (pbuf && (wpa_ielen>0)) { ++ if (pbuf && (wpa_ielen > 0)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen)); + if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { + @@ -9062,7 +9083,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + + pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + -+ if (pbuf && (wpa_ielen>0)) { ++ if (pbuf && (wpa_ielen > 0)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE\n")); + if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE OK!!!\n")); @@ -9100,7 +9121,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + } else { + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; + } -+ rtw_get_sec_ie(pnetwork->network.IEs , pnetwork->network.IELength, NULL,&rsn_len, NULL,&wpa_len); ++ rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); @@ -9123,7 +9144,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + /* get bwmode and ch_offset */ + /* parsing HT_CAP_IE */ + p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); -+ if (p && len>0) { ++ if (p && len > 0) { + pht_cap = (struct ieee80211_ht_cap *)(p + 2); + pnetwork->BcnInfo.ht_cap_info = le16_to_cpu(pht_cap->cap_info); + } else { @@ -9131,7 +9152,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + } + /* parsing HT_INFO_IE */ + p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); -+ if (p && len>0) { ++ if (p && len > 0) { + pht_info = (struct HT_info_element *)(p + 2); + pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; + } else { @@ -9140,12 +9161,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs +} + +/* show MCS rate, unit: 100Kbps */ -+u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char * MCS_rate) ++u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate) +{ + u16 max_rate = 0; + -+ if (rf_type == RF_1T1R) -+ { ++ if (rf_type == RF_1T1R) { + if (MCS_rate[0] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI)?1500:1350):((short_GI)?722:650); + else if (MCS_rate[0] & BIT(6)) @@ -9162,11 +9182,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); + else if (MCS_rate[0] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); -+ } -+ else -+ { -+ if (MCS_rate[1]) -+ { ++ } else{ ++ if (MCS_rate[1]) { + if (MCS_rate[1] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI)?3000:2700):((short_GI)?1444:1300); + else if (MCS_rate[1] & BIT(6)) @@ -9183,9 +9200,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + max_rate = (bw_40MHz) ? ((short_GI)?600:540):((short_GI)?289:260); + else if (MCS_rate[1] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); -+ } -+ else -+ { ++ } else{ + if (MCS_rate[0] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI)?1500:1350):((short_GI)?722:650); + else if (MCS_rate[0] & BIT(6)) @@ -9218,8 +9233,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + + if ((fc & (RTW_IEEE80211_FCTL_FTYPE|RTW_IEEE80211_FCTL_STYPE)) + != (RTW_IEEE80211_FTYPE_MGMT|RTW_IEEE80211_STYPE_ACTION) -+ ) -+ { ++ ) { + return false; + } + @@ -9265,9 +9279,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ieee80211.c linux-4.3-rtl8723bs + action = (action >= ACT_PUBLIC_MAX) ? ACT_PUBLIC_MAX : action; + return _action_public_str[action]; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_io.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_io.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_io.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_io.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_io.c linux/3rdparty/rtl8723bs/core/rtw_io.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_io.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_io.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,203 @@ +/****************************************************************************** + * @@ -9442,7 +9456,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_io.c linux-4.3-rtl8723bs/3rdpar + pintf->padapter = padapter; + pintf->pintf_dev = adapter_to_dvobj(padapter); + -+ set_intf_ops(padapter,&pintf->io_ops); ++ set_intf_ops(padapter, &pintf->io_ops); + + return _SUCCESS; +} @@ -9455,8 +9469,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_io.c linux-4.3-rtl8723bs/3rdpar +int rtw_inc_and_chk_continual_io_error(struct dvobj_priv *dvobj) +{ + int ret = false; -+ int value; -+ if ((value =atomic_inc_return(&dvobj->continual_io_error)) > MAX_CONTINUAL_IO_ERR) { ++ int value = atomic_inc_return(&dvobj->continual_io_error); ++ if (value > MAX_CONTINUAL_IO_ERR) { + DBG_871X("[dvobj:%p][ERROR] continual_io_error:%d > %d\n", dvobj, value, MAX_CONTINUAL_IO_ERR); + ret = true; + } else { @@ -9472,10 +9486,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_io.c linux-4.3-rtl8723bs/3rdpar +{ + atomic_set(&dvobj->continual_io_error, 0); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_ioctl_set.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_ioctl_set.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,736 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux/3rdparty/rtl8723bs/core/rtw_ioctl_set.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_ioctl_set.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_ioctl_set.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,696 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -9518,7 +9532,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + +u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) +{ -+ u8 ret =true; ++ u8 ret = true; + + if (ssid->SsidLength > 32) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length >32\n")); @@ -9527,8 +9541,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + } + +#ifdef CONFIG_VALIDATE_SSID -+ for (i = 0; i < ssid->SsidLength; i++) -+ { ++ for (i = 0; i < ssid->SsidLength; i++) { + /* wifi, printable ascii code must be supported */ + if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e))) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid has nonprintabl ascii\n")); @@ -9565,46 +9578,38 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + pmlmepriv->to_join = true; + -+ if (list_empty(&queue->queue)) -+ { ++ if (list_empty(&queue->queue)) { + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + /* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */ + /* we try to issue sitesurvey firstly */ + -+ if (pmlmepriv->LinkDetectInfo.bBusyTraffic ==false ++ if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false + || rtw_to_roam(padapter) > 0 -+ ) -+ { ++ ) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join(): site survey if scanned_queue is empty\n.")); + /* submit site_survey_cmd */ -+ if (_SUCCESS!=(ret =rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0))) { ++ ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); ++ if (_SUCCESS != ret) { + pmlmepriv->to_join = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n.")); + } -+ } -+ else -+ { ++ } else{ + pmlmepriv->to_join = false; + ret = _FAIL; + } + + goto exit; -+ } -+ else -+ { ++ } else{ + int select_ret; + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); -+ if ((select_ret =rtw_select_and_join_from_scanned_queue(pmlmepriv)) == _SUCCESS) -+ { ++ select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); ++ if (select_ret == _SUCCESS) { + pmlmepriv->to_join = false; + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); -+ } -+ else -+ { -+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ==true) -+ { ++ } else{ ++ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + /* submit createbss_cmd to change to a ADHOC_MASTER */ + + /* pmlmepriv->lock has been acquired by caller... */ @@ -9621,8 +9626,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + rtw_generate_random_ibss(pibss); + -+ if (rtw_createbss_cmd(padapter)!= _SUCCESS) -+ { ++ if (rtw_createbss_cmd(padapter) != _SUCCESS) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>do_goin: rtw_createbss_cmd status FAIL***\n ")); + ret = false; + goto exit; @@ -9632,26 +9636,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode***\n ")); + -+ } -+ else -+ { ++ } else{ + /* can't associate ; reset under-linking */ + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + /* when set_ssid/set_bssid for rtw_do_join(), but there are no desired bss in scanning queue */ + /* we try to issue sitesurvey firstly */ -+ if (pmlmepriv->LinkDetectInfo.bBusyTraffic ==false ++ if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false + || rtw_to_roam(padapter) > 0 -+ ) -+ { ++ ) { + /* DBG_871X("rtw_do_join() when no desired bss in scanning queue\n"); */ -+ if (_SUCCESS!=(ret =rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0))) { ++ ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); ++ if (_SUCCESS != ret) { + pmlmepriv->to_join = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey return error\n.")); + } -+ } -+ else -+ { ++ } else{ + ret = _FAIL; + pmlmepriv->to_join = false; + } @@ -9673,9 +9673,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + DBG_871X_LEVEL(_drv_always_, "set bssid:%pM\n", bssid); + -+ if ((bssid[0]== 0x00 && bssid[1]== 0x00 && bssid[2]== 0x00 && bssid[3]== 0x00 && bssid[4]== 0x00 &&bssid[5]== 0x00) || -+ (bssid[0]== 0xFF && bssid[1]== 0xFF && bssid[2]== 0xFF && bssid[3]== 0xFF && bssid[4]== 0xFF &&bssid[5]== 0xFF)) -+ { ++ if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) || ++ (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF && bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) { + status = _FAIL; + goto exit; + } @@ -9690,12 +9689,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + goto release_mlme_lock; + } + -+ if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); + -+ if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) -+ { ++ if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) + goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ + } else { @@ -9725,12 +9722,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); -+ pmlmepriv->assoc_by_bssid =true; ++ pmlmepriv->assoc_by_bssid = true; + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + pmlmepriv->to_join = true; -+ } -+ else { ++ } else { + status = rtw_do_join(padapter); + } + @@ -9754,7 +9750,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + DBG_871X_LEVEL(_drv_always_, "set ssid [%s] fw_state = 0x%08x\n", + ssid->Ssid, get_fwstate(pmlmepriv)); + -+ if (padapter->hw_init_completed ==false) { ++ if (padapter->hw_init_completed == false) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("set_ssid: hw_init_completed ==false =>exit!!!\n")); + status = _FAIL; @@ -9770,22 +9766,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + goto release_mlme_lock; + } + -+ if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); + + if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && -+ (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) -+ { -+ if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) -+ { ++ (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { ++ if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Set SSID is the same ssid, fw_state = 0x%08x\n", + get_fwstate(pmlmepriv))); + -+ if (rtw_is_same_ibss(padapter, pnetwork) == false) -+ { ++ if (rtw_is_same_ibss(padapter, pnetwork) == false) { + /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ + rtw_disassoc_cmd(padapter, 0, true); + @@ -9798,18 +9790,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + } -+ } -+ else -+ { ++ } else{ + goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ + } -+ } -+ else { ++ } else { + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1); + } -+ } -+ else -+ { ++ } else{ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set SSID not the same ssid\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid =[%s] len = 0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("assoc_ssid =[%s] len = 0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength)); @@ -9840,12 +9827,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + } + + memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); -+ pmlmepriv->assoc_by_bssid =false; ++ pmlmepriv->assoc_by_bssid = false; + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + pmlmepriv->to_join = true; -+ } -+ else { ++ } else { + status = rtw_do_join(padapter); + } + @@ -9879,7 +9865,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + goto exit; + } + -+ if (padapter->hw_init_completed ==false) { ++ if (padapter->hw_init_completed == false) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("set_ssid: hw_init_completed ==false =>exit!!!\n")); + status = _FAIL; @@ -9917,8 +9903,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + pmlmepriv->to_join = true; -+ } -+ else { ++ } else { + status = rtw_do_join(padapter); + } + @@ -9940,13 +9925,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n", + *pold_state, networktype, get_fwstate(pmlmepriv))); + -+ if (*pold_state != networktype) -+ { ++ if (*pold_state != networktype) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!")); + /* DBG_871X("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */ + -+ if (*pold_state ==Ndis802_11APMode) -+ { ++ if (*pold_state == Ndis802_11APMode) { + /* change to other mode from Ndis802_11APMode */ + cur_network->join_res = -1; + @@ -9955,17 +9938,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + spin_lock_bh(&pmlmepriv->lock); + -+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) ||(*pold_state ==Ndis802_11IBSS)) ++ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || (*pold_state == Ndis802_11IBSS)) + rtw_disassoc_cmd(padapter, 0, true); + + if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) + rtw_free_assoc_resources(padapter, 1); + -+ if ((*pold_state == Ndis802_11Infrastructure) ||(*pold_state == Ndis802_11IBSS)) -+ { -+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) -+ { ++ if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) { ++ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not */ + } + } @@ -9974,26 +9955,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE); + -+ switch (networktype) -+ { -+ case Ndis802_11IBSS: -+ set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); -+ break; ++ switch (networktype) { ++ case Ndis802_11IBSS: ++ set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); ++ break; + -+ case Ndis802_11Infrastructure: -+ set_fwstate(pmlmepriv, WIFI_STATION_STATE); -+ break; ++ case Ndis802_11Infrastructure: ++ set_fwstate(pmlmepriv, WIFI_STATION_STATE); ++ break; + -+ case Ndis802_11APMode: -+ set_fwstate(pmlmepriv, WIFI_AP_STATE); -+ start_ap_mode(padapter); -+ /* rtw_indicate_connect(padapter); */ ++ case Ndis802_11APMode: ++ set_fwstate(pmlmepriv, WIFI_AP_STATE); ++ start_ap_mode(padapter); ++ /* rtw_indicate_connect(padapter); */ + -+ break; ++ break; + -+ case Ndis802_11AutoUnknown: -+ case Ndis802_11InfrastructureMax: -+ break; ++ case Ndis802_11AutoUnknown: ++ case Ndis802_11InfrastructureMax: ++ break; + } + + /* SecClearAllKeys(adapter); */ @@ -10009,12 +9989,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + +u8 rtw_set_802_11_disassociate(struct adapter *padapter) +{ -+ struct mlme_priv * pmlmepriv = &padapter->mlmepriv; ++ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + spin_lock_bh(&pmlmepriv->lock); + -+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) -+ { ++ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_disassociate: rtw_indicate_disconnect\n")); + + rtw_disassoc_cmd(padapter, 0, true); @@ -10033,23 +10012,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs +u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -+ u8 res =true; ++ u8 res = true; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv))); + + if (padapter == NULL) { -+ res =false; ++ res = false; + goto exit; + } -+ if (padapter->hw_init_completed ==false) { ++ if (padapter->hw_init_completed == false) { + res = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n ===rtw_set_802_11_bssid_list_scan:hw_init_completed ==false ===\n")); + goto exit; + } + + if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) || -+ (pmlmepriv->LinkDetectInfo.bBusyTraffic == true)) -+ { ++ (pmlmepriv->LinkDetectInfo.bBusyTraffic == true)) { + /* Scan or linking is in progress, do nothing. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid_list_scan fail since fw_state = %x\n", get_fwstate(pmlmepriv))); + res = true; @@ -10085,65 +10063,64 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode)); + -+ psecuritypriv->ndisauthtype =authmode; ++ psecuritypriv->ndisauthtype = authmode; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_set_802_11_authentication_mode:psecuritypriv->ndisauthtype =%d", psecuritypriv->ndisauthtype)); + -+ if (psecuritypriv->ndisauthtype>3) -+ psecuritypriv->dot11AuthAlgrthm =dot11AuthAlgrthm_8021X; ++ if (psecuritypriv->ndisauthtype > 3) ++ psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + -+ res =rtw_set_auth(padapter, psecuritypriv); ++ res = rtw_set_auth(padapter, psecuritypriv); + + if (res == _SUCCESS) -+ ret =true; ++ ret = true; + else -+ ret =false; ++ ret = false; + + return ret; +} + -+u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) { ++u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) ++{ + + u8 bdefaultkey; + u8 btransmitkey; + sint keyid, res; -+ struct security_priv* psecuritypriv =&(padapter->securitypriv); ++ struct security_priv *psecuritypriv = &(padapter->securitypriv); + u8 ret = _SUCCESS; + -+ bdefaultkey =(wep->KeyIndex & 0x40000000) > 0 ? false : true; /* for ??? */ ++ bdefaultkey = (wep->KeyIndex & 0x40000000) > 0 ? false : true; /* for ??? */ + btransmitkey = (wep->KeyIndex & 0x80000000) > 0 ? true : false; /* for ??? */ -+ keyid =wep->KeyIndex & 0x3fffffff; ++ keyid = wep->KeyIndex & 0x3fffffff; + -+ if (keyid>=4) -+ { ++ if (keyid >= 4) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActrtw_set_802_11_add_wep:keyid>4 =>fail\n")); -+ ret =false; ++ ret = false; + goto exit; + } + -+ switch (wep->KeyLength) -+ { -+ case 5: -+ psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; -+ RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength =5\n")); -+ break; -+ case 13: -+ psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; -+ RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 13\n")); -+ break; -+ default: -+ psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; -+ RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength!=5 or 13\n")); -+ break; ++ switch (wep->KeyLength) { ++ case 5: ++ psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; ++ RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength =5\n")); ++ break; ++ case 13: ++ psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; ++ RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 13\n")); ++ break; ++ default: ++ psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; ++ RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength!=5 or 13\n")); ++ break; + } + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_set_802_11_add_wep:befor memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n", wep->KeyLength, wep->KeyIndex, keyid)); + -+ memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]),&(wep->KeyMaterial), wep->KeyLength); ++ memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength); + -+ psecuritypriv->dot11DefKeylen[keyid]=wep->KeyLength; ++ psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength; + -+ psecuritypriv->dot11PrivacyKeyIndex =keyid; ++ psecuritypriv->dot11PrivacyKeyIndex = keyid; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_set_802_11_add_wep:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n", + psecuritypriv->dot11DefKey[keyid].skey[0], psecuritypriv->dot11DefKey[keyid].skey[1], psecuritypriv->dot11DefKey[keyid].skey[2], @@ -10152,7 +10129,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + psecuritypriv->dot11DefKey[keyid].skey[9], psecuritypriv->dot11DefKey[keyid].skey[10], psecuritypriv->dot11DefKey[keyid].skey[11], + psecuritypriv->dot11DefKey[keyid].skey[12])); + -+ res =rtw_set_key(padapter, psecuritypriv, keyid, 1, true); ++ res = rtw_set_key(padapter, psecuritypriv, keyid, 1, true); + + if (res == _FAIL) + ret = false; @@ -10196,13 +10173,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + short_GI, + psta->htpriv.ht_cap.supp_mcs_set + ); -+ } -+ else -+ { -+ while ((pcur_bss->SupportedRates[i]!= 0) && (pcur_bss->SupportedRates[i]!= 0xFF)) -+ { ++ } else{ ++ while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) { + rate = pcur_bss->SupportedRates[i]&0x7F; -+ if (rate>max_rate) ++ if (rate > max_rate) + max_rate = rate; + i++; + } @@ -10212,10 +10186,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_ioctl_set.c linux-4.3-rtl8723bs + + return max_rate; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_mlme.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_mlme.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,3331 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_mlme.c linux/3rdparty/rtl8723bs/core/rtw_mlme.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_mlme.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_mlme.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,3155 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -10238,7 +10212,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + +extern u8 rtw_do_join(struct adapter *padapter); + -+sint _rtw_init_mlme_priv (struct adapter *padapter) ++sint _rtw_init_mlme_priv(struct adapter *padapter) +{ + sint i; + u8 *pbuf; @@ -10253,9 +10227,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + pmlmepriv->pscanned = NULL; + pmlmepriv->fw_state = WIFI_STATION_STATE; /* Must sync with rtw_wdev_alloc() */ -+ /* wdev->iftype = NL80211_IFTYPE_STATION */ ++ /* wdev->iftype = NL80211_IFTYPE_STATION */ + pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; -+ pmlmepriv->scan_mode =SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ ++ pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ + + spin_lock_init(&(pmlmepriv->lock)); + _rtw_init_queue(&(pmlmepriv->free_bss_pool)); @@ -10275,8 +10249,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + pnetwork = (struct wlan_network *)pbuf; + -+ for (i = 0; i < MAX_BSS_CNT; i++) -+ { ++ for (i = 0; i < MAX_BSS_CNT; i++) { + INIT_LIST_HEAD(&(pnetwork->list)); + + list_add_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue)); @@ -10288,9 +10261,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + rtw_clear_scan_deny(padapter); + -+ #define RTW_ROAM_SCAN_RESULT_EXP_MS 5*1000 ++ #define RTW_ROAM_SCAN_RESULT_EXP_MS 5000 + #define RTW_ROAM_RSSI_DIFF_TH 10 -+ #define RTW_ROAM_SCAN_INTERVAL_MS 10*1000 ++ #define RTW_ROAM_SCAN_INTERVAL_MS 10000 + + pmlmepriv->roam_flags = 0 + | RTW_ROAM_ON_EXPIRED @@ -10313,8 +10286,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + +static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) +{ -+ if (*ppie) -+ { ++ if (*ppie) { + kfree(*ppie); + *plen = 0; + *ppie = NULL; @@ -10337,7 +10309,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len); +} + -+void _rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) ++void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) +{ + rtw_free_mlme_priv_ie_data(pmlmepriv); + @@ -10378,7 +10350,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +{ + struct wlan_network *pnetwork; + struct __queue *free_queue = &pmlmepriv->free_bss_pool; -+ struct list_head* plist = NULL; ++ struct list_head *plist = NULL; + + spin_lock_bh(&free_queue->lock); + @@ -10388,7 +10360,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + } + plist = get_next(&(free_queue->queue)); + -+ pnetwork = LIST_CONTAINOR(plist , struct wlan_network, list); ++ pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + list_del_init(&pnetwork->list); + @@ -10399,7 +10371,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + pnetwork->aid = 0; + pnetwork->join_res = 0; + -+ pmlmepriv->num_of_scanned ++; ++ pmlmepriv->num_of_scanned++; + +exit: + spin_unlock_bh(&free_queue->lock); @@ -10407,7 +10379,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + return pnetwork; +} + -+void _rtw_free_network(struct mlme_priv *pmlmepriv , struct wlan_network *pnetwork, u8 isfreeall) ++void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall) +{ + unsigned int delta_time; + u32 lifetime = SCANQUEUE_LIFETIME; @@ -10420,12 +10392,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + if (pnetwork->fixed == true) + return; + -+ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ==true) || -+ (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ==true)) ++ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || ++ (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) + lifetime = 1; + -+ if (!isfreeall) -+ { ++ if (!isfreeall) { + delta_time = jiffies_to_msecs(jiffies - pnetwork->last_scanned); + if (delta_time < lifetime)/* unit:msec */ + return; @@ -10435,9 +10406,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + list_del_init(&(pnetwork->list)); + -+ list_add_tail(&(pnetwork->list),&(free_queue->queue)); ++ list_add_tail(&(pnetwork->list), &(free_queue->queue)); + -+ pmlmepriv->num_of_scanned --; ++ pmlmepriv->num_of_scanned--; + + + /* DBG_871X("_rtw_free_network:SSID =%s\n", pnetwork->network.Ssid.Ssid); */ @@ -10462,7 +10433,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + list_add_tail(&(pnetwork->list), get_list_head(free_queue)); + -+ pmlmepriv->num_of_scanned --; ++ pmlmepriv->num_of_scanned--; + + /* spin_unlock_irqrestore(&free_queue->lock, irqL); */ +} @@ -10488,15 +10459,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + phead = get_list_head(scanned_queue); + plist = get_next(phead); + -+ while (plist != phead) -+ { -+ pnetwork = LIST_CONTAINOR(plist, struct wlan_network , list); ++ while (plist != phead) { ++ pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) -+ break; ++ break; + + plist = get_next(plist); -+ } ++ } + + if (plist == phead) + pnetwork = NULL; @@ -10511,7 +10481,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +{ + struct list_head *phead, *plist; + struct wlan_network *pnetwork; -+ struct mlme_priv* pmlmepriv = &padapter->mlmepriv; ++ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct __queue *scanned_queue = &pmlmepriv->scanned_queue; + + spin_lock_bh(&scanned_queue->lock); @@ -10519,8 +10489,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + phead = get_list_head(scanned_queue); + plist = get_next(phead); + -+ while (phead != plist) -+ { ++ while (phead != plist) { + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + @@ -10536,16 +10505,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + + -+sint rtw_if_up(struct adapter *padapter) { ++sint rtw_if_up(struct adapter *padapter) ++{ + + sint res; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved || + (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_if_up:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); -+ res =false; -+ } -+ else ++ res = false; ++ } else + res = true; + return res; +} @@ -10585,7 +10554,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +} + + -+int rtw_init_mlme_priv (struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ ++int rtw_init_mlme_priv(struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ +{ + int res; + @@ -10593,10 +10562,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + return res; +} + -+void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) ++void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) +{ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n")); -+ _rtw_free_mlme_priv (pmlmepriv); ++ _rtw_free_mlme_priv(pmlmepriv); +} + +/* @@ -10627,7 +10596,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +} + + -+void rtw_free_network_queue(struct adapter * dev, u8 isfreeall) ++void rtw_free_network_queue(struct adapter *dev, u8 isfreeall) +{ + _rtw_free_network_queue(dev, isfreeall); +} @@ -10646,23 +10615,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + +int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) +{ -+ int ret =true; ++ int ret = true; + struct security_priv *psecuritypriv = &adapter->securitypriv; + + if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) && + (pnetwork->network.Privacy == 0)) -+ { -+ ret =false; -+ } ++ ret = false; + else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) && + (pnetwork->network.Privacy == 1)) -+ { -+ ret =false; -+ } ++ ret = false; + else -+ { -+ ret =true; -+ } ++ ret = true; + + return ret; + @@ -10681,7 +10644,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + u16 s_cap, d_cap; + __le16 tmps, tmpd; + -+ if (rtw_bug_check(dst, src, &s_cap, &d_cap) ==false) ++ if (rtw_bug_check(dst, src, &s_cap, &d_cap) == false) + return false; + + memcpy((u8 *)&tmps, rtw_get_capability_from_ie(src->IEs), 2); @@ -10711,7 +10674,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + plist = get_next(phead); + + while (plist != phead) { -+ found = LIST_CONTAINOR(plist, struct wlan_network , list); ++ found = LIST_CONTAINOR(plist, struct wlan_network, list); + + if (is_same_network(&network->network, &found->network, 0)) + break; @@ -10725,7 +10688,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + return found; +} + -+struct wlan_network * rtw_get_oldest_wlan_network(struct __queue *scanned_queue) ++struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) +{ + struct list_head *plist, *phead; + @@ -10737,17 +10700,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + plist = get_next(phead); + -+ while (1) -+ { ++ while (1) { + + if (phead == plist) + break; + + pwlan = LIST_CONTAINOR(plist, struct wlan_network, list); + -+ if (pwlan->fixed!=true) -+ { -+ if (oldest == NULL ||time_after(oldest->last_scanned, pwlan->last_scanned)) ++ if (pwlan->fixed != true) { ++ if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned)) + oldest = pwlan; + } + @@ -10789,8 +10750,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + rssi_final = (src->Rssi+dst->Rssi*4)/5; + else + rssi_final = rssi_ori; -+ } -+ else { ++ } else { + if (sq_smp != 101) { /* from the right channel */ + ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; + sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; @@ -10832,14 +10792,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + &(pmlmepriv->cur_network.network), + &(pmlmepriv->cur_network.network)); + -+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && (is_same_network(&(pmlmepriv->cur_network.network), pnetwork, 0))) -+ { ++ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && (is_same_network(&(pmlmepriv->cur_network.network), pnetwork, 0))) { + /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"Same Network\n"); */ + + /* if (pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */ + { + update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); -+ rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof (struct ndis_802_11_fix_ie), ++ rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fix_ie), + pmlmepriv->cur_network.network.IELength); + } + } @@ -10867,8 +10826,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + phead = get_list_head(queue); + plist = get_next(phead); + -+ while (1) -+ { ++ while (1) { + if (phead == plist) + break; + @@ -10876,8 +10834,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + rtw_bug_check(pnetwork, pnetwork, pnetwork, pnetwork); + -+ if (is_same_network(&(pnetwork->network), target, feature)) -+ { ++ if (is_same_network(&(pnetwork->network), target, feature)) { + target_find = 1; + break; + } @@ -10918,8 +10875,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + /* bss info not receving from the right channel */ + if (pnetwork->network.PhyInfo.SignalQuality == 101) + pnetwork->network.PhyInfo.SignalQuality = 0; -+ } -+ else { ++ } else { + /* Otherwise just pull from the free list */ + + pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ @@ -10939,11 +10895,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + if (pnetwork->network.PhyInfo.SignalQuality == 101) + pnetwork->network.PhyInfo.SignalQuality = 0; + -+ list_add_tail(&(pnetwork->list),&(queue->queue)); ++ list_add_tail(&(pnetwork->list), &(queue->queue)); + + } -+ } -+ else { ++ } else { + /* we have an entry and we are going to update it. But this entry may + * be already expired. In this case we do the same as we found a new + * net and call the new_net handler @@ -10953,7 +10908,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + pnetwork->last_scanned = jiffies; + + /* target.Reserved[0]== 1, means that scaned network is a bcn frame. */ -+ if ((pnetwork->network.IELength>target->IELength) && (target->Reserved[0]== 1)) ++ if ((pnetwork->network.IELength > target->IELength) && (target->Reserved[0] == 1)) + update_ie = false; + + /* probe resp(3) > beacon(1) > probe req(2) */ @@ -10961,8 +10916,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + (target->Reserved[0] >= pnetwork->network.Reserved[0]) + ) { + update_ie = true; -+ } -+ else { ++ } else { + update_ie = false; + } + @@ -11009,28 +10963,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + desired_encmode = psecuritypriv->ndisencryptstatus; + privacy = pnetwork->network.Privacy; + -+ if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) -+ { -+ if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)!= NULL) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { ++ if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL) + return true; -+ } + else -+ { + return false; -+ } ++ + } -+ if (adapter->registrypriv.wifi_spec == 1) /* for correct flow of 8021X to do.... */ -+ { ++ if (adapter->registrypriv.wifi_spec == 1) { /* for correct flow of 8021X to do.... */ + u8 *p = NULL; + uint ie_len = 0; + + if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0)) -+ bselected = false; ++ bselected = false; + + if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) { + p = rtw_get_ie(pnetwork->network.IEs + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pnetwork->network.IELength - _BEACON_IE_OFFSET_)); -+ if (p && ie_len>0) { ++ if (p && ie_len > 0) { + bselected = true; + } else { + bselected = false; @@ -11044,8 +10993,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + bselected = false; + } + -+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + bselected = false; + } @@ -11055,7 +11003,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +} + +/* TODO: Perry : For Power Management */ -+void rtw_atimdone_event_callback(struct adapter *adapter , u8 *pbuf) ++void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf) +{ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); +} @@ -11072,8 +11020,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, ssid =%s\n", pnetwork->Ssid.Ssid)); + + len = get_wlan_bssid_ex_sz(pnetwork); -+ if (len > (sizeof(struct wlan_bssid_ex))) -+ { ++ if (len > (sizeof(struct wlan_bssid_ex))) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n ****rtw_survey_event_callback: return a wrong bss ***\n")); + return; + } @@ -11082,19 +11029,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + spin_lock_bh(&pmlmepriv->lock); + + /* update IBSS_network 's timestamp */ -+ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) -+ { ++ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { + /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"rtw_survey_event_callback : WIFI_ADHOC_MASTER_STATE\n\n"); */ -+ if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) -+ { -+ struct wlan_network* ibss_wlan = NULL; ++ if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { ++ struct wlan_network *ibss_wlan = NULL; + + memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress); -+ if (ibss_wlan) -+ { -+ memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8); ++ if (ibss_wlan) { ++ memcpy(ibss_wlan->network.IEs, pnetwork->IEs, 8); + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + goto exit; + } @@ -11103,10 +11047,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + } + + /* lock pmlmepriv->lock when you accessing network_q */ -+ if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) -+ { -+ if (pnetwork->Ssid.Ssid[0] == 0) -+ { ++ if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) { ++ if (pnetwork->Ssid.Ssid[0] == 0) { + pnetwork->Ssid.SsidLength = 0; + } + rtw_add_network(adapter, pnetwork); @@ -11127,8 +11069,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + + spin_lock_bh(&pmlmepriv->lock); -+ if (pmlmepriv->wps_probe_req_ie) -+ { ++ if (pmlmepriv->wps_probe_req_ie) { + pmlmepriv->wps_probe_req_ie_len = 0; + kfree(pmlmepriv->wps_probe_req_ie); + pmlmepriv->wps_probe_req_ie = NULL; @@ -11136,16 +11077,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv))); + -+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) -+ { ++ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { + /* u8 timer_cancelled; */ + + timer_cancelled = true; + /* _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled); */ + + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); -+ } -+ else { ++ } else { + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); + } @@ -11159,20 +11098,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + rtw_set_signal_stat_timer(&adapter->recvpriv); + -+ if (pmlmepriv->to_join == true) -+ { -+ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ==true)) -+ { -+ if (check_fwstate(pmlmepriv, _FW_LINKED) ==false) -+ { ++ if (pmlmepriv->to_join == true) { ++ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { ++ if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + -+ if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) -+ { ++ if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) { + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); -+ } -+ else -+ { ++ } else{ + struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network); + u8 *pibss = adapter->registrypriv.dev_network.MacAddress; + @@ -11189,31 +11122,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; + -+ if (rtw_createbss_cmd(adapter)!= _SUCCESS) -+ { ++ if (rtw_createbss_cmd(adapter) != _SUCCESS) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd status FAIL\n")); + } + + pmlmepriv->to_join = false; + } + } -+ } -+ else -+ { ++ } else{ + int s_ret; + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + pmlmepriv->to_join = false; -+ if (_SUCCESS == (s_ret =rtw_select_and_join_from_scanned_queue(pmlmepriv))) -+ { ++ s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); ++ if (_SUCCESS == s_ret) { + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); -+ } -+ else if (s_ret == 2)/* there is no need to wait for join */ -+ { ++ } else if (s_ret == 2) {/* there is no need to wait for join */ + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + rtw_indicate_connect(adapter); -+ } -+ else -+ { ++ } else{ + DBG_871X("try_to_join, but select scanning queue fail, to_roam:%d\n", rtw_to_roam(adapter)); + + if (rtw_to_roam(adapter) != 0) { @@ -11222,8 +11148,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + ) { + rtw_set_to_roam(adapter, 0); +#ifdef CONFIG_INTEL_WIDI -+ if (adapter->mlmepriv.widi_state == INTEL_WIDI_STATE_ROAMING) -+ { ++ if (adapter->mlmepriv.widi_state == INTEL_WIDI_STATE_ROAMING) { + memset(pmlmepriv->sa_ext, 0x00, L2SDTA_SERVICE_VE_LEN); + intel_widi_wk_cmd(adapter, INTEL_WIDI_LISTEN_WK, NULL, 0); + DBG_871X("change to widi listen\n"); @@ -11234,19 +11159,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + } else { + pmlmepriv->to_join = true; + } -+ } -+ else -+ { ++ } else + rtw_indicate_disconnect(adapter); -+ } ++ + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + } + } + } else { + if (rtw_chk_roam_flags(adapter, RTW_ROAM_ACTIVE)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) -+ && check_fwstate(pmlmepriv, _FW_LINKED)) -+ { ++ && check_fwstate(pmlmepriv, _FW_LINKED)) { + if (rtw_select_roaming_candidate(pmlmepriv) == _SUCCESS) { + receive_disconnect(adapter, pmlmepriv->cur_network.network.MacAddress + , WLAN_REASON_ACTIVE_ROAM); @@ -11266,11 +11188,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + rtw_indicate_scan_done(adapter, false); +} + -+void rtw_dummy_event_callback(struct adapter *adapter , u8 *pbuf) ++void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf) +{ +} + -+void rtw_fwdbg_event_callback(struct adapter *adapter , u8 *pbuf) ++void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf) +{ +} + @@ -11287,14 +11209,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + phead = get_list_head(scan_queue); + plist = get_next(phead); + -+ while (plist != phead) -+ { ++ while (plist != phead) { + ptemp = get_next(plist); + list_del_init(plist); + list_add_tail(plist, &free_queue->queue); -+ plist =ptemp; -+ pmlmepriv->num_of_scanned --; -+ } ++ plist = ptemp; ++ pmlmepriv->num_of_scanned--; ++ } + + spin_unlock_bh(&free_queue->lock); + spin_unlock_bh(&scan_queue->lock); @@ -11311,7 +11232,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + +static void find_network(struct adapter *adapter) +{ -+ struct wlan_network* pwlan = NULL; ++ struct wlan_network *pwlan = NULL; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct wlan_network *tgt_network = &pmlmepriv->cur_network; + @@ -11342,9 +11263,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress ="MAC_FMT" ssid =%s\n", + MAC_ARG(tgt_network->network.MacAddress), tgt_network->network.Ssid.Ssid)); + -+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) -+ { -+ struct sta_info* psta; ++ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) { ++ struct sta_info *psta; + + psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress); + spin_lock_bh(&(pstapriv->sta_hash_lock)); @@ -11354,9 +11274,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + } + -+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) -+ { -+ struct sta_info* psta; ++ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) { ++ struct sta_info *psta; + + rtw_free_all_stainfo(adapter); + @@ -11390,8 +11309,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + pmlmepriv->to_join = false; + -+ if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) -+ { ++ if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + + set_fwstate(pmlmepriv, _FW_LINKED); + @@ -11400,8 +11318,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + rtw_set_to_roam(padapter, 0); +#ifdef CONFIG_INTEL_WIDI -+ if (padapter->mlmepriv.widi_state == INTEL_WIDI_STATE_ROAMING) -+ { ++ if (padapter->mlmepriv.widi_state == INTEL_WIDI_STATE_ROAMING) { + memset(pmlmepriv->sa_ext, 0x00, L2SDTA_SERVICE_VE_LEN); + intel_widi_wk_cmd(padapter, INTEL_WIDI_LISTEN_WK, NULL, 0); + DBG_871X("change to widi listen\n"); @@ -11424,15 +11341,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING|WIFI_UNDER_WPS); + -+ /* DBG_871X("clear wps when %s\n", __func__); */ ++ /* DBG_871X("clear wps when %s\n", __func__); */ + + if (rtw_to_roam(padapter) > 0) + _clr_fwstate_(pmlmepriv, _FW_LINKED); + + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) + || (rtw_to_roam(padapter) <= 0) -+ ) -+ { ++ ) { + rtw_os_indicate_disconnect(padapter); + + /* set ips_deny_time to avoid enter IPS before LPS leave */ @@ -11503,8 +11419,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); + } + -+ if (psta) /* update ptarget_sta */ -+ { ++ if (psta) { /* update ptarget_sta */ ++ + DBG_871X("%s\n", __func__); + + psta->aid = pnetwork->join_res; @@ -11524,32 +11440,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + + /* security related */ -+ if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) -+ { -+ padapter->securitypriv.binstallGrpkey =false; -+ padapter->securitypriv.busetkipkey =false; -+ padapter->securitypriv.bgrpkey_handshake =false; ++ if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { ++ padapter->securitypriv.binstallGrpkey = false; ++ padapter->securitypriv.busetkipkey = false; ++ padapter->securitypriv.bgrpkey_handshake = false; + -+ psta->ieee8021x_blocked =true; -+ psta->dot118021XPrivacy =padapter->securitypriv.dot11PrivacyAlgrthm; ++ psta->ieee8021x_blocked = true; ++ psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + -+ memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof (union Keytype)); ++ memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof(union Keytype)); + -+ memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof (union Keytype)); -+ memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof (union Keytype)); ++ memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof(union Keytype)); ++ memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof(union Keytype)); + -+ memset((u8 *)&psta->dot11txpn, 0, sizeof (union pn48)); ++ memset((u8 *)&psta->dot11txpn, 0, sizeof(union pn48)); + psta->dot11txpn.val = psta->dot11txpn.val + 1; -+ memset((u8 *)&psta->dot11wtxpn, 0, sizeof (union pn48)); -+ memset((u8 *)&psta->dot11rxpn, 0, sizeof (union pn48)); ++ memset((u8 *)&psta->dot11wtxpn, 0, sizeof(union pn48)); ++ memset((u8 *)&psta->dot11rxpn, 0, sizeof(union pn48)); + } + + /* Commented by Albert 2012/07/21 */ + /* When doing the WPS, the wps_ie_len won't equal to 0 */ + /* And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */ -+ if (padapter->securitypriv.wps_ie_len != 0) -+ { -+ psta->ieee8021x_blocked =true; ++ if (padapter->securitypriv.wps_ie_len != 0) { ++ psta->ieee8021x_blocked = true; + padapter->securitypriv.wps_ie_len = 0; + } + @@ -11557,8 +11471,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */ + /* if A-MPDU Rx is enabled, reseting rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */ + /* todo: check if AP can send A-MPDU packets */ -+ for (i = 0; i < 16 ; i++) -+ { ++ for (i = 0; i < 16 ; i++) { + /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + preorder_ctrl = &psta->recvreorder_ctrl[i]; + preorder_ctrl->enable = false; @@ -11573,10 +11486,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + + bmc_sta = rtw_get_bcmc_stainfo(padapter); -+ if (bmc_sta) -+ { -+ for (i = 0; i < 16 ; i++) -+ { ++ if (bmc_sta) { ++ for (i = 0; i < 16 ; i++) { + /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + preorder_ctrl = &bmc_sta->recvreorder_ctrl[i]; + preorder_ctrl->enable = false; @@ -11636,26 +11547,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + rtw_set_signal_stat_timer(&padapter->recvpriv); + + /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ -+ switch (pnetwork->network.InfrastructureMode) -+ { -+ case Ndis802_11Infrastructure: ++ switch (pnetwork->network.InfrastructureMode) { ++ case Ndis802_11Infrastructure: + -+ if (pmlmepriv->fw_state&WIFI_UNDER_WPS) -+ pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; -+ else -+ pmlmepriv->fw_state = WIFI_STATION_STATE; ++ if (pmlmepriv->fw_state&WIFI_UNDER_WPS) ++ pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; ++ else ++ pmlmepriv->fw_state = WIFI_STATION_STATE; + -+ break; -+ case Ndis802_11IBSS: -+ pmlmepriv->fw_state = WIFI_ADHOC_STATE; -+ break; -+ default: -+ pmlmepriv->fw_state = WIFI_NULL_STATE; -+ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n")); -+ break; ++ break; ++ case Ndis802_11IBSS: ++ pmlmepriv->fw_state = WIFI_ADHOC_STATE; ++ break; ++ default: ++ pmlmepriv->fw_state = WIFI_NULL_STATE; ++ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n")); ++ break; + } + -+ rtw_update_protection(padapter, (cur_network->network.IEs) + sizeof (struct ndis_802_11_fix_ie), ++ rtw_update_protection(padapter, (cur_network->network.IEs) + sizeof(struct ndis_802_11_fix_ie), + (cur_network->network.IELength)); + + rtw_update_ht_cap(padapter, cur_network->network.IEs, cur_network->network.IELength, (u8) cur_network->network.Configuration.DSConfig); @@ -11686,20 +11596,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + rtw_get_encrypt_decrypt_from_registrypriv(adapter); + + -+ if (pmlmepriv->assoc_ssid.SsidLength == 0) -+ { ++ if (pmlmepriv->assoc_ssid.SsidLength == 0) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ joinbss event call back for Any SSid\n")); -+ } -+ else -+ { ++ } else{ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); + } + + the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); + + pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); -+ if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) -+ { ++ if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); + return; + } @@ -11711,23 +11617,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_joinbss_event_callback !! spin_lock_irqsave\n")); + -+ if (pnetwork->join_res > 0) -+ { ++ if (pnetwork->join_res > 0) { + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + retry = 0; -+ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) -+ { ++ if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { + /* s1. find ptarget_wlan */ -+ if (check_fwstate(pmlmepriv, _FW_LINKED)) -+ { -+ if (the_same_macaddr == true) -+ { ++ if (check_fwstate(pmlmepriv, _FW_LINKED)) { ++ if (the_same_macaddr == true) { + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); -+ } -+ else -+ { ++ } else{ + pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); -+ if (pcur_wlan) pcur_wlan->fixed = false; ++ if (pcur_wlan) ++ pcur_wlan->fixed = false; + + pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + if (pcur_sta) @@ -11735,26 +11636,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { -+ if (ptarget_wlan) ptarget_wlan->fixed = true; ++ if (ptarget_wlan) ++ ptarget_wlan->fixed = true; + } + } + -+ } -+ else -+ { ++ } else{ + ptarget_wlan = _rtw_find_same_network(&pmlmepriv->scanned_queue, pnetwork); + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { -+ if (ptarget_wlan) ptarget_wlan->fixed = true; ++ if (ptarget_wlan) ++ ptarget_wlan->fixed = true; + } + } + + /* s2. update cur_network */ -+ if (ptarget_wlan) -+ { ++ if (ptarget_wlan) { + rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork); -+ } -+ else -+ { ++ } else{ + DBG_871X_LEVEL(_drv_always_, "Can't find ptarget_wlan when joinbss_event callback\n"); + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + goto ignore_joinbss_callback; @@ -11762,11 +11660,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + + /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ -+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); -+ if (ptarget_sta == NULL) -+ { ++ if (ptarget_sta == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + goto ignore_joinbss_callback; @@ -11774,13 +11670,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + } + + /* s4. indicate connect */ -+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + pmlmepriv->cur_network_scanned = ptarget_wlan; + rtw_indicate_connect(adapter); -+ } -+ else -+ { ++ } else{ + /* adhoc mode will rtw_indicate_connect when rtw_stassoc_event_callback */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); + } @@ -11791,9 +11684,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("Cancle assoc_timer\n")); + -+ } -+ else -+ { ++ } else{ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_joinbss_event_callback err: fw_state:%x", get_fwstate(pmlmepriv))); + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + goto ignore_joinbss_callback; @@ -11801,23 +11692,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + -+ } -+ else if (pnetwork->join_res == -4) -+ { ++ } else if (pnetwork->join_res == -4) { + rtw_reset_securitypriv(adapter); + _set_timer(&pmlmepriv->assoc_timer, 1); + + /* rtw_free_assoc_resources(adapter, 1); */ + -+ if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) -+ { ++ if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("fail! clear _FW_UNDER_LINKING ^^^fw_state =%x\n", get_fwstate(pmlmepriv))); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + } + -+ } -+ else /* if join_res < 0 (join fails), then try again */ -+ { ++ } else{/* if join_res < 0 (join fails), then try again */ + + #ifdef REJOIN + res = _FAIL; @@ -11826,19 +11712,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_select_and_join_from_scanned_queue again! res:%d\n", res)); + } + -+ if (res == _SUCCESS) -+ { ++ if (res == _SUCCESS) { + /* extend time of assoc_timer */ + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); + retry++; -+ } -+ else if (res == 2)/* there is no need to wait for join */ -+ { ++ } else if (res == 2) {/* there is no need to wait for join */ + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + rtw_indicate_connect(adapter); -+ } -+ else -+ { ++ } else{ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Set Assoc_Timer = 1; can't find match ssid in scanned_q\n")); + #endif + @@ -11871,7 +11752,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +{ + u16 media_status_rpt; + -+ if (psta == NULL) return; ++ if (psta == NULL) ++ return; + + media_status_rpt = (u16)((psta->mac_id<<8)|mstatus); /* MACID|OPMODE:1 connect */ + rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status_rpt); @@ -11881,18 +11763,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +{ + struct sta_info *psta; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); -+ struct stassoc_event *pstassoc = (struct stassoc_event*)pbuf; ++ struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *ptarget_wlan = NULL; + + if (rtw_access_ctrl(adapter, pstassoc->macaddr) == false) + return; + -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); -+ if (psta) -+ { ++ if (psta) { + u8 *passoc_req = NULL; + u32 assoc_req_len = 0; + @@ -11905,11 +11785,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + /* report to upper layer */ + DBG_871X("indicate_sta_assoc_event to upper layer - hostapd\n"); + spin_lock_bh(&psta->lock); -+ if (psta->passoc_req && psta->assoc_req_len>0) -+ { ++ if (psta->passoc_req && psta->assoc_req_len > 0) { + passoc_req = rtw_zmalloc(psta->assoc_req_len); -+ if (passoc_req) -+ { ++ if (passoc_req) { + assoc_req_len = psta->assoc_req_len; + memcpy(passoc_req, psta->passoc_req, assoc_req_len); + @@ -11920,8 +11798,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + } + spin_unlock_bh(&psta->lock); + -+ if (passoc_req && assoc_req_len>0) -+ { ++ if (passoc_req && assoc_req_len > 0) { + rtw_cfg80211_indicate_sta_assoc(adapter, passoc_req, assoc_req_len); + + kfree(passoc_req); @@ -11933,8 +11810,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + /* for AD-HOC mode */ + psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); -+ if (psta != NULL) -+ { ++ if (psta != NULL) { + /* the sta have been in sta_info_queue => do nothing */ + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); @@ -11958,7 +11834,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + rtw_sta_media_status_rpt(adapter, psta, 1); + -+ if (adapter->securitypriv.dot11AuthAlgrthm ==dot11AuthAlgrthm_8021X) ++ if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; + + @@ -11966,15 +11842,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + spin_lock_bh(&pmlmepriv->lock); + -+ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) ==true) || -+ (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) ==true)) -+ { -+ if (adapter->stapriv.asoc_sta_count == 2) -+ { ++ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || ++ (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { ++ if (adapter->stapriv.asoc_sta_count == 2) { + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + pmlmepriv->cur_network_scanned = ptarget_wlan; -+ if (ptarget_wlan) ptarget_wlan->fixed = true; ++ if (ptarget_wlan) ++ ptarget_wlan->fixed = true; + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + rtw_indicate_connect(adapter); @@ -11991,11 +11866,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +{ + int mac_id = (-1); + struct sta_info *psta; -+ struct wlan_network* pwlan = NULL; ++ struct wlan_network *pwlan = NULL; + struct wlan_bssid_ex *pdev_network = NULL; + u8 *pibss = NULL; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); -+ struct stadel_event *pstadel = (struct stadel_event*)pbuf; ++ struct stadel_event *pstadel = (struct stadel_event *)pbuf; + struct wlan_network *tgt_network = &(pmlmepriv->cur_network); + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -12008,7 +11883,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + DBG_871X("%s(mac_id =%d) =" MAC_FMT "\n", __func__, mac_id, MAC_ARG(pstadel->macaddr)); + -+ if (mac_id>= 0) { ++ if (mac_id >= 0) { + u16 media_status; + media_status = (mac_id<<8)|0; /* MACID|OPMODE:0 means disconnect */ + /* for STA, AP, ADHOC mode, report disconnect stauts to FW */ @@ -12017,17 +11892,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + /* if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) */ + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) -+ { + return; -+ } + + + mlmeext_sta_del_event_callback(adapter); + + spin_lock_bh(&pmlmepriv->lock); + -+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + u16 reason = *((unsigned short *)(pstadel->rsvd)); + bool roam = false; + struct wlan_network *roam_target = NULL; @@ -12078,20 +11950,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + } + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || -+ check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) -+ { ++ check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + + rtw_free_stainfo(adapter, psta); + -+ if (adapter->stapriv.asoc_sta_count == 1) /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ -+ { ++ if (adapter->stapriv.asoc_sta_count == 1) {/* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + /* rtw_indicate_disconnect(adapter);removed@20091105 */ + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + /* free old ibss network */ + /* pwlan = rtw_find_network(&pmlmepriv->scanned_queue, pstadel->macaddr); */ + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); -+ if (pwlan) -+ { ++ if (pwlan) { + pwlan->fixed = false; + rtw_free_network_nolock(adapter, pwlan); + } @@ -12109,14 +11978,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + rtw_generate_random_ibss(pibss); + -+ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); + } + -+ if (rtw_createbss_cmd(adapter)!= _SUCCESS) -+ { ++ if (rtw_createbss_cmd(adapter) != _SUCCESS) { + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd status FAIL***\n ")); + @@ -12135,7 +12002,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + struct reportpwrstate_parm *preportpwrstate; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback !!!\n")); -+ preportpwrstate = (struct reportpwrstate_parm*)pbuf; ++ preportpwrstate = (struct reportpwrstate_parm *)pbuf; + preportpwrstate->state |= (u8)(adapter_to_pwrctl(padapter)->cpwm_tog + 0x80); + cpwm_int_hdl(padapter, preportpwrstate); +} @@ -12156,7 +12023,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + DBG_871X("%s, fw_state =%x\n", __func__, get_fwstate(pmlmepriv)); + -+ if (adapter->bDriverStopped ||adapter->bSurpriseRemoved) ++ if (adapter->bDriverStopped || adapter->bSurpriseRemoved) + return; + + spin_lock_bh(&pmlmepriv->lock); @@ -12167,15 +12034,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + if (rtw_to_roam(adapter) != 0) { /* try another */ + int do_join_r; + DBG_871X("%s try another roaming\n", __func__); -+ if (_SUCCESS!=(do_join_r =rtw_do_join(adapter))) { -+ DBG_871X("%s roaming do_join return %d\n", __func__ , do_join_r); ++ do_join_r = rtw_do_join(adapter); ++ if (_SUCCESS != do_join_r) { ++ DBG_871X("%s roaming do_join return %d\n", __func__, do_join_r); + continue; + } + break; + } else { +#ifdef CONFIG_INTEL_WIDI -+ if (adapter->mlmepriv.widi_state == INTEL_WIDI_STATE_ROAMING) -+ { ++ if (adapter->mlmepriv.widi_state == INTEL_WIDI_STATE_ROAMING) { + memset(pmlmepriv->sa_ext, 0x00, L2SDTA_SERVICE_VE_LEN); + intel_widi_wk_cmd(adapter, INTEL_WIDI_LISTEN_WK, NULL, 0); + DBG_871X("change to widi listen\n"); @@ -12187,8 +12054,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + } + } + -+ } else -+ { ++ } else{ + rtw_indicate_disconnect(adapter); + free_scanqueue(pmlmepriv);/* */ + @@ -12226,17 +12092,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmeinfo->VHT_enable) /* disable auto scan when connect to 11AC AP */ -+ { + mlme->auto_scan_int_ms = 0; -+ } -+ else if (adapter->registrypriv.wifi_spec && is_client_associated_to_ap(adapter) == true) { ++ else if (adapter->registrypriv.wifi_spec && is_client_associated_to_ap(adapter) == true) + mlme->auto_scan_int_ms = 60*1000; -+ } else if (rtw_chk_roam_flags(adapter, RTW_ROAM_ACTIVE)) { ++ else if (rtw_chk_roam_flags(adapter, RTW_ROAM_ACTIVE)) { + if (check_fwstate(mlme, WIFI_STATION_STATE) && check_fwstate(mlme, _FW_LINKED)) + mlme->auto_scan_int_ms = mlme->roam_scan_int_ms; -+ } else { ++ } else + mlme->auto_scan_int_ms = 0; /* disabled */ -+ } + + return; +} @@ -12251,14 +12114,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + && jiffies_to_msecs(jiffies - pmlmepriv->scan_start_time) > pmlmepriv->auto_scan_int_ms) { + + if (!padapter->registrypriv.wifi_spec) { -+ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) -+ { ++ if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) { + DBG_871X(FUNC_ADPT_FMT" _FW_UNDER_SURVEY|_FW_UNDER_LINKING\n", FUNC_ADPT_ARG(padapter)); + goto exit; + } + -+ if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) -+ { ++ if (pmlmepriv->LinkDetectInfo.bBusyTraffic == true) { + DBG_871X(FUNC_ADPT_FMT" exit BusyTraffic\n", FUNC_ADPT_ARG(padapter)); + goto exit; + } @@ -12281,41 +12142,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + if (adapter->hw_init_completed == false) + return; + -+ if ((adapter->bDriverStopped == true)||(adapter->bSurpriseRemoved == true)) ++ if ((adapter->bDriverStopped == true) || (adapter->bSurpriseRemoved == true)) + return; + + if (adapter->net_closed == true) -+ { + return; -+ } + + if (is_primary_adapter(adapter)) + DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", rtw_btcoex_IsBtDisabled(adapter), rtw_btcoex_IsBtControlLps(adapter)); + -+ if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode ==true) ++ if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == true) + && (rtw_btcoex_IsBtControlLps(adapter) == false) -+ ) -+ { ++ ) { + u8 bEnterPS; + + linked_status_chk(adapter); + + bEnterPS = traffic_status_watchdog(adapter, 1); -+ if (bEnterPS) -+ { ++ if (bEnterPS) { + /* rtw_lps_ctrl_wk_cmd(adapter, LPS_CTRL_ENTER, 1); */ + rtw_hal_dm_watchdog_in_lps(adapter); -+ } -+ else -+ { ++ } else{ + /* call rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, 1) in traffic_status_watchdog() */ + } + -+ } -+ else -+ { -+ if (is_primary_adapter(adapter)) -+ { ++ } else{ ++ if (is_primary_adapter(adapter)) { + rtw_dynamic_chk_wk_cmd(adapter); + } + } @@ -12371,7 +12223,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + goto exit; + + DBG_871X("roam candidate:%s %s("MAC_FMT", ch%3u) rssi:%d, age:%5d\n", -+ (competitor == mlme->cur_network_scanned)?"*":" " , ++ (competitor == mlme->cur_network_scanned)?"*":" ", + competitor->network.Ssid.Ssid, + MAC_ARG(competitor->network.MacAddress), + competitor->network.Configuration.DSConfig, @@ -12392,7 +12244,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + if (competitor->network.Rssi - mlme->cur_network_scanned->network.Rssi < mlme->roam_rssi_diff_th) + goto exit; + -+ if (*candidate != NULL && (*candidate)->network.Rssi>=competitor->network.Rssi) ++ if (*candidate != NULL && (*candidate)->network.Rssi >= competitor->network.Rssi) + goto exit; + +update: @@ -12479,7 +12331,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + + /* check bssid, if needed */ -+ if (mlme->assoc_by_bssid ==true) { ++ if (mlme->assoc_by_bssid == true) { + if (memcmp(competitor->network.MacAddress, mlme->assoc_bssid, ETH_ALEN)) + goto exit; + } @@ -12502,8 +12354,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + goto exit; + } + -+ if (*candidate == NULL ||(*candidate)->network.Rssinetwork.Rssi) -+ { ++ if (*candidate == NULL || (*candidate)->network.Rssi < competitor->network.Rssi) { + *candidate = competitor; + updated = true; + } @@ -12597,13 +12448,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +candidate_exist: + + /* check for situation of _FW_LINKED */ -+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) -+ { ++ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + DBG_871X("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__); + -+ rtw_disassoc_cmd(adapter, 0, true); -+ rtw_indicate_disconnect(adapter); -+ rtw_free_assoc_resources(adapter, 0); ++ rtw_disassoc_cmd(adapter, 0, true); ++ rtw_indicate_disconnect(adapter); ++ rtw_free_assoc_resources(adapter, 0); + } + + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); @@ -12614,20 +12464,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + return ret; +} + -+sint rtw_set_auth(struct adapter * adapter, struct security_priv *psecuritypriv) ++sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) +{ -+ struct cmd_obj* pcmd; ++ struct cmd_obj *pcmd; + struct setauth_parm *psetauthparm; -+ struct cmd_priv *pcmdpriv =&(adapter->cmdpriv); ++ struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); + sint res = _SUCCESS; + -+ pcmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; /* try again */ + goto exit; + } + -+ psetauthparm =(struct setauth_parm*)rtw_zmalloc(sizeof(struct setauth_parm)); ++ psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); + if (psetauthparm == NULL) { + kfree((unsigned char *)pcmd); + res = _FAIL; @@ -12635,7 +12485,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + } + + memset(psetauthparm, 0, sizeof(struct setauth_parm)); -+ psetauthparm->mode =(unsigned char)psecuritypriv->dot11AuthAlgrthm; ++ psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; + + pcmd->cmdcode = _SetAuth_CMD_; + pcmd->parmbuf = (unsigned char *)psetauthparm; @@ -12654,7 +12504,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + return res; +} + -+sint rtw_set_key(struct adapter * adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue) ++sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, sint keyid, u8 set_tx, bool enqueue) +{ + u8 keylen; + struct cmd_obj *pcmd; @@ -12662,19 +12512,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); + sint res = _SUCCESS; + -+ psetkeyparm =(struct setkey_parm*)rtw_zmalloc(sizeof(struct setkey_parm)); ++ psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + if (psetkeyparm == NULL) { + res = _FAIL; + goto exit; + } + memset(psetkeyparm, 0, sizeof(struct setkey_parm)); + -+ if (psecuritypriv->dot11AuthAlgrthm ==dot11AuthAlgrthm_8021X) { -+ psetkeyparm->algorithm =(unsigned char)psecuritypriv->dot118021XGrpPrivacy; ++ if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { ++ psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key: psetkeyparm->algorithm =(unsigned char)psecuritypriv->dot118021XGrpPrivacy =%d\n", psetkeyparm->algorithm)); -+ } -+ else { -+ psetkeyparm->algorithm =(u8)psecuritypriv->dot11PrivacyAlgrthm; ++ } else { ++ psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key: psetkeyparm->algorithm =(u8)psecuritypriv->dot11PrivacyAlgrthm =%d\n", psetkeyparm->algorithm)); + + } @@ -12688,34 +12537,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + switch (psetkeyparm->algorithm) { + -+ case _WEP40_: -+ keylen =5; -+ memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); -+ break; -+ case _WEP104_: -+ keylen = 13; -+ memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); -+ break; -+ case _TKIP_: -+ keylen = 16; -+ memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); -+ psetkeyparm->grpkey = 1; -+ break; -+ case _AES_: -+ keylen = 16; -+ memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); -+ psetkeyparm->grpkey = 1; -+ break; -+ default: -+ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm = %x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm)); -+ res = _FAIL; -+ kfree((unsigned char *)psetkeyparm); -+ goto exit; ++ case _WEP40_: ++ keylen = 5; ++ memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); ++ break; ++ case _WEP104_: ++ keylen = 13; ++ memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); ++ break; ++ case _TKIP_: ++ keylen = 16; ++ memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); ++ psetkeyparm->grpkey = 1; ++ break; ++ case _AES_: ++ keylen = 16; ++ memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); ++ psetkeyparm->grpkey = 1; ++ break; ++ default: ++ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm = %x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm)); ++ res = _FAIL; ++ kfree((unsigned char *)psetkeyparm); ++ goto exit; + } + + + if (enqueue) { -+ pcmd = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); ++ pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + kfree((unsigned char *)psetkeyparm); + res = _FAIL; /* try again */ @@ -12733,8 +12582,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + /* sema_init(&(pcmd->cmd_sem), 0); */ + + res = rtw_enqueue_cmd(pcmdpriv, pcmd); -+ } -+ else { ++ } else{ + setkey_hdl(adapter, (u8 *)psetkeyparm); + kfree((u8 *) psetkeyparm); + } @@ -12749,25 +12597,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + unsigned int i, j; + + i = 12; /* after the fixed IE */ -+ while (isecuritypriv; ++ struct security_priv *psecuritypriv = &Adapter->securitypriv; + int i = 0; + -+ do -+ { ++ do { + if ((psecuritypriv->PMKIDList[i].bUsed) && -+ (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN))) -+ { ++ (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN))) { + break; -+ } -+ else -+ { ++ } else{ + i++; + /* continue; */ + } + -+ }while (isecuritypriv; ++ struct security_priv *psecuritypriv = &Adapter->securitypriv; + -+ if (ie[13]<=20) { ++ if (ie[13] <= 20) { + /* The RSN IE didn't include the PMK ID, append the PMK information */ -+ ie[ie_len]= 1; ++ ie[ie_len] = 1; + ie_len++; -+ ie[ie_len]= 0; /* PMKID count = 0x0100 */ ++ ie[ie_len] = 0; /* PMKID count = 0x0100 */ + ie_len++; + memcpy(&ie[ie_len], &psecuritypriv->PMKIDList[iEntry].PMKID, 16); + -+ ie_len+= 16; -+ ie[13]+= 18;/* PMKID length = 2+16 */ ++ ie_len += 16; ++ ie[13] += 18;/* PMKID length = 2+16 */ + + } -+ return (ie_len); ++ return ie_len; +} + +sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) @@ -12853,8 +12691,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + int iEntry; + + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; -+ struct security_priv *psecuritypriv =&adapter->securitypriv; -+ uint ndisauthmode =psecuritypriv->ndisauthtype; ++ struct security_priv *psecuritypriv = &adapter->securitypriv; ++ uint ndisauthmode = psecuritypriv->ndisauthtype; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("+rtw_restruct_sec_ie: ndisauthmode =%d ndissecuritytype =%d\n", @@ -12863,19 +12701,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + /* copy fixed ie only */ + memcpy(out_ie, in_ie, 12); + ielength = 12; -+ if ((ndisauthmode ==Ndis802_11AuthModeWPA)||(ndisauthmode ==Ndis802_11AuthModeWPAPSK)) ++ if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == Ndis802_11AuthModeWPAPSK)) + authmode = _WPA_IE_ID_; -+ if ((ndisauthmode ==Ndis802_11AuthModeWPA2)||(ndisauthmode ==Ndis802_11AuthModeWPA2PSK)) ++ if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) + authmode = _WPA2_IE_ID_; + -+ if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { + memcpy(out_ie+ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); + + ielength += psecuritypriv->wps_ie_len; -+ } -+ else if ((authmode == _WPA_IE_ID_)||(authmode == _WPA2_IE_ID_)) -+ { ++ } else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) { + /* copy RSN or SSN */ + memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1]+2); + /* debug for CONFIG_IEEE80211W @@ -12886,29 +12721,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + printk(" %02x ", psecuritypriv->supplicant_ie[jj]); + printk("\n"); + }*/ -+ ielength+=psecuritypriv->supplicant_ie[1]+2; ++ ielength += psecuritypriv->supplicant_ie[1]+2; + rtw_report_sec_ie(adapter, authmode, psecuritypriv->supplicant_ie); + } + + iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); -+ if (iEntry<0) -+ { ++ if (iEntry < 0) { + return ielength; -+ } -+ else -+ { ++ } else{ + if (authmode == _WPA2_IE_ID_) -+ { -+ ielength =rtw_append_pmkid(adapter, iEntry, out_ie, ielength); -+ } ++ ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); + } + return ielength; +} + -+void rtw_init_registrypriv_dev_network(struct adapter * adapter) ++void rtw_init_registrypriv_dev_network(struct adapter *adapter) +{ -+ struct registry_priv* pregistrypriv = &adapter->registrypriv; -+ struct eeprom_priv* peepriv = &adapter->eeprompriv; ++ struct registry_priv *pregistrypriv = &adapter->registrypriv; ++ struct eeprom_priv *peepriv = &adapter->eeprompriv; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + u8 *myhwaddr = myid(peepriv); + @@ -12916,7 +12746,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); + -+ pdev_network->Configuration.Length =sizeof(struct ndis_802_11_conf); ++ pdev_network->Configuration.Length = sizeof(struct ndis_802_11_conf); + pdev_network->Configuration.BeaconPeriod = 100; + pdev_network->Configuration.FHConfig.Length = 0; + pdev_network->Configuration.FHConfig.HopPattern = 0; @@ -12924,12 +12754,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + pdev_network->Configuration.FHConfig.DwellTime = 0; +} + -+void rtw_update_registrypriv_dev_network(struct adapter * adapter) ++void rtw_update_registrypriv_dev_network(struct adapter *adapter) +{ + int sz = 0; -+ struct registry_priv* pregistrypriv = &adapter->registrypriv; ++ struct registry_priv *pregistrypriv = &adapter->registrypriv; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; -+ struct security_priv*psecuritypriv = &adapter->securitypriv; ++ struct security_priv *psecuritypriv = &adapter->securitypriv; + struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; + /* struct xmit_priv *pxmitpriv = &adapter->xmitpriv; */ + @@ -12937,31 +12767,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + pdev_network->Rssi = 0; + -+ switch (pregistrypriv->wireless_mode) -+ { -+ case WIRELESS_11B: -+ pdev_network->NetworkTypeInUse = (Ndis802_11DS); -+ break; -+ case WIRELESS_11G: -+ case WIRELESS_11BG: -+ case WIRELESS_11_24N: -+ case WIRELESS_11G_24N: -+ case WIRELESS_11BG_24N: -+ pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); -+ break; -+ case WIRELESS_11A: -+ case WIRELESS_11A_5N: ++ switch (pregistrypriv->wireless_mode) { ++ case WIRELESS_11B: ++ pdev_network->NetworkTypeInUse = (Ndis802_11DS); ++ break; ++ case WIRELESS_11G: ++ case WIRELESS_11BG: ++ case WIRELESS_11_24N: ++ case WIRELESS_11G_24N: ++ case WIRELESS_11BG_24N: ++ pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); ++ break; ++ case WIRELESS_11A: ++ case WIRELESS_11A_5N: ++ pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); ++ break; ++ case WIRELESS_11ABGN: ++ if (pregistrypriv->channel > 14) + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); -+ break; -+ case WIRELESS_11ABGN: -+ if (pregistrypriv->channel > 14) -+ pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); -+ else -+ pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); -+ break; -+ default : -+ /* TODO */ -+ break; ++ else ++ pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); ++ break; ++ default: ++ /* TODO */ ++ break; + } + + pdev_network->Configuration.DSConfig = (pregistrypriv->channel); @@ -12986,7 +12815,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + /* pdev_network->IELength = cpu_to_le32(sz); */ +} + -+void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter * adapter) ++void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter) +{ +} + @@ -13008,16 +12837,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + /* TH = 1 => means that invalidate usb rx aggregation */ + /* TH = 0 => means that validate usb rx aggregation, use init value. */ -+ if (phtpriv->ht_option) -+ { ++ if (phtpriv->ht_option) { + if (padapter->registrypriv.wifi_spec == 1) + threshold = 1; + else + threshold = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); -+ } -+ else -+ { ++ } else{ + threshold = 1; + rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); + } @@ -13042,14 +12868,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + /* LDPC support */ + rtw_hal_get_def_var(padapter, HAL_DEF_RX_LDPC, (u8 *)&bHwLDPCSupport); + CLEAR_FLAGS(phtpriv->ldpc_cap); -+ if (bHwLDPCSupport) -+ { ++ if (bHwLDPCSupport) { + if (TEST_FLAG(pregistrypriv->ldpc_cap, BIT4)) + SET_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_RX); + } + rtw_hal_get_def_var(padapter, HAL_DEF_TX_LDPC, (u8 *)&bHwLDPCSupport); -+ if (bHwLDPCSupport) -+ { ++ if (bHwLDPCSupport) { + if (TEST_FLAG(pregistrypriv->ldpc_cap, BIT5)) + SET_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_TX); + } @@ -13059,14 +12883,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + /* STBC */ + rtw_hal_get_def_var(padapter, HAL_DEF_TX_STBC, (u8 *)&bHwSTBCSupport); + CLEAR_FLAGS(phtpriv->stbc_cap); -+ if (bHwSTBCSupport) -+ { ++ if (bHwSTBCSupport) { + if (TEST_FLAG(pregistrypriv->stbc_cap, BIT5)) + SET_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX); + } + rtw_hal_get_def_var(padapter, HAL_DEF_RX_STBC, (u8 *)&bHwSTBCSupport); -+ if (bHwSTBCSupport) -+ { ++ if (bHwSTBCSupport) { + if (TEST_FLAG(pregistrypriv->stbc_cap, BIT4)) + SET_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_RX); + } @@ -13077,13 +12899,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + rtw_hal_get_def_var(padapter, HAL_DEF_EXPLICIT_BEAMFORMER, (u8 *)&bHwSupportBeamformer); + rtw_hal_get_def_var(padapter, HAL_DEF_EXPLICIT_BEAMFORMEE, (u8 *)&bHwSupportBeamformee); + CLEAR_FLAGS(phtpriv->beamform_cap); -+ if (TEST_FLAG(pregistrypriv->beamform_cap, BIT4) && bHwSupportBeamformer) -+ { ++ if (TEST_FLAG(pregistrypriv->beamform_cap, BIT4) && bHwSupportBeamformer) { + SET_FLAG(phtpriv->beamform_cap, BEAMFORMING_HT_BEAMFORMER_ENABLE); + DBG_871X("[HT] Support Beamformer\n"); + } -+ if (TEST_FLAG(pregistrypriv->beamform_cap, BIT5) && bHwSupportBeamformee) -+ { ++ if (TEST_FLAG(pregistrypriv->beamform_cap, BIT5) && bHwSupportBeamformee) { + SET_FLAG(phtpriv->beamform_cap, BEAMFORMING_HT_BEAMFORMEE_ENABLE); + DBG_871X("[HT] Support Beamformee\n"); + } @@ -13095,8 +12915,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + int out_len; + u8 *pframe; + -+ if (padapter->mlmepriv.qospriv.qos_option == 0) -+ { ++ if (padapter->mlmepriv.qospriv.qos_option == 0) { + out_len = *pout_len; + pframe = rtw_set_ie(out_ie+out_len, _VENDOR_SPECIFIC_IE_, + _WMM_IE_Length_, WMM_IE, pout_len); @@ -13199,7 +13018,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + if (stbc_rx_enable) + ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_1R);/* RX STBC One spatial stream */ + -+ set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_1R); ++ set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_1R); + break; + + case RF_2T2R: @@ -13209,7 +13028,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_2R);/* RX STBC two spatial stream */ + + #ifdef CONFIG_DISABLE_MCS13TO15 -+ if (((cbw40_enable == 1) && (operation_bw == CHANNEL_WIDTH_40)) && (pregistrypriv->wifi_spec!= 1)) ++ if (((cbw40_enable == 1) && (operation_bw == CHANNEL_WIDTH_40)) && (pregistrypriv->wifi_spec != 1)) + set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_2R_13TO15_OFF); + else + set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_2R); @@ -13241,21 +13060,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + + pframe = rtw_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, -+ sizeof(struct rtw_ieee80211_ht_cap), (unsigned char*)&ht_capie, pout_len); ++ sizeof(struct rtw_ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); + + phtpriv->ht_option = true; + -+ if (in_ie!= NULL) -+ { ++ if (in_ie != NULL) { + p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len); -+ if (p && (ielen ==sizeof(struct ieee80211_ht_addt_info))) -+ { ++ if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { + out_len = *pout_len; -+ pframe = rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2 , pout_len); ++ pframe = rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2, pout_len); + } + } + -+ return (phtpriv->ht_option); ++ return phtpriv->ht_option; + +} + @@ -13287,21 +13104,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + DBG_871X("+rtw_update_ht_cap()\n"); + + /* maybe needs check if ap supports rx ampdu. */ -+ if ((phtpriv->ampdu_enable ==false) && (pregistrypriv->ampdu_enable == 1)) -+ { -+ if (pregistrypriv->wifi_spec == 1) -+ { ++ if ((phtpriv->ampdu_enable == false) && (pregistrypriv->ampdu_enable == 1)) { ++ if (pregistrypriv->wifi_spec == 1) { + /* remove this part because testbed AP should disable RX AMPDU */ + /* phtpriv->ampdu_enable = false; */ + phtpriv->ampdu_enable = true; -+ } -+ else -+ { ++ } else { + phtpriv->ampdu_enable = true; + } -+ } -+ else if (pregistrypriv->ampdu_enable ==2) -+ { ++ } else if (pregistrypriv->ampdu_enable == 2) { + /* remove this part because testbed AP should disable RX AMPDU */ + /* phtpriv->ampdu_enable = true; */ + } @@ -13309,9 +13120,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + /* check Max Rx A-MPDU Size */ + len = 0; -+ p = rtw_get_ie(pie+sizeof (struct ndis_802_11_fix_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof (struct ndis_802_11_fix_ie)); -+ if (p && len>0) -+ { ++ p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); ++ if (p && len > 0) { + pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); + max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); + max_ampdu_sz = 1 << (max_ampdu_sz+3); /* max_ampdu_sz (kbytes); */ @@ -13323,9 +13133,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + + len = 0; -+ p = rtw_get_ie(pie+sizeof (struct ndis_802_11_fix_ie), _HT_ADD_INFO_IE_, &len, ie_len-sizeof (struct ndis_802_11_fix_ie)); -+ if (p && len>0) -+ { ++ p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), _HT_ADD_INFO_IE_, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); ++ if (p && len > 0) { + pht_addtinfo = (struct ieee80211_ht_addt_info *)(p+2); + /* todo: */ + } @@ -13352,39 +13161,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= pmlmeext->default_supported_mcs_set[i]; + + /* update the MCS rates */ -+ switch (rf_type) -+ { -+ case RF_1T1R: -+ case RF_1T2R: -+ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R); -+ break; -+ case RF_2T2R: -+ default: ++ switch (rf_type) { ++ case RF_1T1R: ++ case RF_1T2R: ++ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R); ++ break; ++ case RF_2T2R: ++ default: +#ifdef CONFIG_DISABLE_MCS13TO15 -+ if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1) -+ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF); -+ else -+ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R); -+#else /* CONFIG_DISABLE_MCS13TO15 */ ++ if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1) ++ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF); ++ else + set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R); ++#else /* CONFIG_DISABLE_MCS13TO15 */ ++ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R); +#endif /* CONFIG_DISABLE_MCS13TO15 */ -+ } ++ } + -+ /* switch to the 40M Hz mode accoring to the AP */ -+ /* pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; */ -+ switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) -+ { -+ case EXTCHNL_OFFSET_UPPER: -+ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; -+ break; ++ /* switch to the 40M Hz mode accoring to the AP */ ++ /* pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; */ ++ switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) { ++ case EXTCHNL_OFFSET_UPPER: ++ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; ++ break; + -+ case EXTCHNL_OFFSET_LOWER: -+ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; -+ break; ++ case EXTCHNL_OFFSET_LOWER: ++ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; ++ break; + -+ default: -+ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; -+ break; ++ default: ++ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; ++ break; + } + } + @@ -13395,9 +13202,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & + 0x0C) >> 2; + if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) -+ { + DBG_871X("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); -+ } + + /* */ + /* Config current HT Protection mode. */ @@ -13411,30 +13216,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + int priority; + struct sta_info *psta = NULL; + struct ht_priv *phtpriv; -+ struct pkt_attrib *pattrib =&pxmitframe->attrib; ++ struct pkt_attrib *pattrib = &pxmitframe->attrib; + s32 bmcst = IS_MCAST(pattrib->ra); + + /* if (bmcst || (padapter->mlmepriv.LinkDetectInfo.bTxBusyTraffic == false)) */ -+ if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod<100)) ++ if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100)) + return; + + priority = pattrib->priority; + + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); -+ if (pattrib->psta != psta) -+ { ++ if (pattrib->psta != psta) { + DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta); + return; + } + -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + DBG_871X("%s, psta ==NUL\n", __func__); + return; + } + -+ if (!(psta->state &_FW_LINKED)) -+ { ++ if (!(psta->state & _FW_LINKED)) { + DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + return; + } @@ -13442,13 +13244,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + + phtpriv = &psta->htpriv; + -+ if ((phtpriv->ht_option ==true) && (phtpriv->ampdu_enable ==true)) -+ { ++ if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) { + issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; + issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; + -+ if (0 ==issued) -+ { ++ if (0 == issued) { + DBG_871X("rtw_issue_addbareq_cmd, p =%d\n", priority); + psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority); + rtw_addbareq_cmd(padapter, (u8) priority, pattrib->ra); @@ -13469,7 +13269,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + SET_EXT_CAPABILITY_ELE_BSS_COEXIST(cap_content, 1); + } + -+ pframe = rtw_set_ie(out_ie+*pout_len, EID_EXTCapability, 8, cap_content , pout_len); ++ pframe = rtw_set_ie(out_ie + *pout_len, EID_EXTCapability, 8, cap_content, pout_len); +} + +inline void rtw_set_to_roam(struct adapter *adapter, u8 to_roam) @@ -13513,7 +13313,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp + pmlmepriv->assoc_by_bssid = false; + + while (1) { -+ if (_SUCCESS ==(do_join_r =rtw_do_join(padapter))) { ++ do_join_r = rtw_do_join(padapter); ++ if (_SUCCESS == do_join_r) { + break; + } else { + DBG_871X("roaming do_join return %d\n", do_join_r); @@ -13535,22 +13336,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme.c linux-4.3-rtl8723bs/3rdp +sint rtw_linked_check(struct adapter *padapter) +{ + if ((check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true) || -+ (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true)) -+ { ++ (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true)) { + if (padapter->stapriv.asoc_sta_count > 2) + return true; -+ } -+ else -+ { /* Station mode */ ++ } else{ /* Station mode */ + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == true) + return true; + } + return false; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_mlme_ext.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_mlme_ext.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,7376 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux/3rdparty/rtl8723bs/core/rtw_mlme_ext.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_mlme_ext.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_mlme_ext.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,6940 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -13572,7 +13370,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +#include + + -+static struct mlme_handler mlme_sta_tbl[]={ ++static struct mlme_handler mlme_sta_tbl[] = { + {WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq}, + {WIFI_ASSOCRSP, "OnAssocRsp", &OnAssocRsp}, + {WIFI_REASSOCREQ, "OnReAssocReq", &OnAssocReq}, @@ -13591,10 +13389,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + {WIFI_AUTH, "OnAuth", &OnAuthClient}, + {WIFI_DEAUTH, "OnDeAuth", &OnDeAuth}, + {WIFI_ACTION, "OnAction", &OnAction}, -+ {WIFI_ACTION_NOACK,"OnActionNoAck", &OnAction}, ++ {WIFI_ACTION_NOACK, "OnActionNoAck", &OnAction}, +}; + -+static struct action_handler OnAction_tbl[]={ ++static struct action_handler OnAction_tbl[] = { + {RTW_WLAN_CATEGORY_SPECTRUM_MGMT, "ACTION_SPECTRUM_MGMT", on_action_spct}, + {RTW_WLAN_CATEGORY_QOS, "ACTION_QOS", &DoReserved}, + {RTW_WLAN_CATEGORY_DLS, "ACTION_DLS", &DoReserved}, @@ -13612,7 +13410,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +}; + + -+static u8 null_addr[ETH_ALEN]= {0, 0, 0, 0, 0, 0}; ++static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + +/************************************************** +OUI definitions for the vendor specific IE @@ -13780,7 +13578,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +int rtw_ch_set_search_ch(RT_CHANNEL_INFO *ch_set, const u32 ch) +{ + int i; -+ for (i = 0;ch_set[i].ChannelNum!= 0;i++) { ++ for (i = 0; ch_set[i].ChannelNum != 0; i++) { + if (ch == ch_set[i].ChannelNum) + break; + } @@ -13827,7 +13625,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + unsigned char mixed_datarate[NumRates] = {_1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, _48M_RATE_, _54M_RATE_, 0xff}; -+ unsigned char mixed_basicrate[NumRates] ={_1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, _12M_RATE_, _24M_RATE_, 0xff,}; ++ unsigned char mixed_basicrate[NumRates] = {_1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, _12M_RATE_, _24M_RATE_, 0xff,}; + unsigned char supported_mcs_set[16] = {0xff, 0xff, 0x00, 0x00, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + + memcpy(pmlmeext->datarate, mixed_datarate, NumRates); @@ -13963,14 +13761,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + memset(channel_set, 0, sizeof(RT_CHANNEL_INFO)*MAX_CHANNEL_NUM); + -+ if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) -+ { ++ if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { + DBG_871X("ChannelPlan ID %x error !!!!!\n", ChannelPlan); + return chanset_size; + } + -+ if (IsSupported24G(padapter->registrypriv.wireless_mode)) -+ { ++ if (IsSupported24G(padapter->registrypriv.wireless_mode)) { + b2_4GBand = true; + if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; @@ -13978,42 +13774,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; + } + -+ if (b2_4GBand) -+ { -+ for (index = 0;index= 1 && channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14)) + channel_set[chanset_size].ScanType = SCAN_PASSIVE; -+ } -+ else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == ChannelPlan || ++ } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == ChannelPlan || + RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == ChannelPlan || -+ RT_CHANNEL_DOMAIN_2G_WORLD == Index2G)/* channel 12~13, passive scan */ -+ { ++ RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) { /* channel 12~13, passive scan */ + if (channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else + channel_set[chanset_size].ScanType = SCAN_PASSIVE; -+ } -+ else -+ { ++ } else + channel_set[chanset_size].ScanType = SCAN_ACTIVE; -+ } + + chanset_size++; + } + } + -+ if (b5GBand) -+ { -+ for (index = 0;index= 149) { + channel_set[chanset_size].ChannelNum = RTW_ChannelPlan5G[Index5G].Channel[index]; @@ -14034,7 +13820,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +int init_mlme_ext_priv(struct adapter *padapter) +{ + int res = _SUCCESS; -+ struct registry_priv* pregistrypriv = &padapter->registrypriv; ++ struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -14068,15 +13854,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + +} + -+void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext) ++void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) +{ + struct adapter *padapter = pmlmeext->padapter; + + if (!padapter) + return; + -+ if (padapter->bDriverStopped == true) -+ { ++ if (padapter->bDriverStopped == true) { + del_timer_sync(&pmlmeext->survey_timer); + del_timer_sync(&pmlmeext->link_timer); + /* del_timer_sync(&pmlmeext->ADDBA_timer); */ @@ -14088,17 +13873,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 *pframe = precv_frame->u.hdr.rx_data; + -+ if (ptable->func) -+ { -+ /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ -+ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && -+ memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) -+ { -+ return; -+ } ++ if (ptable->func) { ++ /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ ++ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && ++ memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) ++ return; + -+ ptable->func(padapter, precv_frame); -+ } ++ ptable->func(padapter, precv_frame); ++ } + +} + @@ -14117,16 +13899,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + ("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n", + GetFrameType(pframe), GetFrameSubType(pframe))); + -+ if (GetFrameType(pframe) != WIFI_MGT_TYPE) -+ { ++ if (GetFrameType(pframe) != WIFI_MGT_TYPE) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: type(0x%x) error!\n", GetFrameType(pframe))); + return; + } + + /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && -+ memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) -+ { ++ memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) { + return; + } + @@ -14134,19 +13914,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + index = GetFrameSubType(pframe) >> 4; + -+ if (index >= (sizeof(mlme_sta_tbl) /sizeof(struct mlme_handler))) -+ { ++ if (index >= (sizeof(mlme_sta_tbl) / sizeof(struct mlme_handler))) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type =%d\n", index)); + return; + } + ptable += index; + -+ if (psta != NULL) -+ { -+ if (GetRetry(pframe)) -+ { -+ if (precv_frame->u.hdr.attrib.seq_num == psta->RxMgmtFrameSeqNum) -+ { ++ if (psta != NULL) { ++ if (GetRetry(pframe)) { ++ if (precv_frame->u.hdr.attrib.seq_num == psta->RxMgmtFrameSeqNum) { + /* drop the duplicate management frame */ + pdbgpriv->dbg_rx_dup_mgt_frame_drop_count++; + DBG_871X("Drop duplicate management frame with seq_num = %d.\n", precv_frame->u.hdr.attrib.seq_num); @@ -14156,31 +13932,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + psta->RxMgmtFrameSeqNum = precv_frame->u.hdr.attrib.seq_num; + } + -+ switch (GetFrameSubType(pframe)) -+ { -+ case WIFI_AUTH: -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ ptable->func = &OnAuth; -+ else -+ ptable->func = &OnAuthClient; -+ /* pass through */ -+ case WIFI_ASSOCREQ: -+ case WIFI_REASSOCREQ: -+ _mgt_dispatcher(padapter, ptable, precv_frame); -+ break; -+ case WIFI_PROBEREQ: -+ _mgt_dispatcher(padapter, ptable, precv_frame); -+ break; -+ case WIFI_BEACON: -+ _mgt_dispatcher(padapter, ptable, precv_frame); -+ break; -+ case WIFI_ACTION: -+ /* if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) */ -+ _mgt_dispatcher(padapter, ptable, precv_frame); -+ break; -+ default: -+ _mgt_dispatcher(padapter, ptable, precv_frame); -+ break; ++ switch (GetFrameSubType(pframe)) { ++ case WIFI_AUTH: ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) ++ ptable->func = &OnAuth; ++ else ++ ptable->func = &OnAuthClient; ++ /* pass through */ ++ case WIFI_ASSOCREQ: ++ case WIFI_REASSOCREQ: ++ _mgt_dispatcher(padapter, ptable, precv_frame); ++ break; ++ case WIFI_PROBEREQ: ++ _mgt_dispatcher(padapter, ptable, precv_frame); ++ break; ++ case WIFI_BEACON: ++ _mgt_dispatcher(padapter, ptable, precv_frame); ++ break; ++ case WIFI_ACTION: ++ /* if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) */ ++ _mgt_dispatcher(padapter, ptable, precv_frame); ++ break; ++ default: ++ _mgt_dispatcher(padapter, ptable, precv_frame); ++ break; + } +} + @@ -14203,13 +13978,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 is_valid_p2p_probereq = false; + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) -+ { + return _SUCCESS; -+ } + + if (check_fwstate(pmlmepriv, _FW_LINKED) == false && -+ check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE) ==false) -+ { ++ check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE) == false) { + return _SUCCESS; + } + @@ -14218,12 +13990,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + +#ifdef CONFIG_AUTO_AP_MODE + if (check_fwstate(pmlmepriv, _FW_LINKED) == true && -+ pmlmepriv->cur_network.join_res == true) -+ { ++ pmlmepriv->cur_network.join_res == true) { + struct sta_info *psta; + u8 *mac_addr, *peer_addr; + struct sta_priv *pstapriv = &padapter->stapriv; -+ u8 RC_OUI[4]={0x00, 0xE0, 0x4C, 0x0A}; ++ u8 RC_OUI[4] = {0x00, 0xE0, 0x4C, 0x0A}; + /* EID[1] + EID_LEN[1] + RC_OUI[4] + MAC[6] + PairingID[2] + ChannelNum[2] */ + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, (int *)&ielen, @@ -14235,8 +14006,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (memcmp(p+2, RC_OUI, sizeof(RC_OUI))) + goto _non_rc_device; + -+ if (memcmp(p+6, get_sa(pframe), ETH_ALEN)) -+ { ++ if (memcmp(p+6, get_sa(pframe), ETH_ALEN)) { + DBG_871X("%s, do rc pairing ("MAC_FMT"), but mac addr mismatch!("MAC_FMT")\n", __func__, + MAC_ARG(get_sa(pframe)), MAC_ARG(p+6)); + @@ -14247,21 +14017,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* new a station */ + psta = rtw_get_stainfo(pstapriv, get_sa(pframe)); -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + /* allocate a new one */ + DBG_871X("going to alloc stainfo for rc ="MAC_FMT"\n", MAC_ARG(get_sa(pframe))); + psta = rtw_alloc_stainfo(pstapriv, get_sa(pframe)); -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + /* TODO: */ + DBG_871X(" Exceed the upper limit of supported clients...\n"); + return _SUCCESS; + } + + spin_lock_bh(&pstapriv->asoc_list_lock); -+ if (list_empty(&psta->asoc_list)) -+ { ++ if (list_empty(&psta->asoc_list)) { + psta->expire_to = pstapriv->expire_to; + list_add_tail(&psta->asoc_list, &pstapriv->asoc_list); + pstapriv->asoc_list_cnt++; @@ -14309,7 +14076,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + -+ memset((void*)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); ++ memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + spin_lock_bh(&psta->lock); + psta->state |= _FW_LINKED; @@ -14336,24 +14103,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + + /* check (wildcard) SSID */ -+ if (p != NULL) -+ { ++ if (p != NULL) { + if (is_valid_p2p_probereq == true) -+ { + goto _issue_probersp; -+ } + -+ if ((ielen != 0 && false ==!memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) ++ if ((ielen != 0 && false == !memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) + || (ielen == 0 && pmlmeinfo->hidden_ssid_mode) + ) -+ { + return _SUCCESS; -+ } + +_issue_probersp: + if (((check_fwstate(pmlmepriv, _FW_LINKED) == true && -+ pmlmepriv->cur_network.join_res == true)) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) -+ { ++ pmlmepriv->cur_network.join_res == true)) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + /* DBG_871X("+issue_probersp during ap mode\n"); */ + issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq); + } @@ -14368,8 +14129,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + -+ if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) -+ { ++ if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + report_survey_event(padapter, precv_frame); + return _SUCCESS; + } @@ -14393,29 +14153,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 *p = NULL; + u32 ielen = 0; + -+ p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ielen, precv_frame->u.hdr.len -sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_); -+ if ((p != NULL) && (ielen > 0)) -+ { -+ if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) -+ { ++ p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ielen, precv_frame->u.hdr.len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_); ++ if ((p != NULL) && (ielen > 0)) { ++ if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { + /* Invalid value 0x2D is detected in Extended Supported Rates (ESR) IE. Try to fix the IE length to avoid failed Beacon parsing. */ + DBG_871X("[WIFIDBG] Error in ESR IE is detected in Beacon of BSSID:"MAC_FMT". Fix the length of ESR IE to avoid failed Beacon parsing.\n", MAC_ARG(GetAddr3Ptr(pframe))); + *(p + 1) = ielen - 1; + } + } + -+ if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) -+ { ++ if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + report_survey_event(padapter, precv_frame); + return _SUCCESS; + } + -+ if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) -+ { -+ if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) -+ { ++ if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { ++ if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + /* we should update current network before auth, or some IE is wrong */ -+ pbss = (struct wlan_bssid_ex*)rtw_malloc(sizeof(struct wlan_bssid_ex)); ++ pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); + if (pbss) { + if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { + update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); @@ -14444,50 +14199,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + return _SUCCESS; + } + -+ if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) -+ { -+ if ((psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe))) != NULL) -+ { ++ if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { ++ psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); ++ if (psta != NULL) { + ret = rtw_check_bcn_info(padapter, pframe, len); + if (!ret) { + DBG_871X_LEVEL(_drv_always_, "ap has changed, disconnect now\n "); -+ receive_disconnect(padapter, pmlmeinfo->network.MacAddress , 0); ++ receive_disconnect(padapter, pmlmeinfo->network.MacAddress, 0); + return _SUCCESS; + } + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) -+ { + /* DBG_871X("update_bcn_info\n"); */ + update_beacon_info(padapter, pframe, len, psta); -+ } + + adaptive_early_32k(pmlmeext, pframe, len); + } -+ } -+ else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) -+ { -+ if ((psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe))) != NULL) -+ { ++ } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { ++ psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); ++ if (psta != NULL) { + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ -+ if ((sta_rx_pkts(psta) & 0xf) == 0) -+ { ++ if ((sta_rx_pkts(psta) & 0xf) == 0) { + /* DBG_871X("update_bcn_info\n"); */ + update_beacon_info(padapter, pframe, len, psta); + } -+ } -+ else -+ { ++ } else{ + /* allocate a new CAM entry for IBSS station */ -+ if ((cam_idx = allocate_fw_sta_entry(padapter)) == NUM_STA) -+ { ++ cam_idx = allocate_fw_sta_entry(padapter); ++ if (cam_idx == NUM_STA) + goto _END_ONBEACON_; -+ } + + /* get supported rate */ -+ if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) -+ { ++ if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { + pmlmeinfo->FW_sta_info[cam_idx].status = 0; + goto _END_ONBEACON_; + } @@ -14532,8 +14277,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + auth_mode = psecuritypriv->dot11AuthAlgrthm; + -+ if (GetPrivacy(pframe)) -+ { ++ if (GetPrivacy(pframe)) { + u8 *iv; + struct rx_pkt_attrib *prxattrib = &(precv_frame->u.hdr.attrib); + @@ -14551,8 +14295,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + offset = 4; + } + -+ algorithm = le16_to_cpu(*(__le16*)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset)); -+ seq = le16_to_cpu(*(__le16*)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 2)); ++ algorithm = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset)); ++ seq = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 2)); + + DBG_871X("auth alg =%x, seq =%X\n", algorithm, seq); + @@ -14562,8 +14306,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + auth_mode = 0; + + if ((algorithm > 0 && auth_mode == 0) || /* rx a shared-key auth but shared not enabled */ -+ (algorithm == 0 && auth_mode == 1)) /* rx a open-system auth but shared-key is enabled */ -+ { ++ (algorithm == 0 && auth_mode == 1)) { /* rx a open-system auth but shared-key is enabled */ + DBG_871X("auth rejected due to bad alg [alg =%d, auth_mib =%d] %02X%02X%02X%02X%02X%02X\n", + algorithm, auth_mode, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); + @@ -14572,21 +14315,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + goto auth_fail; + } + -+ if (rtw_access_ctrl(padapter, sa) == false) -+ { ++ if (rtw_access_ctrl(padapter, sa) == false) { + status = _STATS_UNABLE_HANDLE_STA_; + goto auth_fail; + } + + pstat = rtw_get_stainfo(pstapriv, sa); -+ if (pstat == NULL) -+ { ++ if (pstat == NULL) { + + /* allocate a new one */ + DBG_871X("going to alloc stainfo for sa ="MAC_FMT"\n", MAC_ARG(sa)); + pstat = rtw_alloc_stainfo(pstapriv, sa); -+ if (pstat == NULL) -+ { ++ if (pstat == NULL) { + DBG_871X(" Exceed the upper limit of supported clients...\n"); + status = _STATS_UNABLE_HANDLE_STA_; + goto auth_fail; @@ -14597,17 +14337,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* pstat->flags = 0; */ + /* pstat->capability = 0; */ -+ } -+ else -+ { ++ } else{ + + spin_lock_bh(&pstapriv->asoc_list_lock); -+ if (list_empty(&pstat->asoc_list) ==false) -+ { ++ if (list_empty(&pstat->asoc_list) == false) { + list_del_init(&pstat->asoc_list); + pstapriv->asoc_list_cnt--; -+ if (pstat->expire_to > 0) -+ { ++ if (pstat->expire_to > 0) { + /* TODO: STA re_auth within expire_to */ + } + } @@ -14619,8 +14355,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + spin_lock_bh(&pstapriv->auth_list_lock); -+ if (list_empty(&pstat->auth_list)) -+ { ++ if (list_empty(&pstat->auth_list)) { + + list_add_tail(&pstat->auth_list, &pstapriv->auth_list); + pstapriv->auth_list_cnt++; @@ -14631,33 +14366,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pstat->expire_to = pstapriv->auth_to; + + -+ if ((pstat->auth_seq + 1) != seq) -+ { ++ if ((pstat->auth_seq + 1) != seq) { + DBG_871X("(1)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + -+ if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2 || auth_mode == 3)) -+ { -+ if (seq == 1) -+ { ++ if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2 || auth_mode == 3)) { ++ if (seq == 1) { + pstat->state &= ~WIFI_FW_AUTH_NULL; + pstat->state |= WIFI_FW_AUTH_SUCCESS; + pstat->expire_to = pstapriv->assoc_to; + pstat->authalg = algorithm; -+ } -+ else -+ { ++ } else{ + DBG_871X("(2)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } -+ } -+ else /* shared system or auto authentication */ -+ { ++ } else{ /* shared system or auto authentication */ + if (seq == 1) { + /* prepare for the challenging txt... */ + memset((void *)pstat->chg_txt, 78, 128); @@ -14666,38 +14394,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pstat->state |= WIFI_FW_AUTH_STATE; + pstat->authalg = algorithm; + pstat->auth_seq = 2; -+ } -+ else if (seq == 3) -+ { ++ } else if (seq == 3) { + /* checking for challenging txt... */ + DBG_871X("checking for challenging txt...\n"); + -+ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_ , _CHLGETXT_IE_, (int *)&ie_len, ++ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&ie_len, + len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); + -+ if ((p == NULL) || (ie_len<= 0)) -+ { ++ if ((p == NULL) || (ie_len <= 0)) { + DBG_871X("auth rejected because challenge failure!(1)\n"); + status = _STATS_CHALLENGE_FAIL_; + goto auth_fail; + } + -+ if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) -+ { ++ if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) { + pstat->state &= (~WIFI_FW_AUTH_STATE); + pstat->state |= WIFI_FW_AUTH_SUCCESS; + /* challenging txt is correct... */ + pstat->expire_to = pstapriv->assoc_to; -+ } -+ else -+ { ++ } else{ + DBG_871X("auth rejected because challenge failure!\n"); + status = _STATS_CHALLENGE_FAIL_; + goto auth_fail; + } -+ } -+ else -+ { ++ } else{ + DBG_871X("(3)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; @@ -14720,7 +14440,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +auth_fail: + + if (pstat) -+ rtw_free_stainfo(padapter , pstat); ++ rtw_free_stainfo(padapter, pstat); + + pstat = &stat; + memset((char *)pstat, '\0', sizeof(stat)); @@ -14752,17 +14472,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) + return _SUCCESS; + -+ offset = (GetPrivacy(pframe))? 4: 0; ++ offset = (GetPrivacy(pframe)) ? 4 : 0; + + algthm = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset)); + seq = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 2)); + status = le16_to_cpu(*(__le16 *)((SIZE_PTR)pframe + WLAN_HDR_A3_LEN + offset + 4)); + -+ if (status != 0) -+ { ++ if (status != 0) { + DBG_871X("clnt auth fail, status: %d\n", status); -+ if (status == 13)/* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ -+ { ++ if (status == 13) { /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; + else @@ -14774,16 +14492,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + goto authclnt_fail; + } + -+ if (seq == 2) -+ { -+ if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) -+ { ++ if (seq == 2) { ++ if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { + /* legendary shared system */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, + pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); + -+ if (p == NULL) -+ { ++ if (p == NULL) { + /* DBG_871X("marc: no challenge text?\n"); */ + goto authclnt_fail; + } @@ -14794,33 +14509,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + set_link_timer(pmlmeext, REAUTH_TO); + + return _SUCCESS; -+ } -+ else -+ { ++ } else{ + /* open system */ + go2asoc = 1; + } -+ } -+ else if (seq == 4) -+ { -+ if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) -+ { ++ } else if (seq == 4) { ++ if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { + go2asoc = 1; -+ } -+ else -+ { ++ } else{ + goto authclnt_fail; + } -+ } -+ else -+ { ++ } else{ + /* this is also illegal */ + /* DBG_871X("marc: clnt auth failed due to illegal seq =%x\n", seq); */ + goto authclnt_fail; + } + -+ if (go2asoc) -+ { ++ if (go2asoc) { + DBG_871X_LEVEL(_drv_always_, "auth success, start assoc\n"); + start_clnt_assoc(padapter); + return _SUCCESS; @@ -14859,13 +14564,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + return _FAIL; + + frame_type = GetFrameSubType(pframe); -+ if (frame_type == WIFI_ASSOCREQ) -+ { ++ if (frame_type == WIFI_ASSOCREQ) { + reassoc = 0; + ie_offset = _ASOCREQ_IE_OFFSET_; -+ } -+ else /* WIFI_REASSOCREQ */ -+ { ++ } else{ /* WIFI_REASSOCREQ */ + reassoc = 1; + ie_offset = _REASOCREQ_IE_OFFSET_; + } @@ -14878,8 +14580,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); -+ if (pstat == (struct sta_info *)NULL) -+ { ++ if (pstat == (struct sta_info *)NULL) { + status = _RSON_CLS2_; + goto asoc_class2_error; + } @@ -14896,21 +14597,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + DBG_871X("%s\n", __func__); + + /* check if this stat has been successfully authenticated/assocated */ -+ if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) -+ { -+ if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) -+ { ++ if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) { ++ if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) { + status = _RSON_CLS2_; + goto asoc_class2_error; -+ } -+ else -+ { ++ } else{ + pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); + pstat->state |= WIFI_FW_ASSOC_STATE; + } -+ } -+ else -+ { ++ } else{ + pstat->state &= (~WIFI_FW_AUTH_SUCCESS); + pstat->state |= WIFI_FW_ASSOC_STATE; + } @@ -14932,15 +14627,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* checking SSID */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, + pkt_len - WLAN_HDR_A3_LEN - ie_offset); -+ if (p == NULL) -+ { ++ if (p == NULL) { + status = _STATS_FAILURE_; + } + + if (ie_len == 0) /* broadcast ssid, however it is not allowed in assocreq */ + status = _STATS_FAILURE_; -+ else -+ { ++ else { + /* check if ssid match */ + if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) + status = _STATS_FAILURE_; @@ -14962,17 +14655,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + status = _STATS_FAILURE_; + goto OnAssocReqFail; -+ } -+ else { ++ } else { + memcpy(supportRate, p+2, ie_len); + supportRateNum = ie_len; + -+ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_ , &ie_len, ++ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, + pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p != NULL) { + -+ if (supportRateNum<=sizeof(supportRate)) -+ { ++ if (supportRateNum <= sizeof(supportRate)) { + memcpy(supportRate+supportRateNum, p+2, ie_len); + supportRateNum += ie_len; + } @@ -15002,8 +14693,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + wpa_ie = elems.rsn_ie; + wpa_ie_len = elems.rsn_ie_len; + -+ if (rtw_parse_wpa2_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) -+ { ++ if (rtw_parse_wpa2_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(1); + @@ -15015,9 +14705,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + if (!pstat->wpa2_pairwise_cipher) + status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; -+ } -+ else -+ { ++ } else{ + status = WLAN_STATUS_INVALID_IE; + } + @@ -15028,8 +14716,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + wpa_ie = elems.wpa_ie; + wpa_ie_len = elems.wpa_ie_len; + -+ if (rtw_parse_wpa_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) -+ { ++ if (rtw_parse_wpa_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(0); + @@ -15042,9 +14729,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (!pstat->wpa_pairwise_cipher) + status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + -+ } -+ else -+ { ++ } else{ + status = WLAN_STATUS_INVALID_IE; + } + @@ -15076,17 +14761,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ + /* that the selected registrar of AP is _FLASE */ -+ if ((psecuritypriv->wpa_psk >0) -+ && (pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS))) -+ { -+ if (pmlmepriv->wps_beacon_ie) -+ { ++ if ((psecuritypriv->wpa_psk > 0) ++ && (pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS))) { ++ if (pmlmepriv->wps_beacon_ie) { + u8 selected_registrar = 0; + -+ rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR , &selected_registrar, NULL); ++ rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR, &selected_registrar, NULL); + -+ if (!selected_registrar) -+ { ++ if (!selected_registrar) { + DBG_871X("selected_registrar is false , or AP is not ready to do WPS\n"); + + status = _STATS_UNABLE_HANDLE_STA_; @@ -15096,13 +14778,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + } + -+ } -+ else -+ { ++ } else{ + int copy_len; + -+ if (psecuritypriv->wpa_psk == 0) -+ { ++ if (psecuritypriv->wpa_psk == 0) { + DBG_871X("STA " MAC_FMT ": WPA/RSN IE in association " + "request, but AP don't support WPA/RSN\n", MAC_ARG(pstat->hwaddr)); + @@ -15118,14 +14797,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + "used\n"); + pstat->flags |= WLAN_STA_WPS; + copy_len = 0; -+ } -+ else -+ { ++ } else{ + copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)):(wpa_ie_len+2); + } + + -+ if (copy_len>0) ++ if (copy_len > 0) + memcpy(pstat->wpa_ie, wpa_ie-2, copy_len); + + } @@ -15140,11 +14817,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pstat->uapsd_vi = 0; + pstat->uapsd_be = 0; + pstat->uapsd_bk = 0; -+ if (pmlmepriv->qospriv.qos_option) -+ { ++ if (pmlmepriv->qospriv.qos_option) { + p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; -+ for (;;) -+ { ++ for (;;) { + p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p != NULL) { + if (!memcmp(p+2, WMM_IE, 6)) { @@ -15161,8 +14836,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + else + pstat->has_legacy_ac = false; + -+ if (pstat->qos_info&0xf) -+ { ++ if (pstat->qos_info&0xf) { + if (pstat->qos_info&BIT(0)) + pstat->uapsd_vo = BIT(0)|BIT(1); + else @@ -15187,8 +14861,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + break; + } -+ } -+ else { ++ } else { + break; + } + p = p + ie_len + 2; @@ -15197,8 +14870,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* save HT capabilities in the sta object */ + memset(&pstat->htpriv.ht_cap, 0, sizeof(struct rtw_ieee80211_ht_cap)); -+ if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct rtw_ieee80211_ht_cap)) -+ { ++ if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct rtw_ieee80211_ht_cap)) { + pstat->flags |= WLAN_STA_HT; + + pstat->flags |= WLAN_STA_WME; @@ -15209,8 +14881,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pstat->flags &= ~WLAN_STA_HT; + + -+ if ((pmlmepriv->htpriv.ht_option == false) && (pstat->flags&WLAN_STA_HT)) -+ { ++ if ((pmlmepriv->htpriv.ht_option == false) && (pstat->flags&WLAN_STA_HT)) { + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } @@ -15218,8 +14889,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + if ((pstat->flags & WLAN_STA_HT) && + ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || -+ (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) -+ { ++ (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { + DBG_871X("HT: " MAC_FMT " tried to " + "use TKIP with HT association\n", MAC_ARG(pstat->hwaddr)); + @@ -15283,16 +14953,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pstat->state |= WIFI_FW_ASSOC_SUCCESS; + + spin_lock_bh(&pstapriv->auth_list_lock); -+ if (!list_empty(&pstat->auth_list)) -+ { ++ if (!list_empty(&pstat->auth_list)) { + list_del_init(&pstat->auth_list); + pstapriv->auth_list_cnt--; + } + spin_unlock_bh(&pstapriv->auth_list_lock); + + spin_lock_bh(&pstapriv->asoc_list_lock); -+ if (list_empty(&pstat->asoc_list)) -+ { ++ if (list_empty(&pstat->asoc_list)) { + pstat->expire_to = pstapriv->expire_to; + list_add_tail(&pstat->asoc_list, &pstapriv->asoc_list); + pstapriv->asoc_list_cnt++; @@ -15300,8 +14968,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + spin_unlock_bh(&pstapriv->asoc_list_lock); + + /* now the station is qualified to join our BSS... */ -+ if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_==status)) -+ { ++ if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { + /* 1 bss_cap_update & sta_info_update */ + bss_cap_update_on_sta_join(padapter, pstat); + sta_info_update(padapter, pstat); @@ -15313,16 +14980,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); + + spin_lock_bh(&pstat->lock); -+ if (pstat->passoc_req) -+ { ++ if (pstat->passoc_req) { + kfree(pstat->passoc_req); + pstat->passoc_req = NULL; + pstat->assoc_req_len = 0; + } + + pstat->passoc_req = rtw_zmalloc(pkt_len); -+ if (pstat->passoc_req) -+ { ++ if (pstat->passoc_req) { + memcpy(pstat->passoc_req, pframe, pkt_len); + pstat->assoc_req_len = pkt_len; + } @@ -15356,7 +15021,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + uint i; + int res; + unsigned short status; -+ struct ndis_80211_var_ie * pIE; ++ struct ndis_80211_var_ie *pIE; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -15379,8 +15044,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + del_timer_sync(&pmlmeext->link_timer); + + /* status */ -+ if ((status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2))) > 0) -+ { ++ status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2)); ++ if (status > 0) { + DBG_871X("assoc reject, status code: %d\n", status); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + res = -4; @@ -15391,7 +15056,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeinfo->capability = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + /* set slot time */ -+ pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10))? 9: 20; ++ pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; + + /* AID */ + res = pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4))&0x3fff); @@ -15399,32 +15064,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* following are moved to join event callback function */ + /* to handle HT, WMM, rate adaptive, update MAC reg */ + /* for not to handle the synchronous IO in the tasklet */ -+ for (i = (6 + WLAN_HDR_A3_LEN); i < pkt_len;) -+ { ++ for (i = (6 + WLAN_HDR_A3_LEN); i < pkt_len;) { + pIE = (struct ndis_80211_var_ie *)(pframe + i); + -+ switch (pIE->ElementID) -+ { -+ case _VENDOR_SPECIFIC_IE_: -+ if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ -+ { -+ WMM_param_handler(padapter, pIE); -+ } -+ break; ++ switch (pIE->ElementID) { ++ case _VENDOR_SPECIFIC_IE_: ++ if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ ++ WMM_param_handler(padapter, pIE); ++ break; + -+ case _HT_CAPABILITY_IE_: /* HT caps */ -+ HT_caps_handler(padapter, pIE); -+ break; ++ case _HT_CAPABILITY_IE_: /* HT caps */ ++ HT_caps_handler(padapter, pIE); ++ break; + -+ case _HT_EXTRA_INFO_IE_: /* HT info */ -+ HT_info_handler(padapter, pIE); -+ break; ++ case _HT_EXTRA_INFO_IE_: /* HT info */ ++ HT_info_handler(padapter, pIE); ++ break; + -+ case _ERPINFO_IE_: -+ ERP_IE_handler(padapter, pIE); ++ case _ERPINFO_IE_: ++ ERP_IE_handler(padapter, pIE); + -+ default: -+ break; ++ default: ++ break; + } + + i += (pIE->Length + 2); @@ -15464,8 +15125,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + DBG_871X("%s Reason code(%d)\n", __func__, reason); + -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + @@ -15477,13 +15137,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + reason, GetAddr2Ptr(pframe)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); -+ if (psta) -+ { ++ if (psta) { + u8 updated = false; + + spin_lock_bh(&pstapriv->asoc_list_lock); -+ if (list_empty(&psta->asoc_list) ==false) -+ { ++ if (list_empty(&psta->asoc_list) == false) { + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, reason); @@ -15496,9 +15154,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + + return _SUCCESS; -+ } -+ else -+ { ++ } else{ + int ignore_received_deauth = 0; + + /* Commented by Albert 20130604 */ @@ -15507,10 +15163,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. */ + /* Added the following code to avoid this case. */ + if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) || -+ (pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) -+ { -+ if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) -+ { ++ (pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) { ++ if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) { + ignore_received_deauth = 1; + } else if (WLAN_REASON_PREV_AUTH_NOT_VALID == reason) { + /* TODO: 802.11r */ @@ -15521,9 +15175,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + DBG_871X_LEVEL(_drv_always_, "sta recv deauth reason code(%d) sta:%pM, ignore = %d\n", + reason, GetAddr3Ptr(pframe), ignore_received_deauth); + -+ if (0 == ignore_received_deauth) -+ { -+ receive_disconnect(padapter, GetAddr3Ptr(pframe) , reason); ++ if (0 == ignore_received_deauth) { ++ receive_disconnect(padapter, GetAddr3Ptr(pframe), reason); + } + } + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; @@ -15545,10 +15198,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + -+ DBG_871X("%s Reason code(%d)\n", __func__, reason); ++ DBG_871X("%s Reason code(%d)\n", __func__, reason); + -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + @@ -15560,13 +15212,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + reason, GetAddr2Ptr(pframe)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); -+ if (psta) -+ { ++ if (psta) { + u8 updated = false; + + spin_lock_bh(&pstapriv->asoc_list_lock); -+ if (list_empty(&psta->asoc_list) ==false) -+ { ++ if (list_empty(&psta->asoc_list) == false) { + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, reason); @@ -15578,9 +15228,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + return _SUCCESS; -+ } -+ else -+ { ++ } else{ + DBG_871X_LEVEL(_drv_always_, "sta recv disassoc reason code(%d) sta:%pM\n", + reason, GetAddr3Ptr(pframe)); + @@ -15666,88 +15314,76 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr)); + + category = frame_body[0]; -+ if (category == RTW_WLAN_CATEGORY_BACK)/* representing Block Ack */ -+ { -+ if (!pmlmeinfo->HT_enable) -+ { ++ if (category == RTW_WLAN_CATEGORY_BACK) {/* representing Block Ack */ ++ if (!pmlmeinfo->HT_enable) { + return _SUCCESS; + } + + action = frame_body[1]; + DBG_871X("%s, action =%d\n", __func__, action); -+ switch (action) -+ { -+ case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ ++ switch (action) { ++ case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ + -+ memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); -+ /* process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), GetAddr3Ptr(pframe)); */ -+ process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); ++ memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); ++ /* process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), GetAddr3Ptr(pframe)); */ ++ process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); + -+ if (pmlmeinfo->bAcceptAddbaReq == true) -+ { -+ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); -+ } -+ else -+ { -+ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ -+ } ++ if (pmlmeinfo->bAcceptAddbaReq == true) { ++ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); ++ } else{ ++ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ ++ } + -+ break; ++ break; + -+ case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ -+ status = RTW_GET_LE16(&frame_body[3]); -+ tid = ((frame_body[5] >> 2) & 0x7); ++ case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ ++ status = RTW_GET_LE16(&frame_body[3]); ++ tid = ((frame_body[5] >> 2) & 0x7); + -+ if (status == 0) -+ { /* successful */ -+ DBG_871X("agg_enable for TID =%d\n", tid); -+ psta->htpriv.agg_enable_bitmap |= 1 << tid; -+ psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); -+ } -+ else -+ { -+ psta->htpriv.agg_enable_bitmap &= ~BIT(tid); -+ } ++ if (status == 0) { ++ /* successful */ ++ DBG_871X("agg_enable for TID =%d\n", tid); ++ psta->htpriv.agg_enable_bitmap |= 1 << tid; ++ psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); ++ } else{ ++ psta->htpriv.agg_enable_bitmap &= ~BIT(tid); ++ } + -+ if (psta->state & WIFI_STA_ALIVE_CHK_STATE) -+ { -+ DBG_871X("%s alive check - rx ADDBA response\n", __func__); -+ psta->htpriv.agg_enable_bitmap &= ~BIT(tid); -+ psta->expire_to = pstapriv->expire_to; -+ psta->state ^= WIFI_STA_ALIVE_CHK_STATE; -+ } ++ if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { ++ DBG_871X("%s alive check - rx ADDBA response\n", __func__); ++ psta->htpriv.agg_enable_bitmap &= ~BIT(tid); ++ psta->expire_to = pstapriv->expire_to; ++ psta->state ^= WIFI_STA_ALIVE_CHK_STATE; ++ } + -+ /* DBG_871X("marc: ADDBA RSP: %x\n", pmlmeinfo->agg_enable_bitmap); */ -+ break; ++ /* DBG_871X("marc: ADDBA RSP: %x\n", pmlmeinfo->agg_enable_bitmap); */ ++ break; + -+ case RTW_WLAN_ACTION_DELBA: /* DELBA */ -+ if ((frame_body[3] & BIT(3)) == 0) -+ { -+ psta->htpriv.agg_enable_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); -+ psta->htpriv.candidate_tid_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); ++ case RTW_WLAN_ACTION_DELBA: /* DELBA */ ++ if ((frame_body[3] & BIT(3)) == 0) { ++ psta->htpriv.agg_enable_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); ++ psta->htpriv.candidate_tid_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); + -+ /* reason_code = frame_body[4] | (frame_body[5] << 8); */ -+ reason_code = RTW_GET_LE16(&frame_body[4]); -+ } -+ else if ((frame_body[3] & BIT(3)) == BIT(3)) -+ { -+ tid = (frame_body[3] >> 4) & 0x0F; ++ /* reason_code = frame_body[4] | (frame_body[5] << 8); */ ++ reason_code = RTW_GET_LE16(&frame_body[4]); ++ } else if ((frame_body[3] & BIT(3)) == BIT(3)) { ++ tid = (frame_body[3] >> 4) & 0x0F; + -+ preorder_ctrl = &psta->recvreorder_ctrl[tid]; -+ preorder_ctrl->enable = false; -+ preorder_ctrl->indicate_seq = 0xffff; -+ #ifdef DBG_RX_SEQ -+ DBG_871X("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __func__, __LINE__, -+ preorder_ctrl->indicate_seq); -+ #endif -+ } ++ preorder_ctrl = &psta->recvreorder_ctrl[tid]; ++ preorder_ctrl->enable = false; ++ preorder_ctrl->indicate_seq = 0xffff; ++ #ifdef DBG_RX_SEQ ++ DBG_871X("DBG_RX_SEQ %s:%d indicate_seq:%u\n", __func__, __LINE__, ++ preorder_ctrl->indicate_seq); ++ #endif ++ } + -+ DBG_871X("%s(): DELBA: %x(%x)\n", __func__, pmlmeinfo->agg_enable_bitmap, reason_code); -+ /* todo: how to notify the host while receiving DELETE BA */ -+ break; ++ DBG_871X("%s(): DELBA: %x(%x)\n", __func__, pmlmeinfo->agg_enable_bitmap, reason_code); ++ /* todo: how to notify the host while receiving DELETE BA */ ++ break; + -+ default: -+ break; ++ default: ++ break; + } + } + return _SUCCESS; @@ -15764,8 +15400,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (GetRetry(frame)) { + if (token >= 0) { + if ((seq_ctrl == mlmeext->action_public_rxseq) -+ && (token == mlmeext->action_public_dialog_token)) -+ { ++ && (token == mlmeext->action_public_dialog_token)) { + DBG_871X(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x, token:%d\n", + FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq, token); + return _FAIL; @@ -15907,26 +15542,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + DBG_871X("OnAction_sa_query\n"); + -+ switch (pframe[WLAN_HDR_A3_LEN+1]) -+ { -+ case 0: /* SA Query req */ -+ memcpy(&tid, &pframe[WLAN_HDR_A3_LEN+2], sizeof(unsigned short)); -+ DBG_871X("OnAction_sa_query request, action =%d, tid =%04x\n", pframe[WLAN_HDR_A3_LEN+1], tid); -+ issue_action_SA_Query(padapter, GetAddr2Ptr(pframe), 1, tid); -+ break; ++ switch (pframe[WLAN_HDR_A3_LEN+1]) { ++ case 0: /* SA Query req */ ++ memcpy(&tid, &pframe[WLAN_HDR_A3_LEN+2], sizeof(unsigned short)); ++ DBG_871X("OnAction_sa_query request, action =%d, tid =%04x\n", pframe[WLAN_HDR_A3_LEN+1], tid); ++ issue_action_SA_Query(padapter, GetAddr2Ptr(pframe), 1, tid); ++ break; + -+ case 1: /* SA Query rsp */ -+ del_timer_sync(&pmlmeext->sa_query_timer); -+ DBG_871X("OnAction_sa_query response, action =%d, tid =%04x, cancel timer\n", pframe[WLAN_HDR_A3_LEN+1], pframe[WLAN_HDR_A3_LEN+2]); -+ break; -+ default: -+ break; ++ case 1: /* SA Query rsp */ ++ del_timer_sync(&pmlmeext->sa_query_timer); ++ DBG_871X("OnAction_sa_query response, action =%d, tid =%04x, cancel timer\n", pframe[WLAN_HDR_A3_LEN+1], pframe[WLAN_HDR_A3_LEN+2]); ++ break; ++ default: ++ break; + } -+ if (0) -+ { ++ if (0) { + int pp; + printk("pattrib->pktlen = %d =>", pattrib->pkt_len); -+ for (pp = 0;pp< pattrib->pkt_len; pp++) ++ for (pp = 0; pp < pattrib->pkt_len; pp++) + printk(" %02x ", pframe[pp]); + printk("\n"); + } @@ -15946,8 +15579,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + category = frame_body[0]; + -+ for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) -+ { ++ for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { + ptable = &OnAction_tbl[i]; + + if (category == ptable->num) @@ -15981,7 +15613,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + goto exit; + } + -+ if ((pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv)) == NULL) { ++ pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv); ++ if (pxmitbuf == NULL) { + DBG_871X(FUNC_ADPT_FMT" alloc xmitbuf fail\n", FUNC_ADPT_ARG(pxmitpriv->adapter)); + rtw_free_xmitframe(pxmitpriv, pmgntframe); + pmgntframe = NULL; @@ -16070,8 +15703,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe) +{ + if (padapter->bSurpriseRemoved == true || -+ padapter->bDriverStopped == true) -+ { ++ padapter->bDriverStopped == true) { + rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); + rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); + return; @@ -16089,8 +15721,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct submit_ctx sctx; + + if (padapter->bSurpriseRemoved == true || -+ padapter->bDriverStopped == true) -+ { ++ padapter->bDriverStopped == true) { + rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); + rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); + return ret; @@ -16119,8 +15750,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + if (padapter->bSurpriseRemoved == true || -+ padapter->bDriverStopped == true) -+ { ++ padapter->bDriverStopped == true) { + rtw_free_xmitbuf(&padapter->xmitpriv, pmgntframe->pxmitbuf); + rtw_free_xmitframe(&padapter->xmitpriv, pmgntframe); + return -1; @@ -16151,29 +15781,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* DBG_871X("%s hidden_ssid_mode:%u, ssid_ie:%p, ssid_len_ori:%d\n", __func__, hidden_ssid_mode, ssid_ie, ssid_len_ori); */ + -+ if (ssid_ie && ssid_len_ori>0) -+ { -+ switch (hidden_ssid_mode) ++ if (ssid_ie && ssid_len_ori > 0) { ++ switch (hidden_ssid_mode) { ++ case 1: + { -+ case 1: -+ { -+ u8 *next_ie = ssid_ie + 2 + ssid_len_ori; -+ u32 remain_len = 0; ++ u8 *next_ie = ssid_ie + 2 + ssid_len_ori; ++ u32 remain_len = 0; + -+ remain_len = ies_len -(next_ie-ies); ++ remain_len = ies_len - (next_ie-ies); + -+ ssid_ie[1] = 0; -+ memcpy(ssid_ie+2, next_ie, remain_len); -+ len_diff -= ssid_len_ori; ++ ssid_ie[1] = 0; ++ memcpy(ssid_ie+2, next_ie, remain_len); ++ len_diff -= ssid_len_ori; + -+ break; -+ } -+ case 2: -+ memset(&ssid_ie[2], 0, ssid_len_ori); -+ break; -+ default: -+ break; ++ break; + } ++ case 2: ++ memset(&ssid_ie[2], 0, ssid_len_ori); ++ break; ++ default: ++ break; ++ } + } + + return len_diff; @@ -16196,8 +15824,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* DBG_871X("%s\n", __func__); */ + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) -+ { ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) { + DBG_871X("%s, alloc mgnt frame fail\n", __func__); + return; + } @@ -16227,10 +15855,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + SetFrameSubType(pframe, WIFI_BEACON); + + pframe += sizeof(struct ieee80211_hdr_3addr); -+ pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); ++ pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + /* DBG_871X("ie len =%d\n", cur_network->IELength); */ + { + int len_diff; @@ -16248,9 +15875,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 *wps_ie; + uint wps_ielen; + u8 sr = 0; -+ wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof (struct ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, -+ pattrib->pktlen-sizeof (struct ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); -+ if (wps_ie && wps_ielen>0) { ++ wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof(struct ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, ++ pattrib->pktlen-sizeof(struct ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); ++ if (wps_ie && wps_ielen > 0) { + rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); + } + if (sr != 0) @@ -16288,7 +15915,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8)? 8: rate_len), cur_network->SupportedRates, &pattrib->pktlen); ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); @@ -16308,8 +15935,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + + /* EXTERNDED SUPPORTED RATE */ -+ if (rate_len > 8) -+ { ++ if (rate_len > 8) { + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + } + @@ -16322,8 +15948,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + spin_unlock_bh(&pmlmepriv->bcn_update_lock); + -+ if ((pattrib->pktlen + TXDESC_SIZE) > 512) -+ { ++ if ((pattrib->pktlen + TXDESC_SIZE) > 512) { + DBG_871X("beacon frame too large\n"); + return; + } @@ -16361,8 +15986,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (da == NULL) + return; + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) -+ { ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) { + DBG_871X("%s, alloc mgnt frame fail\n", __func__); + return; + } @@ -16395,16 +16020,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pframe += pattrib->hdrlen; + + -+ if (cur_network->IELength>MAX_IE_SZ) ++ if (cur_network->IELength > MAX_IE_SZ) + return; + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + + /* inerset & update wps_probe_resp_ie */ -+ if ((pmlmepriv->wps_probe_resp_ie!= NULL) && pwps_ie && (wps_ielen>0)) -+ { ++ if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie && (wps_ielen > 0)) { + uint wps_offset, remainder_ielen; + u8 *premainder_ie; + @@ -16419,22 +16042,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pattrib->pktlen += wps_offset; + + wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */ -+ if ((wps_offset+wps_ielen+2)<=MAX_IE_SZ) -+ { ++ if ((wps_offset+wps_ielen+2) <= MAX_IE_SZ) { + memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2); + pframe += wps_ielen+2; + pattrib->pktlen += wps_ielen+2; + } + -+ if ((wps_offset+wps_ielen+2+remainder_ielen)<=MAX_IE_SZ) -+ { ++ if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { + memcpy(pframe, premainder_ie, remainder_ielen); + pframe += remainder_ielen; + pattrib->pktlen += remainder_ielen; + } -+ } -+ else -+ { ++ } else{ + memcpy(pframe, cur_network->IEs, cur_network->IELength); + pframe += cur_network->IELength; + pattrib->pktlen += cur_network->IELength; @@ -16473,9 +16092,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pattrib->pktlen += ssid_ielen_diff; + } + } -+ } -+ else -+ { ++ } else{ + /* timestamp will be inserted by hardware */ + pframe += 8; + pattrib->pktlen += 8; @@ -16501,13 +16118,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8)? 8: rate_len), cur_network->SupportedRates, &pattrib->pktlen); ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + + /* DS parameter set */ -+ pframe =rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); ++ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + u8 erpinfo = 0; + u32 ATIMWindow; + /* IBSS Parameter Set... */ @@ -16521,8 +16137,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + + /* EXTERNDED SUPPORTED RATE */ -+ if (rate_len > 8) -+ { ++ if (rate_len > 8) { + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + } + @@ -16540,9 +16155,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* check rc station */ + psta = rtw_get_stainfo(pstapriv, da); -+ if (psta && psta->isrc && psta->pid>0) -+ { -+ u8 RC_OUI[4]={0x00, 0xE0, 0x4C, 0x0A}; ++ if (psta && psta->isrc && psta->pid > 0) { ++ u8 RC_OUI[4] = {0x00, 0xE0, 0x4C, 0x0A}; + u8 RC_INFO[14] = {0}; + /* EID[1] + EID_LEN[1] + RC_OUI[4] + MAC[6] + PairingID[2] + ChannelNum[2] */ + u16 cu_ch = (u16)cur_network->Configuration.DSConfig; @@ -16589,10 +16203,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n")); + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) -+ { ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) + goto exit; -+ } + + /* update attribute */ + pattrib = &pmgntframe->attrib; @@ -16609,14 +16222,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + fctrl = &(pwlanhdr->frame_control); + *(fctrl) = 0; + -+ if (da) -+ { ++ if (da) { + /* unicast probe request frame */ + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr3, da, ETH_ALEN); -+ } -+ else -+ { ++ } else{ + /* broadcast probe request frame */ + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); @@ -16628,8 +16238,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_PROBEREQ); + -+ pframe += sizeof (struct ieee80211_hdr_3addr); -+ pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); ++ pframe += sizeof(struct ieee80211_hdr_3addr); ++ pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); + + if (pssid) + pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); @@ -16638,14 +16248,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + get_rate_set(padapter, bssrate, &bssrate_len); + -+ if (bssrate_len > 8) -+ { -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen)); -+ pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); -+ } -+ else -+ { -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &(pattrib->pktlen)); ++ if (bssrate_len > 8) { ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); ++ pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); ++ } else{ ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); + } + + if (ch) @@ -16653,7 +16260,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + if (append_wps) { + /* add wps_ie for wps2.0 */ -+ if (pmlmepriv->wps_probe_req_ie_len>0 && pmlmepriv->wps_probe_req_ie) { ++ if (pmlmepriv->wps_probe_req_ie_len > 0 && pmlmepriv->wps_probe_req_ie) { + memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len); + pframe += pmlmepriv->wps_probe_req_ie_len; + pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; @@ -16686,9 +16293,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + int ret; + int i = 0; + -+ do -+ { -+ ret = _issue_probereq(padapter, pssid, da, ch, append_wps, wait_ms>0?true:false); ++ do { ++ ret = _issue_probereq(padapter, pssid, da, ch, append_wps, wait_ms > 0?true:false); + + i++; + @@ -16698,7 +16304,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + msleep(wait_ms); + -+ }while ((imlmext_info); + __le16 le_tmp; + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) -+ { ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) + return; -+ } + + /* update attribute */ + pattrib = &pmgntframe->attrib; @@ -16762,8 +16367,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); + + -+ if (psta)/* for AP mode */ -+ { ++ if (psta) { /* for AP mode */ + memcpy(pwlanhdr->addr1, psta->hwaddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); @@ -16774,15 +16378,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (status != _STATS_SUCCESSFUL_) + val16 = 0; + -+ if (val16) { ++ if (val16) + use_shared_key = 1; -+ } ++ + le_tmp = cpu_to_le16(val16); + + pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_tmp, &(pattrib->pktlen)); + + /* setting auth seq number */ -+ val16 =(u16)psta->auth_seq; ++ val16 = (u16)psta->auth_seq; + le_tmp = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_tmp, &(pattrib->pktlen)); + @@ -16793,27 +16397,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* added challenging text... */ + if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) -+ { + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &(pattrib->pktlen)); -+ } -+ } -+ else -+ { ++ ++ } else{ + memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + + /* setting auth algo number */ -+ val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)? 1: 0;/* 0:OPEN System, 1:Shared key */ -+ if (val16) { ++ val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) ? 1 : 0;/* 0:OPEN System, 1:Shared key */ ++ if (val16) { + use_shared_key = 1; + } + le_tmp = cpu_to_le16(val16); + /* DBG_871X("%s auth_algo = %s auth_seq =%d\n", __func__, (pmlmeinfo->auth_algo == 0)?"OPEN":"SHARED", pmlmeinfo->auth_seq); */ + + /* setting IV for auth seq #3 */ -+ if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) -+ { ++ if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { + __le32 le_tmp32; + + /* DBG_871X("==> iv(%d), key_index(%d)\n", pmlmeinfo->iv, pmlmeinfo->key_index); */ @@ -16836,8 +16436,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_tmp, &(pattrib->pktlen)); + + /* then checking to see if sending challenging text... */ -+ if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) -+ { ++ if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &(pattrib->pktlen)); + + SetPrivacy(fctrl); @@ -16882,10 +16481,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + DBG_871X("%s\n", __func__); + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) -+ { ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) + return; -+ } + + /* update attribute */ + pattrib = &pmgntframe->attrib; @@ -16919,70 +16517,60 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* capability */ + val = *(unsigned short *)rtw_get_capability_from_ie(ie); + -+ pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_ , (unsigned char *)&val, &(pattrib->pktlen)); ++ pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_, (unsigned char *)&val, &(pattrib->pktlen)); + + lestatus = cpu_to_le16(status); -+ pframe = rtw_set_fixed_ie(pframe , _STATUS_CODE_ , (unsigned char *)&lestatus, &(pattrib->pktlen)); ++ pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&lestatus, &(pattrib->pktlen)); + + le_tmp = cpu_to_le16(pstat->aid | BIT(14) | BIT(15)); -+ pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_ , (unsigned char *)&le_tmp, &(pattrib->pktlen)); ++ pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, (unsigned char *)&le_tmp, &(pattrib->pktlen)); + -+ if (pstat->bssratelen <= 8) -+ { ++ if (pstat->bssratelen <= 8) { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); -+ } -+ else -+ { ++ } else{ + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); + } + -+ if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) -+ { ++ if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { + uint ie_len = 0; + + /* FILL HT CAP INFO IE */ + /* p = hostapd_eid_ht_capabilities_info(hapd, p); */ + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); -+ if (pbuf && ie_len>0) -+ { ++ if (pbuf && ie_len > 0) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); -+ pattrib->pktlen +=(ie_len+2); ++ pattrib->pktlen += (ie_len+2); + } + + /* FILL HT ADD INFO IE */ + /* p = hostapd_eid_ht_operation(hapd, p); */ + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); -+ if (pbuf && ie_len>0) -+ { ++ if (pbuf && ie_len > 0) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); -+ pattrib->pktlen +=(ie_len+2); ++ pattrib->pktlen += (ie_len+2); + } + + } + + /* FILL WMM IE */ -+ if ((pstat->flags & WLAN_STA_WME) && (pmlmepriv->qospriv.qos_option)) -+ { ++ if ((pstat->flags & WLAN_STA_WME) && (pmlmepriv->qospriv.qos_option)) { + uint ie_len = 0; + unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; + -+ for (pbuf = ie + _BEACON_IE_OFFSET_; ;pbuf+= (ie_len + 2)) -+ { ++ for (pbuf = ie + _BEACON_IE_OFFSET_; ; pbuf += (ie_len + 2)) { + pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); -+ if (pbuf && !memcmp(pbuf+2, WMM_PARA_IE, 6)) -+ { ++ if (pbuf && !memcmp(pbuf+2, WMM_PARA_IE, 6)) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); -+ pattrib->pktlen +=(ie_len+2); ++ pattrib->pktlen += (ie_len+2); + + break; + } + -+ if ((pbuf == NULL) || (ie_len == 0)) -+ { ++ if ((pbuf == NULL) || (ie_len == 0)) { + break; + } + } @@ -16990,14 +16578,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + -+ if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) -+ { -+ pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6 , REALTEK_96B_IE, &(pattrib->pktlen)); ++ if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) { ++ pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); + } + + /* add WPS IE ie for wps 2.0 */ -+ if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len>0) -+ { ++ if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) { + memcpy(pframe, pmlmepriv->wps_assoc_resp_ie, pmlmepriv->wps_assoc_resp_ie_len); + + pframe += pmlmepriv->wps_assoc_resp_ie_len; @@ -17020,7 +16606,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + __le16 val16; + unsigned int i, j, index = 0; + unsigned char bssrate[NumRates], sta_bssrate[NumRates]; -+ struct ndis_80211_var_ie * pIE; ++ struct ndis_80211_var_ie *pIE; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); @@ -17028,7 +16614,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + int bssrate_len = 0, sta_bssrate_len = 0; + u8 vs_ie_length = 0; + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) + goto exit; + + /* update attribute */ @@ -17063,7 +16650,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* listen interval */ + /* todo: listen interval for power saving */ + val16 = cpu_to_le16(3); -+ memcpy(pframe , (unsigned char *)&val16, 2); ++ memcpy(pframe, (unsigned char *)&val16, 2); + pframe += 2; + pattrib->pktlen += 2; + @@ -17076,10 +16663,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + get_rate_set(padapter, sta_bssrate, &sta_bssrate_len); + /* DBG_871X("sta_bssrate_len =%d\n", sta_bssrate_len); */ + -+ if (pmlmeext->cur_channel == 14)/* for JAPAN, channel 14 can only uses B Mode(CCK) */ -+ { ++ if (pmlmeext->cur_channel == 14) /* for JAPAN, channel 14 can only uses B Mode(CCK) */ + sta_bssrate_len = 4; -+ } + + + /* for (i = 0; i < sta_bssrate_len; i++) { */ @@ -17087,13 +16672,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* */ + + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { -+ if (pmlmeinfo->network.SupportedRates[i] == 0) break; ++ if (pmlmeinfo->network.SupportedRates[i] == 0) ++ break; + DBG_871X("network.SupportedRates[%d]=%02X\n", i, pmlmeinfo->network.SupportedRates[i]); + } + + + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { -+ if (pmlmeinfo->network.SupportedRates[i] == 0) break; ++ if (pmlmeinfo->network.SupportedRates[i] == 0) ++ break; + + + /* Check if the AP's supported rates are also supported by STA. */ @@ -17127,71 +16714,59 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + -+ if (bssrate_len > 8) -+ { -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen)); -+ pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); -+ } -+ else -+ { -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &(pattrib->pktlen)); -+ } ++ if (bssrate_len > 8) { ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); ++ pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); ++ } else ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); + + /* vendor specific IE, such as WPA, WMM, WPS */ -+ for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.IELength;) -+ { ++ for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.IEs + i); + -+ switch (pIE->ElementID) -+ { -+ case _VENDOR_SPECIFIC_IE_: -+ if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || -+ (!memcmp(pIE->data, WMM_OUI, 4)) || -+ (!memcmp(pIE->data, WPS_OUI, 4))) -+ { -+ vs_ie_length = pIE->Length; -+ if ((!padapter->registrypriv.wifi_spec) && (!memcmp(pIE->data, WPS_OUI, 4))) -+ { -+ /* Commented by Kurt 20110629 */ -+ /* In some older APs, WPS handshake */ -+ /* would be fail if we append vender extensions informations to AP */ ++ switch (pIE->ElementID) { ++ case _VENDOR_SPECIFIC_IE_: ++ if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || ++ (!memcmp(pIE->data, WMM_OUI, 4)) || ++ (!memcmp(pIE->data, WPS_OUI, 4))) { ++ vs_ie_length = pIE->Length; ++ if ((!padapter->registrypriv.wifi_spec) && (!memcmp(pIE->data, WPS_OUI, 4))) { ++ /* Commented by Kurt 20110629 */ ++ /* In some older APs, WPS handshake */ ++ /* would be fail if we append vender extensions informations to AP */ + -+ vs_ie_length = 14; -+ } -+ -+ pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, vs_ie_length, pIE->data, &(pattrib->pktlen)); ++ vs_ie_length = 14; + } -+ break; + -+ case EID_WPA2: -+ pframe = rtw_set_ie(pframe, EID_WPA2, pIE->Length, pIE->data, &(pattrib->pktlen)); -+ break; -+ case EID_HTCapability: -+ if (padapter->mlmepriv.htpriv.ht_option ==true) { -+ if (!(is_ap_in_tkip(padapter))) -+ { -+ memcpy(&(pmlmeinfo->HT_caps), pIE->data, sizeof(struct HT_caps_element)); -+ pframe = rtw_set_ie(pframe, EID_HTCapability, pIE->Length , (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); -+ } -+ } -+ break; ++ pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, vs_ie_length, pIE->data, &(pattrib->pktlen)); ++ } ++ break; + -+ case EID_EXTCapability: -+ if (padapter->mlmepriv.htpriv.ht_option ==true) { -+ pframe = rtw_set_ie(pframe, EID_EXTCapability, pIE->Length, pIE->data, &(pattrib->pktlen)); ++ case EID_WPA2: ++ pframe = rtw_set_ie(pframe, EID_WPA2, pIE->Length, pIE->data, &(pattrib->pktlen)); ++ break; ++ case EID_HTCapability: ++ if (padapter->mlmepriv.htpriv.ht_option == true) { ++ if (!(is_ap_in_tkip(padapter))) { ++ memcpy(&(pmlmeinfo->HT_caps), pIE->data, sizeof(struct HT_caps_element)); ++ pframe = rtw_set_ie(pframe, EID_HTCapability, pIE->Length, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); + } -+ break; -+ default: -+ break; ++ } ++ break; ++ ++ case EID_EXTCapability: ++ if (padapter->mlmepriv.htpriv.ht_option == true) ++ pframe = rtw_set_ie(pframe, EID_EXTCapability, pIE->Length, pIE->data, &(pattrib->pktlen)); ++ break; ++ default: ++ break; + } + + i += (pIE->Length + 2); + } + + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) -+ { -+ pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6 , REALTEK_96B_IE, &(pattrib->pktlen)); -+ } ++ pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); + + + pattrib->last_txcmdsz = pattrib->pktlen; @@ -17230,10 +16805,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeext = &(padapter->mlmeextpriv); + pmlmeinfo = &(pmlmeext->mlmext_info); + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) -+ { ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) + goto exit; -+ } + + /* update attribute */ + pattrib = &pmgntframe->attrib; @@ -17249,18 +16823,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + *(fctrl) = 0; + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) -+ { + SetFrDs(fctrl); -+ } + else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) -+ { + SetToDs(fctrl); -+ } + + if (power_mode) -+ { + SetPwrMgt(fctrl); -+ } + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); @@ -17275,12 +16843,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + pattrib->last_txcmdsz = pattrib->pktlen; + -+ if (wait_ack) -+ { ++ if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); -+ } -+ else -+ { ++ } else{ + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } @@ -17321,7 +16886,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + do { -+ ret = _issue_nulldata(padapter, da, power_mode, wait_ms>0?true:false); ++ ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0?true:false); + + i++; + @@ -17331,7 +16896,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + msleep(wait_ms); + -+ }while ((iattrib; + update_mgntframe_attrib(padapter, pattrib); + -+ pattrib->hdrlen +=2; ++ pattrib->hdrlen += 2; + pattrib->qos_en = true; + pattrib->eosp = 1; + pattrib->ack_policy = 0; @@ -17419,13 +16983,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + *(fctrl) = 0; + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) -+ { + SetFrDs(fctrl); -+ } + else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) -+ { + SetToDs(fctrl); -+ } + + if (pattrib->mdata) + SetMData(fctrl); @@ -17451,12 +17011,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + pattrib->last_txcmdsz = pattrib->pktlen; + -+ if (wait_ack) -+ { ++ if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); -+ } -+ else -+ { ++ } else{ + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } @@ -17478,9 +17035,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (da == NULL) + da = get_my_bssid(&(pmlmeinfo->network)); + -+ do -+ { -+ ret = _issue_qos_nulldata(padapter, da, tid, wait_ms>0?true:false); ++ do { ++ ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0?true:false); + + i++; + @@ -17490,7 +17046,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + msleep(wait_ms); + -+ }while ((ipktlen = sizeof(struct ieee80211_hdr_3addr); + + le_tmp = cpu_to_le16(reason); -+ pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_ , (unsigned char *)&le_tmp, &(pattrib->pktlen)); ++ pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_, (unsigned char *)&le_tmp, &(pattrib->pktlen)); + + pattrib->last_txcmdsz = pattrib->pktlen; + + -+ if (wait_ack) -+ { ++ if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); -+ } -+ else -+ { ++ } else{ + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } @@ -17589,9 +17142,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + int ret; + int i = 0; + -+ do -+ { -+ ret = _issue_deauth(padapter, da, reason, wait_ms>0?true:false); ++ do { ++ ret = _issue_deauth(padapter, da, reason, wait_ms > 0?true:false); + + i++; + @@ -17601,7 +17153,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + msleep(wait_ms); + -+ }while ((ipktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + -+ switch (action) -+ { -+ case 0: /* SA Query req */ -+ pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeext->sa_query_seq, &pattrib->pktlen); -+ pmlmeext->sa_query_seq++; -+ /* send sa query request to AP, AP should reply sa query response in 1 second */ -+ set_sa_query_timer(pmlmeext, 1000); -+ break; ++ switch (action) { ++ case 0: /* SA Query req */ ++ pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeext->sa_query_seq, &pattrib->pktlen); ++ pmlmeext->sa_query_seq++; ++ /* send sa query request to AP, AP should reply sa query response in 1 second */ ++ set_sa_query_timer(pmlmeext, 1000); ++ break; + -+ case 1: /* SA Query rsp */ -+ le_tmp = cpu_to_le16(tid); -+ pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen); -+ break; -+ default: -+ break; ++ case 1: /* SA Query rsp */ ++ le_tmp = cpu_to_le16(tid); ++ pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen); ++ break; ++ default: ++ break; + } + + pattrib->last_txcmdsz = pattrib->pktlen; @@ -17720,10 +17271,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + DBG_871X("%s, category =%d, action =%d, status =%d\n", __func__, category, action, status); + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) -+ { ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) + return; -+ } + + /* update attribute */ + pattrib = &pmgntframe->attrib; @@ -17780,7 +17330,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + + /* if ((psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress)) != NULL) */ -+ if ((psta = rtw_get_stainfo(pstapriv, raddr)) != NULL) { ++ psta = rtw_get_stainfo(pstapriv, raddr); ++ if (psta != NULL) { + start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1; + + DBG_871X("BA_starting_seqctrl = %d for TID =%d\n", start_seq, status & 0x07); @@ -17882,8 +17433,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + category = RTW_WLAN_CATEGORY_PUBLIC; + action = ACT_PUBLIC_BSSCOEXIST; + -+ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) -+ { ++ pmgntframe = alloc_mgtxmitframe(pxmitpriv); ++ if (pmgntframe == NULL) { + return; + } + @@ -17915,8 +17466,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + + /* */ -+ if (pmlmepriv->num_FortyMHzIntolerant>0) -+ { ++ if (pmlmepriv->num_FortyMHzIntolerant > 0) { + u8 iedata = 0; + + iedata |= BIT(2);/* 20 MHz BSS Width Request */ @@ -17928,8 +17478,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* */ + memset(ICS, 0, sizeof(ICS)); -+ if (pmlmepriv->num_sta_no_ht>0) -+ { ++ if (pmlmepriv->num_sta_no_ht > 0) { + int i; + + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); @@ -17937,8 +17486,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + phead = get_list_head(queue); + plist = get_next(phead); + -+ while (1) -+ { ++ while (1) { + int len; + u8 *p; + struct wlan_bssid_ex *pbss_network; @@ -17953,12 +17501,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pbss_network = (struct wlan_bssid_ex *)&pnetwork->network; + + p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); -+ if ((p == NULL) || (len == 0))/* non-HT */ -+ { -+ if ((pbss_network->Configuration.DSConfig<= 0) || (pbss_network->Configuration.DSConfig>14)) ++ if ((p == NULL) || (len == 0)) {/* non-HT */ ++ ++ if ((pbss_network->Configuration.DSConfig <= 0) || (pbss_network->Configuration.DSConfig > 14)) + continue; + -+ ICS[0][pbss_network->Configuration.DSConfig]= 1; ++ ICS[0][pbss_network->Configuration.DSConfig] = 1; + + if (ICS[0][0] == 0) + ICS[0][0] = 1; @@ -17969,22 +17517,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + + -+ for (i = 0;i<8;i++) -+ { -+ if (ICS[i][0] == 1) -+ { ++ for (i = 0; i < 8; i++) { ++ if (ICS[i][0] == 1) { + int j, k = 0; + + InfoContent[k] = i; + /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; + -+ for (j = 1;j<= 14;j++) -+ { -+ if (ICS[i][j]== 1) -+ { -+ if (k<16) -+ { ++ for (j = 1; j <= 14; j++) { ++ if (ICS[i][j] == 1) { ++ if (k < 16) { + InfoContent[k] = j; /* channel number */ + /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ + k++; @@ -18026,14 +17569,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* DBG_871X("%s:%s\n", __func__, (initiator == 0)?"RX_DIR":"TX_DIR"); */ + -+ if (initiator == 0) /* recipient */ -+ { -+ for (tid = 0;tidrecvreorder_ctrl[tid].enable == true) -+ { ++ if (initiator == 0) {/* recipient */ ++ for (tid = 0; tid < MAXTID; tid++) { ++ if (psta->recvreorder_ctrl[tid].enable == true) { + DBG_871X("rx agg disable tid(%d)\n", tid); -+ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid <<1) |initiator)&0x1F)); ++ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + psta->recvreorder_ctrl[tid].enable = false; + psta->recvreorder_ctrl[tid].indicate_seq = 0xffff; + #ifdef DBG_RX_SEQ @@ -18042,16 +17582,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + #endif + } + } -+ } -+ else if (initiator == 1)/* originator */ -+ { ++ } else if (initiator == 1) {/* originator */ + /* DBG_871X("tx agg_enable_bitmap(0x%08x)\n", psta->htpriv.agg_enable_bitmap); */ -+ for (tid = 0;tidhtpriv.agg_enable_bitmap & BIT(tid)) -+ { ++ for (tid = 0; tid < MAXTID; tid++) { ++ if (psta->htpriv.agg_enable_bitmap & BIT(tid)) { + DBG_871X("tx agg disable tid(%d)\n", tid); -+ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid <<1) |initiator)&0x1F)); ++ issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + psta->htpriv.agg_enable_bitmap &= ~BIT(tid); + psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); + @@ -18072,30 +17608,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); + rtw_hal_set_hwreg(padapter, HW_VAR_DL_BCN_SEL, NULL); -+ do{ ++ do { + issue_beacon(padapter, 100); + issue++; + do { + yield(); + rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); + poll++; -+ }while ((poll%10)!= 0 && false == bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); ++ } while ((poll%10) != 0 && false == bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + -+ }while (false == bxmitok && issue<100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); ++ } while (false == bxmitok && issue < 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + -+ if (padapter->bSurpriseRemoved || padapter->bDriverStopped) -+ { ++ if (padapter->bSurpriseRemoved || padapter->bDriverStopped) { + return _FAIL; + } + + -+ if (false == bxmitok) -+ { ++ if (false == bxmitok) { + DBG_871X("%s fail! %u ms\n", __func__, jiffies_to_msecs(jiffies - start)); + return _FAIL; -+ } -+ else -+ { ++ } else{ + unsigned long passing_time = jiffies_to_msecs(jiffies - start); + + if (passing_time > 100 || issue > 3) @@ -18143,36 +17675,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + DBG_871X(FUNC_ADPT_FMT" fixed_chan:%u\n", pmlmeext->fixed_chan); +#endif + -+ if (survey_channel != 0) -+ { ++ if (survey_channel != 0) { + /* PAUSE 4-AC Queue when site_survey */ + /* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ + /* val8 |= 0x0f; */ + /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ -+ if (pmlmeext->sitesurvey_res.channel_idx == 0) -+ { ++ if (pmlmeext->sitesurvey_res.channel_idx == 0) { +#ifdef DBG_FIXED_CHAN + if (pmlmeext->fixed_chan != 0xff) + set_channel_bwmode(padapter, pmlmeext->fixed_chan, HAL_PRIME_CHNL_OFFSET_DONT_CARE, CHANNEL_WIDTH_20); + else +#endif + set_channel_bwmode(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, CHANNEL_WIDTH_20); -+ } -+ else -+ { ++ } else{ +#ifdef DBG_FIXED_CHAN -+ if (pmlmeext->fixed_chan!= 0xff) ++ if (pmlmeext->fixed_chan != 0xff) + SelectChannel(padapter, pmlmeext->fixed_chan); + else +#endif + SelectChannel(padapter, survey_channel); + } + -+ if (ScanType == SCAN_ACTIVE) /* obey the channel plan setting... */ -+ { ++ if (ScanType == SCAN_ACTIVE) { /* obey the channel plan setting... */ + { + int i; -+ for (i = 0;isitesurvey_res.ssid[i].SsidLength) { + /* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */ + if (padapter->registrypriv.wifi_spec) @@ -18204,13 +17731,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + info.IGIValue = 0; + info.max_time = channel_scan_time_ms/2;/* ms */ + info.chan = survey_channel; -+ rtw_hal_set_odm_var(padapter, HAL_ODM_NOISE_MONITOR,&info, false); ++ rtw_hal_set_odm_var(padapter, HAL_ODM_NOISE_MONITOR, &info, false); + } +#endif + -+ } -+ else -+ { ++ } else{ + + /* channel number is 0 or this channel is not valid. */ + @@ -18236,9 +17761,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ + + if (is_client_associated_to_ap(padapter) == true) -+ { + issue_nulldata(padapter, NULL, 0, 3, 500); -+ } + + val8 = 0; /* survey done */ + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); @@ -18275,8 +17798,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + len = packet_len - sizeof(struct ieee80211_hdr_3addr); + -+ if (len > MAX_IE_SZ) -+ { ++ if (len > MAX_IE_SZ) { + /* DBG_871X("IE too long for survey event\n"); */ + return _FAIL; + } @@ -18285,7 +17807,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + subtype = GetFrameSubType(pframe); + -+ if (subtype ==WIFI_BEACON) { ++ if (subtype == WIFI_BEACON) { + bssid->Reserved[0] = 1; + ie_offset = _BEACON_IE_OFFSET_; + } else { @@ -18293,12 +17815,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (subtype == WIFI_PROBERSP) { + ie_offset = _PROBERSP_IE_OFFSET_; + bssid->Reserved[0] = 3; -+ } -+ else if (subtype == WIFI_PROBEREQ) { ++ } else if (subtype == WIFI_PROBEREQ) { + ie_offset = _PROBEREQ_IE_OFFSET_; + bssid->Reserved[0] = 2; -+ } -+ else { ++ } else { + bssid->Reserved[0] = 0; + ie_offset = _FIXED_IE_LENGTH_; + } @@ -18316,36 +17836,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + bssid->PhyInfo.SignalStrength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ + + /* checking SSID */ -+ if ((p = rtw_get_ie(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset)) == NULL) -+ { ++ p = rtw_get_ie(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset); ++ if (p == NULL) { + DBG_871X("marc: cannot find SSID for survey event\n"); + return _FAIL; + } + -+ if (*(p + 1)) -+ { -+ if (len > NDIS_802_11_LENGTH_SSID) -+ { ++ if (*(p + 1)) { ++ if (len > NDIS_802_11_LENGTH_SSID) { + DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } + memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); + bssid->Ssid.SsidLength = *(p + 1); -+ } -+ else -+ { ++ } else + bssid->Ssid.SsidLength = 0; -+ } + + memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + + /* checking rate info... */ + i = 0; + p = rtw_get_ie(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); -+ if (p != NULL) -+ { -+ if (len > NDIS_802_11_LENGTH_RATES_EX) -+ { ++ if (p != NULL) { ++ if (len > NDIS_802_11_LENGTH_RATES_EX) { + DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } @@ -18354,17 +17867,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + p = rtw_get_ie(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); -+ if (p != NULL) -+ { -+ if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) -+ { ++ if (p != NULL) { ++ if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) { + DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } + memcpy(bssid->SupportedRates + i, (p + 2), len); + } + -+ bssid->NetworkTypeInUse = Ndis802_11OFDM24; ++ bssid->NetworkTypeInUse = Ndis802_11OFDM24; + + if (bssid->IELength < 12) + return _FAIL; @@ -18375,21 +17886,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + bssid->Configuration.DSConfig = 0; + bssid->Configuration.Length = 0; + -+ if (p) -+ { ++ if (p) { + bssid->Configuration.DSConfig = *(p + 2); -+ } -+ else -+ {/* In 5G, some ap do not have DSSET IE */ ++ } else { ++ /* In 5G, some ap do not have DSSET IE */ + /* checking HT info for channel */ + p = rtw_get_ie(bssid->IEs + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->IELength - ie_offset); -+ if (p) -+ { ++ if (p) { + struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); + bssid->Configuration.DSConfig = HT_info->primary_channel; -+ } -+ else -+ { /* use current channel */ ++ } else { /* use current channel */ + bssid->Configuration.DSConfig = rtw_get_oper_ch(padapter); + } + } @@ -18415,29 +17921,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + bssid->Configuration.ATIMWindow = 0; + + /* 20/40 BSS Coexistence check */ -+ if ((pregistrypriv->wifi_spec == 1) && (false == pmlmeinfo->bwmode_updated)) -+ { ++ if ((pregistrypriv->wifi_spec == 1) && (false == pmlmeinfo->bwmode_updated)) { + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + p = rtw_get_ie(bssid->IEs + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->IELength - ie_offset); -+ if (p && len>0) -+ { ++ if (p && len > 0) { + struct HT_caps_element *pHT_caps; + pHT_caps = (struct HT_caps_element *)(p + 2); + + if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & BIT(14)) + pmlmepriv->num_FortyMHzIntolerant++; -+ } else { ++ } else + pmlmepriv->num_sta_no_ht++; -+ } + } + +#ifdef CONFIG_INTEL_WIDI + /* process_intel_widi_query_or_tigger(padapter, bssid); */ + if (process_intel_widi_query_or_tigger(padapter, bssid)) -+ { + return _FAIL; -+ } +#endif /* CONFIG_INTEL_WIDI */ + + #if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) & 1 @@ -18452,9 +17953,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* mark bss info receving from nearby channel as SignalQuality 101 */ + if (bssid->Configuration.DSConfig != rtw_get_oper_ch(padapter)) -+ { + bssid->PhyInfo.SignalQuality = 101; -+ } + + return _SUCCESS; +} @@ -18466,7 +17965,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 join_type; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network)); ++ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); + @@ -18476,8 +17975,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* udpate capability */ + caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); + update_capinfo(padapter, caps); -+ if (caps&cap_IBSS)/* adhoc master */ -+ { ++ if (caps&cap_IBSS) {/* adhoc master */ + val8 = 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + @@ -18494,15 +17992,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + Set_MSR(padapter, (pmlmeinfo->state & 0x3)); + + /* issue beacon */ -+ if (send_beacon(padapter) == _FAIL) -+ { ++ if (send_beacon(padapter) == _FAIL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail....\n")); + + report_join_res(padapter, -1); + pmlmeinfo->state = WIFI_FW_NULL_STATE; -+ } -+ else -+ { ++ } else{ + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); + join_type = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); @@ -18511,9 +18006,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; + rtw_indicate_connect(padapter); + } -+ } -+ else -+ { ++ } else{ + DBG_871X("start_create_ibss, invalid cap:%x\n", caps); + return; + } @@ -18528,7 +18021,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 val8; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network)); ++ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + int beacon_timeout; + + /* update wireless mode */ @@ -18537,11 +18030,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* udpate capability */ + caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); + update_capinfo(padapter, caps); -+ if (caps&cap_ESS) -+ { ++ if (caps&cap_ESS) { + Set_MSR(padapter, WIFI_FW_STATION_STATE); + -+ val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf; ++ val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; + + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + @@ -18561,12 +18053,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + beacon_timeout = decide_wait_for_beacon_timeout(pmlmeinfo->bcn_interval); + set_link_timer(pmlmeext, beacon_timeout); + _set_timer(&padapter->mlmepriv.assoc_timer, -+ (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) +beacon_timeout); ++ (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout); + + pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; -+ } -+ else if (caps&cap_IBSS) /* adhoc client */ -+ { ++ } else if (caps&cap_IBSS) { /* adhoc client */ + Set_MSR(padapter, WIFI_FW_ADHOC_STATE); + + val8 = 0xcf; @@ -18577,9 +18067,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeinfo->state = WIFI_FW_ADHOC_STATE; + + report_join_res(padapter, 1); -+ } -+ else -+ { ++ } else{ + /* DBG_871X("marc: invalid cap:%x\n", caps); */ + return; + } @@ -18637,16 +18125,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + DBG_871X("%s\n", __func__); + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) -+ { -+ if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { ++ if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_del_sta_event(padapter, MacAddr, reason); + -+ } -+ else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) -+ { ++ } else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -2); + } @@ -18669,8 +18153,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* Adjust channel plan by AP Country IE */ + if (pregistrypriv->enable80211d && -+ (!pmlmeext->update_channel_plan_by_ap_done)) -+ { ++ (!pmlmeext->update_channel_plan_by_ap_done)) { + u8 *ie, *p; + u32 len; + RT_CHANNEL_PLAN chplan_ap; @@ -18681,8 +18164,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 j, k; + + ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); -+ if (!ie) return; -+ if (len < 6) return; ++ if (!ie) ++ return; ++ if (len < 6) ++ return; + + ie += 2; + p = ie; @@ -18695,16 +18180,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + ("%s: 802.11d country =%s\n", __func__, country)); + + i = 0; -+ while ((ie - p) >= 3) -+ { ++ while ((ie - p) >= 3) { + fcn = *(p++); + noc = *(p++); + p++; + -+ for (j = 0; j < noc; j++) -+ { -+ if (fcn <= 14) channel = fcn + j; /* 2.4 GHz */ -+ else channel = fcn + j*4; /* 5 GHz */ ++ for (j = 0; j < noc; j++) { ++ if (fcn <= 14) ++ channel = fcn + j; /* 2.4 GHz */ ++ else ++ channel = fcn + j*4; /* 5 GHz */ + + chplan_ap.Channel[i++] = channel; + } @@ -18714,8 +18199,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +#ifdef CONFIG_DEBUG_RTL871X + i = 0; + DBG_871X("%s: AP[%s] channel plan {", __func__, bssid->Ssid.Ssid); -+ while ((i < chplan_ap.Len) && (chplan_ap.Channel[i] != 0)) -+ { ++ while ((i < chplan_ap.Len) && (chplan_ap.Channel[i] != 0)) { + DBG_8192C("%02d,", chplan_ap.Channel[i]); + i++; + } @@ -18726,9 +18210,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +#ifdef CONFIG_DEBUG_RTL871X + i = 0; + DBG_871X("%s: STA channel plan {", __func__); -+ while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) -+ { -+ DBG_871X("%02d(%c),", chplan_sta[i].ChannelNum, chplan_sta[i].ScanType ==SCAN_PASSIVE?'p':'a'); ++ while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { ++ DBG_871X("%02d(%c),", chplan_sta[i].ChannelNum, chplan_sta[i].ScanType == SCAN_PASSIVE?'p':'a'); + i++; + } + DBG_871X("}\n"); @@ -18738,8 +18221,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + chplan_new = pmlmeext->channel_set; + + i = j = k = 0; -+ if (pregistrypriv->wireless_mode & WIRELESS_11G) -+ { ++ if (pregistrypriv->wireless_mode & WIRELESS_11G) { + do { + if ((i == MAX_CHANNEL_NUM) || + (chplan_sta[i].ChannelNum == 0) || @@ -18749,24 +18231,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14)) + break; + -+ if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) -+ { ++ if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + i++; + j++; + k++; -+ } -+ else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) -+ { ++ } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; +/* chplan_new[k].ScanType = chplan_sta[i].ScanType; */ + chplan_new[k].ScanType = SCAN_PASSIVE; + i++; + k++; -+ } -+ else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) -+ { ++ } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + j++; @@ -18777,8 +18254,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* change AP not support channel to Passive scan */ + while ((i < MAX_CHANNEL_NUM) && + (chplan_sta[i].ChannelNum != 0) && -+ (chplan_sta[i].ChannelNum <= 14)) -+ { ++ (chplan_sta[i].ChannelNum <= 14)) { ++ + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; +/* chplan_new[k].ScanType = chplan_sta[i].ScanType; */ + chplan_new[k].ScanType = SCAN_PASSIVE; @@ -18787,21 +18264,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + /* add channel AP supported */ -+ while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) -+ { ++ while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + j++; + k++; + } -+ } -+ else -+ { ++ } else{ + /* keep original STA 2.4G channel plan */ + while ((i < MAX_CHANNEL_NUM) && + (chplan_sta[i].ChannelNum != 0) && -+ (chplan_sta[i].ChannelNum <= 14)) -+ { ++ (chplan_sta[i].ChannelNum <= 14)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = chplan_sta[i].ScanType; + i++; @@ -18809,14 +18282,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + /* skip AP 2.4G channel plan */ -+ while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) -+ { ++ while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { + j++; + } + } + -+ if (pregistrypriv->wireless_mode & WIRELESS_11A) -+ { ++ if (pregistrypriv->wireless_mode & WIRELESS_11A) { + do { + if ((i == MAX_CHANNEL_NUM) || + (chplan_sta[i].ChannelNum == 0)) @@ -18825,24 +18296,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] == 0)) + break; + -+ if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) -+ { ++ if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + i++; + j++; + k++; -+ } -+ else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) -+ { ++ } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; +/* chplan_new[k].ScanType = chplan_sta[i].ScanType; */ + chplan_new[k].ScanType = SCAN_PASSIVE; + i++; + k++; -+ } -+ else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) -+ { ++ } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + j++; @@ -18851,8 +18317,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } while (1); + + /* change AP not support channel to Passive scan */ -+ while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) -+ { ++ while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; +/* chplan_new[k].ScanType = chplan_sta[i].ScanType; */ + chplan_new[k].ScanType = SCAN_PASSIVE; @@ -18861,19 +18326,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + /* add channel AP supported */ -+ while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] != 0)) -+ { ++ while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] != 0)) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + j++; + k++; + } -+ } -+ else -+ { ++ } else{ + /* keep original STA 5G channel plan */ -+ while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) -+ { ++ while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = chplan_sta[i].ScanType; + i++; @@ -18886,9 +18347,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +#ifdef CONFIG_DEBUG_RTL871X + k = 0; + DBG_871X("%s: new STA channel plan {", __func__); -+ while ((k < MAX_CHANNEL_NUM) && (chplan_new[k].ChannelNum != 0)) -+ { -+ DBG_871X("%02d(%c),", chplan_new[k].ChannelNum, chplan_new[k].ScanType ==SCAN_PASSIVE?'p':'c'); ++ while ((k < MAX_CHANNEL_NUM) && (chplan_new[k].ChannelNum != 0)) { ++ DBG_871X("%02d(%c),", chplan_new[k].ChannelNum, chplan_new[k].ScanType == SCAN_PASSIVE?'p':'c'); + k++; + } + DBG_871X("}\n"); @@ -18899,12 +18359,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + channel = bssid->Configuration.DSConfig; + chplan_new = pmlmeext->channel_set; + i = 0; -+ while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) -+ { -+ if (chplan_new[i].ChannelNum == channel) -+ { -+ if (chplan_new[i].ScanType == SCAN_PASSIVE) -+ { ++ while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { ++ if (chplan_new[i].ChannelNum == channel) { ++ if (chplan_new[i].ScanType == SCAN_PASSIVE) { + /* 5G Bnad 2, 3 (DFS) doesn't change to active scan */ + if (channel >= 52 && channel <= 144) + break; @@ -18944,15 +18401,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeext = &padapter->mlmeextpriv; + pcmdpriv = &padapter->cmdpriv; + -+ -+ if ((pcmd_obj = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (pcmd_obj == NULL) + return; -+ } + + cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); -+ if ((pevtcmd = (u8 *)rtw_zmalloc(cmdsz)) == NULL) -+ { ++ pevtcmd = (u8 *)rtw_zmalloc(cmdsz); ++ if (pevtcmd == NULL) { + kfree((u8 *)pcmd_obj); + return; + } @@ -18966,15 +18421,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + -+ pc2h_evt_hdr = (struct C2HEvent_Header*)(pevtcmd); ++ pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct survey_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_Survey); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + -+ psurvey_evt = (struct survey_event*)(pevtcmd + sizeof(struct C2HEvent_Header)); ++ psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + -+ if (collect_bss_info(padapter, precv_frame, (struct wlan_bssid_ex *)&psurvey_evt->bss) == _FAIL) -+ { ++ if (collect_bss_info(padapter, precv_frame, (struct wlan_bssid_ex *)&psurvey_evt->bss) == _FAIL) { + kfree((u8 *)pcmd_obj); + kfree((u8 *)pevtcmd); + return; @@ -19000,14 +18454,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + -+ if ((pcmd_obj = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (pcmd_obj == NULL) + return; -+ } + + cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); -+ if ((pevtcmd = (u8 *)rtw_zmalloc(cmdsz)) == NULL) -+ { ++ pevtcmd = (u8 *)rtw_zmalloc(cmdsz); ++ if (pevtcmd == NULL) { + kfree((u8 *)pcmd_obj); + return; + } @@ -19021,12 +18474,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + -+ pc2h_evt_hdr = (struct C2HEvent_Header*)(pevtcmd); ++ pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct surveydone_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_SurveyDone); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + -+ psurveydone_evt = (struct surveydone_event*)(pevtcmd + sizeof(struct C2HEvent_Header)); ++ psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; + + DBG_871X("survey done event(%x) band:%d for "ADPT_FMT"\n", psurveydone_evt->bss_cnt, padapter->setband, ADPT_ARG(padapter)); @@ -19048,14 +18501,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + -+ if ((pcmd_obj = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (pcmd_obj == NULL) + return; -+ } + + cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); -+ if ((pevtcmd = (u8 *)rtw_zmalloc(cmdsz)) == NULL) -+ { ++ pevtcmd = (u8 *)rtw_zmalloc(cmdsz); ++ if (pevtcmd == NULL) { + kfree((u8 *)pcmd_obj); + return; + } @@ -19069,12 +18521,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + -+ pc2h_evt_hdr = (struct C2HEvent_Header*)(pevtcmd); ++ pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct joinbss_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_JoinBss); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + -+ pjoinbss_evt = (struct joinbss_event*)(pevtcmd + sizeof(struct C2HEvent_Header)); ++ pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + pjoinbss_evt->network.join_res = pjoinbss_evt->network.aid = res; + @@ -19100,14 +18552,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + -+ if ((pcmd_obj = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (pcmd_obj == NULL) + return; -+ } + + cmdsz = (sizeof(struct wmm_event) + sizeof(struct C2HEvent_Header)); -+ if ((pevtcmd = (u8 *)rtw_zmalloc(cmdsz)) == NULL) -+ { ++ pevtcmd = (u8 *)rtw_zmalloc(cmdsz); ++ if (pevtcmd == NULL) { + kfree((u8 *)pcmd_obj); + return; + } @@ -19121,12 +18572,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + -+ pc2h_evt_hdr = (struct C2HEvent_Header*)(pevtcmd); ++ pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct wmm_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_WMM); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + -+ pwmm_event = (struct wmm_event*)(pevtcmd + sizeof(struct C2HEvent_Header)); ++ pwmm_event = (struct wmm_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + pwmm_event->wmm = 0; + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); @@ -19135,7 +18586,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + +} + -+void report_del_sta_event(struct adapter *padapter, unsigned char* MacAddr, unsigned short reason) ++void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; @@ -19147,14 +18598,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + -+ if ((pcmd_obj = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (pcmd_obj == NULL) { + return; + } + + cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); -+ if ((pevtcmd = (u8 *)rtw_zmalloc(cmdsz)) == NULL) -+ { ++ pevtcmd = (u8 *)rtw_zmalloc(cmdsz); ++ if (pevtcmd == NULL) { + kfree((u8 *)pcmd_obj); + return; + } @@ -19168,12 +18619,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + -+ pc2h_evt_hdr = (struct C2HEvent_Header*)(pevtcmd); ++ pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct stadel_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_DelSTA); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + -+ pdel_sta_evt = (struct stadel_event*)(pevtcmd + sizeof(struct C2HEvent_Header)); ++ pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); + memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2); + @@ -19193,7 +18644,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + return; +} + -+void report_add_sta_event(struct adapter *padapter, unsigned char* MacAddr, int cam_idx) ++void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; @@ -19203,14 +18654,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + -+ if ((pcmd_obj = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (pcmd_obj == NULL) + return; -+ } + + cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); -+ if ((pevtcmd = (u8 *)rtw_zmalloc(cmdsz)) == NULL) -+ { ++ pevtcmd = (u8 *)rtw_zmalloc(cmdsz); ++ if (pevtcmd == NULL) { + kfree((u8 *)pcmd_obj); + return; + } @@ -19224,12 +18674,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + -+ pc2h_evt_hdr = (struct C2HEvent_Header*)(pevtcmd); ++ pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct stassoc_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_AddSTA); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); + -+ padd_sta_evt = (struct stassoc_event*)(pevtcmd + sizeof(struct C2HEvent_Header)); ++ padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN); + padd_sta_evt->cam_id = cam_idx; + @@ -19264,8 +18714,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + VCS_update(padapter, psta); + + /* HT */ -+ if (pmlmepriv->htpriv.ht_option) -+ { ++ if (pmlmepriv->htpriv.ht_option) { + psta->htpriv.ht_option = true; + + psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable; @@ -19285,9 +18734,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + psta->htpriv.beamform_cap = pmlmepriv->htpriv.beamform_cap; + + memcpy(&psta->htpriv.ht_cap, &pmlmeinfo->HT_caps, sizeof(struct rtw_ieee80211_ht_cap)); -+ } -+ else -+ { ++ } else{ + psta->htpriv.ht_option = false; + + psta->htpriv.ampdu_enable = false; @@ -19322,7 +18769,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network)); ++ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + u8 state_backup = (pmlmeinfo->state&0x03); + + /* set_opmode_cmd(padapter, infra_client_with_mlme); */ @@ -19349,8 +18796,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + -+ if (state_backup == WIFI_FW_STATION_STATE) -+ { ++ if (state_backup == WIFI_FW_STATION_STATE) { + if (rtw_port_switch_chk(padapter) == true) { + rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); + { @@ -19385,8 +18831,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct sta_priv *pstapriv = &padapter->stapriv; + u8 join_type; + struct sta_info *psta; -+ if (join_res < 0) -+ { ++ if (join_res < 0) { + join_type = 1; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); @@ -19395,10 +18840,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) -+ { + /* update bc/mc sta_info */ + update_bmc_sta(padapter); -+ } + + + /* turn on dynamic functions */ @@ -19425,8 +18868,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); -+ if (psta) /* only for infra. mode */ -+ { ++ if (psta) { /* only for infra. mode */ ++ + pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; + + /* DBG_871X("set_sta_rate\n"); */ @@ -19449,8 +18892,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + join_type = 2; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + /* correcting TSF */ + correct_TSF(padapter, pmlmeext); + @@ -19475,14 +18917,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + DBG_871X("%s\n", __func__); + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) -+ { -+ if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)/* adhoc master or sta_count>1 */ -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { ++ if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { /* adhoc master or sta_count>1 */ ++ + /* nothing to do */ -+ } -+ else/* adhoc client */ -+ { ++ } else{ /* adhoc client */ + /* update TSF Value */ + /* update_TSF(pmlmeext, pframe, len); */ + @@ -19490,8 +18929,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + correct_TSF(padapter, pmlmeext); + + /* start beacon */ -+ if (send_beacon(padapter) == _FAIL) -+ { ++ if (send_beacon(padapter) == _FAIL) { + pmlmeinfo->FW_sta_info[psta->mac_id].status = 0; + + pmlmeinfo->state ^= WIFI_FW_ADHOC_STATE; @@ -19548,15 +18986,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + DBG_871X("\n ============["ADPT_FMT"] linked status check ===================\n", ADPT_ARG(padapter)); + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + rtw_hal_get_def_var(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB); + + DBG_871X("AP[" MAC_FMT "] - UndecoratedSmoothedPWDB:%d\n", + MAC_ARG(padapter->mlmepriv.cur_network.network.MacAddress), UndecoratedSmoothedPWDB); -+ } -+ else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) -+ { ++ } else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) { + struct list_head *phead, *plist; + + struct sta_info *psta = NULL; @@ -19565,8 +19000,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + spin_lock_bh(&pstapriv->asoc_list_lock); + phead = &pstapriv->asoc_list; + plist = get_next(phead); -+ while (phead != plist) -+ { ++ while (phead != plist) { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + plist = get_next(plist); + @@ -19576,10 +19010,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + spin_unlock_bh(&pstapriv->asoc_list_lock); + + } -+ for (i = 0; imacid[i] == true) -+ { ++ for (i = 0; i < NUM_STA; i++) { ++ if (pdvobj->macid[i] == true) { + if (i != 1) /* skip bc/mc sta */ + /* tx info ============ */ + rtw_hal_get_def_var(padapter, HW_DEF_RA_INFO_DUMP, &i); @@ -19621,12 +19053,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if ((sta_rx_data_pkts(psta) == sta_last_rx_data_pkts(psta)) + && sta_rx_beacon_pkts(psta) == sta_last_rx_beacon_pkts(psta) + && sta_rx_probersp_pkts(psta) == sta_last_rx_probersp_pkts(psta) -+ ) -+ { ++ ) { + ret = false; -+ } -+ else -+ { ++ } else{ + ret = true; + } + @@ -19645,8 +19074,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct sta_priv *pstapriv = &padapter->stapriv; + + -+ if (is_client_associated_to_ap(padapter)) -+ { ++ if (is_client_associated_to_ap(padapter)) { + /* linked infrastructure client mode */ + + int tx_chk = _SUCCESS, rx_chk = _SUCCESS; @@ -19668,8 +19096,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* rx_chk_limit = 1; */ + /* endif */ + -+ if ((psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress)) != NULL) -+ { ++ psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); ++ if (psta != NULL) { + if (chk_ap_is_alive(padapter, psta) == false) + rx_chk = _FAIL; + @@ -19717,37 +19145,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + } /* end of if ((psta = rtw_get_stainfo(pstapriv, passoc_res->network.MacAddress)) != NULL) */ -+ } -+ else if (is_client_associated_to_ibss(padapter)) -+ { ++ } else if (is_client_associated_to_ibss(padapter)) { + /* linked IBSS mode */ + /* for each assoc list entry to check the rx pkt counter */ -+ for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) -+ { -+ if (pmlmeinfo->FW_sta_info[i].status == 1) -+ { ++ for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { ++ if (pmlmeinfo->FW_sta_info[i].status == 1) { + psta = pmlmeinfo->FW_sta_info[i].psta; + -+ if (NULL ==psta) continue; ++ if (NULL == psta) ++ continue; + -+ if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) -+ { ++ if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) { + -+ if (pmlmeinfo->FW_sta_info[i].retry<3) -+ { ++ if (pmlmeinfo->FW_sta_info[i].retry < 3) { + pmlmeinfo->FW_sta_info[i].retry++; -+ } -+ else -+ { ++ } else{ + pmlmeinfo->FW_sta_info[i].retry = 0; + pmlmeinfo->FW_sta_info[i].status = 0; + report_del_sta_event(padapter, psta->hwaddr + , 65535/* indicate disconnect caused by no rx */ + ); + } -+ } -+ else -+ { ++ } else{ + pmlmeinfo->FW_sta_info[i].retry = 0; + pmlmeinfo->FW_sta_info[i].rx_pkt = (u32)sta_rx_pkts(psta); + } @@ -19764,21 +19183,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +{ + struct cmd_obj *ph2c; + struct sitesurvey_parm *psurveyPara; -+ struct cmd_priv *pcmdpriv =&padapter->cmdpriv; ++ struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + /* DBG_871X("marc: survey timer\n"); */ + + /* issue rtw_sitesurvey_cmd */ -+ if (pmlmeext->sitesurvey_res.state > SCAN_START) -+ { -+ if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) -+ { ++ if (pmlmeext->sitesurvey_res.state > SCAN_START) { ++ if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + pmlmeext->sitesurvey_res.channel_idx++; + } + -+ if (pmlmeext->scan_abort == true) -+ { ++ if (pmlmeext->scan_abort == true) { + { + pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; + DBG_871X("%s idx:%d\n", __func__ @@ -19789,13 +19205,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeext->scan_abort = false;/* reset */ + } + -+ if ((ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (ph2c == NULL) { + goto exit_survey_timer_hdl; + } + -+ if ((psurveyPara = (struct sitesurvey_parm*)rtw_zmalloc(sizeof(struct sitesurvey_parm))) == NULL) -+ { ++ psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); ++ if (psurveyPara == NULL) { + kfree((unsigned char *)ph2c); + goto exit_survey_timer_hdl; + } @@ -19820,17 +19236,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* struct sta_priv *pstapriv = &padapter->stapriv; */ + + -+ if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) -+ { ++ if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + DBG_871X("link_timer_hdl:no beacon while connecting\n"); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -3); -+ } -+ else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) -+ { ++ } else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) { + /* re-auth timer */ -+ if (++pmlmeinfo->reauth_count > REAUTH_LIMIT) -+ { ++ if (++pmlmeinfo->reauth_count > REAUTH_LIMIT) { + /* if (pmlmeinfo->auth_algo != dot11AuthAlgrthm_Auto) */ + /* */ + pmlmeinfo->state = 0; @@ -19848,12 +19260,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeinfo->auth_seq = 1; + issue_auth(padapter, NULL, 0); + set_link_timer(pmlmeext, REAUTH_TO); -+ } -+ else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) -+ { ++ } else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) { + /* re-assoc timer */ -+ if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) -+ { ++ if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -2); + return; @@ -19876,8 +19285,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + phtpriv = &psta->htpriv; + -+ if ((phtpriv->ht_option ==true) && (phtpriv->ampdu_enable ==true)) -+ { ++ if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) { + if (phtpriv->candidate_tid_bitmap) + phtpriv->candidate_tid_bitmap = 0x0; + @@ -19886,12 +19294,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + +void sa_query_timer_hdl(struct adapter *padapter) +{ -+ struct mlme_priv * pmlmepriv = &padapter->mlmepriv; ++ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + /* disconnect */ + spin_lock_bh(&pmlmepriv->lock); + -+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) -+ { ++ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + rtw_disassoc_cmd(padapter, 0, true); + rtw_indicate_disconnect(padapter); + rtw_free_assoc_resources(padapter, 1); @@ -19939,14 +19346,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + ie += sz; + + /* beacon interval : 2bytes */ -+ *(u16*)ie = cpu_to_le16((u16)100);/* BCN_INTERVAL = 100; */ ++ *(u16 *)ie = cpu_to_le16((u16)100);/* BCN_INTERVAL = 100; */ + sz += 2; + ie += 2; + + /* capability info */ -+ *(u16*)ie = 0; -+ *(u16*)ie |= cpu_to_le16(cap_ESS); -+ *(u16*)ie |= cpu_to_le16(cap_ShortPremble); ++ *(u16 *)ie = 0; ++ *(u16 *)ie |= cpu_to_le16(cap_ESS); ++ *(u16 *)ie |= cpu_to_le16(cap_ShortPremble); + /* u16*)ie |= cpu_to_le16(cap_Privacy); */ + sz += 2; + ie += 2; @@ -19956,48 +19363,38 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* supported rates */ + wireless_mode = WIRELESS_11BG_24N; -+ rtw_set_supported_rate(supportRate, wireless_mode) ; ++ rtw_set_supported_rate(supportRate, wireless_mode); + rateLen = rtw_get_rateset_len(supportRate); -+ if (rateLen > 8) -+ { ++ if (rateLen > 8) { + ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, supportRate, &sz); -+ } -+ else -+ { ++ } else{ + ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, supportRate, &sz); + } + + + /* DS parameter set */ + if (check_buddy_fwstate(adapter, _FW_LINKED) && -+ check_buddy_fwstate(adapter, WIFI_STATION_STATE)) -+ { -+ struct adapter * pbuddystruct adapter = adapter->pbuddystruct adapter; ++ check_buddy_fwstate(adapter, WIFI_STATION_STATE)) { ++ struct adapter *pbuddystruct adapter = adapter->pbuddystruct adapter; + struct mlme_ext_priv *pbuddy_mlmeext = &pbuddystruct adapter->mlmeextpriv; + + oper_channel = pbuddy_mlmeext->cur_channel; -+ } -+ else -+ { ++ } else{ + oper_channel = adapter_to_dvobj(adapter)->oper_channel; + } + ie = rtw_set_ie(ie, _DSSET_IE_, 1, &oper_channel, &sz); + + /* ext supported rates */ -+ if (rateLen > 8) -+ { ++ if (rateLen > 8) { + ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (supportRate + 8), &sz); + } + + DBG_871X("%s, start auto ap beacon sz =%d\n", __func__, sz); + + /* lunch ap mode & start to issue beacon */ -+ if (rtw_check_beacon_data(adapter, pbuf, sz) == _SUCCESS) -+ { ++ if (rtw_check_beacon_data(adapter, pbuf, sz) == _SUCCESS) { + -+ } -+ else -+ { ++ } else{ + ret = -EINVAL; + } + @@ -20016,24 +19413,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; + -+ if (psetop->mode == Ndis802_11APMode) -+ { ++ if (psetop->mode == Ndis802_11APMode) { + pmlmeinfo->state = WIFI_FW_AP_STATE; + type = _HW_STATE_AP_; + /* start_ap_mode(padapter); */ -+ } -+ else if (psetop->mode == Ndis802_11Infrastructure) -+ { ++ } else if (psetop->mode == Ndis802_11Infrastructure) { + pmlmeinfo->state &= ~(BIT(0)|BIT(1));/* clear state */ + pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to STATION_STATE */ + type = _HW_STATE_STATION_; -+ } -+ else if (psetop->mode == Ndis802_11IBSS) -+ { ++ } else if (psetop->mode == Ndis802_11IBSS) { + type = _HW_STATE_ADHOC_; -+ } -+ else -+ { ++ } else{ + type = _HW_STATE_NOLINK_; + } + @@ -20046,8 +19436,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + rtw_auto_ap_start_beacon(padapter); +#endif + -+ if (rtw_port_switch_chk(padapter) == true) -+ { ++ if (rtw_port_switch_chk(padapter) == true) { + rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); + + if (psetop->mode == Ndis802_11APMode) @@ -20059,8 +19448,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + } + -+ if (psetop->mode == Ndis802_11APMode) -+ { ++ if (psetop->mode == Ndis802_11APMode) { + /* Do this after port switch to */ + /* prevent from downloading rsvd page to wrong port */ + rtw_btcoex_MediaStatusNotify(padapter, 1); /* connect */ @@ -20074,7 +19462,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network)); ++ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; + /* u32 initialgain; */ + @@ -20085,8 +19473,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + } + + /* below is for ad-hoc master */ -+ if (pparm->network.InfrastructureMode == Ndis802_11IBSS) -+ { ++ if (pparm->network.InfrastructureMode == Ndis802_11IBSS) { + rtw_joinbss_reset(padapter); + + pmlmeext->cur_bwmode = CHANNEL_WIDTH_20; @@ -20116,7 +19503,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength)); + pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength; + -+ if (pnetwork->IELength>MAX_IE_SZ)/* Check pbuf->IELength */ ++ if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */ + return H2C_PARAMETERS_ERROR; + + memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength); @@ -20132,11 +19519,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ +u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) +{ + u8 join_type; -+ struct ndis_80211_var_ie * pIE; ++ struct ndis_80211_var_ie *pIE; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network)); ++ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + u32 i; + u8 cbw40_enable = 0; + /* u32 initialgain; */ @@ -20144,10 +19531,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 ch, bw, offset; + + /* check already connecting to AP or not */ -+ if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) -+ { -+ if (pmlmeinfo->state & WIFI_FW_STATION_STATE) -+ { ++ if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { ++ if (pmlmeinfo->state & WIFI_FW_STATION_STATE) { + issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 1, 100); + } + pmlmeinfo->state = WIFI_FW_NULL_STATE; @@ -20183,7 +19568,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength)); + pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength; + -+ if (pnetwork->IELength>MAX_IE_SZ)/* Check pbuf->IELength */ ++ if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */ + return H2C_PARAMETERS_ERROR; + + memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength); @@ -20195,64 +19580,58 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + /* pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->IEs, pnetwork->IELength); */ + + /* sizeof(struct ndis_802_11_fix_ie) */ -+ for (i = _FIXED_IE_LENGTH_; i < pnetwork->IELength;) -+ { ++ for (i = _FIXED_IE_LENGTH_; i < pnetwork->IELength;) { + pIE = (struct ndis_80211_var_ie *)(pnetwork->IEs + i); + -+ switch (pIE->ElementID) -+ { -+ case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ -+ if (!memcmp(pIE->data, WMM_OUI, 4)) -+ { -+ WMM_param_handler(padapter, pIE); ++ switch (pIE->ElementID) { ++ case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ ++ if (!memcmp(pIE->data, WMM_OUI, 4)) ++ WMM_param_handler(padapter, pIE); ++ break; ++ ++ case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ ++ pmlmeinfo->HT_caps_enable = 1; ++ break; ++ ++ case _HT_EXTRA_INFO_IE_: /* Get HT Info IE. */ ++ pmlmeinfo->HT_info_enable = 1; ++ ++ /* spec case only for cisco's ap because cisco's ap issue assoc rsp using mcs rate @40MHz or @20MHz */ ++ { ++ struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data); ++ ++ if (pnetwork->Configuration.DSConfig > 14) { ++ if ((pregpriv->bw_mode >> 4) > CHANNEL_WIDTH_20) ++ cbw40_enable = 1; ++ } else { ++ if ((pregpriv->bw_mode & 0x0f) > CHANNEL_WIDTH_20) ++ cbw40_enable = 1; + } -+ break; + -+ case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ -+ pmlmeinfo->HT_caps_enable = 1; -+ break; ++ if ((cbw40_enable) && (pht_info->infos[0] & BIT(2))) { ++ /* switch to the 40M Hz mode according to the AP */ ++ pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; ++ switch (pht_info->infos[0] & 0x3) { ++ case 1: ++ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; ++ break; + -+ case _HT_EXTRA_INFO_IE_: /* Get HT Info IE. */ -+ pmlmeinfo->HT_info_enable = 1; ++ case 3: ++ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; ++ break; + -+ /* spec case only for cisco's ap because cisco's ap issue assoc rsp using mcs rate @40MHz or @20MHz */ -+ { -+ struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data); -+ -+ if (pnetwork->Configuration.DSConfig > 14) { -+ if ((pregpriv->bw_mode >> 4) > CHANNEL_WIDTH_20) -+ cbw40_enable = 1; -+ } else { -+ if ((pregpriv->bw_mode & 0x0f) > CHANNEL_WIDTH_20) -+ cbw40_enable = 1; ++ default: ++ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; ++ pmlmeext->cur_bwmode = CHANNEL_WIDTH_20; ++ break; + } + -+ if ((cbw40_enable) && (pht_info->infos[0] & BIT(2))) -+ { -+ /* switch to the 40M Hz mode according to the AP */ -+ pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; -+ switch (pht_info->infos[0] & 0x3) -+ { -+ case 1: -+ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; -+ break; -+ -+ case 3: -+ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; -+ break; -+ -+ default: -+ pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; -+ pmlmeext->cur_bwmode = CHANNEL_WIDTH_20; -+ break; -+ } -+ -+ DBG_871X("set HT ch/bw before connected\n"); -+ } ++ DBG_871X("set HT ch/bw before connected\n"); + } -+ break; -+ default: -+ break; ++ } ++ break; ++ default: ++ break; + } + + i += (pIE->Length + 2); @@ -20292,16 +19671,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct disconnect_parm *param = (struct disconnect_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network)); ++ struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + u8 val8; + -+ if (is_client_associated_to_ap(padapter)) -+ { ++ if (is_client_associated_to_ap(padapter)) { + issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms/100, 100); + } + -+ if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) -+ { ++ if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + /* Stop BCN */ + val8 = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); @@ -20326,15 +19703,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + /* acquire channels from in */ + j = 0; -+ for (i = 0;ichannel_set, in[i].hw_value); + if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED) -+ && (set_idx =rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value)) >= 0 ++ && set_idx >= 0 + && rtw_mlme_band_check(padapter, in[i].hw_value) == true -+ ) -+ { ++ ) { + if (j >= out_num) { + DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" out_num:%u not enough\n", + FUNC_ADPT_ARG(padapter), out_num); @@ -20348,13 +19725,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + j++; + } -+ if (j>=out_num) ++ if (j >= out_num) + break; + } + + /* if out is empty, use channel_set as default */ + if (j == 0) { -+ for (i = 0;imax_chan_nums;i++) { ++ for (i = 0; i < pmlmeext->max_chan_nums; i++) { + + DBG_871X(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), pmlmeext->channel_set[i].ChannelNum); + @@ -20388,13 +19765,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u32 initialgain; + u32 i; + -+ if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) -+ { ++ if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) { + pmlmeext->sitesurvey_res.state = SCAN_START; + pmlmeext->sitesurvey_res.bss_cnt = 0; + pmlmeext->sitesurvey_res.channel_idx = 0; + -+ for (i = 0;issid[i].SsidLength) { + memcpy(pmlmeext->sitesurvey_res.ssid[i].Ssid, pparm->ssid[i].Ssid, IW_ESSID_MAX_SIZE); + pmlmeext->sitesurvey_res.ssid[i].SsidLength = pparm->ssid[i].SsidLength; @@ -20411,24 +19787,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + pmlmeext->sitesurvey_res.scan_mode = pparm->scan_mode; + + /* issue null data if associating to the AP */ -+ if (is_client_associated_to_ap(padapter) == true) -+ { ++ if (is_client_associated_to_ap(padapter) == true) { + pmlmeext->sitesurvey_res.state = SCAN_TXNULL; + + issue_nulldata(padapter, NULL, 1, 3, 500); + + bdelayscan = true; + } -+ if (bdelayscan) -+ { ++ if (bdelayscan) { + /* delay 50ms to protect nulldata(1). */ + set_survey_timer(pmlmeext, 50); + return H2C_SUCCESS; + } + } + -+ if ((pmlmeext->sitesurvey_res.state == SCAN_START) || (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) -+ { ++ if ((pmlmeext->sitesurvey_res.state == SCAN_START) || (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { + /* disable dynamic functions, such as high power, DIG */ + Save_DM_Func_Flag(padapter); + Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); @@ -20459,8 +19832,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ if (pparm->mode < 4) -+ { ++ if (pparm->mode < 4) { + pmlmeinfo->auth_algo = pparm->mode; + } + @@ -20490,13 +19862,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + else + addr = null_addr; + -+ ctrl = BIT(15) | BIT6 |((pparm->algorithm) << 2) | pparm->keyid; ++ ctrl = BIT(15) | BIT6 | ((pparm->algorithm) << 2) | pparm->keyid; + write_cam(padapter, cam_id, ctrl, addr, pparm->key); + DBG_871X_LEVEL(_drv_always_, "set group key camid:%d, addr:"MAC_FMT", kid:%d, type:%s\n" + , cam_id, MAC_ARG(addr), pparm->keyid, security_type_str(pparm->algorithm)); + } + -+ if (cam_id >= 0 && cam_id <=3) ++ if (cam_id >= 0 && cam_id <= 3) + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_DK_CFG, (u8 *)true); + + /* allow multicast packets to driver */ @@ -20562,17 +19934,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + return H2C_SUCCESS; + + if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) || -+ ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) -+ { ++ ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + /* pmlmeinfo->ADDBA_retry_count = 0; */ + /* pmlmeinfo->candidate_tid_bitmap |= (0x1 << pparm->tid); */ + /* psta->htpriv.candidate_tid_bitmap |= BIT(pparm->tid); */ + issue_action_BA(padapter, pparm->addr, RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); + /* _set_timer(&pmlmeext->ADDBA_timer, ADDBA_TO); */ + _set_timer(&psta->addba_retry_timer, ADDBA_TO); -+ } -+ else -+ { ++ } else{ + psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid); + } + return H2C_SUCCESS; @@ -20585,8 +19954,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + u8 res = _SUCCESS; + -+ if ((ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (ph2c == NULL) { + res = _FAIL; + goto exit; + } @@ -20609,14 +19978,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + u8 res = _SUCCESS; + int len_diff = 0; + -+ if ((ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj))) == NULL) -+ { ++ ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); ++ if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + -+ if ((ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param))) == NULL) -+ { ++ ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); ++ if (ptxBeacon_parm == NULL) { + kfree((unsigned char *)ph2c); + res = _FAIL; + goto exit; @@ -20651,7 +20020,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (pbuf == NULL) + goto _abort_event_; + -+ peventbuf = (uint*)pbuf; ++ peventbuf = (uint *)pbuf; + evt_sz = (u16)(*peventbuf&0xffff); + evt_seq = (u8)((*peventbuf>>24)&0x7f); + evt_code = (u8)((*peventbuf>>16)&0xff); @@ -20659,8 +20028,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + #ifdef CHECK_EVENT_SEQ + /* checking event sequence... */ -+ if (evt_seq != (atomic_read(&pevt_priv->event_seq) & 0x7f)) -+ { ++ if (evt_seq != (atomic_read(&pevt_priv->event_seq) & 0x7f)) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("Evetn Seq Error! %d vs %d\n", (evt_seq & 0x7f), (atomic_read(&pevt_priv->event_seq) & 0x7f))); + + pevt_priv->event_seq = (evt_seq+1)&0x7f; @@ -20670,16 +20038,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + #endif + + /* checking if event code is valid */ -+ if (evt_code >= MAX_C2HEVT) -+ { ++ if (evt_code >= MAX_C2HEVT) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent Code(%d) mismatch!\n", evt_code)); + goto _abort_event_; + } + + /* checking if event size match the event parm size */ + if ((wlanevents[evt_code].parmsize != 0) && -+ (wlanevents[evt_code].parmsize != evt_sz)) -+ { ++ (wlanevents[evt_code].parmsize != evt_sz)) { + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent(%d) Parm Size mismatch (%d vs %d)!\n", + evt_code, wlanevents[evt_code].parmsize, evt_sz)); @@ -20691,8 +20057,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + peventbuf += 2; + -+ if (peventbuf) -+ { ++ if (peventbuf) { + event_callback = wlanevents[evt_code].event_callback; + event_callback(padapter, (u8 *)peventbuf); + @@ -20728,8 +20093,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + if (!psta_bmc) + return H2C_SUCCESS; + -+ if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len>0)) -+ { ++ if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) { + msleep(10);/* 10ms, ATIM(HIQ) Windows */ + + /* spin_lock_bh(&psta_bmc->sleep_q.lock); */ @@ -20738,8 +20102,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + xmitframe_phead = get_list_head(&psta_bmc->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + -+ while (xmitframe_phead != xmitframe_plist) -+ { ++ while (xmitframe_phead != xmitframe_plist) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); @@ -20747,7 +20110,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + list_del_init(&pxmitframe->list); + + psta_bmc->sleepq_len--; -+ if (psta_bmc->sleepq_len>0) ++ if (psta_bmc->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; @@ -20772,8 +20135,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + +u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) +{ -+ if (send_beacon(padapter) == _FAIL) -+ { ++ if (send_beacon(padapter) == _FAIL) { + DBG_871X("issue_beacon, fail!\n"); + return H2C_PARAMETERS_ERROR; + } @@ -20920,16 +20282,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_mlme_ext.c linux-4.3-rtl8723bs/ + + if (NULL == pbuf) + return H2C_PARAMETERS_ERROR; -+ p = (struct RunInThread_param*)pbuf; ++ p = (struct RunInThread_param *)pbuf; + + if (p->func) + p->func(p->context); + + return H2C_SUCCESS; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_odm.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_odm.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_odm.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_odm.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_odm.c linux/3rdparty/rtl8723bs/core/rtw_odm.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_odm.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_odm.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,195 @@ +/****************************************************************************** + * @@ -21038,7 +20400,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_odm.c linux-4.3-rtl8723bs/3rdpa + + rtw_hal_get_def_var(adapter, HW_DEF_ODM_DBG_FLAG, &dbg_comp); + DBG_871X_SEL_NL(sel, "odm.DebugComponents = 0x%016llx\n", dbg_comp); -+ for (i = 0;iodmpriv); + -+ DBG_871X_SEL_NL(sel,"RxRate = %s, RSSI_A = %d(%%), RSSI_B = %d(%%)\n", ++ DBG_871X_SEL_NL(sel, "RxRate = %s, RSSI_A = %d(%%), RSSI_B = %d(%%)\n", + HDATA_RATE(odm->RxRate), odm->RSSI_A, odm->RSSI_B); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_pwrctrl.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_pwrctrl.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1521 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux/3rdparty/rtl8723bs/core/rtw_pwrctrl.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_pwrctrl.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_pwrctrl.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1421 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -21164,8 +20526,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pwrpriv->ips_enter_cnts++; + DBG_871X("==>ips_enter cnts:%d\n", pwrpriv->ips_enter_cnts); + -+ if (rf_off == pwrpriv->change_rfpwrstate) -+ { ++ if (rf_off == pwrpriv->change_rfpwrstate) { + pwrpriv->bpower_saving = true; + DBG_871X_LEVEL(_drv_always_, "nolinked power save enter\n"); + @@ -21196,14 +20557,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); + int result = _SUCCESS; + -+ if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) -+ { ++ if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) { + pwrpriv->bips_processing = true; + pwrpriv->change_rfpwrstate = rf_on; + pwrpriv->ips_leave_cnts++; + DBG_871X("==>ips_leave cnts:%d\n", pwrpriv->ips_leave_cnts); + -+ if ((result = rtw_ips_pwr_up(padapter)) == _SUCCESS) { ++ result = rtw_ips_pwr_up(padapter); ++ if (result == _SUCCESS) { + pwrpriv->rf_pwrstate = rf_on; + } + DBG_871X_LEVEL(_drv_always_, "nolinked power save leave\n"); @@ -21244,7 +20605,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + bool ret = false; + -+ if (adapter_to_pwrctl(adapter)->bpower_saving ==true) { ++ if (adapter_to_pwrctl(adapter)->bpower_saving == true) { + /* DBG_871X("%s: already in LPS or IPS mode\n", __func__); */ + goto exit; + } @@ -21258,9 +20619,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + || check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) + || check_fwstate(pmlmepriv, WIFI_AP_STATE) + || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) -+ ) { ++ ) + goto exit; -+ } + + /* consider buddy, if exist */ + if (buddy) { @@ -21270,9 +20630,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + || check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) + || check_fwstate(b_pmlmepriv, WIFI_AP_STATE) + || check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) -+ ) { ++ ) + goto exit; -+ } + } + + if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF || @@ -21304,8 +20663,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + down(&adapter_to_pwrctl(padapter)->lock); + ps_deny = rtw_ps_deny_get(padapter); + up(&adapter_to_pwrctl(padapter)->lock); -+ if (ps_deny != 0) -+ { ++ if (ps_deny != 0) { + DBG_871X(FUNC_ADPT_FMT ": ps_deny = 0x%08X, skip power save!\n", + FUNC_ADPT_ARG(padapter), ps_deny); + goto exit; @@ -21325,8 +20683,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + if (rtw_pwr_unassociated_idle(padapter) == false) + goto exit; + -+ if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) -+ { ++ if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) { + DBG_871X("==>%s\n", __func__); + pwrpriv->change_rfpwrstate = rf_off; + { @@ -21354,22 +20711,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + + -+ if (tx) /* from tx */ -+ { ++ if (tx) { /* from tx */ + xmit_cnt += tx_packets; + + if (start_time == 0) + start_time = jiffies; + -+ if (jiffies_to_msecs(jiffies - start_time) > 2000) /* 2 sec == watch dog timer */ -+ { -+ if (xmit_cnt > 8) -+ { ++ if (jiffies_to_msecs(jiffies - start_time) > 2000) { /* 2 sec == watch dog timer */ ++ if (xmit_cnt > 8) { + if ((adapter_to_pwrctl(padapter)->bLeisurePs) + && (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE) + && (rtw_btcoex_IsBtControlLps(padapter) == false) -+ ) -+ { ++ ) { + DBG_871X("leave lps via Tx = %d\n", xmit_cnt); + bLeaveLPS = true; + } @@ -21379,16 +20732,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + xmit_cnt = 0; + } + -+ } -+ else /* from rx path */ -+ { -+ if (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 4/*2*/) -+ { ++ } else { /* from rx path */ ++ if (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 4/*2*/) { + if ((adapter_to_pwrctl(padapter)->bLeisurePs) + && (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE) + && (rtw_btcoex_IsBtControlLps(padapter) == false) -+ ) -+ { ++ ) { + DBG_871X("leave lps via Rx = %d\n", pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); + bLeaveLPS = true; + } @@ -21396,11 +20745,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + } + + if (bLeaveLPS) -+ { + /* DBG_871X("leave lps via %s, Tx = %d, Rx = %d\n", tx?"Tx":"Rx", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */ + /* rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, 1); */ + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, tx?0:1); -+ } +} + +/* @@ -21420,15 +20767,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + pslv = PS_STATE(pslv); + -+ if (pwrpriv->brpwmtimeout == true) -+ { ++ if (pwrpriv->brpwmtimeout == true) { + DBG_871X("%s: RPWM timeout, force to set RPWM(0x%02X) again!\n", __func__, pslv); -+ } -+ else -+ { ++ } else{ + if ((pwrpriv->rpwm == pslv) -+ || ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) -+ { ++ || ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: Already set rpwm[0x%02X], new = 0x%02X!\n", __func__, pwrpriv->rpwm, pslv)); + return; @@ -21436,8 +20779,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + } + + if ((padapter->bSurpriseRemoved == true) || -+ (padapter->hw_init_completed == false)) -+ { ++ (padapter->hw_init_completed == false)) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n", + __func__, padapter->bSurpriseRemoved, padapter->hw_init_completed)); @@ -21447,8 +20789,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + return; + } + -+ if (padapter->bDriverStopped == true) -+ { ++ if (padapter->bDriverStopped == true) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: change power state(0x%02X) when DriverStopped\n", __func__, pslv)); + @@ -21470,9 +20811,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + cpwm_orig = 0; + if (rpwm & PS_ACK) -+ { + rtw_hal_get_hwreg(padapter, HW_VAR_CPWM, &cpwm_orig); -+ } + + if (rpwm & PS_ACK) + _set_timer(&pwrpriv->pwr_rpwm_timer, LPS_RPWM_WAIT_MS); @@ -21481,8 +20820,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pwrpriv->tog += 0x80; + + /* No LPS 32K, No Ack */ -+ if (rpwm & PS_ACK) -+ { ++ if (rpwm & PS_ACK) { + unsigned long start_time; + u8 cpwm_now; + u8 poll_cnt = 0; @@ -21494,25 +20832,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + mdelay(1); + poll_cnt++; + rtw_hal_get_hwreg(padapter, HW_VAR_CPWM, &cpwm_now); -+ if ((cpwm_orig ^ cpwm_now) & 0x80) -+ { ++ if ((cpwm_orig ^ cpwm_now) & 0x80) { + pwrpriv->cpwm = PS_STATE_S4; + pwrpriv->cpwm_tog = cpwm_now & PS_TOGGLE; + break; + } + -+ if (jiffies_to_msecs(jiffies - start_time) > LPS_RPWM_WAIT_MS) -+ { ++ if (jiffies_to_msecs(jiffies - start_time) > LPS_RPWM_WAIT_MS) { + DBG_871X("%s: polling cpwm timeout! poll_cnt =%d, cpwm_orig =%02x, cpwm_now =%02x\n", __func__, poll_cnt, cpwm_orig, cpwm_now); + _set_timer(&pwrpriv->pwr_rpwm_timer, 1); + break; + } + } while (1); -+ } -+ else -+ { ++ } else + pwrpriv->cpwm = pslv; -+ } +} + +static u8 PS_RDY_CHECK(struct adapter *padapter) @@ -21535,12 +20868,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + curr_time = jiffies; + -+ delta_time = curr_time -pwrpriv->DelayLPSLastTimeStamp; ++ delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp; + + if (delta_time < LPS_DELAY_TIME) -+ { + return false; -+ } + + if (check_fwstate(pmlmepriv, WIFI_SITE_MONITOR) + || check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) @@ -21550,8 +20881,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + ) + return false; + -+ if ((padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && (padapter->securitypriv.binstallGrpkey == false)) -+ { ++ if ((padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && (padapter->securitypriv.binstallGrpkey == false)) { + DBG_871X("Group handshake still in progress !!!\n"); + return false; + } @@ -21579,23 +20909,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + } + + if (pwrpriv->pwr_mode == ps_mode) -+ { -+ if (PS_MODE_ACTIVE == ps_mode) return; -+ } ++ if (PS_MODE_ACTIVE == ps_mode) ++ return; ++ + + down(&pwrpriv->lock); + + /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ -+ if (ps_mode == PS_MODE_ACTIVE) -+ { ++ if (ps_mode == PS_MODE_ACTIVE) { + if (1 + && (((rtw_btcoex_IsBtControlLps(padapter) == false) + ) + || ((rtw_btcoex_IsBtControlLps(padapter) == true) + && (rtw_btcoex_IsLpsOn(padapter) == false)) + ) -+ ) -+ { ++ ) { + DBG_871X(FUNC_ADPT_FMT" Leave 802.11 power save - %s\n", + FUNC_ADPT_ARG(padapter), msg); + @@ -21604,8 +20932,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + +#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN) + if (pwrpriv->wowlan_mode == true || -+ pwrpriv->wowlan_ap_mode == true) -+ { ++ pwrpriv->wowlan_ap_mode == true) { + unsigned long start_time; + u32 delay_ms; + u8 val8; @@ -21617,8 +20944,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pwrpriv->cpwm = PS_STATE_S4; + break; + } -+ if (jiffies_to_msecs(jiffies - start_time) > delay_ms) -+ { ++ if (jiffies_to_msecs(jiffies - start_time) > delay_ms) { + DBG_871X("%s: Wait for FW 32K leave more than %u ms!!!\n", + __func__, delay_ms); + pdbgpriv->dbg_wow_leave_ps_fail_cnt++; @@ -21633,14 +20959,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + rtw_btcoex_LpsNotify(padapter, ps_mode); + } -+ } -+ else -+ { ++ } else{ + if ((PS_RDY_CHECK(padapter) && check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) + || ((rtw_btcoex_IsBtControlLps(padapter) == true) + && (rtw_btcoex_IsLpsOn(padapter) == true)) -+ ) -+ { ++ ) { + u8 pslv; + + DBG_871X(FUNC_ADPT_FMT" Enter 802.11 power save - %s\n", @@ -21659,8 +20982,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pslv = PS_STATE_S0; + + if ((rtw_btcoex_IsBtDisabled(padapter) == false) -+ && (rtw_btcoex_IsBtControlLps(padapter) == true)) -+ { ++ && (rtw_btcoex_IsBtControlLps(padapter) == true)) { + u8 val8; + + val8 = rtw_btcoex_LpsVal(padapter); @@ -21689,21 +21011,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + + start_time = jiffies; -+ while (1) -+ { ++ while (1) { + rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); + if (true == bAwake) + break; + -+ if (true == padapter->bSurpriseRemoved) -+ { ++ if (true == padapter->bSurpriseRemoved) { + err = -2; + DBG_871X("%s: device surprise removed!!\n", __func__); + break; + } + -+ if (jiffies_to_msecs(jiffies - start_time) > delay_ms) -+ { ++ if (jiffies_to_msecs(jiffies - start_time) > delay_ms) { + err = -1; + DBG_871X("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms); + break; @@ -21743,16 +21062,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + if (pwrpriv->bLeisurePs) { + /* Idle for a while if we connect to AP a while ago. */ -+ if (pwrpriv->LpsIdleCount >= 2) /* 4 Sec */ -+ { -+ if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) -+ { ++ if (pwrpriv->LpsIdleCount >= 2) { /* 4 Sec */ ++ if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) { + sprintf(buf, "WIFI-%s", msg); + pwrpriv->bpower_saving = true; + rtw_set_ps_mode(padapter, pwrpriv->power_mgnt, padapter->registrypriv.smart_ps, 0, buf); + } -+ } -+ else ++ } else + pwrpriv->LpsIdleCount++; + } + @@ -21776,10 +21092,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + if (rtw_btcoex_IsBtControlLps(padapter) == true) + return; + -+ if (pwrpriv->bLeisurePs) -+ { -+ if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) -+ { ++ if (pwrpriv->bLeisurePs) { ++ if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { + sprintf(buf, "WIFI-%s", msg); + rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, buf); + @@ -21793,23 +21107,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + +} + -+void LeaveAllPowerSaveModeDirect(struct adapter * Adapter) ++void LeaveAllPowerSaveModeDirect(struct adapter *Adapter) +{ -+ struct adapter * pri_padapter = GET_PRIMARY_ADAPTER(Adapter); ++ struct adapter *pri_padapter = GET_PRIMARY_ADAPTER(Adapter); + struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); + struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(Adapter); + + DBG_871X("%s.....\n", __func__); + -+ if (true == Adapter->bSurpriseRemoved) -+ { ++ if (true == Adapter->bSurpriseRemoved) { + DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved =%d Skip!\n", + FUNC_ADPT_ARG(Adapter), Adapter->bSurpriseRemoved); + return; + } + -+ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true)) -+ { /* connect */ ++ if ((check_fwstate(pmlmepriv, _FW_LINKED) == true)) { /* connect */ + + if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) { + DBG_871X("%s: Driver Already Leave LPS\n", __func__); @@ -21823,16 +21135,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + up(&pwrpriv->lock); + + rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0); -+ } -+ else -+ { ++ } else{ + if (pwrpriv->rf_pwrstate == rf_off) -+ { + if (false == ips_leave(pri_padapter)) -+ { + DBG_871X("======> ips_leave fail.............\n"); -+ } -+ } + } +} + @@ -21840,7 +21146,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 +/* Description: Leave all power save mode: LPS, FwLPS, IPS if needed. */ +/* Move code to function by tynli. 2010.03.26. */ +/* */ -+void LeaveAllPowerSaveMode(struct adapter * Adapter) ++void LeaveAllPowerSaveMode(struct adapter *Adapter) +{ + struct dvobj_priv *dvobj = adapter_to_dvobj(Adapter); + u8 enqueue = 0; @@ -21889,25 +21195,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + yield(); + -+ while (1) -+ { ++ while (1) { + down(&pwrpriv->lock); + + if ((padapter->bSurpriseRemoved == true) + || (padapter->hw_init_completed == false) + || (pwrpriv->pwr_mode == PS_MODE_ACTIVE) + ) -+ { + bReady = true; -+ } + + up(&pwrpriv->lock); + + if (true == bReady) + break; + -+ if (jiffies_to_msecs(jiffies - start_time)>100) -+ { ++ if (jiffies_to_msecs(jiffies - start_time) > 100) { + DBG_871X("Wait for cpwm event than 100 ms!!!\n"); + break; + } @@ -21932,8 +21234,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + down(&pwrpriv->lock); + -+ if (pwrpriv->rpwm < PS_STATE_S2) -+ { ++ if (pwrpriv->rpwm < PS_STATE_S2) { + DBG_871X("%s: Redundant CPWM Int. RPWM = 0x%02X CPWM = 0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); + up(&pwrpriv->lock); + goto exit; @@ -21942,8 +21243,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pwrpriv->cpwm = PS_STATE(preportpwrstate->state); + pwrpriv->cpwm_tog = preportpwrstate->state & PS_TOGGLE; + -+ if (pwrpriv->cpwm >= PS_STATE_S2) -+ { ++ if (pwrpriv->cpwm >= PS_STATE_S2) { + if (pwrpriv->alives & CMD_ALIVE) + up(&padapter->cmdpriv.cmd_queue_sema); + @@ -21984,15 +21284,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 +/* DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); */ + + down(&pwrpriv->lock); -+ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) -+ { ++ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { + DBG_871X("%s: rpwm = 0x%02X cpwm = 0x%02X CPWM done!\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); + goto exit; + } + up(&pwrpriv->lock); + -+ if (rtw_read8(padapter, 0x100) != 0xEA) -+ { ++ if (rtw_read8(padapter, 0x100) != 0xEA) { + struct reportpwrstate_parm report; + + report.state = PS_STATE_S2; @@ -22004,8 +21302,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + down(&pwrpriv->lock); + -+ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) -+ { ++ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { + DBG_871X("%s: cpwm =%d, nothing to do!\n", __func__, pwrpriv->cpwm); + goto exit; + } @@ -22030,8 +21327,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pwrpriv = adapter_to_pwrctl(padapter); + DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); + -+ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) -+ { ++ if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { + DBG_871X("+%s: cpwm =%d, nothing to do!\n", __func__, pwrpriv->cpwm); + return; + } @@ -22039,12 +21335,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + _set_workitem(&pwrpriv->rpwmtimeoutwi); +} + -+__inline static void register_task_alive(struct pwrctrl_priv *pwrctrl, u32 tag) ++static __inline void register_task_alive(struct pwrctrl_priv *pwrctrl, u32 tag) +{ + pwrctrl->alives |= tag; +} + -+__inline static void unregister_task_alive(struct pwrctrl_priv *pwrctrl, u32 tag) ++static __inline void unregister_task_alive(struct pwrctrl_priv *pwrctrl, u32 tag) +{ + pwrctrl->alives &= ~tag; +} @@ -22079,14 +21375,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + register_task_alive(pwrctrl, task); + -+ if (pwrctrl->bFwCurrentInPSMode == true) -+ { ++ if (pwrctrl->bFwCurrentInPSMode == true) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, + ("%s: task = 0x%x cpwm = 0x%02x alives = 0x%08x\n", + __func__, task, pwrctrl->cpwm, pwrctrl->alives)); + -+ if (pwrctrl->cpwm < pslv) -+ { ++ if (pwrctrl->cpwm < pslv) { + if (pwrctrl->cpwm < PS_STATE_S2) + res = _FAIL; + if (pwrctrl->rpwm < pslv) @@ -22097,10 +21391,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + up(&pwrctrl->lock); + + if (_FAIL == res) -+ { + if (pwrctrl->cpwm >= PS_STATE_S2) + res = _SUCCESS; -+ } ++ + return res; +} + @@ -22123,8 +21416,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pslv = PS_STATE_S0; + + if ((rtw_btcoex_IsBtDisabled(padapter) == false) -+ && (rtw_btcoex_IsBtControlLps(padapter) == true)) -+ { ++ && (rtw_btcoex_IsBtControlLps(padapter) == true)) { + u8 val8; + + val8 = rtw_btcoex_LpsVal(padapter); @@ -22137,17 +21429,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + unregister_task_alive(pwrctrl, task); + + if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) -+ && (pwrctrl->bFwCurrentInPSMode == true)) -+ { ++ && (pwrctrl->bFwCurrentInPSMode == true)) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, + ("%s: cpwm = 0x%02x alives = 0x%08x\n", + __func__, pwrctrl->cpwm, pwrctrl->alives)); + + if (pwrctrl->cpwm > pslv) -+ { + if ((pslv >= PS_STATE_S2) || (pwrctrl->alives == 0)) + rtw_set_rpwm(padapter, pslv); -+ } ++ + } + + up(&pwrctrl->lock); @@ -22180,14 +21470,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + register_task_alive(pwrctrl, XMIT_ALIVE); + -+ if (pwrctrl->bFwCurrentInPSMode == true) -+ { ++ if (pwrctrl->bFwCurrentInPSMode == true) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, + ("rtw_register_tx_alive: cpwm = 0x%02x alives = 0x%08x\n", + pwrctrl->cpwm, pwrctrl->alives)); + -+ if (pwrctrl->cpwm < pslv) -+ { ++ if (pwrctrl->cpwm < pslv) { + if (pwrctrl->cpwm < PS_STATE_S2) + res = _FAIL; + if (pwrctrl->rpwm < pslv) @@ -22198,10 +21486,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + up(&pwrctrl->lock); + + if (_FAIL == res) -+ { + if (pwrctrl->cpwm >= PS_STATE_S2) + res = _SUCCESS; -+ } ++ + return res; +} + @@ -22232,14 +21519,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + register_task_alive(pwrctrl, CMD_ALIVE); + -+ if (pwrctrl->bFwCurrentInPSMode == true) -+ { ++ if (pwrctrl->bFwCurrentInPSMode == true) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_info_, + ("rtw_register_cmd_alive: cpwm = 0x%02x alives = 0x%08x\n", + pwrctrl->cpwm, pwrctrl->alives)); + -+ if (pwrctrl->cpwm < pslv) -+ { ++ if (pwrctrl->cpwm < pslv) { + if (pwrctrl->cpwm < PS_STATE_S2) + res = _FAIL; + if (pwrctrl->rpwm < pslv) @@ -22250,10 +21535,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + up(&pwrctrl->lock); + + if (_FAIL == res) -+ { + if (pwrctrl->cpwm >= PS_STATE_S2) + res = _SUCCESS; -+ } ++ + return res; +} + @@ -22273,8 +21557,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pslv = PS_STATE_S0; + + if ((rtw_btcoex_IsBtDisabled(padapter) == false) -+ && (rtw_btcoex_IsBtControlLps(padapter) == true)) -+ { ++ && (rtw_btcoex_IsBtControlLps(padapter) == true)) { + u8 val8; + + val8 = rtw_btcoex_LpsVal(padapter); @@ -22287,17 +21570,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + unregister_task_alive(pwrctrl, XMIT_ALIVE); + + if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) -+ && (pwrctrl->bFwCurrentInPSMode == true)) -+ { ++ && (pwrctrl->bFwCurrentInPSMode == true)) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, + ("%s: cpwm = 0x%02x alives = 0x%08x\n", + __func__, pwrctrl->cpwm, pwrctrl->alives)); + + if (pwrctrl->cpwm > pslv) -+ { + if ((pslv >= PS_STATE_S2) || (pwrctrl->alives == 0)) + rtw_set_rpwm(padapter, pslv); -+ } + } + + up(&pwrctrl->lock); @@ -22319,8 +21599,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pslv = PS_STATE_S0; + + if ((rtw_btcoex_IsBtDisabled(padapter) == false) -+ && (rtw_btcoex_IsBtControlLps(padapter) == true)) -+ { ++ && (rtw_btcoex_IsBtControlLps(padapter) == true)) { + u8 val8; + + val8 = rtw_btcoex_LpsVal(padapter); @@ -22333,14 +21612,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + unregister_task_alive(pwrctrl, CMD_ALIVE); + + if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) -+ && (pwrctrl->bFwCurrentInPSMode == true)) -+ { ++ && (pwrctrl->bFwCurrentInPSMode == true)) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_info_, + ("%s: cpwm = 0x%02x alives = 0x%08x\n", + __func__, pwrctrl->cpwm, pwrctrl->alives)); + -+ if (pwrctrl->cpwm > pslv) -+ { ++ if (pwrctrl->cpwm > pslv) { + if ((pslv >= PS_STATE_S2) || (pwrctrl->alives == 0)) + rtw_set_rpwm(padapter, pslv); + } @@ -22370,7 +21647,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pwrctrlpriv->bkeepfwalive = false; + + pwrctrlpriv->LpsIdleCount = 0; -+ pwrctrlpriv->power_mgnt =padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ ++ pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ + pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; + + pwrctrlpriv->bFwCurrentInPSMode = false; @@ -22408,7 +21685,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 +} + + -+void rtw_free_pwrctrl_priv(struct adapter * adapter) ++void rtw_free_pwrctrl_priv(struct adapter *adapter) +{ + /* memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv)); */ + @@ -22493,18 +21770,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + } + + /* I think this should be check in IPS, LPS, autosuspend functions... */ -+ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) -+ { ++ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + ret = _SUCCESS; + goto exit; + } + -+ if (rf_off == pwrpriv->rf_pwrstate) -+ { ++ if (rf_off == pwrpriv->rf_pwrstate) { + { + DBG_8192C("%s call ips_leave....\n", __func__); -+ if (_FAIL == ips_leave(padapter)) -+ { ++ if (_FAIL == ips_leave(padapter)) { + DBG_8192C("======> ips_leave fail.............\n"); + ret = _FAIL; + goto exit; @@ -22539,26 +21813,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + int ret = 0; + struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); + -+ if (mode < PS_MODE_NUM) -+ { -+ if (pwrctrlpriv->power_mgnt !=mode) -+ { ++ if (mode < PS_MODE_NUM) { ++ if (pwrctrlpriv->power_mgnt != mode) { + if (PS_MODE_ACTIVE == mode) -+ { + LeaveAllPowerSaveMode(padapter); -+ } + else -+ { + pwrctrlpriv->LpsIdleCount = 2; -+ } ++ + pwrctrlpriv->power_mgnt = mode; + pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?true:false; + } -+ } -+ else -+ { ++ } else + ret = -EINVAL; -+ } + + return ret; +} @@ -22571,16 +21837,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + rtw_ips_mode_req(pwrctrlpriv, mode); + DBG_871X("%s %s\n", __func__, mode == IPS_NORMAL?"IPS_NORMAL":"IPS_LEVEL_2"); + return 0; -+ } -+ else if (mode ==IPS_NONE) { ++ } else if (mode == IPS_NONE) { + rtw_ips_mode_req(pwrctrlpriv, mode); + DBG_871X("%s %s\n", __func__, "IPS_NONE"); + if ((padapter->bSurpriseRemoved == 0) && (_FAIL == rtw_pwr_wakeup(padapter))) + return -EFAULT; -+ } -+ else { ++ } else + return -EINVAL; -+ } ++ + return 0; +} + @@ -22598,8 +21862,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pwrpriv = adapter_to_pwrctl(padapter); + + down(&pwrpriv->lock); -+ if (pwrpriv->ps_deny & BIT(reason)) -+ { ++ if (pwrpriv->ps_deny & BIT(reason)) { + DBG_871X(FUNC_ADPT_FMT ": [WARNING] Reason %d had been set before!!\n", + FUNC_ADPT_ARG(padapter), reason); + } @@ -22625,8 +21888,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + pwrpriv = adapter_to_pwrctl(padapter); + + down(&pwrpriv->lock); -+ if ((pwrpriv->ps_deny & BIT(reason)) == 0) -+ { ++ if ((pwrpriv->ps_deny & BIT(reason)) == 0) { + DBG_871X(FUNC_ADPT_FMT ": [ERROR] Reason %d had been canceled before!!\n", + FUNC_ADPT_ARG(padapter), reason); + } @@ -22651,10 +21913,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_pwrctrl.c linux-4.3-rtl8723bs/3 + + return deny; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_recv.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_recv.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,2931 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_recv.c linux/3rdparty/rtl8723bs/core/rtw_recv.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_recv.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_recv.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,2693 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -22679,17 +21941,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; +static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; + -+u8 rtw_rfc1042_header[] = -+{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; ++u8 rtw_rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; +/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ -+u8 rtw_bridge_tunnel_header[] = -+{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; ++u8 rtw_bridge_tunnel_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; + +void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); + +void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) +{ -+ memset((u8 *)psta_recvpriv, 0, sizeof (struct sta_recv_priv)); ++ memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv)); + + spin_lock_init(&psta_recvpriv->lock); + @@ -22730,11 +21990,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */ + /* ((SIZE_PTR) (precvpriv->pallocated_frame_buf) &(RXFRAME_ALIGN_SZ-1)); */ + -+ precvframe = (union recv_frame*) precvpriv->precv_frame_buf; ++ precvframe = (union recv_frame *) precvpriv->precv_frame_buf; + + -+ for (i = 0; i < NR_RECVFRAME ; i++) -+ { ++ for (i = 0; i < NR_RECVFRAME; i++) { + INIT_LIST_HEAD(&(precvframe->u.list)); + + list_add_tail(&(precvframe->u.list), &(precvpriv->free_recv_queue.queue)); @@ -22743,7 +22002,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + precvframe->u.hdr.len = 0; + -+ precvframe->u.hdr.adapter =padapter; ++ precvframe->u.hdr.adapter = padapter; + precvframe++; + + } @@ -22760,7 +22019,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + return res; +} + -+void _rtw_free_recv_priv (struct recv_priv *precvpriv) ++void _rtw_free_recv_priv(struct recv_priv *precvpriv) +{ + struct adapter *padapter = precvpriv->adapter; + @@ -22768,14 +22027,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + rtw_os_recv_resource_free(precvpriv); + -+ if (precvpriv->pallocated_frame_buf) { ++ if (precvpriv->pallocated_frame_buf) + vfree(precvpriv->pallocated_frame_buf); -+ } + + rtw_hal_free_recv_priv(padapter); +} + -+union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) ++union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) +{ + + union recv_frame *precvframe; @@ -22784,11 +22042,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + struct recv_priv *precvpriv; + + if (list_empty(&pfree_recv_queue->queue)) -+ { + precvframe = NULL; -+ } -+ else -+ { ++ else{ + phead = get_list_head(pfree_recv_queue); + + plist = get_next(phead); @@ -22796,9 +22051,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + + list_del_init(&precvframe->u.hdr.list); -+ padapter =precvframe->u.hdr.adapter; ++ padapter = precvframe->u.hdr.adapter; + if (padapter != NULL) { -+ precvpriv =&padapter->recvpriv; ++ precvpriv = &padapter->recvpriv; + if (pfree_recv_queue == &precvpriv->free_recv_queue) + precvpriv->free_recvframe_cnt--; + } @@ -22806,7 +22061,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + return precvframe; +} + -+union recv_frame *rtw_alloc_recvframe (struct __queue *pfree_recv_queue) ++union recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue) +{ + union recv_frame *precvframe; + @@ -22821,7 +22076,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + +int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_queue) +{ -+ struct adapter *padapter =precvframe->u.hdr.adapter; ++ struct adapter *padapter = precvframe->u.hdr.adapter; + struct recv_priv *precvpriv = &padapter->recvpriv; + + rtw_os_free_recvframe(precvframe); @@ -22849,7 +22104,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +sint _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) +{ + -+ struct adapter *padapter =precvframe->u.hdr.adapter; ++ struct adapter *padapter = precvframe->u.hdr.adapter; + struct recv_priv *precvpriv = &padapter->recvpriv; + + /* INIT_LIST_HEAD(&(precvframe->u.hdr.list)); */ @@ -22858,10 +22113,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + list_add_tail(&(precvframe->u.hdr.list), get_list_head(queue)); + -+ if (padapter != NULL) { ++ if (padapter != NULL) + if (queue == &precvpriv->free_recv_queue) + precvpriv->free_recvframe_cnt++; -+ } ++ + return _SUCCESS; +} + @@ -22906,8 +22161,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + phead = get_list_head(pframequeue); + plist = get_next(phead); + -+ while (phead != plist) -+ { ++ while (phead != plist) { + precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + + plist = get_next(plist); @@ -22922,7 +22176,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +{ + u32 cnt = 0; + union recv_frame *pending_frame; -+ while ((pending_frame =rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) { ++ while ((pending_frame = rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) { + rtw_free_recvframe(pending_frame, &adapter->recvpriv.free_recv_queue); + cnt++; + } @@ -22958,7 +22212,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + +} + -+struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) ++struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue) +{ + struct recv_buf *precvbuf; + struct list_head *plist, *phead; @@ -22966,11 +22220,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + spin_lock_bh(&queue->lock); + + if (list_empty(&queue->queue)) -+ { + precvbuf = NULL; -+ } -+ else -+ { ++ else{ + phead = get_list_head(queue); + + plist = get_next(phead); @@ -22988,94 +22239,90 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +} + +sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe); -+sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) { ++sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) ++{ + + sint i, res = _SUCCESS; + u32 datalen; + u8 miccode[8]; -+ u8 bmic_err =false, brpt_micerror = true; -+ u8 *pframe, *payload,*pframemic; ++ u8 bmic_err = false, brpt_micerror = true; ++ u8 *pframe, *payload, *pframemic; + u8 *mickey; + /* u8 *iv, rxdata_key_idx = 0; */ + struct sta_info *stainfo; -+ struct rx_pkt_attrib *prxattrib =&precvframe->u.hdr.attrib; -+ struct security_priv *psecuritypriv =&adapter->securitypriv; ++ struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib; ++ struct security_priv *psecuritypriv = &adapter->securitypriv; + + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ stainfo =rtw_get_stainfo(&adapter->stapriv ,&prxattrib->ta[0]); ++ stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); + -+ if (prxattrib->encrypt == _TKIP_) -+ { ++ if (prxattrib->encrypt == _TKIP_) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:prxattrib->encrypt == _TKIP_\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:da = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); + + /* calculate mic code */ -+ if (stainfo!= NULL) -+ { -+ if (IS_MCAST(prxattrib->ra)) -+ { ++ if (stainfo != NULL) { ++ if (IS_MCAST(prxattrib->ra)) { + /* mickey =&psecuritypriv->dot118021XGrprxmickey.skey[0]; */ + /* iv = precvframe->u.hdr.rx_data+prxattrib->hdrlen; */ + /* rxdata_key_idx =(((iv[3])>>6)&0x3) ; */ -+ mickey =&psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; ++ mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); + /* DBG_871X("\n recvframe_chkmic: bcmc key psecuritypriv->dot118021XGrpKeyid(%d), pmlmeinfo->key_index(%d) , recv key_id(%d)\n", */ + /* psecuritypriv->dot118021XGrpKeyid, pmlmeinfo->key_index, rxdata_key_idx); */ + -+ if (psecuritypriv->binstallGrpkey ==false) -+ { ++ if (psecuritypriv->binstallGrpkey == false) { + res = _FAIL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n")); + DBG_871X("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"); + goto exit; + } -+ } -+ else { -+ mickey =&stainfo->dot11tkiprxmickey.skey[0]; ++ } else { ++ mickey = &stainfo->dot11tkiprxmickey.skey[0]; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); + } + -+ datalen =precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ -+ pframe =precvframe->u.hdr.rx_data; -+ payload =pframe+prxattrib->hdrlen+prxattrib->iv_len; ++ datalen = precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ ++ pframe = precvframe->u.hdr.rx_data; ++ payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len =%d prxattrib->icv_len =%d\n", prxattrib->iv_len, prxattrib->icv_len)); + + -+ rtw_seccalctkipmic(mickey, pframe, payload, datalen ,&miccode[0], (unsigned char)prxattrib->priority); /* care the length of the data */ ++ rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], (unsigned char)prxattrib->priority); /* care the length of the data */ + -+ pframemic =payload+datalen; ++ pframemic = payload+datalen; + -+ bmic_err =false; ++ bmic_err = false; + -+ for (i = 0;i<8;i++) { ++ for (i = 0; i < 8; i++) { + if (miccode[i] != *(pframemic+i)) { -+ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic:miccode[%d](%02x) != *(pframemic+%d)(%02x) ", i, miccode[i], i,*(pframemic+i))); -+ bmic_err =true; ++ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic:miccode[%d](%02x) != *(pframemic+%d)(%02x) ", i, miccode[i], i, *(pframemic+i))); ++ bmic_err = true; + } + } + + -+ if (bmic_err ==true) { ++ if (bmic_err == true) { + + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n *(pframemic-8)-*(pframemic-1) = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", -+ *(pframemic-8),*(pframemic-7),*(pframemic-6),*(pframemic-5),*(pframemic-4),*(pframemic-3),*(pframemic-2),*(pframemic-1))); ++ *(pframemic-8), *(pframemic-7), *(pframemic-6), *(pframemic-5), *(pframemic-4), *(pframemic-3), *(pframemic-2), *(pframemic-1))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n *(pframemic-16)-*(pframemic-9) = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", -+ *(pframemic-16),*(pframemic-15),*(pframemic-14),*(pframemic-13),*(pframemic-12),*(pframemic-11),*(pframemic-10),*(pframemic-9))); ++ *(pframemic-16), *(pframemic-15), *(pframemic-14), *(pframemic-13), *(pframemic-12), *(pframemic-11), *(pframemic-10), *(pframemic-9))); + + { + uint i; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet (len =%d) ======\n", precvframe->u.hdr.len)); -+ for (i = 0;iu.hdr.len;i =i+8) { ++ for (i = 0; i < precvframe->u.hdr.len; i = i+8) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", -+ *(precvframe->u.hdr.rx_data+i),*(precvframe->u.hdr.rx_data+i+1), -+ *(precvframe->u.hdr.rx_data+i+2),*(precvframe->u.hdr.rx_data+i+3), -+ *(precvframe->u.hdr.rx_data+i+4),*(precvframe->u.hdr.rx_data+i+5), -+ *(precvframe->u.hdr.rx_data+i+6),*(precvframe->u.hdr.rx_data+i+7))); ++ *(precvframe->u.hdr.rx_data+i), *(precvframe->u.hdr.rx_data+i+1), ++ *(precvframe->u.hdr.rx_data+i+2), *(precvframe->u.hdr.rx_data+i+3), ++ *(precvframe->u.hdr.rx_data+i+4), *(precvframe->u.hdr.rx_data+i+5), ++ *(precvframe->u.hdr.rx_data+i+6), *(precvframe->u.hdr.rx_data+i+7))); + } + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet end [len =%d]======\n", precvframe->u.hdr.len)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n hrdlen =%d,\n", prxattrib->hdrlen)); @@ -23087,37 +22334,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + /* double check key_index for some timing issue , */ + /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */ -+ if ((IS_MCAST(prxattrib->ra) ==true) && (prxattrib->key_index != pmlmeinfo->key_index)) ++ if ((IS_MCAST(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index)) + brpt_micerror = false; + -+ if ((prxattrib->bdecrypted ==true) && (brpt_micerror == true)) -+ { ++ if ((prxattrib->bdecrypted == true) && (brpt_micerror == true)) { + rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted =%d ", prxattrib->bdecrypted)); + DBG_871X(" mic error :prxattrib->bdecrypted =%d\n", prxattrib->bdecrypted); -+ } -+ else -+ { ++ } else{ + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted =%d ", prxattrib->bdecrypted)); + DBG_871X(" mic error :prxattrib->bdecrypted =%d\n", prxattrib->bdecrypted); + } + + res = _FAIL; + -+ } -+ else { ++ } else { + /* mic checked ok */ -+ if ((psecuritypriv->bcheck_grpkey ==false) && (IS_MCAST(prxattrib->ra) ==true)) { -+ psecuritypriv->bcheck_grpkey =true; ++ if ((psecuritypriv->bcheck_grpkey == false) && (IS_MCAST(prxattrib->ra) == true)) { ++ psecuritypriv->bcheck_grpkey = true; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("psecuritypriv->bcheck_grpkey =true")); + } + } + -+ } -+ else -+ { ++ } else + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic: rtw_get_stainfo == NULL!!!\n")); -+ } + + recvframe_pull_tail(precvframe, 8); + @@ -23129,45 +22369,42 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +} + +/* decrypt and set the ivlen, icvlen of the recv_frame */ -+union recv_frame * decryptor(struct adapter *padapter, union recv_frame *precv_frame); -+union recv_frame * decryptor(struct adapter *padapter, union recv_frame *precv_frame) ++union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame); ++union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame) +{ + + struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; -+ union recv_frame *return_packet =precv_frame; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; ++ union recv_frame *return_packet = precv_frame; + u32 res = _SUCCESS; + + DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted =%x prxattrib->encrypt = 0x%03x\n", prxattrib->bdecrypted, prxattrib->encrypt)); + -+ if (prxattrib->encrypt>0) -+ { ++ if (prxattrib->encrypt > 0) { + u8 *iv = precv_frame->u.hdr.rx_data+prxattrib->hdrlen; -+ prxattrib->key_index = (((iv[3])>>6)&0x3) ; ++ prxattrib->key_index = (((iv[3])>>6)&0x3); + -+ if (prxattrib->key_index > WEP_KEYS) -+ { ++ if (prxattrib->key_index > WEP_KEYS) { + DBG_871X("prxattrib->key_index(%d) > WEP_KEYS\n", prxattrib->key_index); + + switch (prxattrib->encrypt) { -+ case _WEP40_: -+ case _WEP104_: -+ prxattrib->key_index = psecuritypriv->dot11PrivacyKeyIndex; -+ break; -+ case _TKIP_: -+ case _AES_: -+ default: -+ prxattrib->key_index = psecuritypriv->dot118021XGrpKeyid; -+ break; ++ case _WEP40_: ++ case _WEP104_: ++ prxattrib->key_index = psecuritypriv->dot11PrivacyKeyIndex; ++ break; ++ case _TKIP_: ++ case _AES_: ++ default: ++ prxattrib->key_index = psecuritypriv->dot118021XGrpKeyid; ++ break; + } + } + } + -+ if ((prxattrib->encrypt>0) && ((prxattrib->bdecrypted == 0) ||(psecuritypriv->sw_decrypt ==true))) -+ { -+ psecuritypriv->hw_decrypted =false; ++ if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) || (psecuritypriv->sw_decrypt == true))) { ++ psecuritypriv->hw_decrypted = false; + + #ifdef DBG_RX_DECRYPTOR + DBG_871X("[%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d\n", @@ -23195,15 +22432,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + default: + break; + } -+ } -+ else if (prxattrib->bdecrypted == 1 -+ && prxattrib->encrypt >0 ++ } else if (prxattrib->bdecrypted == 1 ++ && prxattrib->encrypt > 0 + && (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_) -+ ) -+ { ++ ) { + DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_hw); + -+ psecuritypriv->hw_decrypted =true; ++ psecuritypriv->hw_decrypted = true; + #ifdef DBG_RX_DECRYPTOR + DBG_871X("[%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d\n", + __func__, @@ -23213,8 +22448,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + psecuritypriv->hw_decrypted); + + #endif -+ } -+ else { ++ } else { + DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_unknown); + #ifdef DBG_RX_DECRYPTOR + DBG_871X("[%s] %d:prxstat->bdecrypted:%d, prxattrib->encrypt:%d, Setting psecuritypriv->hw_decrypted = %d\n", @@ -23226,29 +22460,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + #endif + } + -+ if (res == _FAIL) -+ { -+ rtw_free_recvframe(return_packet,&padapter->recvpriv.free_recv_queue); ++ if (res == _FAIL) { ++ rtw_free_recvframe(return_packet, &padapter->recvpriv.free_recv_queue); + return_packet = NULL; -+ } -+ else -+ { ++ } else + prxattrib->bdecrypted = true; -+ } + + return return_packet; +} + +/* set the security information in the recv_frame */ -+union recv_frame * portctrl(struct adapter *adapter, union recv_frame * precv_frame); -+union recv_frame * portctrl(struct adapter *adapter, union recv_frame * precv_frame) ++union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame); ++union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame) +{ + u8 *psta_addr = NULL; + u8 *ptr; + uint auth_alg; + struct recv_frame_hdr *pfhdr; + struct sta_info *psta; -+ struct sta_priv *pstapriv ; ++ struct sta_priv *pstapriv; + union recv_frame *prtnframe; + u16 ether_type = 0; + u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ @@ -23269,45 +22499,38 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm =%d\n", adapter->securitypriv.dot11AuthAlgrthm)); + -+ if (auth_alg ==2) -+ { -+ if ((psta!= NULL) && (psta->ieee8021x_blocked)) -+ { ++ if (auth_alg == 2) { ++ if ((psta != NULL) && (psta->ieee8021x_blocked)) { + __be16 be_tmp; + + /* blocked */ + /* only accept EAPOL frame */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked == 1\n")); + -+ prtnframe =precv_frame; ++ prtnframe = precv_frame; + + /* get ether_type */ -+ ptr =ptr+pfhdr->attrib.hdrlen+pfhdr->attrib.iv_len+LLC_HEADER_SIZE; ++ ptr = ptr+pfhdr->attrib.hdrlen+pfhdr->attrib.iv_len+LLC_HEADER_SIZE; + memcpy(&be_tmp, ptr, 2); + ether_type = ntohs(be_tmp); + -+ if (ether_type == eapol_type) { -+ prtnframe =precv_frame; -+ } ++ if (ether_type == eapol_type) ++ prtnframe = precv_frame; + else { + /* free this frame */ + rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue); + prtnframe = NULL; + } -+ } -+ else -+ { ++ } else{ + /* allowed */ + /* check decryption status, and decrypt the frame if needed */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked == 0\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:precv_frame->hdr.attrib.privacy =%x\n", precv_frame->u.hdr.attrib.privacy)); + + if (pattrib->bdecrypted == 0) -+ { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:prxstat->decrypted =%x\n", pattrib->bdecrypted)); -+ } + -+ prtnframe =precv_frame; ++ prtnframe = precv_frame; + /* check is the EAPOL frame or not (Rekey) */ + /* if (ether_type == eapol_type) { */ + /* RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("########portctrl:ether_type == 0x888e\n")); */ @@ -23319,11 +22542,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:ether_type = 0x%04x\n", ether_type)); */ + /* */ + } -+ } -+ else -+ { -+ prtnframe =precv_frame; -+ } ++ } else ++ prtnframe = precv_frame; ++ + return prtnframe; +} + @@ -23335,17 +22556,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | + (precv_frame->u.hdr.attrib.frag_num & 0xf); + -+ if (tid>15) -+ { ++ if (tid > 15) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, (tid>15)! seq_ctrl = 0x%x, tid = 0x%x\n", seq_ctrl, tid)); + + return _FAIL; + } + -+ if (1)/* if (bretry) */ -+ { -+ if (seq_ctrl == prxcache->tid_rxseq[tid]) -+ { ++ if (1) { /* if (bretry) */ ++ if (seq_ctrl == prxcache->tid_rxseq[tid]) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, seq_ctrl = 0x%x, tid = 0x%x, tid_rxseq = 0x%x\n", seq_ctrl, tid, prxcache->tid_rxseq[tid])); + + return _FAIL; @@ -23371,12 +22589,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + pwrbit = GetPwrMgt(ptr); + -+ if (psta) -+ { -+ if (pwrbit) -+ { -+ if (!(psta->state & WIFI_SLEEP_STATE)) -+ { ++ if (psta) { ++ if (pwrbit) { ++ if (!(psta->state & WIFI_SLEEP_STATE)) { + /* psta->state |= WIFI_SLEEP_STATE; */ + /* pstapriv->sta_dz_bitmap |= BIT(psta->aid); */ + @@ -23384,11 +22599,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + /* DBG_871X("to sleep, sta_dz_bitmap =%x\n", pstapriv->sta_dz_bitmap); */ + } -+ } -+ else -+ { -+ if (psta->state & WIFI_SLEEP_STATE) -+ { ++ } else{ ++ if (psta->state & WIFI_SLEEP_STATE) { + /* psta->state ^= WIFI_SLEEP_STATE; */ + /* pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); */ + @@ -23410,7 +22622,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + psta = rtw_get_stainfo(pstapriv, pattrib->src); + -+ if (!psta) return; ++ if (!psta) ++ return; + + if (!psta->qos_option) + return; @@ -23418,54 +22631,47 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + if (!(psta->qos_info&0xf)) + return; + -+ if (psta->state&WIFI_SLEEP_STATE) -+ { ++ if (psta->state&WIFI_SLEEP_STATE) { + u8 wmmps_ac = 0; + -+ switch (pattrib->priority) -+ { -+ case 1: -+ case 2: -+ wmmps_ac = psta->uapsd_bk&BIT(1); -+ break; -+ case 4: -+ case 5: -+ wmmps_ac = psta->uapsd_vi&BIT(1); -+ break; -+ case 6: -+ case 7: -+ wmmps_ac = psta->uapsd_vo&BIT(1); -+ break; -+ case 0: -+ case 3: -+ default: -+ wmmps_ac = psta->uapsd_be&BIT(1); -+ break; ++ switch (pattrib->priority) { ++ case 1: ++ case 2: ++ wmmps_ac = psta->uapsd_bk&BIT(1); ++ break; ++ case 4: ++ case 5: ++ wmmps_ac = psta->uapsd_vi&BIT(1); ++ break; ++ case 6: ++ case 7: ++ wmmps_ac = psta->uapsd_vo&BIT(1); ++ break; ++ case 0: ++ case 3: ++ default: ++ wmmps_ac = psta->uapsd_be&BIT(1); ++ break; + } + -+ if (wmmps_ac) -+ { -+ if (psta->sleepq_ac_len>0) -+ { ++ if (wmmps_ac) { ++ if (psta->sleepq_ac_len > 0) + /* process received triggered frame */ + xmit_delivery_enabled_frames(padapter, psta); -+ } + else -+ { + /* issue one qos null frame with More data bit = 0 and the EOSP bit set (= 1) */ + issue_qos_nulldata(padapter, psta->hwaddr, (u16)pattrib->priority, 0, 0); -+ } + } + } +} + -+void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info*sta); -+void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info*sta) ++void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta); ++void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta) +{ + int sz; + struct sta_info *psta = NULL; + struct stainfo_stats *pstats = NULL; -+ struct rx_pkt_attrib *pattrib = & prframe->u.hdr.attrib; ++ struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct recv_priv *precvpriv = &padapter->recvpriv; + + sz = get_recvframe_len(prframe); @@ -23482,8 +22688,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + else + psta = prframe->u.hdr.psta; + -+ if (psta) -+ { ++ if (psta) { + pstats = &psta->sta_stats; + + pstats->rx_data_pkts++; @@ -23496,29 +22701,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +sint sta2sta_data_frame( + struct adapter *adapter, + union recv_frame *precv_frame, -+ struct sta_info**psta ++ struct sta_info **psta +); +sint sta2sta_data_frame( + struct adapter *adapter, + union recv_frame *precv_frame, -+ struct sta_info**psta ++ struct sta_info **psta +) +{ + u8 *ptr = precv_frame->u.hdr.rx_data; + sint ret = _SUCCESS; -+ struct rx_pkt_attrib *pattrib = & precv_frame->u.hdr.attrib; ++ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u8 *mybssid = get_bssid(pmlmepriv); + u8 *myhwaddr = myid(&adapter->eeprompriv); -+ u8 * sta_addr = NULL; ++ u8 *sta_addr = NULL; + sint bmcast = IS_MCAST(pattrib->dst); + + /* DBG_871X("[%s] %d, seqnum:%d\n", __func__, __LINE__, pattrib->seq_num); */ + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || -+ (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) -+ { ++ (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + + /* filter packets that SA is myself or multicast or broadcast */ + if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { @@ -23541,34 +22745,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + sta_addr = pattrib->src; + -+ } -+ else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) -+ { ++ } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + { + /* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */ -+ if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) -+ { ++ if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("bssid != TA under STATION_MODE; drop pkt\n")); + ret = _FAIL; + goto exit; -+ } ++ } + + sta_addr = pattrib->bssid; + } + -+ } -+ else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ { -+ if (bmcast) -+ { ++ } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { ++ if (bmcast) { + /* For AP mode, if DA == MCAST, then BSSID should be also MCAST */ + if (!IS_MCAST(pattrib->bssid)) { + ret = _FAIL; + goto exit; + } -+ } -+ else /* not mc-frame */ -+ { ++ } else{ /* not mc-frame */ + /* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */ + if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { + ret = _FAIL; @@ -23578,9 +22774,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + sta_addr = pattrib->src; + } + -+ } -+ else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) -+ { ++ } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) { + memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); + memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); + memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); @@ -23588,11 +22782,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + + sta_addr = mybssid; -+ } -+ else -+ { ++ } else + ret = _FAIL; -+ } + + + @@ -23614,14 +22805,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +sint ap2sta_data_frame( + struct adapter *adapter, + union recv_frame *precv_frame, -+ struct sta_info**psta); ++ struct sta_info **psta); +sint ap2sta_data_frame( + struct adapter *adapter, + union recv_frame *precv_frame, -+ struct sta_info**psta) ++ struct sta_info **psta) +{ + u8 *ptr = precv_frame->u.hdr.rx_data; -+ struct rx_pkt_attrib *pattrib = & precv_frame->u.hdr.attrib; ++ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + sint ret = _SUCCESS; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -23631,9 +22822,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) + && (check_fwstate(pmlmepriv, _FW_LINKED) == true -+ || check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true ) -+ ) -+ { ++ || check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) ++ ) { + + /* filter packets that SA is myself or multicast or broadcast */ + if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { @@ -23647,8 +22837,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + } + + /* da should be for me */ -+ if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) -+ { ++ if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + (" ap2sta_data_frame: compare DA fail; DA ="MAC_FMT"\n", MAC_ARG(pattrib->dst))); + #ifdef DBG_RX_DROP_FRAME @@ -23662,8 +22851,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* check BSSID */ + if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || -+ (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) -+ { ++ (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + (" ap2sta_data_frame: compare BSSID fail ; BSSID ="MAC_FMT"\n", MAC_ARG(pattrib->bssid))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid ="MAC_FMT"\n", MAC_ARG(mybssid))); @@ -23673,8 +22861,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + DBG_871X("this adapter = %d, buddy adapter = %d\n", adapter->adapter_type, adapter->pbuddystruct adapter->adapter_type); + #endif + -+ if (!bmcast) -+ { ++ if (!bmcast) { + DBG_871X("issue_deauth to the nonassociated ap =" MAC_FMT " for the reason(7)\n", MAC_ARG(pattrib->bssid)); + issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + } @@ -23707,10 +22894,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + goto exit; + } + -+ } -+ else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && -+ (check_fwstate(pmlmepriv, _FW_LINKED) == true)) -+ { ++ } else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && ++ (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); + memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); + memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); @@ -23732,28 +22917,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + } + + -+ } -+ else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ { ++ } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + /* Special case */ + ret = RTW_RX_HANDLED; + goto exit; -+ } -+ else -+ { -+ if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) -+ { ++ } else{ ++ if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { + *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ -+ if (*psta == NULL) -+ { ++ if (*psta == NULL) { + + /* for AP multicast issue , modify by yiwei */ + static unsigned long send_issue_deauth_time = 0; + + /* DBG_871X("After send deauth , %u ms has elapsed.\n", jiffies_to_msecs(jiffies - send_issue_deauth_time)); */ + -+ if (jiffies_to_msecs(jiffies - send_issue_deauth_time) > 10000 || send_issue_deauth_time == 0) -+ { ++ if (jiffies_to_msecs(jiffies - send_issue_deauth_time) > 10000 || send_issue_deauth_time == 0) { + send_issue_deauth_time = jiffies; + + DBG_871X("issue_deauth to the ap =" MAC_FMT " for the reason(7)\n", MAC_ARG(pattrib->bssid)); @@ -23776,31 +22954,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +sint sta2ap_data_frame( + struct adapter *adapter, + union recv_frame *precv_frame, -+ struct sta_info**psta); ++ struct sta_info **psta); +sint sta2ap_data_frame( + struct adapter *adapter, + union recv_frame *precv_frame, -+ struct sta_info**psta) ++ struct sta_info **psta) +{ + u8 *ptr = precv_frame->u.hdr.rx_data; -+ struct rx_pkt_attrib *pattrib = & precv_frame->u.hdr.attrib; ++ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + unsigned char *mybssid = get_bssid(pmlmepriv); + sint ret = _SUCCESS; + -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + /* For AP mode, RA =BSSID, TX =STA(SRC_ADDR), A3 =DST_ADDR */ -+ if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) -+ { ++ if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + ret = _FAIL; + goto exit; + } + + *psta = rtw_get_stainfo(pstapriv, pattrib->src); -+ if (*psta == NULL) -+ { ++ if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under AP_MODE; drop pkt\n")); + DBG_871X("issue_deauth to sta =" MAC_FMT " for the reason(7)\n", MAC_ARG(pattrib->src)); + @@ -23822,8 +22997,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + ret = RTW_RX_HANDLED; + goto exit; + } -+ } -+ else { ++ } else { + u8 *myhwaddr = myid(&adapter->eeprompriv); + if (memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { + ret = RTW_RX_HANDLED; @@ -23851,70 +23025,58 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* DBG_871X("+validate_recv_ctrl_frame\n"); */ + + if (GetFrameType(pframe) != WIFI_CTRL_TYPE) -+ { + return _FAIL; -+ } + + /* receive the frames that ra(a1) is my address */ + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN)) -+ { + return _FAIL; -+ } + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta == NULL) -+ { + return _FAIL; -+ } + + /* for rx pkt statistics */ + psta->sta_stats.rx_ctrl_pkts++; + + /* only handle ps-poll */ -+ if (GetFrameSubType(pframe) == WIFI_PSPOLL) -+ { ++ if (GetFrameSubType(pframe) == WIFI_PSPOLL) { + u16 aid; + u8 wmmps_ac = 0; + + aid = GetAid(pframe); -+ if (psta->aid!=aid) -+ { ++ if (psta->aid != aid) + return _FAIL; -+ } + -+ switch (pattrib->priority) -+ { -+ case 1: -+ case 2: -+ wmmps_ac = psta->uapsd_bk&BIT(0); -+ break; -+ case 4: -+ case 5: -+ wmmps_ac = psta->uapsd_vi&BIT(0); -+ break; -+ case 6: -+ case 7: -+ wmmps_ac = psta->uapsd_vo&BIT(0); -+ break; -+ case 0: -+ case 3: -+ default: -+ wmmps_ac = psta->uapsd_be&BIT(0); -+ break; ++ switch (pattrib->priority) { ++ case 1: ++ case 2: ++ wmmps_ac = psta->uapsd_bk&BIT(0); ++ break; ++ case 4: ++ case 5: ++ wmmps_ac = psta->uapsd_vi&BIT(0); ++ break; ++ case 6: ++ case 7: ++ wmmps_ac = psta->uapsd_vo&BIT(0); ++ break; ++ case 0: ++ case 3: ++ default: ++ wmmps_ac = psta->uapsd_be&BIT(0); ++ break; + } + + if (wmmps_ac) + return _FAIL; + -+ if (psta->state & WIFI_STA_ALIVE_CHK_STATE) -+ { ++ if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { + DBG_871X("%s alive check-rx ps-poll\n", __func__); + psta->expire_to = pstapriv->expire_to; + psta->state ^= WIFI_STA_ALIVE_CHK_STATE; + } + -+ if ((psta->state&WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap&BIT(psta->aid))) -+ { ++ if ((psta->state&WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap&BIT(psta->aid))) { + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -23925,8 +23087,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + -+ if (xmitframe_phead != xmitframe_plist) -+ { ++ if (xmitframe_phead != xmitframe_plist) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); @@ -23935,7 +23096,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + psta->sleepq_len--; + -+ if (psta->sleepq_len>0) ++ if (psta->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; @@ -23946,8 +23107,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + rtw_hal_xmitframe_enqueue(padapter, pxmitframe); + -+ if (psta->sleepq_len == 0) -+ { ++ if (psta->sleepq_len == 0) { + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + /* DBG_871X("after handling ps-poll, tim =%x\n", pstapriv->tim_bitmap); */ @@ -23960,24 +23120,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* spin_unlock_bh(&psta->sleep_q.lock); */ + spin_unlock_bh(&pxmitpriv->lock); + -+ } -+ else -+ { ++ } else{ + /* spin_unlock_bh(&psta->sleep_q.lock); */ + spin_unlock_bh(&pxmitpriv->lock); + + /* DBG_871X("no buffered packets to xmit\n"); */ -+ if (pstapriv->tim_bitmap&BIT(psta->aid)) -+ { -+ if (psta->sleepq_len == 0) -+ { ++ if (pstapriv->tim_bitmap&BIT(psta->aid)) { ++ if (psta->sleepq_len == 0) { + DBG_871X("no buffered packets to xmit\n"); + + /* issue nulldata with More data bit = 0 to indicate we have no buffered packets */ + issue_nulldata_in_interrupt(padapter, psta->hwaddr); -+ } -+ else -+ { ++ } else{ + DBG_871X("error!psta->sleepq_len =%d\n", psta->sleepq_len); + psta->sleepq_len = 0; + } @@ -23996,7 +23150,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + +} + -+union recv_frame* recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame); ++union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame); +sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame); +sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_frame) +{ @@ -24044,7 +23198,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + u8 *psa, *pda, *pbssid; + struct sta_info *psta = NULL; + u8 *ptr = precv_frame->u.hdr.rx_data; -+ struct rx_pkt_attrib *pattrib = & precv_frame->u.hdr.attrib; ++ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct security_priv *psecuritypriv = &adapter->securitypriv; + sint ret = _SUCCESS; + @@ -24066,36 +23220,35 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + memcpy(pattrib->bssid, pbssid, ETH_ALEN); + -+ switch (pattrib->to_fr_ds) -+ { -+ case 0: -+ memcpy(pattrib->ra, pda, ETH_ALEN); -+ memcpy(pattrib->ta, psa, ETH_ALEN); -+ ret = sta2sta_data_frame(adapter, precv_frame, &psta); -+ break; ++ switch (pattrib->to_fr_ds) { ++ case 0: ++ memcpy(pattrib->ra, pda, ETH_ALEN); ++ memcpy(pattrib->ta, psa, ETH_ALEN); ++ ret = sta2sta_data_frame(adapter, precv_frame, &psta); ++ break; + -+ case 1: -+ memcpy(pattrib->ra, pda, ETH_ALEN); -+ memcpy(pattrib->ta, pbssid, ETH_ALEN); -+ ret = ap2sta_data_frame(adapter, precv_frame, &psta); -+ break; ++ case 1: ++ memcpy(pattrib->ra, pda, ETH_ALEN); ++ memcpy(pattrib->ta, pbssid, ETH_ALEN); ++ ret = ap2sta_data_frame(adapter, precv_frame, &psta); ++ break; + -+ case 2: -+ memcpy(pattrib->ra, pbssid, ETH_ALEN); -+ memcpy(pattrib->ta, psa, ETH_ALEN); -+ ret = sta2ap_data_frame(adapter, precv_frame, &psta); -+ break; ++ case 2: ++ memcpy(pattrib->ra, pbssid, ETH_ALEN); ++ memcpy(pattrib->ta, psa, ETH_ALEN); ++ ret = sta2ap_data_frame(adapter, precv_frame, &psta); ++ break; + -+ case 3: -+ memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN); -+ memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN); -+ ret = _FAIL; -+ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n")); -+ break; ++ case 3: ++ memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN); ++ memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN); ++ ret = _FAIL; ++ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n")); ++ break; + -+ default: -+ ret = _FAIL; -+ break; ++ default: ++ ret = _FAIL; ++ break; + + } + @@ -24126,35 +23279,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + pattrib->amsdu = 0; + pattrib->ack_policy = 0; + /* parsing QC field */ -+ if (pattrib->qos == 1) -+ { ++ if (pattrib->qos == 1) { + pattrib->priority = GetPriority((ptr + 24)); + pattrib->ack_policy = GetAckpolicy((ptr + 24)); + pattrib->amsdu = GetAMsdu((ptr + 24)); -+ pattrib->hdrlen = pattrib->to_fr_ds ==3 ? 32 : 26; ++ pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 32 : 26; + -+ if (pattrib->priority!= 0 && pattrib->priority!=3) -+ { ++ if (pattrib->priority != 0 && pattrib->priority != 3) + adapter->recvpriv.bIsAnyNonBEPkts = true; -+ } -+ } -+ else -+ { ++ ++ } else{ + pattrib->priority = 0; -+ pattrib->hdrlen = pattrib->to_fr_ds ==3 ? 30 : 24; ++ pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 30 : 24; + } + + + if (pattrib->order)/* HT-CTRL 11n */ -+ { + pattrib->hdrlen += 4; -+ } + + precv_frame->u.hdr.preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority]; + + /* decache, drop duplicate recv packets */ -+ if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) -+ { ++ if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decache : drop pkt\n")); + #ifdef DBG_RX_DROP_FRAME + DBG_871X("DBG_RX_DROP_FRAME %s recv_decache return _FAIL\n", __func__); @@ -24173,9 +23319,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt =%d\n", pattrib->encrypt)); + + SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); -+ } -+ else -+ { ++ } else{ + pattrib->encrypt = 0; + pattrib->iv_len = pattrib->icv_len = 0; + } @@ -24187,7 +23331,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *precv_frame) +{ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; -+ struct rx_pkt_attrib *pattrib = & precv_frame->u.hdr.attrib; ++ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + u8 *ptr = precv_frame->u.hdr.rx_data; + u8 type; + u8 subtype; @@ -24197,12 +23341,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + /* only support station mode */ + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED) -+ && adapter->securitypriv.binstallBIPkey == true) -+ { ++ && adapter->securitypriv.binstallBIPkey == true) { + /* unicast management frame decrypt */ + if (pattrib->privacy && !(IS_MCAST(GetAddr1Ptr(ptr))) && -+ (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC || subtype == WIFI_ACTION)) -+ { ++ (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC || subtype == WIFI_ACTION)) { + u8 *ppp, *mgmt_DATA; + u32 data_len = 0; + ppp = GetAddr2Ptr(ptr); @@ -24217,8 +23359,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* actual management data frame body */ + data_len = pattrib->pkt_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; + mgmt_DATA = rtw_zmalloc(data_len); -+ if (mgmt_DATA == NULL) -+ { ++ if (mgmt_DATA == NULL) { + DBG_871X("%s mgmt allocate fail !!!!!!!!!\n", __func__); + goto validate_80211w_fail; + } @@ -24230,48 +23371,36 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* remove the iv and icv length */ + pattrib->pkt_len = pattrib->pkt_len - pattrib->iv_len - pattrib->icv_len; + kfree(mgmt_DATA); -+ if (!precv_frame) -+ { ++ if (!precv_frame) { + DBG_871X("%s mgmt descrypt fail !!!!!!!!!\n", __func__); + goto validate_80211w_fail; + } -+ } -+ else if (IS_MCAST(GetAddr1Ptr(ptr)) && -+ (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC)) -+ { ++ } else if (IS_MCAST(GetAddr1Ptr(ptr)) && ++ (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC)) { + sint BIP_ret = _SUCCESS; + /* verify BIP MME IE of broadcast/multicast de-auth/disassoc packet */ + BIP_ret = rtw_BIP_verify(adapter, (u8 *)precv_frame); -+ if (BIP_ret == _FAIL) -+ { ++ if (BIP_ret == _FAIL) { + /* DBG_871X("802.11w BIP verify fail\n"); */ + goto validate_80211w_fail; -+ } -+ else if (BIP_ret == RTW_RX_HANDLED) -+ { ++ } else if (BIP_ret == RTW_RX_HANDLED) { + /* DBG_871X("802.11w recv none protected packet\n"); */ + /* issue sa query request */ + issue_action_SA_Query(adapter, NULL, 0, 0); + goto validate_80211w_fail; + } -+ }/* 802.11w protect */ -+ else -+ { -+ if (subtype == WIFI_ACTION) -+ { ++ } else { /* 802.11w protect */ ++ if (subtype == WIFI_ACTION) { + /* according 802.11-2012 standard, these five types are not robust types */ + if (ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_PUBLIC && + ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_HT && + ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_UNPROTECTED_WNM && + ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_SELF_PROTECTED && -+ ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_P2P) -+ { ++ ptr[WLAN_HDR_A3_LEN] != RTW_WLAN_CATEGORY_P2P) { + DBG_871X("action frame category =%d should robust\n", ptr[WLAN_HDR_A3_LEN]); + goto validate_80211w_fail; + } -+ } -+ else if (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC) -+ { ++ } else if (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC) { + DBG_871X("802.11w recv none protected packet\n"); + /* issue sa query request */ + issue_action_SA_Query(adapter, NULL, 0, 0); @@ -24291,9 +23420,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + int i; + + DBG_871X("#############################\n"); -+ for (i = 0; i<64;i =i+8) ++ for (i = 0; i < 64; i = i+8) + DBG_871X("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), -+ *(ptr+i+1), *(ptr+i+2) ,*(ptr+i+3) ,*(ptr+i+4),*(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); ++ *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + DBG_871X("#############################\n"); +} + @@ -24308,13 +23437,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + u8 subtype; + sint retval = _SUCCESS; + -+ struct rx_pkt_attrib *pattrib = & precv_frame->u.hdr.attrib; ++ struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + + u8 *ptr = precv_frame->u.hdr.rx_data; -+ u8 ver =(unsigned char) (*ptr)&0x3 ; ++ u8 ver = (unsigned char) (*ptr)&0x3; + + /* add version chk */ -+ if (ver!= 0) { ++ if (ver != 0) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! (ver!= 0)\n")); + retval = _FAIL; + DBG_COUNTER(adapter->rx_logs.core_rx_pre_ver_err); @@ -24345,75 +23474,65 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + dump_rx_packet(ptr); +} + -+ switch (type) -+ { -+ case WIFI_MGT_TYPE: /* mgnt */ -+ DBG_COUNTER(adapter->rx_logs.core_rx_pre_mgmt); -+ if (validate_80211w_mgmt(adapter, precv_frame) == _FAIL) -+ { -+ retval = _FAIL; -+ DBG_COUNTER(padapter->rx_logs.core_rx_pre_mgmt_err_80211w); -+ break; -+ } -+ -+ retval = validate_recv_mgnt_frame(adapter, precv_frame); -+ if (retval == _FAIL) -+ { -+ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_mgnt_frame fail\n")); -+ DBG_COUNTER(adapter->rx_logs.core_rx_pre_mgmt_err); -+ } -+ retval = _FAIL; /* only data frame return _SUCCESS */ -+ break; -+ case WIFI_CTRL_TYPE: /* ctrl */ -+ DBG_COUNTER(adapter->rx_logs.core_rx_pre_ctrl); -+ retval = validate_recv_ctrl_frame(adapter, precv_frame); -+ if (retval == _FAIL) -+ { -+ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_ctrl_frame fail\n")); -+ DBG_COUNTER(adapter->rx_logs.core_rx_pre_ctrl_err); -+ } -+ retval = _FAIL; /* only data frame return _SUCCESS */ -+ break; -+ case WIFI_DATA_TYPE: /* data */ -+ DBG_COUNTER(adapter->rx_logs.core_rx_pre_data); -+ -+ pattrib->qos = (subtype & BIT(7))? 1:0; -+ retval = validate_recv_data_frame(adapter, precv_frame); -+ if (retval == _FAIL) -+ { -+ struct recv_priv *precvpriv = &adapter->recvpriv; -+ /* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail\n")); */ -+ precvpriv->rx_drop++; -+ DBG_COUNTER(adapter->rx_logs.core_rx_pre_data_err); -+ } -+ else if (retval == _SUCCESS) -+ { -+#ifdef DBG_RX_DUMP_EAP -+ u8 bDumpRxPkt; -+ u16 eth_type; -+ -+ /* dump eapol */ -+ rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt)); -+ /* get ether_type */ -+ memcpy(ð_type, ptr + pattrib->hdrlen + pattrib->iv_len + LLC_HEADER_SIZE, 2); -+ eth_type = ntohs((unsigned short) eth_type); -+ if ((bDumpRxPkt == 4) && (eth_type == 0x888e)) -+ dump_rx_packet(ptr); -+#endif -+ } -+ else -+ { -+ DBG_COUNTER(adapter->rx_logs.core_rx_pre_data_handled); -+ } -+ break; -+ default: -+ DBG_COUNTER(adapter->rx_logs.core_rx_pre_unknown); -+ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! type = 0x%x\n", type)); -+ #ifdef DBG_RX_DROP_FRAME -+ DBG_871X("DBG_RX_DROP_FRAME validate_recv_data_frame fail! type = 0x%x\n", type); -+ #endif ++ switch (type) { ++ case WIFI_MGT_TYPE: /* mgnt */ ++ DBG_COUNTER(adapter->rx_logs.core_rx_pre_mgmt); ++ if (validate_80211w_mgmt(adapter, precv_frame) == _FAIL) { + retval = _FAIL; ++ DBG_COUNTER(padapter->rx_logs.core_rx_pre_mgmt_err_80211w); + break; ++ } ++ ++ retval = validate_recv_mgnt_frame(adapter, precv_frame); ++ if (retval == _FAIL) { ++ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_mgnt_frame fail\n")); ++ DBG_COUNTER(adapter->rx_logs.core_rx_pre_mgmt_err); ++ } ++ retval = _FAIL; /* only data frame return _SUCCESS */ ++ break; ++ case WIFI_CTRL_TYPE: /* ctrl */ ++ DBG_COUNTER(adapter->rx_logs.core_rx_pre_ctrl); ++ retval = validate_recv_ctrl_frame(adapter, precv_frame); ++ if (retval == _FAIL) { ++ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_ctrl_frame fail\n")); ++ DBG_COUNTER(adapter->rx_logs.core_rx_pre_ctrl_err); ++ } ++ retval = _FAIL; /* only data frame return _SUCCESS */ ++ break; ++ case WIFI_DATA_TYPE: /* data */ ++ DBG_COUNTER(adapter->rx_logs.core_rx_pre_data); ++ ++ pattrib->qos = (subtype & BIT(7)) ? 1:0; ++ retval = validate_recv_data_frame(adapter, precv_frame); ++ if (retval == _FAIL) { ++ struct recv_priv *precvpriv = &adapter->recvpriv; ++ /* RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail\n")); */ ++ precvpriv->rx_drop++; ++ DBG_COUNTER(adapter->rx_logs.core_rx_pre_data_err); ++ } else if (retval == _SUCCESS) { ++#ifdef DBG_RX_DUMP_EAP ++ u8 bDumpRxPkt; ++ u16 eth_type; ++ ++ /* dump eapol */ ++ rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt)); ++ /* get ether_type */ ++ memcpy(ð_type, ptr + pattrib->hdrlen + pattrib->iv_len + LLC_HEADER_SIZE, 2); ++ eth_type = ntohs((unsigned short) eth_type); ++ if ((bDumpRxPkt == 4) && (eth_type == 0x888e)) ++ dump_rx_packet(ptr); ++#endif ++ } else ++ DBG_COUNTER(adapter->rx_logs.core_rx_pre_data_handled); ++ break; ++ default: ++ DBG_COUNTER(adapter->rx_logs.core_rx_pre_unknown); ++ RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! type = 0x%x\n", type)); ++ #ifdef DBG_RX_DROP_FRAME ++ DBG_871X("DBG_RX_DROP_FRAME validate_recv_data_frame fail! type = 0x%x\n", type); ++ #endif ++ retval = _FAIL; ++ break; + } + +exit: @@ -24422,8 +23541,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + +/* remove the wlanhdr and add the eth_hdr */ -+sint wlanhdr_to_ethhdr (union recv_frame *precvframe); -+sint wlanhdr_to_ethhdr (union recv_frame *precvframe) ++sint wlanhdr_to_ethhdr(union recv_frame *precvframe); ++sint wlanhdr_to_ethhdr(union recv_frame *precvframe) +{ + sint rmv_len; + u16 eth_type, len; @@ -24432,33 +23551,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + struct ieee80211_snap_hdr *psnap; + __be16 be_tmp; + sint ret = _SUCCESS; -+ struct adapter *adapter =precvframe->u.hdr.adapter; ++ struct adapter *adapter = precvframe->u.hdr.adapter; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u8 *ptr = get_recvframe_data(precvframe) ; /* point to frame_ctrl field */ -+ struct rx_pkt_attrib *pattrib = & precvframe->u.hdr.attrib; ++ struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; + + if (pattrib->encrypt) { + recvframe_pull_tail(precvframe, pattrib->icv_len); + } + -+ psnap =(struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); -+ psnap_type =ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; ++ psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); ++ psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; + /* convert hdr + possible LLC headers into Ethernet header */ + /* eth_type = (psnap_type[0] << 8) | psnap_type[1]; */ + if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && + (memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2)) && -+ (memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)))|| ++ (memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2))) || + /* eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || */ + !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ + bsnaphdr = true; -+ } -+ else { ++ } else + /* Leave Ethernet header part of hdr and full payload */ + bsnaphdr = false; -+ } + -+ rmv_len = pattrib->hdrlen + pattrib->iv_len +(bsnaphdr?SNAP_SIZE:0); ++ rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr?SNAP_SIZE:0); + len = precvframe->u.hdr.len - rmv_len; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n ===pattrib->hdrlen: %x, pattrib->iv_len:%x ===\n\n", pattrib->hdrlen, pattrib->iv_len)); @@ -24468,31 +23585,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + pattrib->eth_type = eth_type; + +#ifdef CONFIG_AUTO_AP_MODE -+ if (0x8899 == pattrib->eth_type) -+ { ++ if (0x8899 == pattrib->eth_type) { + struct sta_info *psta = precvframe->u.hdr.psta; + + DBG_871X("wlan rx: got eth_type = 0x%x\n", pattrib->eth_type); + -+ if (psta && psta->isrc && psta->pid>0) -+ { ++ if (psta && psta->isrc && psta->pid > 0) { + u16 rx_pid; + -+ rx_pid = *(u16*)(ptr+rmv_len+2); ++ rx_pid = *(u16 *)(ptr+rmv_len+2); + + DBG_871X("wlan rx(pid = 0x%x): sta("MAC_FMT") pid = 0x%x\n", + rx_pid, MAC_ARG(psta->hwaddr), psta->pid); + -+ if (rx_pid == psta->pid) -+ { ++ if (rx_pid == psta->pid) { + int i; -+ u16 len = *(u16*)(ptr+rmv_len+4); ++ u16 len = *(u16 *)(ptr+rmv_len+4); + /* u16 ctrl_type = *(u16*)(ptr+rmv_len+6); */ + + /* DBG_871X("RC: len = 0x%x, ctrl_type = 0x%x\n", len, ctrl_type); */ + DBG_871X("RC: len = 0x%x\n", len); + -+ for (i = 0;idst, ETH_ALEN); + memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN); @@ -24530,26 +23641,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +} + +/* perform defrag */ -+union recv_frame * recvframe_defrag(struct adapter *adapter, struct __queue *defrag_q) ++union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queue *defrag_q) +{ + struct list_head *plist, *phead; + u8 *data, wlanhdr_offset; + u8 curfragnum; -+ struct recv_frame_hdr *pfhdr,*pnfhdr; -+ union recv_frame* prframe, *pnextrframe; ++ struct recv_frame_hdr *pfhdr, *pnfhdr; ++ union recv_frame *prframe, *pnextrframe; + struct __queue *pfree_recv_queue; + + curfragnum = 0; -+ pfree_recv_queue =&adapter->recvpriv.free_recv_queue; ++ pfree_recv_queue = &adapter->recvpriv.free_recv_queue; + + phead = get_list_head(defrag_q); + plist = get_next(phead); + prframe = LIST_CONTAINOR(plist, union recv_frame, u); -+ pfhdr =&prframe->u.hdr; ++ pfhdr = &prframe->u.hdr; + list_del_init(&(prframe->u.list)); + -+ if (curfragnum!=pfhdr->attrib.frag_num) -+ { ++ if (curfragnum != pfhdr->attrib.frag_num) { + /* the first fragment number must be 0 */ + /* free the whole queue */ + rtw_free_recvframe(prframe, pfree_recv_queue); @@ -24564,18 +23674,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + plist = get_next(plist); + -+ data =get_recvframe_data(prframe); ++ data = get_recvframe_data(prframe); + -+ while (phead != plist) -+ { -+ pnextrframe = LIST_CONTAINOR(plist, union recv_frame , u); -+ pnfhdr =&pnextrframe->u.hdr; ++ while (phead != plist) { ++ pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); ++ pnfhdr = &pnextrframe->u.hdr; + + + /* check the fragment sequence (2nd ~n fragment frame) */ + -+ if (curfragnum!=pnfhdr->attrib.frag_num) -+ { ++ if (curfragnum != pnfhdr->attrib.frag_num) { + /* the fragment number must be increasing (after decache) */ + /* release the defrag_q & prframe */ + rtw_free_recvframe(prframe, pfree_recv_queue); @@ -24600,7 +23708,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + recvframe_put(prframe, pnfhdr->len); + -+ pfhdr->attrib.icv_len =pnfhdr->attrib.icv_len; ++ pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len; + plist = get_next(plist); + + }; @@ -24614,7 +23722,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +} + +/* check if need to defrag, if needed queue the frame to defrag_q */ -+union recv_frame* recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame) ++union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame) +{ + u8 ismfrag; + u8 fragnum; @@ -24638,38 +23746,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + psta_addr = pfhdr->attrib.ta; + psta = rtw_get_stainfo(pstapriv, psta_addr); -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + u8 type = GetFrameType(pfhdr->rx_data); + if (type != WIFI_DATA_TYPE) { + psta = rtw_get_bcmc_stainfo(padapter); + pdefrag_q = &psta->sta_recvpriv.defrag_q; + } else + pdefrag_q = NULL; -+ } -+ else ++ } else + pdefrag_q = &psta->sta_recvpriv.defrag_q; + + if ((ismfrag == 0) && (fragnum == 0)) -+ { + prtnframe = precv_frame;/* isn't a fragment frame */ -+ } + -+ if (ismfrag == 1) -+ { ++ if (ismfrag == 1) { + /* 0~(n-1) fragment frame */ + /* enqueue to defraf_g */ -+ if (pdefrag_q != NULL) -+ { ++ if (pdefrag_q != NULL) { + if (fragnum == 0) -+ { + /* the first fragment */ + if (!list_empty(&pdefrag_q->queue)) -+ { + /* free current defrag_q */ + rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue); -+ } -+ } + + + /* Then enqueue the 0~(n-1) fragment into the defrag_q */ @@ -24683,9 +23781,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + prtnframe = NULL; + -+ } -+ else -+ { ++ } else{ + /* can't find this ta's defrag_queue, so free this recv_frame */ + rtw_free_recvframe(precv_frame, pfree_recv_queue); + prtnframe = NULL; @@ -24694,12 +23790,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + } + -+ if ((ismfrag == 0) && (fragnum!= 0)) -+ { ++ if ((ismfrag == 0) && (fragnum != 0)) { + /* the last fragment frame */ + /* enqueue the last fragment */ -+ if (pdefrag_q != NULL) -+ { ++ if (pdefrag_q != NULL) { + /* spin_lock(&pdefrag_q->lock); */ + phead = get_list_head(pdefrag_q); + list_add_tail(&pfhdr->list, phead); @@ -24708,11 +23802,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* call recvframe_defrag to defrag */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("defrag: ismfrag = %d, fragnum = %d\n", ismfrag, fragnum)); + precv_frame = recvframe_defrag(padapter, pdefrag_q); -+ prtnframe =precv_frame; ++ prtnframe = precv_frame; + -+ } -+ else -+ { ++ } else{ + /* can't find this ta's defrag_queue, so free this recv_frame */ + rtw_free_recvframe(precv_frame, pfree_recv_queue); + prtnframe = NULL; @@ -24722,11 +23814,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + } + + -+ if ((prtnframe!= NULL) && (prtnframe->u.hdr.attrib.privacy)) -+ { ++ if ((prtnframe != NULL) && (prtnframe->u.hdr.attrib.privacy)) { + /* after defrag we must check tkip mic code */ -+ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) -+ { ++ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe) == _FAIL\n")); + rtw_free_recvframe(prtnframe, pfree_recv_queue); + prtnframe = NULL; @@ -24741,7 +23831,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + u16 nSubframe_Length; + u8 nr_subframes, i; + u8 *pdata; -+ _pkt *sub_pkt,*subframes[MAX_SUBFRAME_COUNT]; ++ _pkt *sub_pkt, *subframes[MAX_SUBFRAME_COUNT]; + struct recv_priv *precvpriv = &padapter->recvpriv; + struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue); + int ret = _SUCCESS; @@ -24750,10 +23840,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + recvframe_pull(prframe, prframe->u.hdr.attrib.hdrlen); + -+ if (prframe->u.hdr.attrib.iv_len >0) -+ { ++ if (prframe->u.hdr.attrib.iv_len > 0) + recvframe_pull(prframe, prframe->u.hdr.attrib.iv_len); -+ } + + a_len = prframe->u.hdr.len; + @@ -24803,7 +23891,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + } + } + -+ for (i = 0; idvobj; + struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; + u8 wsize = preorder_ctrl->wsize_b; -+ u16 wend = (preorder_ctrl->indicate_seq + wsize -1) & 0xFFF;/* 4096; */ ++ u16 wend = (preorder_ctrl->indicate_seq + wsize - 1) & 0xFFF;/* 4096; */ + + /* Rx Reorder initialize condition. */ -+ if (preorder_ctrl->indicate_seq == 0xFFFF) -+ { ++ if (preorder_ctrl->indicate_seq == 0xFFFF) { + preorder_ctrl->indicate_seq = seq_num; + #ifdef DBG_RX_SEQ + DBG_871X("DBG_RX_SEQ %s:%d init IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__, @@ -24842,8 +23929,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* DbgPrint("enter->check_indicate_seq(): IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */ + + /* Drop out the packet which SeqNum is smaller than WinStart */ -+ if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) -+ { ++ if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) { + /* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, ("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, NewSeqNum)); */ + /* DbgPrint("CheckRxTsIndicateSeq(): Packet Drop! IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */ + @@ -24861,23 +23947,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* 1. Incoming SeqNum is equal to WinStart =>Window shift 1 */ + /* 2. Incoming SeqNum is larger than the WinEnd => Window shift N */ + /* */ -+ if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq)) -+ { ++ if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq)) { + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; + + #ifdef DBG_RX_SEQ + DBG_871X("DBG_RX_SEQ %s:%d SN_EQUAL IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__, + preorder_ctrl->indicate_seq, seq_num); + #endif -+ } -+ else if (SN_LESS(wend, seq_num)) -+ { ++ } else if (SN_LESS(wend, seq_num)) { + /* RT_TRACE(COMP_RX_REORDER, DBG_LOUD, ("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, NewSeqNum)); */ + /* DbgPrint("CheckRxTsIndicateSeq(): Window Shift! IndicateSeq: %d, NewSeq: %d\n", precvpriv->indicate_seq, seq_num); */ + + /* boundary situation, when seq_num cross 0xFFF */ + if (seq_num >= (wsize - 1)) -+ preorder_ctrl->indicate_seq = seq_num + 1 -wsize; ++ preorder_ctrl->indicate_seq = seq_num + 1 - wsize; + else + preorder_ctrl->indicate_seq = 0xFFF - (wsize - (seq_num + 1)) + 1; + pdbgpriv->dbg_rx_ampdu_window_shift_cnt++; @@ -24910,28 +23993,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + phead = get_list_head(ppending_recvframe_queue); + plist = get_next(phead); + -+ while (phead != plist) -+ { ++ while (phead != plist) { + pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); + pnextattrib = &pnextrframe->u.hdr.attrib; + + if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) -+ { + plist = get_next(plist); -+ } + else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) -+ { + /* Duplicate entry is found!! Do not insert current entry. */ + /* RT_TRACE(COMP_RX_REORDER, DBG_TRACE, ("InsertRxReorderList(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum)); */ -+ + /* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */ -+ + return false; -+ } + else -+ { + break; -+ } + + /* DbgPrint("enqueue_reorder_recvframe():while\n"); */ + @@ -24958,14 +24032,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp +void recv_indicatepkts_pkt_loss_cnt(struct debug_priv *pdbgpriv, u64 prev_seq, u64 current_seq) +{ + if (current_seq < prev_seq) -+ { -+ pdbgpriv->dbg_rx_ampdu_loss_count+= (4096 + current_seq - prev_seq); -+ -+ } ++ pdbgpriv->dbg_rx_ampdu_loss_count += (4096 + current_seq - prev_seq); + else -+ { -+ pdbgpriv->dbg_rx_ampdu_loss_count+= (current_seq - prev_seq); -+ } ++ pdbgpriv->dbg_rx_ampdu_loss_count += (current_seq - prev_seq); ++ +} +int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced); +int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced) @@ -24991,11 +24061,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + plist = get_next(phead); + + /* Handling some condition for forced indicate case. */ -+ if (bforced ==true) -+ { ++ if (bforced == true) { + pdbgpriv->dbg_rx_ampdu_forced_indicate_count++; -+ if (list_empty(phead)) -+ { ++ if (list_empty(phead)) { + /* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */ + /* spin_unlock(&ppending_recvframe_queue->lock); */ + return true; @@ -25015,14 +24083,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + /* Prepare indication list and indication. */ + /* Check if there is any packet need indicate. */ -+ while (!list_empty(phead)) -+ { ++ while (!list_empty(phead)) { + + prframe = LIST_CONTAINOR(plist, union recv_frame, u); + pattrib = &prframe->u.hdr.attrib; + -+ if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) -+ { ++ if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, + ("recv_indicatepkts_in_order: indicate =%d seq =%d amsdu =%d\n", + preorder_ctrl->indicate_seq, pattrib->seq_num, pattrib->amsdu)); @@ -25030,8 +24096,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + plist = get_next(plist); + list_del_init(&(prframe->u.hdr.list)); + -+ if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) -+ { ++ if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) { + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; + #ifdef DBG_RX_SEQ + DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__, @@ -25048,27 +24113,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + /* indicate this recv_frame */ + /* DbgPrint("recv_indicatepkts_in_order, indicate_seq =%d, seq_num =%d\n", precvpriv->indicate_seq, pattrib->seq_num); */ -+ if (!pattrib->amsdu) -+ { ++ if (!pattrib->amsdu) { + /* DBG_871X("recv_indicatepkts_in_order, amsdu!= 1, indicate_seq =%d, seq_num =%d\n", preorder_ctrl->indicate_seq, pattrib->seq_num); */ + + if ((padapter->bDriverStopped == false) && + (padapter->bSurpriseRemoved == false)) -+ { -+ + rtw_recv_indicatepkt(padapter, prframe);/* indicate this recv_frame */ + -+ } -+ } -+ else if (pattrib->amsdu == 1) -+ { -+ if (amsdu_to_msdu(padapter, prframe)!= _SUCCESS) -+ { ++ } else if (pattrib->amsdu == 1) { ++ if (amsdu_to_msdu(padapter, prframe) != _SUCCESS) + rtw_free_recvframe(prframe, &precvpriv->free_recv_queue); -+ } -+ } -+ else -+ { ++ ++ } else{ + /* error condition; */ + } + @@ -25076,9 +24132,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* Update local variables. */ + bPktInBuf = false; + -+ } -+ else -+ { ++ } else{ + bPktInBuf = true; + break; + } @@ -25105,16 +24159,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + DBG_COUNTER(padapter->rx_logs.core_rx_post_indicate_reoder); + -+ if (!pattrib->amsdu) -+ { ++ if (!pattrib->amsdu) { + /* s1. */ + wlanhdr_to_ethhdr(prframe); + -+ if (pattrib->qos!= 1) -+ { ++ if (pattrib->qos != 1) { + if ((padapter->bDriverStopped == false) && -+ (padapter->bSurpriseRemoved == false)) -+ { ++ (padapter->bSurpriseRemoved == false)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ recv_indicatepkt_reorder -recv_func recv_indicatepkt\n")); + + rtw_recv_indicatepkt(padapter, prframe); @@ -25130,8 +24181,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + } + -+ if (preorder_ctrl->enable == false) -+ { ++ if (preorder_ctrl->enable == false) { + /* indicate this recv_frame */ + preorder_ctrl->indicate_seq = pattrib->seq_num; + #ifdef DBG_RX_SEQ @@ -25149,11 +24199,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + return _SUCCESS; + } -+ } -+ else if (pattrib->amsdu == 1) /* temp filter -> means didn't support A-MSDUs in a A-MPDU */ -+ { -+ if (preorder_ctrl->enable == false) -+ { ++ } else if (pattrib->amsdu == 1) { /* temp filter -> means didn't support A-MSDUs in a A-MPDU */ ++ if (preorder_ctrl->enable == false) { + preorder_ctrl->indicate_seq = pattrib->seq_num; + #ifdef DBG_RX_SEQ + DBG_871X("DBG_RX_SEQ %s:%d IndicateSeq: %d, NewSeq: %d\n", __func__, __LINE__, @@ -25185,8 +24232,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + preorder_ctrl->indicate_seq, pattrib->seq_num)); + + /* s2. check if winstart_b(indicate_seq) needs to been updated */ -+ if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) -+ { ++ if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) { + pdbgpriv->dbg_rx_ampdu_drop_count++; + #ifdef DBG_RX_DROP_FRAME + DBG_871X("DBG_RX_DROP_FRAME %s check_indicate_seq fail\n", __func__); @@ -25196,8 +24242,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + + /* s3. Insert all packet into Reorder Queue to maintain its ordering. */ -+ if (!enqueue_reorder_recvframe(preorder_ctrl, prframe)) -+ { ++ if (!enqueue_reorder_recvframe(preorder_ctrl, prframe)) { + /* DbgPrint("recv_indicatepkt_reorder, enqueue_reorder_recvframe fail!\n"); */ + /* spin_unlock_irqrestore(&ppending_recvframe_queue->lock, irql); */ + /* return _FAIL; */ @@ -25219,13 +24264,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + /* */ + + /* recv_indicatepkts_in_order(padapter, preorder_ctrl, true); */ -+ if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false) ==true) -+ { ++ if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false) == true) { + _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); + spin_unlock_bh(&ppending_recvframe_queue->lock); -+ } -+ else -+ { ++ } else{ + spin_unlock_bh(&ppending_recvframe_queue->lock); + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); + } @@ -25233,8 +24275,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + return _SUCCESS; + +_err_exit: -+ -+ spin_unlock_bh(&ppending_recvframe_queue->lock); ++ spin_unlock_bh(&ppending_recvframe_queue->lock); + + return _FAIL; +} @@ -25247,19 +24288,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + -+ if (padapter->bDriverStopped ||padapter->bSurpriseRemoved) -+ { ++ if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + return; -+ } + + /* DBG_871X("+rtw_reordering_ctrl_timeout_handler() =>\n"); */ + + spin_lock_bh(&ppending_recvframe_queue->lock); + -+ if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) ==true) -+ { ++ if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) == true) + _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); -+ } + + spin_unlock_bh(&ppending_recvframe_queue->lock); + @@ -25276,29 +24313,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + DBG_COUNTER(padapter->rx_logs.core_rx_post_indicate); + -+ if (phtpriv->ht_option ==true) /* B/G/N Mode */ -+ { ++ if (phtpriv->ht_option == true) { /* B/G/N Mode */ + /* prframe->u.hdr.preorder_ctrl = &precvpriv->recvreorder_ctrl[pattrib->priority]; */ + -+ if (recv_indicatepkt_reorder(padapter, prframe)!= _SUCCESS)/* including perform A-MPDU Rx Ordering Buffer Control */ -+ { ++ if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) { /* including perform A-MPDU Rx Ordering Buffer Control */ + #ifdef DBG_RX_DROP_FRAME + DBG_871X("DBG_RX_DROP_FRAME %s recv_indicatepkt_reorder error!\n", __func__); + #endif + + if ((padapter->bDriverStopped == false) && -+ (padapter->bSurpriseRemoved == false)) -+ { ++ (padapter->bSurpriseRemoved == false)) { + retval = _FAIL; + return retval; + } + } -+ } -+ else /* B/G mode */ -+ { -+ retval =wlanhdr_to_ethhdr (prframe); -+ if (retval != _SUCCESS) -+ { ++ } else { /* B/G mode */ ++ retval = wlanhdr_to_ethhdr(prframe); ++ if (retval != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("wlanhdr_to_ethhdr: drop pkt\n")); + #ifdef DBG_RX_DROP_FRAME + DBG_871X("DBG_RX_DROP_FRAME %s wlanhdr_to_ethhdr error!\n", __func__); @@ -25306,16 +24337,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + return retval; + } + -+ if ((padapter->bDriverStopped ==false) && (padapter->bSurpriseRemoved ==false)) -+ { ++ if ((padapter->bDriverStopped == false) && (padapter->bSurpriseRemoved == false)) { + /* indicate this recv_frame */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func recv_indicatepkt\n")); + rtw_recv_indicatepkt(padapter, prframe); + + -+ } -+ else -+ { ++ } else{ + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func free_indicatepkt\n")); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_func:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); @@ -25338,8 +24366,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + /* check the frame crtl field and decache */ + ret = validate_recv_frame(padapter, rframe); -+ if (ret != _SUCCESS) -+ { ++ if (ret != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recv_func: validate_recv_frame fail! drop pkt\n")); + rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ + goto exit; @@ -25379,7 +24406,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + goto _recv_data_drop; + } + -+ prframe =portctrl(padapter, prframe); ++ prframe = portctrl(padapter, prframe); + if (prframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("portctrl: drop pkt\n")); + #ifdef DBG_RX_DROP_FRAME @@ -25393,8 +24420,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + count_rx_stats(padapter, prframe, NULL); + + ret = process_recv_indicatepkts(padapter, prframe); -+ if (ret != _SUCCESS) -+ { ++ if (ret != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recv_func: process_recv_indicatepkts fail!\n")); + #ifdef DBG_RX_DROP_FRAME + DBG_871X("DBG_RX_DROP_FRAME %s process_recv_indicatepkts fail!\n", __func__); @@ -25416,16 +24442,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + int ret; + struct rx_pkt_attrib *prxattrib = &rframe->u.hdr.attrib; + struct recv_priv *recvpriv = &padapter->recvpriv; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *mlmepriv = &padapter->mlmepriv; + + /* check if need to handle uc_swdec_pending_queue*/ -+ if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) -+ { ++ if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) { + union recv_frame *pending_frame; + int cnt = 0; + -+ while ((pending_frame =rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue))) { ++ while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue))) { + cnt++; + DBG_COUNTER(padapter->rx_logs.core_rx_dequeue); + recv_func_posthandle(padapter, pending_frame); @@ -25443,11 +24468,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + /* check if need to enqueue into uc_swdec_pending_queue*/ + if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && -+ !IS_MCAST(prxattrib->ra) && prxattrib->encrypt>0 && -+ (prxattrib->bdecrypted == 0 ||psecuritypriv->sw_decrypt == true) && ++ !IS_MCAST(prxattrib->ra) && prxattrib->encrypt > 0 && ++ (prxattrib->bdecrypted == 0 || psecuritypriv->sw_decrypt == true) && + psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPAPSK && -+ !psecuritypriv->busetkipkey) -+ { ++ !psecuritypriv->busetkipkey) { + DBG_COUNTER(padapter->rx_logs.core_rx_enqueue); + rtw_enqueue_recvframe(rframe, &padapter->recvpriv.uc_swdec_pending_queue); + /* DBG_871X("%s: no key, enqueue uc_swdec_pending_queue\n", __func__); */ @@ -25482,9 +24506,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + precvpriv = &padapter->recvpriv; + -+ -+ if ((ret = recv_func(padapter, precvframe)) == _FAIL) -+ { ++ ret = recv_func(padapter, precvframe); ++ if (ret == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("rtw_recv_entry: recv_func return fail!!!\n")); + goto _recv_entry_drop; + } @@ -25501,7 +24524,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + return ret; +} + -+void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS) { ++void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS) ++{ + struct adapter *adapter = (struct adapter *)FunctionContext; + struct recv_priv *recvpriv = &adapter->recvpriv; + @@ -25515,7 +24539,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + if (adapter->recvpriv.is_signal_dbg) { + /* update the user specific value, signal_strength_dbg, to signal_strength, rssi */ + adapter->recvpriv.signal_strength = adapter->recvpriv.signal_strength_dbg; -+ adapter->recvpriv.rssi =(s8)translate_percentage_to_dbm((u8)adapter->recvpriv.signal_strength_dbg); ++ adapter->recvpriv.rssi = (s8)translate_percentage_to_dbm((u8)adapter->recvpriv.signal_strength_dbg); + } else { + + if (recvpriv->signal_strength_data.update_req == 0) {/* update_req is clear, means we got rx */ @@ -25548,19 +24572,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + + /* update value of signal_strength, rssi, signal_qual */ + tmp_s = (avg_signal_strength+(_alpha-1)*recvpriv->signal_strength); -+ if (tmp_s %_alpha) ++ if (tmp_s % _alpha) + tmp_s = tmp_s/_alpha + 1; + else + tmp_s = tmp_s/_alpha; -+ if (tmp_s>100) ++ if (tmp_s > 100) + tmp_s = 100; + + tmp_q = (avg_signal_qual+(_alpha-1)*recvpriv->signal_qual); -+ if (tmp_q %_alpha) ++ if (tmp_q % _alpha) + tmp_q = tmp_q/_alpha + 1; + else + tmp_q = tmp_q/_alpha; -+ if (tmp_q>100) ++ if (tmp_q > 100) + tmp_q = 100; + + recvpriv->signal_strength = tmp_s; @@ -25586,10 +24610,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_recv.c linux-4.3-rtl8723bs/3rdp + rtw_set_signal_stat_timer(recvpriv); + +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_rf.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_rf.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_rf.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_rf.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,66 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_rf.c linux/3rdparty/rtl8723bs/core/rtw_rf.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_rf.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_rf.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,64 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -25643,10 +24667,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_rf.c linux-4.3-rtl8723bs/3rdpar + u8 i; + u32 freq = 0; + -+ for (i = 0; i < ch_freq_map_num; i++) -+ { -+ if (channel == ch_freq_map[i].channel) -+ { ++ for (i = 0; i < ch_freq_map_num; i++) { ++ if (channel == ch_freq_map[i].channel) { + freq = ch_freq_map[i].frequency; + break; + } @@ -25656,10 +24678,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_rf.c linux-4.3-rtl8723bs/3rdpar + + return freq; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_security.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_security.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,2486 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_security.c linux/3rdparty/rtl8723bs/core/rtw_security.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_security.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_security.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,2448 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -25759,20 +24781,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + +#define CRC32_POLY 0x04c11db7 + -+struct arc4context -+{ ++struct arc4context { + u32 x; + u32 y; + u8 state[256]; +}; + + -+static void arcfour_init(struct arc4context *parc4ctx, u8 * key, u32 key_len) ++static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) +{ + u32 t, u; + u32 keyindex; + u32 stateindex; -+ u8 * state; ++ u8 *state; + u32 counter; + + state = parc4ctx->state; @@ -25782,8 +24803,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + state[counter] = (u8)counter; + keyindex = 0; + stateindex = 0; -+ for (counter = 0; counter < 256; counter++) -+ { ++ for (counter = 0; counter < 256; counter++) { + t = state[counter]; + stateindex = (stateindex + key[keyindex] + t) & 0xff; + u = state[stateindex]; @@ -25799,7 +24819,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + u32 x; + u32 y; + u32 sx, sy; -+ u8 * state; ++ u8 *state; + + state = parc4ctx->state; + x = (parc4ctx->x + 1) & 0xff; @@ -25813,10 +24833,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + return state[(sx + sy) & 0xff]; +} + -+static void arcfour_encrypt(struct arc4context *parc4ctx, -+ u8 * dest, -+ u8 * src, -+ u32 len) ++static void arcfour_encrypt( ++ struct arc4context *parc4ctx, ++ u8 *dest, ++ u8 *src, ++ u32 len ++) +{ + u32 i; + @@ -25840,13 +24862,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + else { + sint i, j; + u32 c; -+ u8 *p =(u8 *)&c, *p1; ++ u8 *p = (u8 *)&c, *p1; + u8 k; + + c = 0x12340000; + -+ for (i = 0; i < 256; ++i) -+ { ++ for (i = 0; i < 256; ++i) { + k = crc32_reverseBit((u8)i); + for (c = ((u32)k) << 24, j = 8; j > 0; --j) { + c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); @@ -25867,13 +24888,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + u8 *p; + u32 crc; + -+ if (bcrc32initialized == 0) crc32_init(); ++ if (bcrc32initialized == 0) ++ crc32_init(); + + crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ + -+ for (p = buf; len > 0; ++p, --len) -+ { -+ crc = crc32_table[ (crc ^ *p) & 0xff] ^ (crc >> 8); ++ for (p = buf; len > 0; ++p, --len) { ++ crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); + } + return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ +} @@ -25891,35 +24912,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + sint curfragnum, length; + u32 keylength; + -+ u8 *pframe, *payload,*iv; /* wepkey */ ++ u8 *pframe, *payload, *iv; /* wepkey */ + u8 wepkey[16]; + u8 hw_hdr_offset = 0; -+ struct pkt_attrib *pattrib = &((struct xmit_frame*)pxmitframe)->attrib; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; -+ struct xmit_priv *pxmitpriv =&padapter->xmitpriv; ++ struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; ++ struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + -+ if (((struct xmit_frame*)pxmitframe)->buf_addr == NULL) ++ if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return; + + hw_hdr_offset = TXDESC_OFFSET; -+ pframe = ((struct xmit_frame*)pxmitframe)->buf_addr + hw_hdr_offset; ++ pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + + /* start to encrypt each fragment */ -+ if ((pattrib->encrypt == _WEP40_)||(pattrib->encrypt == _WEP104_)) -+ { -+ keylength =psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex]; ++ if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) { ++ keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex]; + -+ for (curfragnum = 0;curfragnumnr_frags;curfragnum++) -+ { -+ iv =pframe+pattrib->hdrlen; ++ for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { ++ iv = pframe+pattrib->hdrlen; + memcpy(&wepkey[0], iv, 3); + memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); -+ payload =pframe+pattrib->iv_len+pattrib->hdrlen; ++ payload = pframe+pattrib->iv_len+pattrib->hdrlen; + -+ if ((curfragnum+1) ==pattrib->nr_frags) -+ { /* the last fragment */ ++ if ((curfragnum+1) == pattrib->nr_frags) { /* the last fragment */ + -+ length =pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len; ++ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + *((__le32 *)crc) = getcrc32(payload, length); + @@ -25927,17 +24945,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + -+ } -+ else -+ { -+ length =pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; ++ } else{ ++ length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + *((__le32 *)crc) = getcrc32(payload, length); + arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + -+ pframe+=pxmitpriv->frag_len; -+ pframe =(u8 *)RND4((SIZE_PTR)(pframe)); ++ pframe += pxmitpriv->frag_len; ++ pframe = (u8 *)RND4((SIZE_PTR)(pframe)); + + } + @@ -25954,36 +24970,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + struct arc4context mycontext; + sint length; + u32 keylength; -+ u8 *pframe, *payload,*iv, wepkey[16]; ++ u8 *pframe, *payload, *iv, wepkey[16]; + u8 keyindex; -+ struct rx_pkt_attrib *prxattrib = &(((union recv_frame*)precvframe)->u.hdr.attrib); -+ struct security_priv *psecuritypriv =&padapter->securitypriv; ++ struct rx_pkt_attrib *prxattrib = &(((union recv_frame *)precvframe)->u.hdr.attrib); ++ struct security_priv *psecuritypriv = &padapter->securitypriv; + -+ pframe =(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data; ++ pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + + /* start to decrypt recvframe */ -+ if ((prxattrib->encrypt == _WEP40_)||(prxattrib->encrypt == _WEP104_)) -+ { -+ iv =pframe+prxattrib->hdrlen; ++ if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { ++ iv = pframe+prxattrib->hdrlen; + /* keyindex =(iv[3]&0x3); */ + keyindex = prxattrib->key_index; -+ keylength =psecuritypriv->dot11DefKeylen[keyindex]; ++ keylength = psecuritypriv->dot11DefKeylen[keyindex]; + memcpy(&wepkey[0], iv, 3); + /* memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); */ + memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength); + length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + -+ payload =pframe+prxattrib->iv_len+prxattrib->hdrlen; ++ payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + + /* decrypt payload include icv */ + arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_encrypt(&mycontext, payload, payload, length); + + /* calculate icv and compare the icv */ -+ *((u32 *)crc) =le32_to_cpu(getcrc32(payload, length-4)); ++ *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); + -+ if (crc[3]!=payload[length-1] || crc[2]!=payload[length-2] || crc[1]!=payload[length-3] || crc[0]!=payload[length-4]) -+ { ++ if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", + crc[3], payload[length-1], crc[2], payload[length-2], crc[1], payload[length-3], crc[0], payload[length-4])); + } @@ -25995,26 +25009,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + +/* 3 =====TKIP related ===== */ + -+static u32 secmicgetuint32(u8 * p) ++static u32 secmicgetuint32(u8 *p) +/* Convert from Byte[] to Us3232 in a portable way */ +{ + s32 i; + u32 res = 0; + -+ for (i = 0; i<4; i++) -+ { ++ for (i = 0; i < 4; i++) { + res |= ((u32)(*p++)) << (8*i); + } ++ + return res; +} + -+static void secmicputuint32(u8 * p, u32 val) ++static void secmicputuint32(u8 *p, u32 val) +/* Convert from Us3232 to Byte[] in a portable way */ +{ + long i; + -+ for (i = 0; i<4; i++) -+ { ++ for (i = 0; i < 4; i++) { + *p++ = (u8) (val & 0xff); + val >>= 8; + } @@ -26029,7 +25042,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + pmicdata->M = 0; +} + -+void rtw_secmicsetkey(struct mic_data *pmicdata, u8 * key) ++void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key) +{ + /* Set the key */ + pmicdata->K0 = secmicgetuint32(key); @@ -26044,8 +25057,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM); + pmicdata->nBytesInM++; + /* Process the word if it is full. */ -+ if (pmicdata->nBytesInM >= 4) -+ { ++ if (pmicdata->nBytesInM >= 4) { + pmicdata->L ^= pmicdata->M; + pmicdata->R ^= ROL32(pmicdata->L, 17); + pmicdata->L += pmicdata->R; @@ -26061,17 +25073,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + } +} + -+void rtw_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nbytes) ++void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nbytes) +{ + /* This is simple */ -+ while (nbytes > 0) -+ { ++ while (nbytes > 0) { + rtw_secmicappendbyte(pmicdata, *src++); + nbytes--; + } +} + -+void rtw_secgetmic(struct mic_data *pmicdata, u8 * dst) ++void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) +{ + /* Append the minimum padding */ + rtw_secmicappendbyte(pmicdata, 0x5a); @@ -26080,8 +25091,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + rtw_secmicappendbyte(pmicdata, 0); + rtw_secmicappendbyte(pmicdata, 0); + /* and then zeroes until the length is a multiple of 4 */ -+ while (pmicdata->nBytesInM != 0) -+ { ++ while (pmicdata->nBytesInM != 0) { + rtw_secmicappendbyte(pmicdata, 0); + } + /* The appendByte function has already computed the result. */ @@ -26092,14 +25102,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +} + + -+void rtw_seccalctkipmic(u8 * key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri) ++void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri) +{ + + struct mic_data micdata; -+ u8 priority[4]={0x0, 0x0, 0x0, 0x0}; ++ u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; + + rtw_secmicsetkey(&micdata, key); -+ priority[0]=pri; ++ priority[0] = pri; + + /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */ + if (header[1]&1) { /* ToDS == 1 */ @@ -26108,8 +25118,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + rtw_secmicappend(&micdata, &header[24], 6); + else + rtw_secmicappend(&micdata, &header[10], 6); -+ } -+ else { /* ToDS == 0 */ ++ } else { /* ToDS == 0 */ + rtw_secmicappend(&micdata, &header[4], 6); /* DA */ + if (header[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &header[16], 6); @@ -26130,7 +25139,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +#define Lo8(v16) ((u8)((v16) & 0x00FF)) +#define Hi8(v16) ((u8)(((v16) >> 8) & 0x00FF)) +#define Lo16(v32) ((u16)((v32) & 0xFFFF)) -+#define Hi16(v32) ((u16)(((v32) >>16) & 0xFFFF)) ++#define Hi16(v32) ((u16)(((v32) >> 16) & 0xFFFF)) +#define Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8)) + +/* select the Nth 16-bit word of the temporal key unsigned char array TK[] */ @@ -26148,77 +25157,77 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + + +/* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */ -+static const unsigned short Sbox1[2][256]= /* Sbox for hash (can be in ROM) */ -+{ { -+ 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, -+ 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, -+ 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, -+ 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, -+ 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, -+ 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, -+ 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, -+ 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, -+ 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, -+ 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, -+ 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, -+ 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, -+ 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, -+ 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, -+ 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, -+ 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, -+ 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, -+ 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, -+ 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, -+ 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, -+ 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, -+ 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, -+ 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, -+ 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, -+ 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, -+ 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, -+ 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, -+ 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, -+ 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, -+ 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, -+ 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, -+ 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, -+ }, ++static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) */ ++{ ++ 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, ++ 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, ++ 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, ++ 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, ++ 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, ++ 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, ++ 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, ++ 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, ++ 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, ++ 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, ++ 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, ++ 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, ++ 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, ++ 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, ++ 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, ++ 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, ++ 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, ++ 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, ++ 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, ++ 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, ++ 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, ++ 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, ++ 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, ++ 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, ++ 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, ++ 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, ++ 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, ++ 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, ++ 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, ++ 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, ++ 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, ++ 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, ++ }, + + -+ { /* second half of table is unsigned char-reversed version of first! */ -+ 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, -+ 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, -+ 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, -+ 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, -+ 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, -+ 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, -+ 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, -+ 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, -+ 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, -+ 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, -+ 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, -+ 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, -+ 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, -+ 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, -+ 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, -+ 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, -+ 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, -+ 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, -+ 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, -+ 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, -+ 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, -+ 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, -+ 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, -+ 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, -+ 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, -+ 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, -+ 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, -+ 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, -+ 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, -+ 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, -+ 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, -+ 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C, -+ } ++ { /* second half of table is unsigned char-reversed version of first! */ ++ 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, ++ 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, ++ 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, ++ 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, ++ 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, ++ 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, ++ 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, ++ 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, ++ 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, ++ 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, ++ 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, ++ 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, ++ 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, ++ 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, ++ 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, ++ 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, ++ 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, ++ 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, ++ 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, ++ 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, ++ 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, ++ 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, ++ 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, ++ 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, ++ 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, ++ 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, ++ 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, ++ 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, ++ 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, ++ 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, ++ 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, ++ 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C, ++ } +}; + + /* @@ -26251,15 +25260,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + + /* Now compute an unbalanced Feistel cipher with 80-bit block */ + /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ -+ for (i = 0; i < PHASE1_LOOP_CNT ;i++) -+ { /* Each add operation here is mod 2**16 */ ++ for (i = 0; i < PHASE1_LOOP_CNT; i++) { ++ /* Each add operation here is mod 2**16 */ + p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0)); + p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2)); + p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4)); + p1k[3] += _S_(p1k[2] ^ TK16((i&1)+6)); + p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); -+ p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ -+ } ++ p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ ++ } +} + + @@ -26292,8 +25301,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + u16 PPK[6]; /* temporary key for mixing */ + + /* Note: all adds in the PPK[] equations below are mod 2**16 */ -+ for (i = 0;i<5;i++) PPK[i]=p1k[i]; /* first, copy P1K to PPK */ -+ PPK[5] = p1k[4] +iv16; /* next, add in IV16 */ ++ for (i = 0; i < 5; i++) ++ PPK[i] = p1k[i]; /* first, copy P1K to PPK */ ++ ++ PPK[5] = p1k[4]+iv16; /* next, add in IV16 */ + + /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */ + PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */ @@ -26317,14 +25328,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + + /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key */ + rc4key[0] = Hi8(iv16); /* RC4KEY[0..2] is the WEP IV */ -+ rc4key[1] =(Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */ ++ rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */ + rc4key[2] = Lo8(iv16); + rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1); + + + /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ -+ for (i = 0;i<6;i++) -+ { ++ for (i = 0; i < 6; i++) { + rc4key[4+2*i] = Lo8(PPK[i]); + rc4key[5+2*i] = Hi8(PPK[i]); + } @@ -26344,19 +25354,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + sint curfragnum, length; + u32 prwskeylen; + -+ u8 *pframe, *payload,*iv,*prwskey; ++ u8 *pframe, *payload, *iv, *prwskey; + union pn48 dot11txpn; + /* struct sta_info *stainfo; */ + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; -+ struct xmit_priv *pxmitpriv =&padapter->xmitpriv; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; ++ struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u32 res = _SUCCESS; + -+ if (((struct xmit_frame*)pxmitframe)->buf_addr == NULL) ++ if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return _FAIL; + + hw_hdr_offset = TXDESC_OFFSET; -+ pframe = ((struct xmit_frame*)pxmitframe)->buf_addr + hw_hdr_offset; ++ pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + + /* 4 start to encrypt each fragment */ + if (pattrib->encrypt == _TKIP_) { @@ -26384,32 +25394,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo!= NULL!!!\n")); + + if (IS_MCAST(pattrib->ra)) -+ { -+ prwskey =psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; -+ } ++ prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; + else -+ { + /* prwskey =&stainfo->dot118021x_UncstKey.skey[0]; */ -+ prwskey =pattrib->dot118021x_UncstKey.skey; -+ } ++ prwskey = pattrib->dot118021x_UncstKey.skey; + + prwskeylen = 16; + -+ for (curfragnum = 0;curfragnumnr_frags;curfragnum++) { -+ iv =pframe+pattrib->hdrlen; -+ payload =pframe+pattrib->iv_len+pattrib->hdrlen; ++ for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { ++ iv = pframe+pattrib->hdrlen; ++ payload = pframe+pattrib->iv_len+pattrib->hdrlen; + + GET_TKIP_PN(iv, dot11txpn); + -+ pnl =(u16)(dot11txpn.val); -+ pnh =(u32)(dot11txpn.val>>16); ++ pnl = (u16)(dot11txpn.val); ++ pnh = (u32)(dot11txpn.val>>16); + -+ phase1((u16 *)&ttkey[0], prwskey,&pattrib->ta[0], pnh); ++ phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh); + + phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl); + -+ if ((curfragnum+1) ==pattrib->nr_frags) { /* 4 the last fragment */ -+ length =pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len; ++ if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ ++ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + RT_TRACE(_module_rtl871x_security_c_, _drv_info_, ("pattrib->iv_len =%x, pattrib->icv_len =%x\n", pattrib->iv_len, pattrib->icv_len)); + *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + @@ -26417,16 +25423,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + -+ } -+ else { -+ length =pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; ++ } else { ++ length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + -+ pframe+=pxmitpriv->frag_len; -+ pframe =(u8 *)RND4((SIZE_PTR)(pframe)); ++ pframe += pxmitpriv->frag_len; ++ pframe = (u8 *)RND4((SIZE_PTR)(pframe)); + + } + } @@ -26436,7 +25441,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/* + else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo == NULL!!!\n")); -+ DBG_871X("%s, psta ==NUL\n", __func__); ++ DBG_871X("%s, psta ==NUL\n", __func__); + res = _FAIL; + } +*/ @@ -26458,30 +25463,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + sint length; + u32 prwskeylen; + -+ u8 *pframe, *payload,*iv,*prwskey; ++ u8 *pframe, *payload, *iv, *prwskey; + union pn48 dot11txpn; + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; +/* struct recv_priv *precvpriv =&padapter->recvpriv; */ + u32 res = _SUCCESS; + -+ pframe =(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data; ++ pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + + /* 4 start to decrypt recvframe */ + if (prxattrib->encrypt == _TKIP_) { + -+ stainfo =rtw_get_stainfo(&padapter->stapriv ,&prxattrib->ta[0]); -+ if (stainfo!= NULL) { ++ stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); ++ if (stainfo != NULL) { + -+ if (IS_MCAST(prxattrib->ra)) -+ { ++ if (IS_MCAST(prxattrib->ra)) { + static unsigned long start = 0; + static u32 no_gkey_bc_cnt = 0; + static u32 no_gkey_mc_cnt = 0; + -+ if (psecuritypriv->binstallGrpkey ==false) -+ { ++ if (psecuritypriv->binstallGrpkey == false) { + res = _FAIL; + + if (start == 0) @@ -26516,23 +25519,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + /* prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; */ + prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; + prwskeylen = 16; -+ } -+ else -+ { -+ prwskey =&stainfo->dot118021x_UncstKey.skey[0]; ++ } else{ ++ prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + prwskeylen = 16; + } + -+ iv =pframe+prxattrib->hdrlen; -+ payload =pframe+prxattrib->iv_len+prxattrib->hdrlen; ++ iv = pframe+prxattrib->hdrlen; ++ payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + + GET_TKIP_PN(iv, dot11txpn); + -+ pnl =(u16)(dot11txpn.val); -+ pnh =(u32)(dot11txpn.val>>16); ++ pnl = (u16)(dot11txpn.val); ++ pnh = (u32)(dot11txpn.val>>16); + -+ phase1((u16 *)&ttkey[0], prwskey,&prxattrib->ta[0], pnh); ++ phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh); + phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl); + + /* 4 decrypt payload include icv */ @@ -26540,18 +25541,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + -+ *((u32 *)crc) =le32_to_cpu(getcrc32(payload, length-4)); ++ *((u32 *)crc) = le32_to_cpu(getcrc32(payload, length-4)); + -+ if (crc[3]!=payload[length-1] || crc[2]!=payload[length-2] || crc[1]!=payload[length-3] || crc[0]!=payload[length-4]) -+ { ++ if (crc[3] != payload[length-1] || crc[2] != payload[length-2] || crc[1] != payload[length-3] || crc[0] != payload[length-4]) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt:icv error crc[3](%x)!=payload[length-1](%x) || crc[2](%x)!=payload[length-2](%x) || crc[1](%x)!=payload[length-3](%x) || crc[0](%x)!=payload[length-4](%x)\n", + crc[3], payload[length-1], crc[2], payload[length-2], crc[1], payload[length-3], crc[0], payload[length-4])); + res = _FAIL; + } + + TKIP_SW_DEC_CNT_INC(psecuritypriv, prxattrib->ra); -+ } -+ else { ++ } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo == NULL!!!\n")); + res = _FAIL; + } @@ -26572,41 +25571,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/******** SBOX Table *********/ +/*****************************/ + -+ static u8 sbox_table[256] = -+ { -+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, -+ 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, -+ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, -+ 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, -+ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, -+ 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, -+ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, -+ 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, -+ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, -+ 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, -+ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, -+ 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, -+ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, -+ 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, -+ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, -+ 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, -+ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, -+ 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, -+ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, -+ 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, -+ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, -+ 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, -+ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, -+ 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, -+ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, -+ 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, -+ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, -+ 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, -+ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, -+ 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, -+ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, -+ 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 -+ }; ++ static u8 sbox_table[256] = { ++ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, ++ 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, ++ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, ++ 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, ++ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, ++ 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, ++ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, ++ 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, ++ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, ++ 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, ++ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, ++ 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, ++ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, ++ 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, ++ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, ++ 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, ++ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, ++ 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, ++ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, ++ 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, ++ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, ++ 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, ++ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, ++ 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, ++ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, ++ 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, ++ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, ++ 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, ++ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, ++ 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, ++ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, ++ 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 ++ }; + +/*****************************/ +/**** Function Prototypes ****/ @@ -26614,31 +25612,35 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + +static void bitwise_xor(u8 *ina, u8 *inb, u8 *out); +static void construct_mic_iv( -+ u8 *mic_header1, -+ sint qc_exists, -+ sint a4_exists, -+ u8 *mpdu, -+ uint payload_length, -+ u8 * pn_vector, -+ uint frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ ++ u8 *mic_header1, ++ sint qc_exists, ++ sint a4_exists, ++ u8 *mpdu, ++ uint payload_length, ++ u8 *pn_vector, ++ uint frtype ++);/* add for CONFIG_IEEE80211W, none 11w also can use */ +static void construct_mic_header1( -+ u8 *mic_header1, -+ sint header_length, -+ u8 *mpdu, -+ uint frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ ++ u8 *mic_header1, ++ sint header_length, ++ u8 *mpdu, ++ uint frtype ++);/* add for CONFIG_IEEE80211W, none 11w also can use */ +static void construct_mic_header2( -+ u8 *mic_header2, -+ u8 *mpdu, -+ sint a4_exists, -+ sint qc_exists); ++ u8 *mic_header2, ++ u8 *mpdu, ++ sint a4_exists, ++ sint qc_exists ++); +static void construct_ctr_preload( -+ u8 *ctr_preload, -+ sint a4_exists, -+ sint qc_exists, -+ u8 *mpdu, -+ u8 *pn_vector, -+ sint c, -+ uint frtype);/* add for CONFIG_IEEE80211W, none 11w also can use */ ++ u8 *ctr_preload, ++ sint a4_exists, ++ sint qc_exists, ++ u8 *mpdu, ++ u8 *pn_vector, ++ sint c, ++ uint frtype ++);/* add for CONFIG_IEEE80211W, none 11w also can use */ +static void xor_128(u8 *a, u8 *b, u8 *out); +static void xor_32(u8 *a, u8 *b, u8 *out); +static u8 sbox(u8 a); @@ -26656,185 +25658,173 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/****************************************/ +static void xor_128(u8 *a, u8 *b, u8 *out) +{ -+ sint i; ++ sint i; + -+ for (i = 0;i<16; i++) -+ { -+ out[i] = a[i] ^ b[i]; -+ } ++ for (i = 0; i < 16; i++) { ++ out[i] = a[i] ^ b[i]; ++ } +} + + +static void xor_32(u8 *a, u8 *b, u8 *out) +{ -+ sint i; ++ sint i; + -+ for (i = 0;i<4; i++) -+ { -+ out[i] = a[i] ^ b[i]; -+ } ++ for (i = 0; i < 4; i++) { ++ out[i] = a[i] ^ b[i]; ++ } +} + + +static u8 sbox(u8 a) +{ -+ return sbox_table[(sint)a]; ++ return sbox_table[(sint)a]; +} + + +static void next_key(u8 *key, sint round) +{ -+ u8 rcon; -+ u8 sbox_key[4]; -+ u8 rcon_table[12] = -+ { -+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, -+ 0x1b, 0x36, 0x36, 0x36 -+ }; -+ sbox_key[0] = sbox(key[13]); -+ sbox_key[1] = sbox(key[14]); -+ sbox_key[2] = sbox(key[15]); -+ sbox_key[3] = sbox(key[12]); ++ u8 rcon; ++ u8 sbox_key[4]; ++ u8 rcon_table[12] = { ++ 0x01, 0x02, 0x04, 0x08, ++ 0x10, 0x20, 0x40, 0x80, ++ 0x1b, 0x36, 0x36, 0x36 ++ }; ++ sbox_key[0] = sbox(key[13]); ++ sbox_key[1] = sbox(key[14]); ++ sbox_key[2] = sbox(key[15]); ++ sbox_key[3] = sbox(key[12]); + -+ rcon = rcon_table[round]; ++ rcon = rcon_table[round]; + -+ xor_32(&key[0], sbox_key, &key[0]); -+ key[0] = key[0] ^ rcon; ++ xor_32(&key[0], sbox_key, &key[0]); ++ key[0] = key[0] ^ rcon; + -+ xor_32(&key[4], &key[0], &key[4]); -+ xor_32(&key[8], &key[4], &key[8]); -+ xor_32(&key[12], &key[8], &key[12]); ++ xor_32(&key[4], &key[0], &key[4]); ++ xor_32(&key[8], &key[4], &key[8]); ++ xor_32(&key[12], &key[8], &key[12]); +} + + +static void byte_sub(u8 *in, u8 *out) +{ -+ sint i; ++ sint i; + -+ for (i = 0; i< 16; i++) -+ { -+ out[i] = sbox(in[i]); -+ } ++ for (i = 0; i < 16; i++) { ++ out[i] = sbox(in[i]); ++ } +} + + +static void shift_row(u8 *in, u8 *out) +{ -+ out[0] = in[0]; -+ out[1] = in[5]; -+ out[2] = in[10]; -+ out[3] = in[15]; -+ out[4] = in[4]; -+ out[5] = in[9]; -+ out[6] = in[14]; -+ out[7] = in[3]; -+ out[8] = in[8]; -+ out[9] = in[13]; -+ out[10] = in[2]; -+ out[11] = in[7]; -+ out[12] = in[12]; -+ out[13] = in[1]; -+ out[14] = in[6]; -+ out[15] = in[11]; ++ out[0] = in[0]; ++ out[1] = in[5]; ++ out[2] = in[10]; ++ out[3] = in[15]; ++ out[4] = in[4]; ++ out[5] = in[9]; ++ out[6] = in[14]; ++ out[7] = in[3]; ++ out[8] = in[8]; ++ out[9] = in[13]; ++ out[10] = in[2]; ++ out[11] = in[7]; ++ out[12] = in[12]; ++ out[13] = in[1]; ++ out[14] = in[6]; ++ out[15] = in[11]; +} + + +static void mix_column(u8 *in, u8 *out) +{ -+ sint i; -+ u8 add1b[4]; -+ u8 add1bf7[4]; -+ u8 rotl[4]; -+ u8 swap_halfs[4]; -+ u8 andf7[4]; -+ u8 rotr[4]; -+ u8 temp[4]; -+ u8 tempb[4]; ++ sint i; ++ u8 add1b[4]; ++ u8 add1bf7[4]; ++ u8 rotl[4]; ++ u8 swap_halfs[4]; ++ u8 andf7[4]; ++ u8 rotr[4]; ++ u8 temp[4]; ++ u8 tempb[4]; + -+ for (i = 0 ; i<4; i++) -+ { -+ if ((in[i] & 0x80) == 0x80) -+ add1b[i] = 0x1b; -+ else -+ add1b[i] = 0x00; -+ } ++ for (i = 0; i < 4; i++) { ++ if ((in[i] & 0x80) == 0x80) ++ add1b[i] = 0x1b; ++ else ++ add1b[i] = 0x00; ++ } + -+ swap_halfs[0] = in[2]; /* Swap halfs */ -+ swap_halfs[1] = in[3]; -+ swap_halfs[2] = in[0]; -+ swap_halfs[3] = in[1]; ++ swap_halfs[0] = in[2]; /* Swap halfs */ ++ swap_halfs[1] = in[3]; ++ swap_halfs[2] = in[0]; ++ swap_halfs[3] = in[1]; + -+ rotl[0] = in[3]; /* Rotate left 8 bits */ -+ rotl[1] = in[0]; -+ rotl[2] = in[1]; -+ rotl[3] = in[2]; ++ rotl[0] = in[3]; /* Rotate left 8 bits */ ++ rotl[1] = in[0]; ++ rotl[2] = in[1]; ++ rotl[3] = in[2]; + -+ andf7[0] = in[0] & 0x7f; -+ andf7[1] = in[1] & 0x7f; -+ andf7[2] = in[2] & 0x7f; -+ andf7[3] = in[3] & 0x7f; ++ andf7[0] = in[0] & 0x7f; ++ andf7[1] = in[1] & 0x7f; ++ andf7[2] = in[2] & 0x7f; ++ andf7[3] = in[3] & 0x7f; + -+ for (i = 3; i>0; i--) /* logical shift left 1 bit */ -+ { -+ andf7[i] = andf7[i] << 1; -+ if ((andf7[i-1] & 0x80) == 0x80) -+ { -+ andf7[i] = (andf7[i] | 0x01); -+ } -+ } -+ andf7[0] = andf7[0] << 1; -+ andf7[0] = andf7[0] & 0xfe; ++ for (i = 3; i > 0; i--) { /* logical shift left 1 bit */ ++ andf7[i] = andf7[i] << 1; ++ if ((andf7[i-1] & 0x80) == 0x80) ++ andf7[i] = (andf7[i] | 0x01); ++ } ++ andf7[0] = andf7[0] << 1; ++ andf7[0] = andf7[0] & 0xfe; + -+ xor_32(add1b, andf7, add1bf7); ++ xor_32(add1b, andf7, add1bf7); + -+ xor_32(in, add1bf7, rotr); ++ xor_32(in, add1bf7, rotr); + -+ temp[0] = rotr[0]; /* Rotate right 8 bits */ -+ rotr[0] = rotr[1]; -+ rotr[1] = rotr[2]; -+ rotr[2] = rotr[3]; -+ rotr[3] = temp[0]; ++ temp[0] = rotr[0]; /* Rotate right 8 bits */ ++ rotr[0] = rotr[1]; ++ rotr[1] = rotr[2]; ++ rotr[2] = rotr[3]; ++ rotr[3] = temp[0]; + -+ xor_32(add1bf7, rotr, temp); -+ xor_32(swap_halfs, rotl, tempb); -+ xor_32(temp, tempb, out); ++ xor_32(add1bf7, rotr, temp); ++ xor_32(swap_halfs, rotl, tempb); ++ xor_32(temp, tempb, out); +} + +static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) +{ -+ sint round; -+ sint i; -+ u8 intermediatea[16]; -+ u8 intermediateb[16]; -+ u8 round_key[16]; ++ sint round; ++ sint i; ++ u8 intermediatea[16]; ++ u8 intermediateb[16]; ++ u8 round_key[16]; + -+ for (i = 0; i<16; i++) round_key[i] = key[i]; ++ for (i = 0; i < 16; i++) ++ round_key[i] = key[i]; + -+ for (round = 0; round < 11; round++) -+ { -+ if (round == 0) -+ { -+ xor_128(round_key, data, ciphertext); -+ next_key(round_key, round); -+ } -+ else if (round == 10) -+ { -+ byte_sub(ciphertext, intermediatea); -+ shift_row(intermediatea, intermediateb); -+ xor_128(intermediateb, round_key, ciphertext); -+ } -+ else /* 1 - 9 */ -+ { -+ byte_sub(ciphertext, intermediatea); -+ shift_row(intermediatea, intermediateb); -+ mix_column(&intermediateb[0], &intermediatea[0]); -+ mix_column(&intermediateb[4], &intermediatea[4]); -+ mix_column(&intermediateb[8], &intermediatea[8]); -+ mix_column(&intermediateb[12], &intermediatea[12]); -+ xor_128(intermediatea, round_key, ciphertext); -+ next_key(round_key, round); -+ } -+ } ++ for (round = 0; round < 11; round++) { ++ if (round == 0) { ++ xor_128(round_key, data, ciphertext); ++ next_key(round_key, round); ++ } else if (round == 10) { ++ byte_sub(ciphertext, intermediatea); ++ shift_row(intermediatea, intermediateb); ++ xor_128(intermediateb, round_key, ciphertext); ++ } else{ /* 1 - 9 */ ++ byte_sub(ciphertext, intermediatea); ++ shift_row(intermediatea, intermediateb); ++ mix_column(&intermediateb[0], &intermediatea[0]); ++ mix_column(&intermediateb[4], &intermediatea[4]); ++ mix_column(&intermediateb[8], &intermediatea[8]); ++ mix_column(&intermediateb[12], &intermediatea[12]); ++ xor_128(intermediatea, round_key, ciphertext); ++ next_key(round_key, round); ++ } ++ } +} + + @@ -26845,35 +25835,43 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/* nonce */ +/************************************************/ +static void construct_mic_iv( -+ u8 *mic_iv, -+ sint qc_exists, -+ sint a4_exists, -+ u8 *mpdu, -+ uint payload_length, -+ u8 *pn_vector, -+ uint frtype/* add for CONFIG_IEEE80211W, none 11w also can use */ -+ ) ++ u8 *mic_iv, ++ sint qc_exists, ++ sint a4_exists, ++ u8 *mpdu, ++ uint payload_length, ++ u8 *pn_vector, ++ uint frtype/* add for CONFIG_IEEE80211W, none 11w also can use */ ++) +{ -+ sint i; ++ sint i; + -+ mic_iv[0] = 0x59; -+ if (qc_exists && a4_exists) mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */ -+ if (qc_exists && !a4_exists) mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */ -+ if (!qc_exists) mic_iv[1] = 0x00; -+ /* 802.11w management frame should set management bit(4) */ -+ if (frtype == WIFI_MGT_TYPE) -+ mic_iv[1] |= BIT(4); -+ for (i = 2; i < 8; i++) -+ mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ -+ #ifdef CONSISTENT_PN_ORDER -+ for (i = 8; i < 14; i++) -+ mic_iv[i] = pn_vector[i - 8]; /* mic_iv[8:13] = PN[0:5] */ -+ #else -+ for (i = 8; i < 14; i++) -+ mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ -+ #endif -+ mic_iv[14] = (unsigned char) (payload_length / 256); -+ mic_iv[15] = (unsigned char) (payload_length % 256); ++ mic_iv[0] = 0x59; ++ ++ if (qc_exists && a4_exists) ++ mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */ ++ ++ if (qc_exists && !a4_exists) ++ mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */ ++ ++ if (!qc_exists) ++ mic_iv[1] = 0x00; ++ ++ /* 802.11w management frame should set management bit(4) */ ++ if (frtype == WIFI_MGT_TYPE) ++ mic_iv[1] |= BIT(4); ++ ++ for (i = 2; i < 8; i++) ++ mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ ++ #ifdef CONSISTENT_PN_ORDER ++ for (i = 8; i < 14; i++) ++ mic_iv[i] = pn_vector[i - 8]; /* mic_iv[8:13] = PN[0:5] */ ++ #else ++ for (i = 8; i < 14; i++) ++ mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ ++ #endif ++ mic_iv[14] = (unsigned char) (payload_length / 256); ++ mic_iv[15] = (unsigned char) (payload_length % 256); +} + + @@ -26884,34 +25882,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/* Build AAD SC, A1, A2 */ +/************************************************/ +static void construct_mic_header1( -+ u8 *mic_header1, -+ sint header_length, -+ u8 *mpdu, -+ uint frtype/* add for CONFIG_IEEE80211W, none 11w also can use */ -+ ) ++ u8 *mic_header1, ++ sint header_length, ++ u8 *mpdu, ++ uint frtype/* add for CONFIG_IEEE80211W, none 11w also can use */ ++) +{ -+ mic_header1[0] = (u8)((header_length - 2) / 256); -+ mic_header1[1] = (u8)((header_length - 2) % 256); ++ mic_header1[0] = (u8)((header_length - 2) / 256); ++ mic_header1[1] = (u8)((header_length - 2) % 256); + -+ /* 802.11w management frame don't AND subtype bits 4, 5, 6 of frame control field */ -+ if (frtype == WIFI_MGT_TYPE) -+ mic_header1[2] = mpdu[0]; -+ else -+ mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */ ++ /* 802.11w management frame don't AND subtype bits 4, 5, 6 of frame control field */ ++ if (frtype == WIFI_MGT_TYPE) ++ mic_header1[2] = mpdu[0]; ++ else ++ mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */ + -+ mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */ -+ mic_header1[4] = mpdu[4]; /* A1 */ -+ mic_header1[5] = mpdu[5]; -+ mic_header1[6] = mpdu[6]; -+ mic_header1[7] = mpdu[7]; -+ mic_header1[8] = mpdu[8]; -+ mic_header1[9] = mpdu[9]; -+ mic_header1[10] = mpdu[10]; /* A2 */ -+ mic_header1[11] = mpdu[11]; -+ mic_header1[12] = mpdu[12]; -+ mic_header1[13] = mpdu[13]; -+ mic_header1[14] = mpdu[14]; -+ mic_header1[15] = mpdu[15]; ++ mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */ ++ mic_header1[4] = mpdu[4]; /* A1 */ ++ mic_header1[5] = mpdu[5]; ++ mic_header1[6] = mpdu[6]; ++ mic_header1[7] = mpdu[7]; ++ mic_header1[8] = mpdu[8]; ++ mic_header1[9] = mpdu[9]; ++ mic_header1[10] = mpdu[10]; /* A2 */ ++ mic_header1[11] = mpdu[11]; ++ mic_header1[12] = mpdu[12]; ++ mic_header1[13] = mpdu[13]; ++ mic_header1[14] = mpdu[14]; ++ mic_header1[15] = mpdu[15]; +} + + @@ -26921,46 +25919,46 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/* header fields. */ +/************************************************/ +static void construct_mic_header2( -+ u8 *mic_header2, -+ u8 *mpdu, -+ sint a4_exists, -+ sint qc_exists -+ ) ++ u8 *mic_header2, ++ u8 *mpdu, ++ sint a4_exists, ++ sint qc_exists ++) +{ -+ sint i; ++ sint i; + -+ for (i = 0; i<16; i++) mic_header2[i]= 0x00; ++ for (i = 0; i < 16; i++) ++ mic_header2[i] = 0x00; + -+ mic_header2[0] = mpdu[16]; /* A3 */ -+ mic_header2[1] = mpdu[17]; -+ mic_header2[2] = mpdu[18]; -+ mic_header2[3] = mpdu[19]; -+ mic_header2[4] = mpdu[20]; -+ mic_header2[5] = mpdu[21]; ++ mic_header2[0] = mpdu[16]; /* A3 */ ++ mic_header2[1] = mpdu[17]; ++ mic_header2[2] = mpdu[18]; ++ mic_header2[3] = mpdu[19]; ++ mic_header2[4] = mpdu[20]; ++ mic_header2[5] = mpdu[21]; + -+ mic_header2[6] = 0x00; -+ mic_header2[7] = 0x00; /* mpdu[23]; */ ++ mic_header2[6] = 0x00; ++ mic_header2[7] = 0x00; /* mpdu[23]; */ + + -+ if (!qc_exists && a4_exists) -+ { -+ for (i = 0;i<6;i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */ ++ if (!qc_exists && a4_exists) { ++ for (i = 0; i < 6; i++) ++ mic_header2[8+i] = mpdu[24+i]; /* A4 */ + -+ } ++ } + -+ if (qc_exists && !a4_exists) -+ { -+ mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */ -+ mic_header2[9] = mpdu[25] & 0x00; -+ } ++ if (qc_exists && !a4_exists) { ++ mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */ ++ mic_header2[9] = mpdu[25] & 0x00; ++ } + -+ if (qc_exists && a4_exists) -+ { -+ for (i = 0;i<6;i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */ ++ if (qc_exists && a4_exists) { ++ for (i = 0; i < 6; i++) ++ mic_header2[8+i] = mpdu[24+i]; /* A4 */ + -+ mic_header2[14] = mpdu[30] & 0x0f; -+ mic_header2[15] = mpdu[31] & 0x00; -+ } ++ mic_header2[14] = mpdu[30] & 0x0f; ++ mic_header2[15] = mpdu[31] & 0x00; ++ } + +} + @@ -26972,39 +25970,42 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/* nonce */ +/************************************************/ +static void construct_ctr_preload( -+ u8 *ctr_preload, -+ sint a4_exists, -+ sint qc_exists, -+ u8 *mpdu, -+ u8 *pn_vector, -+ sint c, -+ uint frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ -+ ) ++ u8 *ctr_preload, ++ sint a4_exists, ++ sint qc_exists, ++ u8 *mpdu, ++ u8 *pn_vector, ++ sint c, ++ uint frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ ++) +{ -+ sint i = 0; ++ sint i = 0; + -+ for (i = 0; i<16; i++) ctr_preload[i] = 0x00; -+ i = 0; ++ for (i = 0; i < 16; i++) ++ ctr_preload[i] = 0x00; ++ i = 0; + -+ ctr_preload[0] = 0x01; /* flag */ -+ if (qc_exists && a4_exists) ++ ctr_preload[0] = 0x01; /* flag */ ++ if (qc_exists && a4_exists) + ctr_preload[1] = mpdu[30] & 0x0f; /* QoC_Control */ -+ if (qc_exists && !a4_exists) ++ if (qc_exists && !a4_exists) + ctr_preload[1] = mpdu[24] & 0x0f; ++ + /* 802.11w management frame should set management bit(4) */ + if (frtype == WIFI_MGT_TYPE) + ctr_preload[1] |= BIT(4); -+ for (i = 2; i < 8; i++) -+ ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ -+ #ifdef CONSISTENT_PN_ORDER -+ for (i = 8; i < 14; i++) -+ ctr_preload[i] = pn_vector[i - 8]; /* ctr_preload[8:13] = PN[0:5] */ -+ #else -+ for (i = 8; i < 14; i++) -+ ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ -+ #endif -+ ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */ -+ ctr_preload[15] = (unsigned char) (c % 256); ++ ++ for (i = 2; i < 8; i++) ++ ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ ++#ifdef CONSISTENT_PN_ORDER ++ for (i = 8; i < 14; i++) ++ ctr_preload[i] = pn_vector[i - 8]; /* ctr_preload[8:13] = PN[0:5] */ ++#else ++ for (i = 8; i < 14; i++) ++ ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ ++#endif ++ ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */ ++ ctr_preload[15] = (unsigned char) (c % 256); +} + + @@ -27014,12 +26015,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/************************************/ +static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) +{ -+ sint i; ++ sint i; + -+ for (i = 0; i<16; i++) -+ { -+ out[i] = ina[i] ^ inb[i]; -+ } ++ for (i = 0; i < 16; i++) { ++ out[i] = ina[i] ^ inb[i]; ++ } +} + + @@ -27043,7 +26043,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + uint frtype = GetFrameType(pframe); + uint frsubtype = GetFrameSubType(pframe); + -+ frsubtype =frsubtype>>4; ++ frsubtype = frsubtype>>4; + + + memset((void *)mic_iv, 0, 16); @@ -27054,166 +26054,164 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + memset((void *)aes_out, 0, 16); + memset((void *)padded_buffer, 0, 16); + -+ if ((hdrlen == WLAN_HDR_A3_LEN)||(hdrlen == WLAN_HDR_A3_QOS_LEN)) ++ if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) + a4_exists = 0; + else + a4_exists = 1; + + if ( + ((frtype|frsubtype) == WIFI_DATA_CFACK) || -+ ((frtype|frsubtype) == WIFI_DATA_CFPOLL)|| -+ ((frtype|frsubtype) == WIFI_DATA_CFACKPOLL)) -+ { ++ ((frtype|frsubtype) == WIFI_DATA_CFPOLL) || ++ ((frtype|frsubtype) == WIFI_DATA_CFACKPOLL)) { + qc_exists = 1; -+ if (hdrlen != WLAN_HDR_A3_QOS_LEN) { ++ if (hdrlen != WLAN_HDR_A3_QOS_LEN) ++ hdrlen += 2; + -+ hdrlen += 2; -+ } -+ } -+ /* add for CONFIG_IEEE80211W, none 11w also can use */ -+ else if ((frtype == WIFI_DATA) && ++ } else if ((frtype == WIFI_DATA) && /* add for CONFIG_IEEE80211W, none 11w also can use */ + ((frsubtype == 0x08) || -+ (frsubtype == 0x09)|| -+ (frsubtype == 0x0a)|| -+ (frsubtype == 0x0b))) -+ { -+ if (hdrlen != WLAN_HDR_A3_QOS_LEN) { -+ ++ (frsubtype == 0x09) || ++ (frsubtype == 0x0a) || ++ (frsubtype == 0x0b))) { ++ if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; -+ } -+ qc_exists = 1; -+ } -+ else -+ qc_exists = 0; + -+ pn_vector[0]=pframe[hdrlen]; -+ pn_vector[1]=pframe[hdrlen+1]; -+ pn_vector[2]=pframe[hdrlen+4]; -+ pn_vector[3]=pframe[hdrlen+5]; -+ pn_vector[4]=pframe[hdrlen+6]; -+ pn_vector[5]=pframe[hdrlen+7]; ++ qc_exists = 1; ++ } else ++ qc_exists = 0; ++ ++ pn_vector[0] = pframe[hdrlen]; ++ pn_vector[1] = pframe[hdrlen+1]; ++ pn_vector[2] = pframe[hdrlen+4]; ++ pn_vector[3] = pframe[hdrlen+5]; ++ pn_vector[4] = pframe[hdrlen+6]; ++ pn_vector[5] = pframe[hdrlen+7]; + + construct_mic_iv( -+ mic_iv, -+ qc_exists, -+ a4_exists, -+ pframe, /* message, */ -+ plen, -+ pn_vector, -+ frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ -+ ); ++ mic_iv, ++ qc_exists, ++ a4_exists, ++ pframe, /* message, */ ++ plen, ++ pn_vector, ++ frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ ++ ); + -+ construct_mic_header1( -+ mic_header1, -+ hdrlen, -+ pframe, /* message */ -+ frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ -+ ); -+ construct_mic_header2( -+ mic_header2, -+ pframe, /* message, */ -+ a4_exists, -+ qc_exists -+ ); ++ construct_mic_header1( ++ mic_header1, ++ hdrlen, ++ pframe, /* message */ ++ frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ ++ ); ++ construct_mic_header2( ++ mic_header2, ++ pframe, /* message, */ ++ a4_exists, ++ qc_exists ++ ); + + + payload_remainder = plen % 16; -+ num_blocks = plen / 16; ++ num_blocks = plen / 16; + -+ /* Find start of payload */ -+ payload_index = (hdrlen + 8); ++ /* Find start of payload */ ++ payload_index = (hdrlen + 8); + -+ /* Calculate MIC */ -+ aes128k128d(key, mic_iv, aes_out); -+ bitwise_xor(aes_out, mic_header1, chain_buffer); -+ aes128k128d(key, chain_buffer, aes_out); -+ bitwise_xor(aes_out, mic_header2, chain_buffer); -+ aes128k128d(key, chain_buffer, aes_out); ++ /* Calculate MIC */ ++ aes128k128d(key, mic_iv, aes_out); ++ bitwise_xor(aes_out, mic_header1, chain_buffer); ++ aes128k128d(key, chain_buffer, aes_out); ++ bitwise_xor(aes_out, mic_header2, chain_buffer); ++ aes128k128d(key, chain_buffer, aes_out); + -+ for (i = 0; i < num_blocks; i++) -+ { -+ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ ++ for (i = 0; i < num_blocks; i++) { ++ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ + -+ payload_index += 16; -+ aes128k128d(key, chain_buffer, aes_out); -+ } ++ payload_index += 16; ++ aes128k128d(key, chain_buffer, aes_out); ++ } + -+ /* Add on the final payload block if it needs padding */ -+ if (payload_remainder > 0) -+ { -+ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; -+ for (j = 0; j < payload_remainder; j++) -+ { -+ padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */ -+ } -+ bitwise_xor(aes_out, padded_buffer, chain_buffer); -+ aes128k128d(key, chain_buffer, aes_out); ++ /* Add on the final payload block if it needs padding */ ++ if (payload_remainder > 0) { ++ for (j = 0; j < 16; j++) ++ padded_buffer[j] = 0x00; ++ for (j = 0; j < payload_remainder; j++) { ++ padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */ ++ } ++ bitwise_xor(aes_out, padded_buffer, chain_buffer); ++ aes128k128d(key, chain_buffer, aes_out); + -+ } ++ } + -+ for (j = 0 ; j < 8; j++) mic[j] = aes_out[j]; ++ for (j = 0 ; j < 8; j++) ++ mic[j] = aes_out[j]; + -+ /* Insert MIC into payload */ -+ for (j = 0; j < 8; j++) -+ pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ ++ /* Insert MIC into payload */ ++ for (j = 0; j < 8; j++) ++ pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ + -+ payload_index = hdrlen + 8; -+ for (i = 0; i< num_blocks; i++) -+ { -+ construct_ctr_preload( -+ ctr_preload, -+ a4_exists, -+ qc_exists, -+ pframe, /* message, */ -+ pn_vector, -+ i+1, -+ frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ -+ aes128k128d(key, ctr_preload, aes_out); -+ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ -+ for (j = 0; j<16;j++) pframe[payload_index++] = chain_buffer[j];/* for (j = 0; j<16;j++) message[payload_index++] = chain_buffer[j]; */ -+ } ++ payload_index = hdrlen + 8; ++ for (i = 0; i < num_blocks; i++) { ++ construct_ctr_preload( ++ ctr_preload, ++ a4_exists, ++ qc_exists, ++ pframe, /* message, */ ++ pn_vector, ++ i+1, ++ frtype ++ ); /* add for CONFIG_IEEE80211W, none 11w also can use */ ++ aes128k128d(key, ctr_preload, aes_out); ++ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ ++ for (j = 0; j < 16; j++) ++ pframe[payload_index++] = chain_buffer[j];/* for (j = 0; j<16;j++) message[payload_index++] = chain_buffer[j]; */ ++ } + -+ if (payload_remainder > 0) /* If there is a short final block, then pad it,*/ -+ { /* encrypt it and copy the unpadded part back */ -+ construct_ctr_preload( -+ ctr_preload, -+ a4_exists, -+ qc_exists, -+ pframe, /* message, */ -+ pn_vector, -+ num_blocks+1, -+ frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ ++ if (payload_remainder > 0) { ++ /* If there is a short final block, then pad it,*/ ++ /* encrypt it and copy the unpadded part back */ ++ construct_ctr_preload( ++ ctr_preload, ++ a4_exists, ++ qc_exists, ++ pframe, /* message, */ ++ pn_vector, ++ num_blocks+1, ++ frtype ++ ); /* add for CONFIG_IEEE80211W, none 11w also can use */ + -+ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; -+ for (j = 0; j < payload_remainder; j++) -+ { -+ padded_buffer[j] = pframe[payload_index+j];/* padded_buffer[j] = message[payload_index+j]; */ -+ } -+ aes128k128d(key, ctr_preload, aes_out); -+ bitwise_xor(aes_out, padded_buffer, chain_buffer); -+ for (j = 0; jattrib; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; -+ struct xmit_priv *pxmitpriv =&padapter->xmitpriv; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; ++ struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + +/* uint offset = 0; */ + u32 res = _SUCCESS; + -+ if (((struct xmit_frame*)pxmitframe)->buf_addr == NULL) ++ if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return _FAIL; + + hw_hdr_offset = TXDESC_OFFSET; -+ pframe = ((struct xmit_frame*)pxmitframe)->buf_addr + hw_hdr_offset; ++ pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + + /* 4 start to encrypt each fragment */ + if ((pattrib->encrypt == _AES_)) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo!= NULL!!!\n")); + + if (IS_MCAST(pattrib->ra)) -+ { -+ prwskey =psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; -+ } ++ prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; + else -+ { + /* prwskey =&stainfo->dot118021x_UncstKey.skey[0]; */ -+ prwskey =pattrib->dot118021x_UncstKey.skey; -+ } ++ prwskey = pattrib->dot118021x_UncstKey.skey; + + prwskeylen = 16; + -+ for (curfragnum = 0;curfragnumnr_frags;curfragnum++) { ++ for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + -+ if ((curfragnum+1) ==pattrib->nr_frags) { /* 4 the last fragment */ -+ length =pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len- pattrib->icv_len; ++ if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ ++ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + aes_cipher(prwskey, pattrib->hdrlen, pframe, length); -+ } -+ else { -+ length =pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; ++ } else { ++ length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + aes_cipher(prwskey, pattrib->hdrlen, pframe, length); -+ pframe+=pxmitpriv->frag_len; -+ pframe =(u8 *)RND4((SIZE_PTR)(pframe)); ++ pframe += pxmitpriv->frag_len; ++ pframe = (u8 *)RND4((SIZE_PTR)(pframe)); + + } + } @@ -27294,7 +26287,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + u8 mic_header2[16]; + u8 ctr_preload[16]; + -+ /* Intermediate Buffers */ ++ /* Intermediate Buffers */ + u8 chain_buffer[16]; + u8 aes_out[16]; + u8 padded_buffer[16]; @@ -27305,7 +26298,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + uint frtype = GetFrameType(pframe); + uint frsubtype = GetFrameSubType(pframe); + -+ frsubtype =frsubtype>>4; ++ frsubtype = frsubtype>>4; + + + memset((void *)mic_iv, 0, 16); @@ -27329,221 +26322,223 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + pn_vector[4] = pframe[hdrlen+6]; + pn_vector[5] = pframe[hdrlen+7]; + -+ if ((hdrlen == WLAN_HDR_A3_LEN)||(hdrlen == WLAN_HDR_A3_QOS_LEN)) ++ if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) + a4_exists = 0; + else + a4_exists = 1; + + if ( + ((frtype|frsubtype) == WIFI_DATA_CFACK) || -+ ((frtype|frsubtype) == WIFI_DATA_CFPOLL)|| -+ ((frtype|frsubtype) == WIFI_DATA_CFACKPOLL)) -+ { ++ ((frtype|frsubtype) == WIFI_DATA_CFPOLL) || ++ ((frtype|frsubtype) == WIFI_DATA_CFACKPOLL)) { + qc_exists = 1; + if (hdrlen != WLAN_HDR_A3_QOS_LEN) { + + hdrlen += 2; + } -+ }/* only for data packet . add for CONFIG_IEEE80211W, none 11w also can use */ -+ else if ((frtype == WIFI_DATA) && ++ } else if ((frtype == WIFI_DATA) && /* only for data packet . add for CONFIG_IEEE80211W, none 11w also can use */ + ((frsubtype == 0x08) || -+ (frsubtype == 0x09)|| -+ (frsubtype == 0x0a)|| -+ (frsubtype == 0x0b))) -+ { ++ (frsubtype == 0x09) || ++ (frsubtype == 0x0a) || ++ (frsubtype == 0x0b))) { + if (hdrlen != WLAN_HDR_A3_QOS_LEN) { + + hdrlen += 2; + } + qc_exists = 1; -+ } -+ else -+ qc_exists = 0; ++ } else ++ qc_exists = 0; + + + /* now, decrypt pframe with hdrlen offset and plen long */ + + payload_index = hdrlen + 8; /* 8 is for extiv */ + -+ for (i = 0; i< num_blocks; i++) -+ { -+ construct_ctr_preload( -+ ctr_preload, -+ a4_exists, -+ qc_exists, -+ pframe, -+ pn_vector, -+ i+1, -+ frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ -+ ); ++ for (i = 0; i < num_blocks; i++) { ++ construct_ctr_preload( ++ ctr_preload, ++ a4_exists, ++ qc_exists, ++ pframe, ++ pn_vector, ++ i+1, ++ frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ ++ ); + -+ aes128k128d(key, ctr_preload, aes_out); -+ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); ++ aes128k128d(key, ctr_preload, aes_out); ++ bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); + -+ for (j = 0; j<16;j++) pframe[payload_index++] = chain_buffer[j]; -+ } ++ for (j = 0; j < 16; j++) ++ pframe[payload_index++] = chain_buffer[j]; ++ } + -+ if (payload_remainder > 0) /* If there is a short final block, then pad it,*/ -+ { /* encrypt it and copy the unpadded part back */ -+ construct_ctr_preload( -+ ctr_preload, -+ a4_exists, -+ qc_exists, -+ pframe, -+ pn_vector, -+ num_blocks+1, -+ frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ -+ ); ++ if (payload_remainder > 0) { ++ /* If there is a short final block, then pad it,*/ ++ /* encrypt it and copy the unpadded part back */ ++ construct_ctr_preload( ++ ctr_preload, ++ a4_exists, ++ qc_exists, ++ pframe, ++ pn_vector, ++ num_blocks+1, ++ frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ ++ ); + -+ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; -+ for (j = 0; j < payload_remainder; j++) -+ { -+ padded_buffer[j] = pframe[payload_index+j]; -+ } -+ aes128k128d(key, ctr_preload, aes_out); -+ bitwise_xor(aes_out, padded_buffer, chain_buffer); -+ for (j = 0; j 0) -+ { -+ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; -+ for (j = 0; j < payload_remainder; j++) -+ { -+ padded_buffer[j] = message[payload_index++]; -+ } -+ bitwise_xor(aes_out, padded_buffer, chain_buffer); -+ aes128k128d(key, chain_buffer, aes_out); ++ /* Add on the final payload block if it needs padding */ ++ if (payload_remainder > 0) { ++ for (j = 0; j < 16; j++) ++ padded_buffer[j] = 0x00; ++ for (j = 0; j < payload_remainder; j++) { ++ padded_buffer[j] = message[payload_index++]; ++ } ++ bitwise_xor(aes_out, padded_buffer, chain_buffer); ++ aes128k128d(key, chain_buffer, aes_out); + -+ } ++ } + -+ for (j = 0 ; j < 8; j++) mic[j] = aes_out[j]; ++ for (j = 0; j < 8; j++) ++ mic[j] = aes_out[j]; + -+ /* Insert MIC into payload */ -+ for (j = 0; j < 8; j++) ++ /* Insert MIC into payload */ ++ for (j = 0; j < 8; j++) + message[payload_index+j] = mic[j]; + + payload_index = hdrlen + 8; -+ for (i = 0; i< num_blocks; i++) -+ { -+ construct_ctr_preload( -+ ctr_preload, -+ a4_exists, -+ qc_exists, -+ message, -+ pn_vector, -+ i+1, -+ frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ -+ aes128k128d(key, ctr_preload, aes_out); -+ bitwise_xor(aes_out, &message[payload_index], chain_buffer); -+ for (j = 0; j<16;j++) message[payload_index++] = chain_buffer[j]; -+ } ++ for (i = 0; i < num_blocks; i++) { ++ construct_ctr_preload( ++ ctr_preload, ++ a4_exists, ++ qc_exists, ++ message, ++ pn_vector, ++ i+1, ++ frtype ++ ); /* add for CONFIG_IEEE80211W, none 11w also can use */ ++ aes128k128d(key, ctr_preload, aes_out); ++ bitwise_xor(aes_out, &message[payload_index], chain_buffer); ++ for (j = 0; j < 16; j++) ++ message[payload_index++] = chain_buffer[j]; ++ } + -+ if (payload_remainder > 0) /* If there is a short final block, then pad it,*/ -+ { /* encrypt it and copy the unpadded part back */ -+ construct_ctr_preload( -+ ctr_preload, -+ a4_exists, -+ qc_exists, -+ message, -+ pn_vector, -+ num_blocks+1, -+ frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ ++ if (payload_remainder > 0) { ++ /* If there is a short final block, then pad it,*/ ++ /* encrypt it and copy the unpadded part back */ ++ construct_ctr_preload( ++ ctr_preload, ++ a4_exists, ++ qc_exists, ++ message, ++ pn_vector, ++ num_blocks+1, ++ frtype ++ ); /* add for CONFIG_IEEE80211W, none 11w also can use */ + -+ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; -+ for (j = 0; j < payload_remainder; j++) -+ { -+ padded_buffer[j] = message[payload_index+j]; -+ } -+ aes128k128d(key, ctr_preload, aes_out); -+ bitwise_xor(aes_out, padded_buffer, chain_buffer); -+ for (j = 0; ju.hdr.attrib; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; +/* struct recv_priv *precvpriv =&padapter->recvpriv; */ + u32 res = _SUCCESS; + -+ pframe =(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data; ++ pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + /* 4 start to encrypt each fragment */ + if ((prxattrib->encrypt == _AES_)) { + -+ stainfo =rtw_get_stainfo(&padapter->stapriv ,&prxattrib->ta[0]); -+ if (stainfo!= NULL) { ++ stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); ++ if (stainfo != NULL) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); + -+ if (IS_MCAST(prxattrib->ra)) -+ { ++ if (IS_MCAST(prxattrib->ra)) { + static unsigned long start = 0; + static u32 no_gkey_bc_cnt = 0; + static u32 no_gkey_mc_cnt = 0; + + /* DBG_871X("rx bc/mc packets, to perform sw rtw_aes_decrypt\n"); */ + /* prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; */ -+ if (psecuritypriv->binstallGrpkey ==false) -+ { ++ if (psecuritypriv->binstallGrpkey == false) { + res = _FAIL; + + if (start == 0) @@ -27623,18 +26616,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + no_gkey_mc_cnt = 0; + + prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; -+ if (psecuritypriv->dot118021XGrpKeyid != prxattrib->key_index) -+ { ++ if (psecuritypriv->dot118021XGrpKeyid != prxattrib->key_index) { + DBG_871X("not match packet_index =%d, install_index =%d\n" + , prxattrib->key_index, psecuritypriv->dot118021XGrpKeyid); + res = _FAIL; + goto exit; + } -+ } -+ else -+ { -+ prwskey =&stainfo->dot118021x_UncstKey.skey[0]; -+ } ++ } else ++ prwskey = &stainfo->dot118021x_UncstKey.skey[0]; ++ + + length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + @@ -27666,13 +26656,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + ori_len = pattrib->pkt_len-WLAN_HDR_A3_LEN+BIP_AAD_SIZE; + BIP_AAD = rtw_zmalloc(ori_len); + -+ if (BIP_AAD == NULL) -+ { ++ if (BIP_AAD == NULL) { + DBG_871X("BIP AAD allocate fail\n"); + return _FAIL; + } + /* PKT start */ -+ pframe =(unsigned char *)((union recv_frame*)precvframe)->u.hdr.rx_data; ++ pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + /* mapping to wlan header */ + pwlanhdr = (struct ieee80211_hdr *)pframe; + /* save the frame body + MME */ @@ -27680,24 +26669,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + /* find MME IE pointer */ + p = rtw_get_ie(BIP_AAD+BIP_AAD_SIZE, _MME_IE_, &len, pattrib->pkt_len-WLAN_HDR_A3_LEN); + /* Baron */ -+ if (p) -+ { ++ if (p) { + u16 keyid = 0; + u64 temp_ipn = 0; + /* save packet number */ + memcpy(&le_tmp64, p+4, 6); + temp_ipn = le64_to_cpu(le_tmp64); + /* BIP packet number should bigger than previous BIP packet */ -+ if (temp_ipn <= pmlmeext->mgnt_80211w_IPN_rx) -+ { ++ if (temp_ipn <= pmlmeext->mgnt_80211w_IPN_rx) { + DBG_871X("replay BIP packet\n"); + goto BIP_exit; + } + /* copy key index */ + memcpy(&le_tmp, p+2, 2); + keyid = le16_to_cpu(le_tmp); -+ if (keyid != padapter->securitypriv.dot11wBIPKeyid) -+ { ++ if (keyid != padapter->securitypriv.dot11wBIPKeyid) { + DBG_871X("BIP key index error!\n"); + goto BIP_exit; + } @@ -27717,16 +26703,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + goto BIP_exit; + + /* MIC field should be last 8 bytes of packet (packet without FCS) */ -+ if (!memcmp(mic, pframe+pattrib->pkt_len-8, 8)) -+ { ++ if (!memcmp(mic, pframe+pattrib->pkt_len-8, 8)) { + pmlmeext->mgnt_80211w_IPN_rx = temp_ipn; + res = _SUCCESS; -+ } -+ else ++ } else + DBG_871X("BIP MIC error!\n"); + -+ } -+ else ++ } else + res = RTW_RX_HANDLED; +BIP_exit: + @@ -27736,170 +26719,170 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + +/* AES tables*/ +const u32 Te0[256] = { -+ 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, -+ 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, -+ 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, -+ 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, -+ 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, -+ 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, -+ 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, -+ 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, -+ 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, -+ 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, -+ 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, -+ 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, -+ 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, -+ 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, -+ 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, -+ 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, -+ 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, -+ 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, -+ 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, -+ 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, -+ 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, -+ 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, -+ 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, -+ 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, -+ 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, -+ 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, -+ 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, -+ 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, -+ 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, -+ 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, -+ 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, -+ 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, -+ 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, -+ 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, -+ 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, -+ 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, -+ 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, -+ 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, -+ 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, -+ 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, -+ 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, -+ 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, -+ 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, -+ 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, -+ 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, -+ 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, -+ 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, -+ 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, -+ 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, -+ 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, -+ 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, -+ 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, -+ 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, -+ 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, -+ 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, -+ 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, -+ 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, -+ 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, -+ 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, -+ 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, -+ 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, -+ 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, -+ 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, -+ 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, ++ 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, ++ 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, ++ 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, ++ 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, ++ 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, ++ 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, ++ 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, ++ 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, ++ 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, ++ 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, ++ 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, ++ 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, ++ 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, ++ 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, ++ 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, ++ 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, ++ 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, ++ 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, ++ 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, ++ 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, ++ 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, ++ 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, ++ 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, ++ 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, ++ 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, ++ 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, ++ 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, ++ 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, ++ 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, ++ 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, ++ 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, ++ 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, ++ 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, ++ 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, ++ 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, ++ 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, ++ 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, ++ 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, ++ 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, ++ 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, ++ 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, ++ 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, ++ 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, ++ 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, ++ 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, ++ 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, ++ 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, ++ 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, ++ 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, ++ 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, ++ 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, ++ 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, ++ 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, ++ 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, ++ 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, ++ 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, ++ 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, ++ 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, ++ 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, ++ 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, ++ 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, ++ 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, ++ 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, ++ 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, +}; +const u32 Td0[256] = { -+ 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, -+ 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, -+ 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, -+ 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, -+ 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, -+ 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, -+ 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, -+ 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, -+ 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, -+ 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, -+ 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, -+ 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, -+ 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, -+ 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, -+ 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, -+ 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, -+ 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, -+ 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, -+ 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, -+ 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, -+ 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, -+ 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, -+ 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, -+ 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, -+ 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, -+ 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, -+ 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, -+ 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, -+ 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, -+ 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, -+ 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, -+ 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, -+ 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, -+ 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, -+ 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, -+ 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, -+ 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, -+ 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, -+ 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, -+ 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, -+ 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, -+ 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, -+ 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, -+ 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, -+ 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, -+ 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, -+ 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, -+ 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, -+ 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, -+ 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, -+ 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, -+ 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, -+ 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, -+ 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, -+ 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, -+ 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, -+ 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, -+ 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, -+ 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, -+ 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, -+ 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, -+ 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, -+ 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, -+ 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, ++ 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, ++ 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, ++ 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, ++ 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, ++ 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, ++ 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, ++ 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, ++ 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, ++ 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, ++ 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, ++ 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, ++ 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, ++ 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, ++ 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, ++ 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, ++ 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, ++ 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, ++ 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, ++ 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, ++ 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, ++ 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, ++ 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, ++ 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, ++ 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, ++ 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, ++ 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, ++ 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, ++ 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, ++ 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, ++ 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, ++ 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, ++ 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, ++ 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, ++ 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, ++ 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, ++ 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, ++ 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, ++ 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, ++ 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, ++ 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, ++ 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, ++ 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, ++ 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, ++ 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, ++ 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, ++ 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, ++ 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, ++ 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, ++ 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, ++ 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, ++ 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, ++ 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, ++ 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, ++ 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, ++ 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, ++ 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, ++ 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, ++ 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, ++ 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, ++ 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, ++ 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, ++ 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, ++ 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, ++ 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, +}; +const u8 Td4s[256] = { -+ 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U, -+ 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU, -+ 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U, -+ 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU, -+ 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU, -+ 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU, -+ 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U, -+ 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U, -+ 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U, -+ 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U, -+ 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU, -+ 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U, -+ 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU, -+ 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U, -+ 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U, -+ 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU, -+ 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU, -+ 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U, -+ 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U, -+ 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU, -+ 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U, -+ 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU, -+ 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U, -+ 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U, -+ 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U, -+ 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU, -+ 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU, -+ 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU, -+ 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U, -+ 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U, -+ 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U, -+ 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU, ++ 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U, ++ 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU, ++ 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U, ++ 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU, ++ 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU, ++ 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU, ++ 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U, ++ 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U, ++ 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U, ++ 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U, ++ 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU, ++ 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U, ++ 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU, ++ 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U, ++ 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U, ++ 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU, ++ 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU, ++ 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U, ++ 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U, ++ 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU, ++ 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U, ++ 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU, ++ 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U, ++ 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U, ++ 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U, ++ 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU, ++ 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU, ++ 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU, ++ 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U, ++ 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U, ++ 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U, ++ 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU, +}; +const u8 rcons[] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 @@ -27916,7 +26899,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + int i; + u32 temp; + -+ rk[0] = GETU32(cipherKey ); ++ rk[0] = GETU32(cipherKey); + rk[1] = GETU32(cipherKey + 4); + rk[2] = GETU32(cipherKey + 8); + rk[3] = GETU32(cipherKey + 12); @@ -27942,7 +26925,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + * map byte array block to cipher state + * and add initial round key: + */ -+ s0 = GETU32(pt ) ^ rk[0]; ++ s0 = GETU32(pt) ^ rk[0]; + s1 = GETU32(pt + 4) ^ rk[1]; + s2 = GETU32(pt + 8) ^ rk[2]; + s3 = GETU32(pt + 12) ^ rk[3]; @@ -27970,7 +26953,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + * map cipher state to byte array block: + */ + s0 = TE41(t0) ^ TE42(t1) ^ TE43(t2) ^ TE44(t3) ^ rk[0]; -+ PUTU32(ct , s0); ++ PUTU32(ct, s0); + s1 = TE41(t1) ^ TE42(t2) ^ TE43(t3) ^ TE44(t0) ^ rk[1]; + PUTU32(ct + 4, s1); + s2 = TE41(t2) ^ TE42(t3) ^ TE43(t0) ^ TE44(t1) ^ rk[2]; @@ -27984,7 +26967,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + u32 *rk; + if (len != 16) + return NULL; -+ rk = (u32*)rtw_malloc(AES_PRIV_SIZE); ++ rk = (u32 *)rtw_malloc(AES_PRIV_SIZE); + if (rk == NULL) + return NULL; + rijndaelKeySetupEnc(rk, key); @@ -28004,6 +26987,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + carry = pad[0] & 0x80; + for (i = 0; i < AES_BLOCK_SIZE - 1; i++) + pad[i] = (pad[i] << 1) | (pad[i + 1] >> 7); ++ + pad[AES_BLOCK_SIZE - 1] <<= 1; + if (carry) + pad[AES_BLOCK_SIZE - 1] ^= 0x87; @@ -28110,11 +27094,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ +/* Restore HW wep key setting according to key_mask */ +void rtw_sec_restore_wep_key(struct adapter *adapter) +{ -+ struct security_priv* securitypriv =&(adapter->securitypriv); ++ struct security_priv *securitypriv = &(adapter->securitypriv); + sint keyid; + -+ if ((_WEP40_ == securitypriv->dot11PrivacyAlgrthm) ||(_WEP104_ == securitypriv->dot11PrivacyAlgrthm)) { -+ for (keyid = 0;keyid<4;keyid++) { ++ if ((_WEP40_ == securitypriv->dot11PrivacyAlgrthm) || (_WEP104_ == securitypriv->dot11PrivacyAlgrthm)) { ++ for (keyid = 0; keyid < 4; keyid++) { + if (securitypriv->key_mask & BIT(keyid)) { + if (keyid == securitypriv->dot11PrivacyKeyIndex) + rtw_set_key(adapter, securitypriv, keyid, 1, false); @@ -28125,9 +27109,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + } +} + -+u8 rtw_handle_tkip_countermeasure(struct adapter * adapter, const char *caller) ++u8 rtw_handle_tkip_countermeasure(struct adapter *adapter, const char *caller) +{ -+ struct security_priv* securitypriv =&(adapter->securitypriv); ++ struct security_priv *securitypriv = &(adapter->securitypriv); + u8 status = _SUCCESS; + + if (securitypriv->btkip_countermeasure == true) { @@ -28146,10 +27130,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_security.c linux-4.3-rtl8723bs/ + + return status; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_sta_mgt.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_sta_mgt.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,646 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux/3rdparty/rtl8723bs/core/rtw_sta_mgt.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_sta_mgt.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_sta_mgt.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,641 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -28172,7 +27156,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 +void _rtw_init_stainfo(struct sta_info *psta); +void _rtw_init_stainfo(struct sta_info *psta) +{ -+ memset((u8 *)psta, 0, sizeof (struct sta_info)); ++ memset((u8 *)psta, 0, sizeof(struct sta_info)); + + spin_lock_init(&psta->lock); + INIT_LIST_HEAD(&psta->list); @@ -28216,7 +27200,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + struct sta_info *psta; + s32 i; + -+ pstapriv->pallocated_stainfo_buf = vzalloc (sizeof(struct sta_info) * NUM_STA+ 4); ++ pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA+4); + + if (!pstapriv->pallocated_stainfo_buf) + return _FAIL; @@ -28236,8 +27220,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + psta = (struct sta_info *)(pstapriv->pstainfo_buf); + + -+ for (i = 0; i < NUM_STA; i++) -+ { ++ for (i = 0; i < NUM_STA; i++) { + _rtw_init_stainfo(psta); + + INIT_LIST_HEAD(&(pstapriv->sta_hash[i])); @@ -28294,9 +27277,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + phead = get_list_head(&pstapriv->free_sta_queue); + plist = get_next(phead); + -+ while (phead != plist) -+ { -+ psta = LIST_CONTAINOR(plist, struct sta_info , list); ++ while (phead != plist) { ++ psta = LIST_CONTAINOR(plist, struct sta_info, list); + plist = get_next(plist); + } + @@ -28320,19 +27302,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + + /*delete all reordering_ctrl_timer */ + spin_lock_bh(&pstapriv->sta_hash_lock); -+ for (index = 0; index < NUM_STA; index++) -+ { ++ for (index = 0; index < NUM_STA; index++) { + phead = &(pstapriv->sta_hash[index]); + plist = get_next(phead); + -+ while (phead != plist) -+ { ++ while (phead != plist) { + int i; -+ psta = LIST_CONTAINOR(plist, struct sta_info , hash_list); ++ psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + plist = get_next(plist); + -+ for (i = 0; i < 16 ; i++) -+ { ++ for (i = 0; i < 16 ; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); + } @@ -28343,9 +27322,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + + kfree_sta_priv_lock(pstapriv); + -+ if (pstapriv->pallocated_stainfo_buf) { ++ if (pstapriv->pallocated_stainfo_buf) + vfree(pstapriv->pallocated_stainfo_buf); -+ } ++ + } + return _SUCCESS; +} @@ -28366,15 +27345,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + + /* spin_lock_bh(&(pfree_sta_queue->lock)); */ + spin_lock_bh(&(pstapriv->sta_hash_lock)); -+ if (list_empty(&pfree_sta_queue->queue)) -+ { ++ if (list_empty(&pfree_sta_queue->queue)) { + /* spin_unlock_bh(&(pfree_sta_queue->lock)); */ + spin_unlock_bh(&(pstapriv->sta_hash_lock)); + psta = NULL; + return psta; -+ } -+ else -+ { ++ } else{ + psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct sta_info, list); + + list_del_init(&(psta->list)); @@ -28405,7 +27381,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + + list_add_tail(&psta->hash_list, phash_list); + -+ pstapriv->asoc_sta_count ++ ; ++ pstapriv->asoc_sta_count++; + + /* spin_unlock_bh(&(pstapriv->sta_hash_lock)); */ + @@ -28414,19 +27390,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 +/* In this case, this packet will be dropped by recv_decache function if we use the 0x00 as the default value for tid_rxseq variable. */ +/* So, we initialize the tid_rxseq variable as the 0xffff. */ + -+ for (i = 0; i < 16; i++) -+ { -+ memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[ i ], &wRxSeqInitialValue, 2); ++ for (i = 0; i < 16; i++) { ++ memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); + } + -+ RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("alloc number_%d stainfo with hwaddr = %x %x %x %x %x %x \n", -+ pstapriv->asoc_sta_count , hwaddr[0], hwaddr[1], hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5])); ++ RT_TRACE( ++ _module_rtl871x_sta_mgt_c_, ++ _drv_info_, ( ++ "alloc number_%d stainfo with hwaddr = %x %x %x %x %x %x \n", ++ pstapriv->asoc_sta_count, ++ hwaddr[0], ++ hwaddr[1], ++ hwaddr[2], ++ hwaddr[3], ++ hwaddr[4], ++ hwaddr[5] ++ ) ++ ); + + init_addba_retry_timer(pstapriv->padapter, psta); + + /* for A-MPDU Rx reordering buffer control */ -+ for (i = 0; i < 16 ; i++) -+ { ++ for (i = 0; i < 16 ; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + + preorder_ctrl->padapter = pstapriv->padapter; @@ -28467,7 +27452,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 +} + +/* using pstapriv->sta_hash_lock to protect */ -+u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) ++u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) +{ + int i; + struct __queue *pfree_sta_queue; @@ -28538,8 +27523,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + spin_unlock_bh(&pxmitpriv->lock); + + list_del_init(&psta->hash_list); -+ RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x \n", pstapriv->asoc_sta_count , psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5])); -+ pstapriv->asoc_sta_count --; ++ RT_TRACE( ++ _module_rtl871x_sta_mgt_c_, ++ _drv_err_, ( ++ "\n free number_%d stainfo with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x \n", ++ pstapriv->asoc_sta_count, ++ psta->hwaddr[0], ++ psta->hwaddr[1], ++ psta->hwaddr[2], ++ psta->hwaddr[3], ++ psta->hwaddr[4], ++ psta->hwaddr[5] ++ ) ++ ); ++ pstapriv->asoc_sta_count--; + + + /* re-init sta_info; 20061114 will be init in alloc_stainfo */ @@ -28549,8 +27546,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + del_timer_sync(&psta->addba_retry_timer); + + /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */ -+ for (i = 0; i < 16 ; i++) -+ { ++ for (i = 0; i < 16 ; i++) { + struct list_head *phead, *plist; + union recv_frame *prframe; + struct __queue *ppending_recvframe_queue; @@ -28568,8 +27564,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + phead = get_list_head(ppending_recvframe_queue); + plist = get_next(phead); + -+ while (!list_empty(phead)) -+ { ++ while (!list_empty(phead)) { + prframe = LIST_CONTAINOR(plist, union recv_frame, u); + + plist = get_next(plist); @@ -28614,11 +27609,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + + psta->has_legacy_ac = 0; + -+ pstapriv->sta_dz_bitmap &=~BIT(psta->aid); -+ pstapriv->tim_bitmap &=~BIT(psta->aid); ++ pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); ++ pstapriv->tim_bitmap &= ~BIT(psta->aid); + -+ if ((psta->aid >0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) -+ { ++ if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) { + pstapriv->sta_aid[psta->aid - 1] = NULL; + psta->aid = 0; + } @@ -28640,26 +27634,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + s32 index; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; -+ struct sta_info* pbcmc_stainfo =rtw_get_bcmc_stainfo(padapter); ++ struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter); + + if (pstapriv->asoc_sta_count == 1) + return; + + spin_lock_bh(&pstapriv->sta_hash_lock); + -+ for (index = 0; index< NUM_STA; index++) -+ { ++ for (index = 0; index < NUM_STA; index++) { + phead = &(pstapriv->sta_hash[index]); + plist = get_next(phead); + -+ while (phead != plist) -+ { -+ psta = LIST_CONTAINOR(plist, struct sta_info , hash_list); ++ while (phead != plist) { ++ psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + + plist = get_next(plist); + -+ if (pbcmc_stainfo!=psta) -+ rtw_free_stainfo(padapter , psta); ++ if (pbcmc_stainfo != psta) ++ rtw_free_stainfo(padapter, psta); + + } + } @@ -28680,13 +27672,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + return NULL; + + if (IS_MCAST(hwaddr)) -+ { + addr = bc_addr; -+ } + else -+ { + addr = hwaddr; -+ } + + index = wifi_mac_hash(addr); + @@ -28696,15 +27684,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + plist = get_next(phead); + + -+ while (phead != plist) -+ { ++ while (phead != plist) { + + psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + + if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) -+ { /* if found the matched address */ ++ /* if found the matched address */ + break; -+ } ++ + psta = NULL; + plist = get_next(plist); + } @@ -28716,7 +27703,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 +u32 rtw_init_bcmc_stainfo(struct adapter *padapter) +{ + -+ struct sta_info *psta; ++ struct sta_info *psta; + struct tx_servq *ptxservq; + u32 res = _SUCCESS; + NDIS_802_11_MAC_ADDRESS bcast_addr = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -28741,10 +27728,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 +} + + -+struct sta_info* rtw_get_bcmc_stainfo(struct adapter *padapter) ++struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) +{ -+ struct sta_info *psta; -+ struct sta_priv *pstapriv = &padapter->stapriv; ++ struct sta_info *psta; ++ struct sta_priv *pstapriv = &padapter->stapriv; + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + psta = rtw_get_stainfo(pstapriv, bc_addr); @@ -28759,47 +27746,39 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_sta_mgt.c linux-4.3-rtl8723bs/3 + u8 match = false; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; -+ struct __queue *pacl_node_q =&pacl_list->acl_node_q; ++ struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + spin_lock_bh(&(pacl_node_q->lock)); + phead = get_list_head(pacl_node_q); + plist = get_next(phead); -+ while (phead != plist) -+ { ++ while (phead != plist) { + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + + if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) -+ { -+ if (paclnode->valid == true) -+ { ++ if (paclnode->valid == true) { + match = true; + break; + } -+ } ++ + } + spin_unlock_bh(&(pacl_node_q->lock)); + + -+ if (pacl_list->mode == 1)/* accept unless in deny list */ -+ { ++ if (pacl_list->mode == 1) /* accept unless in deny list */ + res = (match == true) ? false:true; -+ } ++ + else if (pacl_list->mode == 2)/* deny unless in accept list */ -+ { + res = (match == true) ? true:false; -+ } + else -+ { + res = true; -+ } + + return res; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_wlan_util.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_wlan_util.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,2542 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux/3rdparty/rtl8723bs/core/rtw_wlan_util.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_wlan_util.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_wlan_util.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,2328 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -28865,8 +27844,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +{ + int i; + -+ for (i = 0; i < ratelen; i++) -+ { ++ for (i = 0; i < ratelen; i++) { + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + return true; @@ -28880,8 +27858,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +{ + int i; + -+ for (i = 0; i < ratelen; i++) -+ { ++ for (i = 0; i < ratelen; i++) { + if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && + (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + return false; @@ -28898,54 +27875,51 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + if (cur_rf_type == RF_1T1R) { + rf_type = RF_1T1R; -+ } -+ else if (IsSupportedVHT(psta->wireless_mode)) { ++ } else if (IsSupportedVHT(psta->wireless_mode)) { + if (psta->ra_mask & 0xffc00000) + rf_type = RF_2T2R; -+ } -+ else if (IsSupportedHT(psta->wireless_mode)) { ++ } else if (IsSupportedHT(psta->wireless_mode)) { + if (psta->ra_mask & 0xfff00000) + rf_type = RF_2T2R; + } + -+ switch (psta->wireless_mode) -+ { -+ case WIRELESS_11B: -+ raid = RATEID_IDX_B; -+ break; -+ case WIRELESS_11A: -+ case WIRELESS_11G: -+ raid = RATEID_IDX_G; -+ break; -+ case WIRELESS_11BG: -+ raid = RATEID_IDX_BG; -+ break; -+ case WIRELESS_11_24N: -+ case WIRELESS_11_5N: -+ case WIRELESS_11A_5N: -+ case WIRELESS_11G_24N: ++ switch (psta->wireless_mode) { ++ case WIRELESS_11B: ++ raid = RATEID_IDX_B; ++ break; ++ case WIRELESS_11A: ++ case WIRELESS_11G: ++ raid = RATEID_IDX_G; ++ break; ++ case WIRELESS_11BG: ++ raid = RATEID_IDX_BG; ++ break; ++ case WIRELESS_11_24N: ++ case WIRELESS_11_5N: ++ case WIRELESS_11A_5N: ++ case WIRELESS_11G_24N: ++ if (rf_type == RF_2T2R) ++ raid = RATEID_IDX_GN_N2SS; ++ else ++ raid = RATEID_IDX_GN_N1SS; ++ break; ++ case WIRELESS_11B_24N: ++ case WIRELESS_11BG_24N: ++ if (psta->bw_mode == CHANNEL_WIDTH_20) { + if (rf_type == RF_2T2R) -+ raid = RATEID_IDX_GN_N2SS; ++ raid = RATEID_IDX_BGN_20M_2SS_BN; + else -+ raid = RATEID_IDX_GN_N1SS; -+ break; -+ case WIRELESS_11B_24N: -+ case WIRELESS_11BG_24N: -+ if (psta->bw_mode == CHANNEL_WIDTH_20) { -+ if (rf_type == RF_2T2R) -+ raid = RATEID_IDX_BGN_20M_2SS_BN; -+ else -+ raid = RATEID_IDX_BGN_20M_1SS_BN; -+ } else { -+ if (rf_type == RF_2T2R) -+ raid = RATEID_IDX_BGN_40M_2SS; -+ else -+ raid = RATEID_IDX_BGN_40M_1SS; -+ } -+ break; -+ default: -+ raid = RATEID_IDX_BGN_40M_2SS; -+ break; ++ raid = RATEID_IDX_BGN_20M_1SS_BN; ++ } else { ++ if (rf_type == RF_2T2R) ++ raid = RATEID_IDX_BGN_40M_2SS; ++ else ++ raid = RATEID_IDX_BGN_40M_1SS; ++ } ++ break; ++ default: ++ raid = RATEID_IDX_BGN_40M_2SS; ++ break; + + } + return raid; @@ -28957,55 +27931,54 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +{ + unsigned char val = 0; + -+ switch (rate & 0x7f) -+ { -+ case 0: -+ val = IEEE80211_CCK_RATE_1MB; -+ break; ++ switch (rate & 0x7f) { ++ case 0: ++ val = IEEE80211_CCK_RATE_1MB; ++ break; + -+ case 1: -+ val = IEEE80211_CCK_RATE_2MB; -+ break; ++ case 1: ++ val = IEEE80211_CCK_RATE_2MB; ++ break; + -+ case 2: -+ val = IEEE80211_CCK_RATE_5MB; -+ break; ++ case 2: ++ val = IEEE80211_CCK_RATE_5MB; ++ break; + -+ case 3: -+ val = IEEE80211_CCK_RATE_11MB; -+ break; ++ case 3: ++ val = IEEE80211_CCK_RATE_11MB; ++ break; + -+ case 4: -+ val = IEEE80211_OFDM_RATE_6MB; -+ break; ++ case 4: ++ val = IEEE80211_OFDM_RATE_6MB; ++ break; + -+ case 5: -+ val = IEEE80211_OFDM_RATE_9MB; -+ break; ++ case 5: ++ val = IEEE80211_OFDM_RATE_9MB; ++ break; + -+ case 6: -+ val = IEEE80211_OFDM_RATE_12MB; -+ break; ++ case 6: ++ val = IEEE80211_OFDM_RATE_12MB; ++ break; + -+ case 7: -+ val = IEEE80211_OFDM_RATE_18MB; -+ break; ++ case 7: ++ val = IEEE80211_OFDM_RATE_18MB; ++ break; + -+ case 8: -+ val = IEEE80211_OFDM_RATE_24MB; -+ break; ++ case 8: ++ val = IEEE80211_OFDM_RATE_24MB; ++ break; + -+ case 9: -+ val = IEEE80211_OFDM_RATE_36MB; -+ break; ++ case 9: ++ val = IEEE80211_OFDM_RATE_36MB; ++ break; + -+ case 10: -+ val = IEEE80211_OFDM_RATE_48MB; -+ break; ++ case 10: ++ val = IEEE80211_OFDM_RATE_48MB; ++ break; + -+ case 11: -+ val = IEEE80211_OFDM_RATE_54MB; -+ break; ++ case 11: ++ val = IEEE80211_OFDM_RATE_54MB; ++ break; + + } + @@ -29020,17 +27993,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + unsigned char val; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + -+ for (i = 0; i < NumRates; i++) -+ { ++ for (i = 0; i < NumRates; i++) { + val = pmlmeext->basicrate[i]; + + if ((val != 0xff) && (val != 0xfe)) -+ { + if (rate == ratetbl_val_2wifirate(val)) -+ { + return true; -+ } -+ } + } + + return false; @@ -29044,29 +28012,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + unsigned int len = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + -+ for (i = 0; i < NumRates; i++) -+ { ++ for (i = 0; i < NumRates; i++) { + rate = pmlmeext->datarate[i]; + -+ switch (rate) -+ { -+ case 0xff: -+ return len; ++ switch (rate) { ++ case 0xff: ++ return len; + -+ case 0xfe: -+ continue; ++ case 0xfe: ++ continue; + -+ default: -+ rate = ratetbl_val_2wifirate(rate); ++ default: ++ rate = ratetbl_val_2wifirate(rate); + -+ if (is_basicrate(padapter, rate) == true) -+ { -+ rate |= IEEE80211_BASIC_RATE_MASK; -+ } ++ if (is_basicrate(padapter, rate) == true) ++ rate |= IEEE80211_BASIC_RATE_MASK; + -+ rateset[len] = rate; -+ len++; -+ break; ++ rateset[len] = rate; ++ len++; ++ break; + } + } + return len; @@ -29094,29 +28058,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + mcs_set[3] &= mcs_rate_4r; +} + -+void UpdateBrateTbl( -+ struct adapter * Adapter, -+ u8 *mBratesOS -+) ++void UpdateBrateTbl(struct adapter *Adapter, u8 *mBratesOS) +{ + u8 i; + u8 rate; + + /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ -+ for (i = 0;ibNotifyChannelChange) -+ { + DBG_871X("[%s] ch = %d, offset = %d, bwmode = %d\n", __func__, channel, channel_offset, bwmode); -+ } + + center_ch = rtw_get_center_ch(channel, bwmode, channel_offset); + -+ if (bwmode == CHANNEL_WIDTH_80) -+ { ++ if (bwmode == CHANNEL_WIDTH_80) { + if (center_ch > channel) + chnl_offset80 = HAL_PRIME_CHNL_OFFSET_LOWER; + else if (center_ch < channel) @@ -29325,7 +28276,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + +__inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork) +{ -+ return (pnetwork->MacAddress); ++ return pnetwork->MacAddress; +} + +u16 get_beacon_interval(struct wlan_bssid_ex *bss) @@ -29349,13 +28300,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)) -+ { + return true; -+ } + else -+ { + return _FAIL; -+ } +} + +int is_client_associated_to_ibss(struct adapter *padapter) @@ -29364,13 +28311,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) -+ { + return true; -+ } + else -+ { + return _FAIL; -+ } +} + +int is_IBSS_empty(struct adapter *padapter) @@ -29379,12 +28322,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) -+ { ++ for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { + if (pmlmeinfo->FW_sta_info[i].status == 1) -+ { + return _FAIL; -+ } + } + + return true; @@ -29394,17 +28334,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval) +{ + if ((bcn_interval << 2) < WAIT_FOR_BCN_TO_MIN) -+ { + return WAIT_FOR_BCN_TO_MIN; -+ } + else if ((bcn_interval << 2) > WAIT_FOR_BCN_TO_MAX) -+ { + return WAIT_FOR_BCN_TO_MAX; -+ } + else -+ { + return ((bcn_interval << 2)); -+ } +} + +void invalidate_cam_all(struct adapter *padapter) @@ -29420,31 +28354,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + spin_unlock_bh(&cam_ctl->lock); +} + -+static u32 _ReadCAM(struct adapter *padapter , u32 addr) ++static u32 _ReadCAM(struct adapter *padapter, u32 addr) +{ + u32 count = 0, cmd; -+ cmd = CAM_POLLINIG |addr ; ++ cmd = CAM_POLLINIG | addr; + rtw_write32(padapter, RWCAM, cmd); + -+ do{ -+ if (0 == (rtw_read32(padapter, REG_CAMCMD) & CAM_POLLINIG)) { ++ do { ++ if (0 == (rtw_read32(padapter, REG_CAMCMD) & CAM_POLLINIG)) + break; -+ } -+ }while (count++ < 100); ++ } while (count++ < 100); + + return rtw_read32(padapter, REG_CAMREAD); +} -+void read_cam(struct adapter *padapter , u8 entry, u8 *get_key) ++void read_cam(struct adapter *padapter, u8 entry, u8 *get_key) +{ + u32 j, addr, cmd; + addr = entry << 3; + + /* DBG_8192C("********* DUMP CAM Entry_#%02d***************\n", entry); */ -+ for (j = 0; j < 6; j++) -+ { -+ cmd = _ReadCAM(padapter , addr+j); ++ for (j = 0; j < 6; j++) { ++ cmd = _ReadCAM(padapter, addr+j); + /* DBG_8192C("offset:0x%02x => 0x%08x\n", addr+j, cmd); */ -+ if (j>1) /* get key from cam */ ++ if (j > 1) /* get key from cam */ + memcpy(get_key+(j-2)*4, &cmd, 4); + } + /* DBG_8192C("*********************************\n"); */ @@ -29490,7 +28422,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +inline void write_cam(struct adapter *adapter, u8 id, u16 ctrl, u8 *mac, u8 *key) +{ + _write_cam(adapter, id, ctrl, mac, key); -+ write_cam_cache(adapter, id , ctrl, mac, key); ++ write_cam_cache(adapter, id, ctrl, mac, key); +} + +inline void clear_cam_entry(struct adapter *adapter, u8 id) @@ -29562,7 +28494,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + int i; + s16 cam_id = -1; + -+ for (i = 0;icam_cache[i].mac, addr, ETH_ALEN)) + continue; + if (kid >= 0 && kid != (dvobj->cam_cache[i].ctrl&0x03)) @@ -29617,8 +28549,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + } + + cam_id = kid; -+ } -+ else { ++ } else { + int i; + u8 *addr = sta?sta->hwaddr:NULL; + @@ -29631,7 +28562,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + addr = get_bssid(&adapter->mlmepriv); + } + -+ if ((i = _rtw_camid_search(adapter, addr, kid)) >= 0) { ++ i = _rtw_camid_search(adapter, addr, kid); ++ if (i >= 0) { + /* Fix issue that pairwise and group key have same key id. Pairwise key first, group key can overwirte group only(ex: rekey) */ + if (sta || _rtw_camid_is_gk(adapter, i) == true) + cam_id = i; @@ -29641,7 +28573,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + goto bitmap_handle; + } + -+ for (i =4;ibitmap & BIT(i))) + break; + @@ -29687,10 +28619,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) -+ { -+ if (pmlmeinfo->FW_sta_info[mac_id].status == 0) -+ { ++ for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { ++ if (pmlmeinfo->FW_sta_info[mac_id].status == 0) { + pmlmeinfo->FW_sta_info[mac_id].status = 1; + pmlmeinfo->FW_sta_info[mac_id].retry = 0; + break; @@ -29713,27 +28643,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + +} + -+int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE) ++int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) +{ + /* struct registry_priv *pregpriv = &padapter->registrypriv; */ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ if (pmlmepriv->qospriv.qos_option == 0) -+ { ++ if (pmlmepriv->qospriv.qos_option == 0) { + pmlmeinfo->WMM_enable = 0; + return false; + } + + if (!memcmp(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element))) -+ { + return false; -+ } + else -+ { + memcpy(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element)); -+ } ++ + pmlmeinfo->WMM_enable = 1; + return true; +} @@ -29757,13 +28683,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + else + aSifsTime = 10; + -+ if (pmlmeinfo->WMM_enable == 0) -+ { ++ if (pmlmeinfo->WMM_enable == 0) { + padapter->mlmepriv.acm_mask = 0; + + AIFS = aSifsTime + (2 * pmlmeinfo->slotTime); + -+ if (pmlmeext->cur_wireless_mode & (WIRELESS_11G |WIRELESS_11A)) { ++ if (pmlmeext->cur_wireless_mode & (WIRELESS_11G | WIRELESS_11A)) { + ECWMin = 4; + ECWMax = 10; + } else if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { @@ -29785,13 +28710,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + TXOP = 0x2f; + acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16); + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); -+ } -+ else -+ { ++ } else{ + edca[0] = edca[1] = edca[2] = edca[3] = 0; + -+ for (i = 0; i < 4; i++) -+ { ++ for (i = 0; i < 4; i++) { + ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03; + ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01; + @@ -29804,31 +28726,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16); + -+ switch (ACI) -+ { -+ case 0x0: -+ rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); -+ acm_mask |= (ACM? BIT(1):0); -+ edca[XMIT_BE_QUEUE] = acParm; -+ break; ++ switch (ACI) { ++ case 0x0: ++ rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); ++ acm_mask |= (ACM ? BIT(1):0); ++ edca[XMIT_BE_QUEUE] = acParm; ++ break; + -+ case 0x1: -+ rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); -+ /* acm_mask |= (ACM? BIT(0):0); */ -+ edca[XMIT_BK_QUEUE] = acParm; -+ break; ++ case 0x1: ++ rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); ++ /* acm_mask |= (ACM? BIT(0):0); */ ++ edca[XMIT_BK_QUEUE] = acParm; ++ break; + -+ case 0x2: -+ rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); -+ acm_mask |= (ACM? BIT(2):0); -+ edca[XMIT_VI_QUEUE] = acParm; -+ break; ++ case 0x2: ++ rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); ++ acm_mask |= (ACM ? BIT(2):0); ++ edca[XMIT_VI_QUEUE] = acParm; ++ break; + -+ case 0x3: -+ rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); -+ acm_mask |= (ACM? BIT(3):0); -+ edca[XMIT_VO_QUEUE] = acParm; -+ break; ++ case 0x3: ++ rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); ++ acm_mask |= (ACM ? BIT(3):0); ++ edca[XMIT_VO_QUEUE] = acParm; ++ break; + } + + DBG_871X("WMM(%x): %x, %x\n", ACI, ACM, acParm); @@ -29841,29 +28762,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; + -+ if (pregpriv->wifi_spec == 1) -+ { -+ u32 j, tmp, change_inx =false; ++ if (pregpriv->wifi_spec == 1) { ++ u32 j, tmp, change_inx = false; + + /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ -+ for (i = 0; i<4; i++) -+ { -+ for (j =i+1; j<4; j++) -+ { ++ for (i = 0; i < 4; i++) { ++ for (j = i+1; j < 4; j++) { + /* compare CW and AIFS */ -+ if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) -+ { ++ if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { + change_inx = true; -+ } -+ else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) -+ { ++ } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) { + /* compare TXOP */ + if ((edca[j] >> 16) > (edca[i] >> 16)) + change_inx = true; + } + -+ if (change_inx) -+ { ++ if (change_inx) { + tmp = edca[i]; + edca[i] = edca[j]; + edca[j] = tmp; @@ -29878,14 +28792,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + } + } + -+ for (i = 0; i<4; i++) { ++ for (i = 0; i < 4; i++) { + pxmitpriv->wmm_para_seq[i] = inx[i]; + DBG_871X("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]); + } + } +} + -+static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ie * pIE) ++static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ie *pIE) +{ + unsigned char new_bwmode; + unsigned char new_ch_offset; @@ -29900,9 +28814,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + if (!pIE) + return; + -+ if (phtpriv->ht_option == false) return; ++ if (phtpriv->ht_option == false) ++ return; + -+ if (pmlmeext->cur_bwmode >= CHANNEL_WIDTH_80) return; ++ if (pmlmeext->cur_bwmode >= CHANNEL_WIDTH_80) ++ return; + + if (pIE->Length > sizeof(struct HT_info_element)) + return; @@ -29912,40 +28828,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + if (pmlmeext->cur_channel > 14) { + if ((pregistrypriv->bw_mode & 0xf0) > 0) + cbw40_enable = 1; -+ } else { ++ } else + if ((pregistrypriv->bw_mode & 0x0f) > 0) + cbw40_enable = 1; -+ } + -+ if ((pHT_info->infos[0] & BIT(2)) && cbw40_enable) -+ { ++ if ((pHT_info->infos[0] & BIT(2)) && cbw40_enable) { + new_bwmode = CHANNEL_WIDTH_40; + -+ switch (pHT_info->infos[0] & 0x3) -+ { -+ case 1: -+ new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; -+ break; ++ switch (pHT_info->infos[0] & 0x3) { ++ case 1: ++ new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; ++ break; + -+ case 3: -+ new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; -+ break; ++ case 3: ++ new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; ++ break; + -+ default: -+ new_bwmode = CHANNEL_WIDTH_20; -+ new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; -+ break; ++ default: ++ new_bwmode = CHANNEL_WIDTH_20; ++ new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; ++ break; + } -+ } -+ else -+ { ++ } else{ + new_bwmode = CHANNEL_WIDTH_20; + new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } + + -+ if ((new_bwmode!= pmlmeext->cur_bwmode) || (new_ch_offset!=pmlmeext->cur_ch_offset)) -+ { ++ if ((new_bwmode != pmlmeext->cur_bwmode) || (new_ch_offset != pmlmeext->cur_ch_offset)) { + pmlmeinfo->bwmode_updated = true; + + pmlmeext->cur_bwmode = new_bwmode; @@ -29953,15 +28863,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + /* update HT info also */ + HT_info_handler(padapter, pIE); -+ } -+ else -+ { ++ } else + pmlmeinfo->bwmode_updated = false; -+ } + + -+ if (true == pmlmeinfo->bwmode_updated) -+ { ++ if (true == pmlmeinfo->bwmode_updated) { + struct sta_info *psta; + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct sta_priv *pstapriv = &padapter->stapriv; @@ -29971,18 +28877,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + /* update ap's stainfo */ + psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); -+ if (psta) -+ { ++ if (psta) { + struct ht_priv *phtpriv_sta = &psta->htpriv; + -+ if (phtpriv_sta->ht_option) -+ { ++ if (phtpriv_sta->ht_option) { + /* bwmode */ + psta->bw_mode = pmlmeext->cur_bwmode; + phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; -+ } -+ else -+ { ++ } else{ + psta->bw_mode = CHANNEL_WIDTH_20; + phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } @@ -29992,7 +28894,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + } +} + -+void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE) ++void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) +{ + unsigned int i; + u8 rf_type; @@ -30003,40 +28905,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + -+ if (pIE == NULL) return; ++ if (pIE == NULL) ++ return; + -+ if (phtpriv->ht_option == false) return; ++ if (phtpriv->ht_option == false) ++ return; + + pmlmeinfo->HT_caps_enable = 1; + -+ for (i = 0; i < (pIE->Length); i++) -+ { -+ if (i != 2) -+ { ++ for (i = 0; i < (pIE->Length); i++) { ++ if (i != 2) { + /* Commented by Albert 2010/07/12 */ + /* Got the endian issue here. */ + pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]); -+ } -+ else -+ { ++ } else{ + /* modify from fw by Thomas 2010/11/17 */ + if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3)) -+ { + max_AMPDU_len = (pIE->data[i] & 0x3); -+ } + else -+ { + max_AMPDU_len = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3); -+ } + + if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c)) -+ { + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c); -+ } + else -+ { + min_MPDU_spacing = (pIE->data[i] & 0x1c); -+ } + + pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing; + } @@ -30048,44 +28940,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= pmlmeext->default_supported_mcs_set[i]; + + /* update the MCS rates */ -+ switch (rf_type) -+ { -+ case RF_1T1R: -+ case RF_1T2R: -+ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R); -+ break; -+ case RF_2T2R: -+ default: ++ switch (rf_type) { ++ case RF_1T1R: ++ case RF_1T2R: ++ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R); ++ break; ++ case RF_2T2R: ++ default: +#ifdef CONFIG_DISABLE_MCS13TO15 -+ if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1) -+ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF); -+ else -+ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R); -+#else /* CONFIG_DISABLE_MCS13TO15 */ ++ if (pmlmeext->cur_bwmode == CHANNEL_WIDTH_40 && pregistrypriv->wifi_spec != 1) ++ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R_13TO15_OFF); ++ else + set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R); ++#else /* CONFIG_DISABLE_MCS13TO15 */ ++ set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R); +#endif /* CONFIG_DISABLE_MCS13TO15 */ + } + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + /* Config STBC setting */ -+ if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_TX_STBC(pIE->data)) -+ { ++ if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_TX_STBC(pIE->data)) { + SET_FLAG(cur_stbc_cap, STBC_HT_ENABLE_TX); + DBG_871X("Enable HT Tx STBC !\n"); + } + phtpriv->stbc_cap = cur_stbc_cap; + } else { + /* Config LDPC Coding Capability */ -+ if (TEST_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_LDPC_CAP(pIE->data)) -+ { ++ if (TEST_FLAG(phtpriv->ldpc_cap, LDPC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_LDPC_CAP(pIE->data)) { + SET_FLAG(cur_ldpc_cap, (LDPC_HT_ENABLE_TX | LDPC_HT_CAP_TX)); + DBG_871X("Enable HT Tx LDPC!\n"); + } + phtpriv->ldpc_cap = cur_ldpc_cap; + + /* Config STBC setting */ -+ if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_RX_STBC(pIE->data)) -+ { ++ if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_RX_STBC(pIE->data)) { + SET_FLAG(cur_stbc_cap, (STBC_HT_ENABLE_TX | STBC_HT_CAP_TX)); + DBG_871X("Enable HT Tx STBC!\n"); + } @@ -30093,16 +28981,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + } +} + -+void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE) ++void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + -+ if (pIE == NULL) return; ++ if (pIE == NULL) ++ return; + -+ if (phtpriv->ht_option == false) return; ++ if (phtpriv->ht_option == false) ++ return; + + + if (pIE->Length > sizeof(struct HT_info_element)) @@ -30124,12 +29014,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + DBG_871X("%s\n", __func__); + -+ if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) -+ { ++ if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) { + pmlmeinfo->HT_enable = 1; -+ } -+ else -+ { ++ } else{ + pmlmeinfo->HT_enable = 0; + /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ + return; @@ -30149,12 +29036,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); +} + -+void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie * pIE) ++void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ if (pIE->Length>1) ++ if (pIE->Length > 1) + return; + + pmlmeinfo->ERP_enable = 1; @@ -30167,47 +29054,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ switch (pregpriv->vrtl_carrier_sense)/* 0:off 1:on 2:auto */ -+ { -+ case 0: /* off */ -+ psta->rtsen = 0; -+ psta->cts2self = 0; -+ break; ++ switch (pregpriv->vrtl_carrier_sense) {/* 0:off 1:on 2:auto */ ++ case 0: /* off */ ++ psta->rtsen = 0; ++ psta->cts2self = 0; ++ break; + -+ case 1: /* on */ -+ if (pregpriv->vcs_type == 1) /* 1:RTS/CTS 2:CTS to self */ -+ { ++ case 1: /* on */ ++ if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */ ++ psta->rtsen = 1; ++ psta->cts2self = 0; ++ } else{ ++ psta->rtsen = 0; ++ psta->cts2self = 1; ++ } ++ break; ++ ++ case 2: /* auto */ ++ default: ++ if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1))) { ++ if (pregpriv->vcs_type == 1) { + psta->rtsen = 1; + psta->cts2self = 0; -+ } -+ else -+ { ++ } else{ + psta->rtsen = 0; + psta->cts2self = 1; + } -+ break; -+ -+ case 2: /* auto */ -+ default: -+ if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1))) -+ { -+ if (pregpriv->vcs_type == 1) -+ { -+ psta->rtsen = 1; -+ psta->cts2self = 0; -+ } -+ else -+ { -+ psta->rtsen = 0; -+ psta->cts2self = 1; -+ } -+ } -+ else -+ { -+ psta->rtsen = 0; -+ psta->cts2self = 0; -+ } -+ break; ++ } else{ ++ psta->rtsen = 0; ++ psta->cts2self = 0; ++ } ++ break; + } +} + @@ -30269,15 +29146,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + return true; + } + -+ if ((pmlmepriv->timeBcnInfoChkStart != 0) && (jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart) > DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS)) -+ { ++ if ((pmlmepriv->timeBcnInfoChkStart != 0) && (jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart) > DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS)) { + pmlmepriv->timeBcnInfoChkStart = 0; + pmlmepriv->NumOfBcnInfoChkFail = 0; + } + + subtype = GetFrameSubType(pframe) >> 4; + -+ if (subtype ==WIFI_BEACON) ++ if (subtype == WIFI_BEACON) + bssid->Reserved[0] = 1; + + bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; @@ -30289,7 +29165,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + /* check bw and channel offset */ + /* parsing HT_CAP_IE */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); -+ if (p && len>0) { ++ if (p && len > 0) { + pht_cap = (struct rtw_ieee80211_ht_cap *)(p + 2); + ht_cap_info = le16_to_cpu(pht_cap->cap_info); + } else { @@ -30297,7 +29173,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + } + /* parsing HT_INFO_IE */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); -+ if (p && len>0) { ++ if (p && len > 0) { + pht_info = (struct HT_info_element *)(p + 2); + ht_info_infos_0 = pht_info->infos[0]; + } else { @@ -30339,7 +29215,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + } + + /* checking SSID */ -+ if ((p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_)) == NULL) { ++ p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); ++ if (p == NULL) { + DBG_871X("%s marc: cannot find SSID for survey event\n", __func__); + hidden_ssid = true; + } else { @@ -30383,7 +29260,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + goto _mismatch; + } + -+ rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL,&rsn_len, NULL,&wpa_len); ++ rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, &wpa_len); + + if (rsn_len > 0) { + encryp_protocol = ENCRYP_PROTOCOL_WPA2; @@ -30401,7 +29278,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { + pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); -+ if (pbuf && (wpa_ielen>0)) { ++ if (pbuf && (wpa_ielen > 0)) { + if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, @@ -30410,7 +29287,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + } else { + pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + -+ if (pbuf && (wpa_ielen>0)) { ++ if (pbuf && (wpa_ielen > 0)) { + if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", @@ -30441,16 +29318,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + kfree((u8 *)bssid); + + if (pmlmepriv->NumOfBcnInfoChkFail == 0) -+ { + pmlmepriv->timeBcnInfoChkStart = jiffies; -+ } + + pmlmepriv->NumOfBcnInfoChkFail++; + DBG_871X("%s by "ADPT_FMT" - NumOfChkFail = %d (SeqNum of this Beacon frame = %d).\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail, GetSequence(pframe)); + + if ((pmlmepriv->timeBcnInfoChkStart != 0) && (jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart) <= DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS) -+ && (pmlmepriv->NumOfBcnInfoChkFail >= DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD)) -+ { ++ && (pmlmepriv->NumOfBcnInfoChkFail >= DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD)) { + DBG_871X("%s by "ADPT_FMT" - NumOfChkFail = %d >= threshold : %d (in %d ms), return FAIL.\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail, + DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD, jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart)); + pmlmepriv->timeBcnInfoChkStart = 0; @@ -30465,38 +29339,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +{ + unsigned int i; + unsigned int len; -+ struct ndis_80211_var_ie * pIE; ++ struct ndis_80211_var_ie *pIE; + + len = pkt_len - (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN); + -+ for (i = 0; i < len;) -+ { ++ for (i = 0; i < len;) { + pIE = (struct ndis_80211_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i); + -+ switch (pIE->ElementID) -+ { -+ case _VENDOR_SPECIFIC_IE_: -+ /* to update WMM paramter set while receiving beacon */ -+ if (!memcmp(pIE->data, WMM_PARA_OUI, 6) && pIE->Length == WLAN_WMM_LEN) /* WMM */ -+ { -+ if (WMM_param_handler(padapter, pIE)) -+ report_wmm_edca_update(padapter); -+ } ++ switch (pIE->ElementID) { ++ case _VENDOR_SPECIFIC_IE_: ++ /* to update WMM paramter set while receiving beacon */ ++ if (!memcmp(pIE->data, WMM_PARA_OUI, 6) && pIE->Length == WLAN_WMM_LEN) /* WMM */ ++ if (WMM_param_handler(padapter, pIE)) ++ report_wmm_edca_update(padapter); + -+ break; ++ break; + -+ case _HT_EXTRA_INFO_IE_: /* HT info */ -+ /* HT_info_handler(padapter, pIE); */ -+ bwmode_update_check(padapter, pIE); -+ break; ++ case _HT_EXTRA_INFO_IE_: /* HT info */ ++ /* HT_info_handler(padapter, pIE); */ ++ bwmode_update_check(padapter, pIE); ++ break; + -+ case _ERPINFO_IE_: -+ ERP_IE_handler(padapter, pIE); -+ VCS_update(padapter, psta); -+ break; ++ case _ERPINFO_IE_: ++ ERP_IE_handler(padapter, pIE); ++ VCS_update(padapter, psta); ++ break; + -+ default: -+ break; ++ default: ++ break; + } + + i += (pIE->Length + 2); @@ -30506,45 +29376,36 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +unsigned int is_ap_in_tkip(struct adapter *padapter) +{ + u32 i; -+ struct ndis_80211_var_ie * pIE; ++ struct ndis_80211_var_ie *pIE; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + -+ if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) -+ { -+ for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.IELength;) -+ { ++ if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { ++ for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.IEs + i); + -+ switch (pIE->ElementID) -+ { -+ case _VENDOR_SPECIFIC_IE_: -+ if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) -+ { -+ return true; -+ } -+ break; ++ switch (pIE->ElementID) { ++ case _VENDOR_SPECIFIC_IE_: ++ if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) ++ return true; + -+ case _RSN_IE_2_: -+ if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) -+ { -+ return true; -+ } ++ break; + -+ default: -+ break; ++ case _RSN_IE_2_: ++ if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) ++ return true; ++ ++ default: ++ break; + } + + i += (pIE->Length + 2); + } + + return false; -+ } -+ else -+ { ++ } else + return false; -+ } + +} + @@ -30557,16 +29418,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + if (!(pmlmeinfo->HT_enable)) + return _FAIL; + -+ bit_offset = (bwmode & CHANNEL_WIDTH_40)? 6: 5; ++ bit_offset = (bwmode & CHANNEL_WIDTH_40) ? 6 : 5; + + if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & (0x1 << bit_offset)) -+ { + return _SUCCESS; -+ } + else -+ { + return _FAIL; -+ } +} + +unsigned char get_highest_rate_idx(u32 mask) @@ -30574,10 +29431,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + int i; + unsigned char rate_idx = 0; + -+ for (i =31; i>= 0; i--) -+ { -+ if (mask & BIT(i)) -+ { ++ for (i = 31; i >= 0; i--) { ++ if (mask & BIT(i)) { + rate_idx = i; + break; + } @@ -30606,90 +29461,66 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +unsigned char check_assoc_AP(u8 *pframe, uint len) +{ + unsigned int i; -+ struct ndis_80211_var_ie * pIE; ++ struct ndis_80211_var_ie *pIE; + -+ for (i = sizeof(struct ndis_802_11_fix_ie); i < len;) -+ { ++ for (i = sizeof(struct ndis_802_11_fix_ie); i < len;) { + pIE = (struct ndis_80211_var_ie *)(pframe + i); + -+ switch (pIE->ElementID) -+ { -+ case _VENDOR_SPECIFIC_IE_: -+ if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) -+ { -+ DBG_871X("link to Artheros AP\n"); -+ return HT_IOT_PEER_ATHEROS; -+ } -+ else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) -+ || (!memcmp(pIE->data, BROADCOM_OUI2, 3)) -+ || (!memcmp(pIE->data, BROADCOM_OUI3, 3))) -+ { -+ DBG_871X("link to Broadcom AP\n"); -+ return HT_IOT_PEER_BROADCOM; -+ } -+ else if (!memcmp(pIE->data, MARVELL_OUI, 3)) -+ { -+ DBG_871X("link to Marvell AP\n"); -+ return HT_IOT_PEER_MARVELL; -+ } -+ else if (!memcmp(pIE->data, RALINK_OUI, 3)) -+ { -+ DBG_871X("link to Ralink AP\n"); -+ return HT_IOT_PEER_RALINK; -+ } -+ else if (!memcmp(pIE->data, CISCO_OUI, 3)) -+ { -+ DBG_871X("link to Cisco AP\n"); -+ return HT_IOT_PEER_CISCO; -+ } -+ else if (!memcmp(pIE->data, REALTEK_OUI, 3)) -+ { -+ u32 Vender = HT_IOT_PEER_REALTEK; ++ switch (pIE->ElementID) { ++ case _VENDOR_SPECIFIC_IE_: ++ if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { ++ DBG_871X("link to Artheros AP\n"); ++ return HT_IOT_PEER_ATHEROS; ++ } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) ++ || (!memcmp(pIE->data, BROADCOM_OUI2, 3)) ++ || (!memcmp(pIE->data, BROADCOM_OUI3, 3))) { ++ DBG_871X("link to Broadcom AP\n"); ++ return HT_IOT_PEER_BROADCOM; ++ } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) { ++ DBG_871X("link to Marvell AP\n"); ++ return HT_IOT_PEER_MARVELL; ++ } else if (!memcmp(pIE->data, RALINK_OUI, 3)) { ++ DBG_871X("link to Ralink AP\n"); ++ return HT_IOT_PEER_RALINK; ++ } else if (!memcmp(pIE->data, CISCO_OUI, 3)) { ++ DBG_871X("link to Cisco AP\n"); ++ return HT_IOT_PEER_CISCO; ++ } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) { ++ u32 Vender = HT_IOT_PEER_REALTEK; + -+ if (pIE->Length >= 5) { -+ if (pIE->data[4]== 1) -+ { -+ /* if (pIE->data[5] & RT_HT_CAP_USE_LONG_PREAMBLE) */ -+ /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */ ++ if (pIE->Length >= 5) { ++ if (pIE->data[4] == 1) ++ /* if (pIE->data[5] & RT_HT_CAP_USE_LONG_PREAMBLE) */ ++ /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */ ++ if (pIE->data[5] & RT_HT_CAP_USE_92SE) ++ /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; */ ++ Vender = HT_IOT_PEER_REALTEK_92SE; + -+ if (pIE->data[5] & RT_HT_CAP_USE_92SE) -+ { -+ /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; */ -+ Vender = HT_IOT_PEER_REALTEK_92SE; -+ } ++ if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP) ++ Vender = HT_IOT_PEER_REALTEK_SOFTAP; ++ ++ if (pIE->data[4] == 2) { ++ if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) { ++ Vender = HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP; ++ DBG_871X("link to Realtek JAGUAR_BCUTAP\n"); + } -+ -+ if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP) -+ Vender = HT_IOT_PEER_REALTEK_SOFTAP; -+ -+ if (pIE->data[4] == 2) -+ { -+ if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) { -+ Vender = HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP; -+ DBG_871X("link to Realtek JAGUAR_BCUTAP\n"); -+ } -+ if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT) { -+ Vender = HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP; -+ DBG_871X("link to Realtek JAGUAR_CCUTAP\n"); -+ } ++ if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT) { ++ Vender = HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP; ++ DBG_871X("link to Realtek JAGUAR_CCUTAP\n"); + } + } -+ -+ DBG_871X("link to Realtek AP\n"); -+ return Vender; -+ } -+ else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) -+ { -+ DBG_871X("link to Airgo Cap\n"); -+ return HT_IOT_PEER_AIRGO; -+ } -+ else -+ { -+ break; + } + -+ default: ++ DBG_871X("link to Realtek AP\n"); ++ return Vender; ++ } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) { ++ DBG_871X("link to Airgo Cap\n"); ++ return HT_IOT_PEER_AIRGO; ++ } else + break; ++ ++ default: ++ break; + } + + i += (pIE->Length + 2); @@ -30704,34 +29535,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + -+ switch (pmlmeinfo->assoc_AP_vendor) -+ { -+ case HT_IOT_PEER_MARVELL: -+ pmlmeinfo->turboMode_cts2self = 1; -+ pmlmeinfo->turboMode_rtsen = 0; -+ break; ++ switch (pmlmeinfo->assoc_AP_vendor) { ++ case HT_IOT_PEER_MARVELL: ++ pmlmeinfo->turboMode_cts2self = 1; ++ pmlmeinfo->turboMode_rtsen = 0; ++ break; + -+ case HT_IOT_PEER_RALINK: -+ pmlmeinfo->turboMode_cts2self = 0; -+ pmlmeinfo->turboMode_rtsen = 1; -+ /* disable high power */ -+ Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); -+ break; -+ case HT_IOT_PEER_REALTEK: -+ /* rtw_write16(padapter, 0x4cc, 0xffff); */ -+ /* rtw_write16(padapter, 0x546, 0x01c0); */ -+ /* disable high power */ -+ Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); -+ break; -+ default: -+ pmlmeinfo->turboMode_cts2self = 0; -+ pmlmeinfo->turboMode_rtsen = 1; -+ break; ++ case HT_IOT_PEER_RALINK: ++ pmlmeinfo->turboMode_cts2self = 0; ++ pmlmeinfo->turboMode_rtsen = 1; ++ /* disable high power */ ++ Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); ++ break; ++ case HT_IOT_PEER_REALTEK: ++ /* rtw_write16(padapter, 0x4cc, 0xffff); */ ++ /* rtw_write16(padapter, 0x546, 0x01c0); */ ++ /* disable high power */ ++ Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); ++ break; ++ default: ++ pmlmeinfo->turboMode_cts2self = 0; ++ pmlmeinfo->turboMode_rtsen = 1; ++ break; + } + +} + -+void update_capinfo(struct adapter * Adapter, u16 updateCap) ++void update_capinfo(struct adapter *Adapter, u16 updateCap) +{ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -30742,19 +29572,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + /* if (pMgntInfo->RegPreambleMode == PREAMBLE_AUTO) */ + { + -+ if (updateCap & cShortPreamble) -+ { /* Short Preamble */ -+ if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) /* PREAMBLE_LONG or PREAMBLE_AUTO */ -+ { ++ if (updateCap & cShortPreamble) { ++ /* Short Preamble */ ++ if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ + ShortPreamble = true; + pmlmeinfo->preamble_mode = PREAMBLE_SHORT; + rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + } -+ } -+ else -+ { /* Long Preamble */ -+ if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) /* PREAMBLE_SHORT or PREAMBLE_AUTO */ -+ { ++ } else{ ++ /* Long Preamble */ ++ if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ + ShortPreamble = false; + pmlmeinfo->preamble_mode = PREAMBLE_LONG; + rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); @@ -30762,33 +29589,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + } + } + -+ if (updateCap & cIBSS) { ++ if (updateCap & cIBSS) + /* Filen: See 802.11-2007 p.91 */ + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; -+ } -+ else -+ { ++ else { + /* Filen: See 802.11-2007 p.90 */ + if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N | WIRELESS_11A | WIRELESS_11_5N | WIRELESS_11AC)) -+ { + pmlmeinfo->slotTime = SHORT_SLOT_TIME; -+ } -+ else if (pmlmeext->cur_wireless_mode & (WIRELESS_11G)) -+ { ++ else if (pmlmeext->cur_wireless_mode & (WIRELESS_11G)) { + if ((updateCap & cShortSlotTime) /* && (!(pMgntInfo->pHTInfo->RT2RT_HT_Mode & RT_HT_CAP_USE_LONG_PREAMBLE)) */) -+ { /* Short Slot Time */ ++ /* Short Slot Time */ + pmlmeinfo->slotTime = SHORT_SLOT_TIME; -+ } + else -+ { /* Long Slot Time */ ++ /* Long Slot Time */ + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; -+ } -+ } -+ else -+ { ++ } else + /* B Mode */ + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; -+ } + } + + rtw_hal_set_hwreg(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); @@ -30807,44 +29624,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + ratelen = rtw_get_rateset_len(cur_network->SupportedRates); + + if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) -+ { + pmlmeinfo->HT_enable = 1; -+ } + -+ if (pmlmeext->cur_channel > 14) -+ { ++ if (pmlmeext->cur_channel > 14) { + if (pmlmeinfo->VHT_enable) + network_type = WIRELESS_11AC; + else if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_5N; + + network_type |= WIRELESS_11A; -+ } -+ else -+ { ++ } else{ + if (pmlmeinfo->VHT_enable) + network_type = WIRELESS_11AC; + else if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_24N; + + if ((cckratesonly_included(rate, ratelen)) == true) -+ { + network_type |= WIRELESS_11B; -+ } + else if ((cckrates_included(rate, ratelen)) == true) -+ { + network_type |= WIRELESS_11BG; -+ } + else -+ { + network_type |= WIRELESS_11G; -+ } + } + + pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode; + + SIFS_Timer = 0x0a0a0808; /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ -+ /* change this value if having IOT issues. */ ++ /* change this value if having IOT issues. */ + + padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); + @@ -30858,14 +29664,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + +void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode) +{ -+ if (IsSupportedTxCCK(wireless_mode)) -+ { ++ if (IsSupportedTxCCK(wireless_mode)) { + /* Only B, B/G, and B/G/N AP could use CCK rate */ + memcpy(psta->bssrateset, rtw_basic_rate_cck, 4); + psta->bssratelen = 4; -+ } -+ else -+ { ++ } else{ + memcpy(psta->bssrateset, rtw_basic_rate_ofdm, 3); + psta->bssratelen = 3; + } @@ -30874,25 +29677,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx) +{ + unsigned int ie_len; -+ struct ndis_80211_var_ie * pIE; ++ struct ndis_80211_var_ie *pIE; + int supportRateNum = 0; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + if (pIE == NULL) -+ { + return _FAIL; -+ } + + memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); + supportRateNum = ie_len; + + pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + if (pIE) -+ { + memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); -+ } + + return _SUCCESS; + @@ -30904,14 +29703,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + u16 tid, start_seq, param; + struct recv_reorder_ctrl *preorder_ctrl; + struct sta_priv *pstapriv = &padapter->stapriv; -+ struct ADDBA_request *preq = (struct ADDBA_request*)paddba_req; ++ struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + psta = rtw_get_stainfo(pstapriv, addr); + -+ if (psta) -+ { ++ if (psta) { + start_seq = le16_to_cpu(preq->BA_starting_seqctrl) >> 4; + + param = le16_to_cpu(preq->BA_para_set); @@ -30929,7 +29727,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + preorder_ctrl->indicate_seq = 0xffff; + #endif + -+ preorder_ctrl->enable =(pmlmeinfo->bAcceptAddbaReq == true)? true :false; ++ preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq == true) ? true : false; + } + +} @@ -30981,15 +29779,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + delay_ms = delay_ms/1000; + + if (delay_ms >= 8) -+ { + pmlmeext->bcn_delay_cnt[8]++; + /* pmlmeext->bcn_delay_ratio[8] = (pmlmeext->bcn_delay_cnt[8] * 100) /pmlmeext->bcn_cnt; */ -+ } + else -+ { + pmlmeext->bcn_delay_cnt[delay_ms]++; + /* pmlmeext->bcn_delay_ratio[delay_ms] = (pmlmeext->bcn_delay_cnt[delay_ms] * 100) /pmlmeext->bcn_cnt; */ -+ } + +/* + DBG_871X("%s(): (a)bcn_cnt = %d\n", __func__, pmlmeext->bcn_cnt); @@ -31003,8 +29797,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +*/ + + /* dump for adaptive_early_32k */ -+ if (pmlmeext->bcn_cnt > 100 && (pmlmeext->adaptive_tsf_done ==true)) -+ { ++ if (pmlmeext->bcn_cnt > 100 && (pmlmeext->adaptive_tsf_done == true)) { + u8 ratio_20_delay, ratio_80_delay; + u8 DrvBcnEarly, DrvBcnTimeOut; + @@ -31015,25 +29808,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + DBG_871X("%s(): bcn_cnt = %d\n", __func__, pmlmeext->bcn_cnt); + -+ for (i = 0; i<9; i++) -+ { -+ pmlmeext->bcn_delay_ratio[i] = (pmlmeext->bcn_delay_cnt[i] * 100) /pmlmeext->bcn_cnt; ++ for (i = 0; i < 9; i++) { ++ pmlmeext->bcn_delay_ratio[i] = (pmlmeext->bcn_delay_cnt[i] * 100) / pmlmeext->bcn_cnt; + + + DBG_871X("%s():bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d]=%d\n", __func__, i, -+ pmlmeext->bcn_delay_cnt[i] , i, pmlmeext->bcn_delay_ratio[i]); ++ pmlmeext->bcn_delay_cnt[i], i, pmlmeext->bcn_delay_ratio[i]); + + ratio_20_delay += pmlmeext->bcn_delay_ratio[i]; + ratio_80_delay += pmlmeext->bcn_delay_ratio[i]; + -+ if (ratio_20_delay > 20 && DrvBcnEarly == 0xff) -+ { ++ if (ratio_20_delay > 20 && DrvBcnEarly == 0xff) { + DrvBcnEarly = i; + DBG_871X("%s(): DrvBcnEarly = %d\n", __func__, DrvBcnEarly); + } + -+ if (ratio_80_delay > 80 && DrvBcnTimeOut == 0xff) -+ { ++ if (ratio_80_delay > 80 && DrvBcnTimeOut == 0xff) { + DrvBcnTimeOut = i; + DBG_871X("%s(): DrvBcnTimeOut = %d\n", __func__, DrvBcnTimeOut); + } @@ -31067,30 +29857,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + if (!memcmp(psta->hwaddr, bc_addr, ETH_ALEN)) + return; + -+ if (!memcmp(psta->hwaddr, myid(&padapter->eeprompriv), ETH_ALEN)) -+ { ++ if (!memcmp(psta->hwaddr, myid(&padapter->eeprompriv), ETH_ALEN)) { + psta->mac_id = NUM_STA; + return; + } + + spin_lock_bh(&pdvobj->lock); -+ for (i = 0; imacid[i] == false) -+ { ++ for (i = 0; i < NUM_STA; i++) { ++ if (pdvobj->macid[i] == false) { + pdvobj->macid[i] = true; + break; + } + } + spin_unlock_bh(&pdvobj->lock); + -+ if (i > (NUM_STA-1)) -+ { ++ if (i > (NUM_STA-1)) { + psta->mac_id = NUM_STA; + DBG_871X(" no room for more MACIDs\n"); -+ } -+ else -+ { ++ } else{ + psta->mac_id = i; + DBG_871X("%s = %d\n", __func__, psta->mac_id); + } @@ -31107,17 +29891,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + return; + + if (!memcmp(psta->hwaddr, myid(&padapter->eeprompriv), ETH_ALEN)) -+ { + return; -+ } + + spin_lock_bh(&pdvobj->lock); -+ if (psta->mac_idmac_id != 1) -+ { -+ if (pdvobj->macid[psta->mac_id] == true) -+ { ++ if (psta->mac_id < NUM_STA && psta->mac_id != 1) { ++ if (pdvobj->macid[psta->mac_id] == true) { + DBG_871X("%s = %d\n", __func__, psta->mac_id); -+ pdvobj->macid[psta->mac_id] = false; ++ pdvobj->macid[psta->mac_id] = false; + psta->mac_id = NUM_STA; + } + @@ -31132,12 +29912,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); + int i; + spin_lock_bh(&pdvobj->lock); -+ for (i =(NUM_STA-1); i>= 0 ; i--) -+ { ++ for (i = (NUM_STA-1); i >= 0 ; i--) { + if (pdvobj->macid[i] == true) -+ { + break; -+ } + } + max_mac_id = i; + spin_unlock_bh(&pdvobj->lock); @@ -31172,9 +29949,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + /* According the direction to read register value */ + if (direction) -+ value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1)& BIT(gpio_num)) >> gpio_num; ++ value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) & BIT(gpio_num)) >> gpio_num; + else -+ value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL)& BIT(gpio_num)) >> gpio_num; ++ value = (rtw_read8(adapter, REG_GPIO_PIN_CTRL) & BIT(gpio_num)) >> gpio_num; + + rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL); + DBG_871X("%s direction =%d value =%d\n", __func__, direction, value); @@ -31190,8 +29967,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev); + + /* Check GPIO is 4~7 */ -+ if (gpio_num > 7 || gpio_num < 4) -+ { ++ if (gpio_num > 7 || gpio_num < 4) { + DBG_871X("%s The gpio number does not included 4~7.\n", __func__); + return -1; + } @@ -31204,8 +29980,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + direction = (rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & BIT(gpio_num)) >> gpio_num; + + /* If GPIO is output direction, setting value. */ -+ if (direction) -+ { ++ if (direction) { + if (isHigh) + rtw_write8(adapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 1) | BIT(gpio_num)); + else @@ -31213,9 +29988,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + + DBG_871X("%s Set gpio %x[%d]=%d\n", __func__, REG_GPIO_PIN_CTRL+1, gpio_num, isHigh); + res = 0; -+ } -+ else -+ { ++ } else{ + DBG_871X("%s The gpio is input, not be set!\n", __func__); + res = -1; + } @@ -31229,8 +30002,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +{ + struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev); + -+ if (gpio_num > 7 || gpio_num < 4) -+ { ++ if (gpio_num > 7 || gpio_num < 4) { + DBG_871X("%s The gpio number does not included 4~7.\n", __func__); + return -1; + } @@ -31242,13 +30014,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + LeaveAllPowerSaveModeDirect(adapter); + + if (isOutput) -+ { + rtw_write8(adapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) | BIT(gpio_num)); -+ } + else -+ { + rtw_write8(adapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(adapter, REG_GPIO_PIN_CTRL + 2) & ~BIT(gpio_num)); -+ } + + rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL); + @@ -31268,7 +30036,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + if ((pmlmeinfo->state & WIFI_FW_LINKING_STATE) || + pmlmeinfo->state & WIFI_FW_AP_STATE) { + if (my_ip_ptr != NULL) { -+ struct in_ifaddr *my_ifa_list = my_ip_ptr->ifa_list ; ++ struct in_ifaddr *my_ifa_list = my_ip_ptr->ifa_list; + if (my_ifa_list != NULL) { + ipaddress[0] = my_ifa_list->ifa_address & 0xFF; + ipaddress[1] = (my_ifa_list->ifa_address >> 8) & 0xFF; @@ -31283,7 +30051,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +} +#endif +#ifdef CONFIG_WOWLAN -+void rtw_get_sec_iv(struct adapter *padapter, u8*pcur_dot11txpn, u8 *StaAddr) ++void rtw_get_sec_iv(struct adapter *padapter, u8 *pcur_dot11txpn, u8 *StaAddr) +{ + struct sta_info *psta; + struct security_priv *psecpriv = &padapter->securitypriv; @@ -31296,8 +30064,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs + __func__, StaAddr[0], StaAddr[1], StaAddr[2], + StaAddr[3], StaAddr[4], StaAddr[5]); + -+ if (psta) -+ { ++ if (psta) { + if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ && psta->dot11txpn.val > 0) + psta->dot11txpn.val--; + AES_IV(pcur_dot11txpn, psta->dot11txpn, 0); @@ -31310,27 +30077,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +} +void rtw_set_sec_pn(struct adapter *padapter) +{ -+ struct sta_info *psta; -+ struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); -+ struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); ++ struct sta_info *psta; ++ struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); ++ struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); ++ struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); + struct security_priv *psecpriv = &padapter->securitypriv; + -+ psta = rtw_get_stainfo(&padapter->stapriv, -+ get_my_bssid(&pmlmeinfo->network)); ++ psta = rtw_get_stainfo(&padapter->stapriv, ++ get_my_bssid(&pmlmeinfo->network)); + -+ if (psta) -+ { -+ if (pwrpriv->wowlan_fw_iv > psta->dot11txpn.val) -+ { -+ if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) -+ psta->dot11txpn.val = pwrpriv->wowlan_fw_iv + 2; -+ } else { -+ DBG_871X("%s(): FW IV is smaller than driver\n", __func__); -+ psta->dot11txpn.val += 2; ++ if (psta) { ++ if (pwrpriv->wowlan_fw_iv > psta->dot11txpn.val) { ++ if (psecpriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) ++ psta->dot11txpn.val = pwrpriv->wowlan_fw_iv + 2; ++ } else { ++ DBG_871X("%s(): FW IV is smaller than driver\n", __func__); ++ psta->dot11txpn.val += 2; ++ } ++ DBG_871X("%s: dot11txpn: 0x%016llx\n", __func__, psta->dot11txpn.val); + } -+ DBG_871X("%s: dot11txpn: 0x%016llx\n", __func__ , psta->dot11txpn.val); -+ } +} +#endif /* CONFIG_WOWLAN */ + @@ -31342,10 +30107,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_wlan_util.c linux-4.3-rtl8723bs +#define CIPHER_WPA_EAP "WPA-EAP IEEE8021X" + +#endif /* CONFIG_PNO_SUPPORT */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_xmit.c ---- linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/core/rtw_xmit.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,3263 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/core/rtw_xmit.c linux/3rdparty/rtl8723bs/core/rtw_xmit.c +--- linux.old/3rdparty/rtl8723bs/core/rtw_xmit.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/core/rtw_xmit.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,3100 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -31377,7 +30142,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + +void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) +{ -+ memset((unsigned char *)psta_xmitpriv, 0, sizeof (struct sta_xmit_priv)); ++ memset((unsigned char *)psta_xmitpriv, 0, sizeof(struct sta_xmit_priv)); + + spin_lock_init(&psta_xmitpriv->lock); + @@ -31445,10 +30210,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* pxmitpriv->pxmit_frame_buf = pxmitpriv->pallocated_frame_buf + 4 - */ + /* ((SIZE_PTR) (pxmitpriv->pallocated_frame_buf) &3); */ + -+ pxframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf; ++ pxframe = (struct xmit_frame *) pxmitpriv->pxmit_frame_buf; + -+ for (i = 0; i < NR_XMITFRAME; i++) -+ { ++ for (i = 0; i < NR_XMITFRAME; i++) { + INIT_LIST_HEAD(&(pxframe->list)); + + pxframe->padapter = padapter; @@ -31485,10 +30249,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - */ + /* ((SIZE_PTR) (pxmitpriv->pallocated_xmitbuf) &3); */ + -+ pxmitbuf = (struct xmit_buf*)pxmitpriv->pxmitbuf; ++ pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + -+ for (i = 0; i < NR_XMITBUFF; i++) -+ { ++ for (i = 0; i < NR_XMITBUFF; i++) { + INIT_LIST_HEAD(&pxmitbuf->list); + + pxmitbuf->priv_data = NULL; @@ -31496,12 +30259,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pxmitbuf->buf_tag = XMITBUF_DATA; + + /* Tx buf allocation may fail sometimes, so sleep and retry. */ -+ if ((res =rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), true)) == _FAIL) { ++ res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), true); ++ if (res == _FAIL) { + msleep(10); + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ), true); -+ if (res == _FAIL) { ++ if (res == _FAIL) + goto exit; -+ } + } + + pxmitbuf->phead = pxmitbuf->pbuf; @@ -31513,7 +30276,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); + #ifdef DBG_XMIT_BUF -+ pxmitbuf->no =i; ++ pxmitbuf->no = i; + #endif + + pxmitbuf++; @@ -31534,7 +30297,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + goto exit; + } + pxmitpriv->xframe_ext = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->xframe_ext_alloc_addr), 4); -+ pxframe = (struct xmit_frame*)pxmitpriv->xframe_ext; ++ pxframe = (struct xmit_frame *)pxmitpriv->xframe_ext; + + for (i = 0; i < NR_XMIT_EXTBUFF; i++) { + INIT_LIST_HEAD(&(pxframe->list)); @@ -31568,17 +30331,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitpriv->pallocated_xmit_extbuf), 4); + -+ pxmitbuf = (struct xmit_buf*)pxmitpriv->pxmit_extbuf; ++ pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + -+ for (i = 0; i < NR_XMIT_EXTBUFF; i++) -+ { ++ for (i = 0; i < NR_XMIT_EXTBUFF; i++) { + INIT_LIST_HEAD(&pxmitbuf->list); + + pxmitbuf->priv_data = NULL; + pxmitbuf->padapter = padapter; + pxmitbuf->buf_tag = XMITBUF_MGNT; + -+ if ((res =rtw_os_xmit_resource_alloc(padapter, pxmitbuf, MAX_XMIT_EXTBUF_SZ + XMITBUF_ALIGN_SZ, true)) == _FAIL) { ++ res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, MAX_XMIT_EXTBUF_SZ + XMITBUF_ALIGN_SZ, true); ++ if (res == _FAIL) { + res = _FAIL; + goto exit; + } @@ -31590,7 +30353,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + #ifdef DBG_XMIT_BUF_EXT -+ pxmitbuf->no =i; ++ pxmitbuf->no = i; + #endif + pxmitbuf++; + @@ -31598,7 +30361,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + pxmitpriv->free_xmit_extbuf_cnt = NR_XMIT_EXTBUFF; + -+ for (i = 0; ipcmd_xmitbuf[i]; + if (pxmitbuf) { + INIT_LIST_HEAD(&pxmitbuf->list); @@ -31607,7 +30370,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pxmitbuf->padapter = padapter; + pxmitbuf->buf_tag = XMITBUF_CMD; + -+ if ((res =rtw_os_xmit_resource_alloc(padapter, pxmitbuf, MAX_CMDBUF_SZ+XMITBUF_ALIGN_SZ, true)) == _FAIL) { ++ res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, MAX_CMDBUF_SZ+XMITBUF_ALIGN_SZ, true); ++ if (res == _FAIL) { + res = _FAIL; + goto exit; + } @@ -31623,8 +30387,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + rtw_alloc_hwxmits(padapter); + rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); + -+ for (i = 0; i < 4; i ++) -+ { ++ for (i = 0; i < 4; i++) { + pxmitpriv->wmm_para_seq[i] = i; + } + @@ -31638,11 +30401,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + return res; +} + -+void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) ++void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) +{ + int i; + struct adapter *padapter = pxmitpriv->adapter; -+ struct xmit_frame *pxmitframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf; ++ struct xmit_frame *pxmitframe = (struct xmit_frame *) pxmitpriv->pxmit_frame_buf; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + + rtw_hal_free_xmit_priv(padapter); @@ -31650,32 +30413,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + if (pxmitpriv->pxmit_frame_buf == NULL) + return; + -+ for (i = 0; ipallocated_frame_buf) { ++ if (pxmitpriv->pallocated_frame_buf) + vfree(pxmitpriv->pallocated_frame_buf); -+ } + + -+ if (pxmitpriv->pallocated_xmitbuf) { ++ if (pxmitpriv->pallocated_xmitbuf) + vfree(pxmitpriv->pallocated_xmitbuf); -+ } + + /* free xframe_ext queue, the same count as extbuf */ -+ if ((pxmitframe = (struct xmit_frame*)pxmitpriv->xframe_ext)) { -+ for (i = 0; ixframe_ext; ++ if (pxmitframe) { ++ for (i = 0; i < NR_XMIT_EXTBUFF; i++) { + rtw_os_xmit_complete(padapter, pxmitframe); + pxmitframe++; + } @@ -31685,8 +30445,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + /* free xmit extension buff */ + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; -+ for (i = 0; ipallocated_xmit_extbuf); + } + -+ for (i = 0; ipcmd_xmitbuf[i]; -+ if (pxmitbuf!= NULL) -+ rtw_os_xmit_resource_free(padapter, pxmitbuf, MAX_CMDBUF_SZ+XMITBUF_ALIGN_SZ , true); ++ if (pxmitbuf != NULL) ++ rtw_os_xmit_resource_free(padapter, pxmitbuf, MAX_CMDBUF_SZ+XMITBUF_ALIGN_SZ, true); + } + + rtw_free_hwxmits(padapter); @@ -31715,16 +30474,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + sgi_40m = psta->htpriv.sgi_40m; + + switch (psta->bw_mode) { -+ case CHANNEL_WIDTH_80: -+ sgi = sgi_80m; -+ break; -+ case CHANNEL_WIDTH_40: -+ sgi = sgi_40m; -+ break; -+ case CHANNEL_WIDTH_20: -+ default: -+ sgi = sgi_20m; -+ break; ++ case CHANNEL_WIDTH_80: ++ sgi = sgi_80m; ++ break; ++ case CHANNEL_WIDTH_40: ++ sgi = sgi_40m; ++ break; ++ case CHANNEL_WIDTH_20: ++ default: ++ sgi = sgi_20m; ++ break; + } + + return sgi; @@ -31739,26 +30498,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pattrib->nr_frags != 1) -+ { + sz = padapter->xmitpriv.frag_len; -+ } + else /* no frag */ -+ { + sz = pattrib->last_txcmdsz; -+ } + + /* (1) RTS_Threshold is compared to the MPDU, not MSDU. */ + /* (2) If there are more than one frag in this MSDU, only the first frag uses protection frame. */ + /* Other fragments are protected by previous fragment. */ + /* So we only need to check the length of first fragment. */ -+ if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec) -+ { ++ if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec) { + if (sz > padapter->registrypriv.rts_thresh) -+ { + pattrib->vcs_mode = RTS_CTS; -+ } -+ else -+ { ++ else{ + if (pattrib->rtsen) + pattrib->vcs_mode = RTS_CTS; + else if (pattrib->cts2self) @@ -31766,23 +30517,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + else + pattrib->vcs_mode = NONE_VCS; + } -+ } -+ else -+ { -+ while (true) -+ { ++ } else{ ++ while (true) { + /* IOT action */ -+ if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && (pattrib->ampdu_en ==true) && -+ (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) -+ { ++ if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && (pattrib->ampdu_en == true) && ++ (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { + pattrib->vcs_mode = CTS_TO_SELF; + break; + } + + + /* check ERP protection */ -+ if (pattrib->rtsen || pattrib->cts2self) -+ { ++ if (pattrib->rtsen || pattrib->cts2self) { + if (pattrib->rtsen) + pattrib->vcs_mode = RTS_CTS; + else if (pattrib->cts2self) @@ -31792,20 +30538,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + + /* check HT op mode */ -+ if (pattrib->ht_en) -+ { ++ if (pattrib->ht_en) { + u8 HTOpMode = pmlmeinfo->HT_protection; + if ((pmlmeext->cur_bwmode && (HTOpMode == 2 || HTOpMode == 3)) || -+ (!pmlmeext->cur_bwmode && HTOpMode == 3)) -+ { ++ (!pmlmeext->cur_bwmode && HTOpMode == 3)) { + pattrib->vcs_mode = RTS_CTS; + break; + } + } + + /* check rts */ -+ if (sz > padapter->registrypriv.rts_thresh) -+ { ++ if (sz > padapter->registrypriv.rts_thresh) { + pattrib->vcs_mode = RTS_CTS; + break; + } @@ -31813,8 +30556,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* to do list: check MIMO power save condition. */ + + /* check AMPDU aggregation for TXOP */ -+ if (pattrib->ampdu_en ==true) -+ { ++ if (pattrib->ampdu_en == true) { + pattrib->vcs_mode = RTS_CTS; + break; + } @@ -31875,7 +30617,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pattrib->retry_ctrl = false; + +#ifdef CONFIG_AUTO_AP_MODE -+ if (psta->isrc && psta->pid>0) ++ if (psta->isrc && psta->pid > 0) + pattrib->pctrl = true; +#endif + @@ -31892,14 +30634,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + memset(pattrib->dot11tkiptxmickey.skey, 0, 16); + pattrib->mac_id = psta->mac_id; + -+ if (psta->ieee8021x_blocked == true) -+ { ++ if (psta->ieee8021x_blocked == true) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\n psta->ieee8021x_blocked == true\n")); + + pattrib->encrypt = 0; + -+ if ((pattrib->ether_type != 0x888e) && (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) -+ { ++ if ((pattrib->ether_type != 0x888e) && (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, pattrib->ether_type(%.4x) != 0x888e\n", pattrib->ether_type)); + #ifdef DBG_TX_DROP_FRAME + DBG_871X("DBG_TX_DROP_FRAME %s psta->ieee8021x_blocked == true, pattrib->ether_type(%04x) != 0x888e\n", __func__, pattrib->ether_type); @@ -31907,86 +30647,81 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + res = _FAIL; + goto exit; + } -+ } -+ else -+ { ++ } else{ + GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast); + -+ switch (psecuritypriv->dot11AuthAlgrthm) -+ { -+ case dot11AuthAlgrthm_Open: -+ case dot11AuthAlgrthm_Shared: -+ case dot11AuthAlgrthm_Auto: -+ pattrib->key_idx = (u8)psecuritypriv->dot11PrivacyKeyIndex; -+ break; -+ case dot11AuthAlgrthm_8021X: -+ if (bmcast) -+ pattrib->key_idx = (u8)psecuritypriv->dot118021XGrpKeyid; -+ else -+ pattrib->key_idx = 0; -+ break; -+ default: ++ switch (psecuritypriv->dot11AuthAlgrthm) { ++ case dot11AuthAlgrthm_Open: ++ case dot11AuthAlgrthm_Shared: ++ case dot11AuthAlgrthm_Auto: ++ pattrib->key_idx = (u8)psecuritypriv->dot11PrivacyKeyIndex; ++ break; ++ case dot11AuthAlgrthm_8021X: ++ if (bmcast) ++ pattrib->key_idx = (u8)psecuritypriv->dot118021XGrpKeyid; ++ else + pattrib->key_idx = 0; -+ break; ++ break; ++ default: ++ pattrib->key_idx = 0; ++ break; + } + + /* For WPS 1.0 WEP, driver should not encrypt EAPOL Packet for WPS handshake. */ -+ if (((pattrib->encrypt == _WEP40_)||(pattrib->encrypt == _WEP104_)) && (pattrib->ether_type == 0x888e)) ++ if (((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) && (pattrib->ether_type == 0x888e)) + pattrib->encrypt = _NO_PRIVACY_; + + } + -+ switch (pattrib->encrypt) -+ { -+ case _WEP40_: -+ case _WEP104_: -+ pattrib->iv_len = 4; -+ pattrib->icv_len = 4; -+ WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); -+ break; ++ switch (pattrib->encrypt) { ++ case _WEP40_: ++ case _WEP104_: ++ pattrib->iv_len = 4; ++ pattrib->icv_len = 4; ++ WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); ++ break; + -+ case _TKIP_: -+ pattrib->iv_len = 8; -+ pattrib->icv_len = 4; ++ case _TKIP_: ++ pattrib->iv_len = 8; ++ pattrib->icv_len = 4; + -+ if (psecuritypriv->busetkipkey == _FAIL) -+ { -+ #ifdef DBG_TX_DROP_FRAME -+ DBG_871X("DBG_TX_DROP_FRAME %s psecuritypriv->busetkipkey(%d) == _FAIL drop packet\n", __func__, psecuritypriv->busetkipkey); -+ #endif -+ res = _FAIL; -+ goto exit; -+ } ++ if (psecuritypriv->busetkipkey == _FAIL) { ++ #ifdef DBG_TX_DROP_FRAME ++ DBG_871X("DBG_TX_DROP_FRAME %s psecuritypriv->busetkipkey(%d) == _FAIL drop packet\n", __func__, psecuritypriv->busetkipkey); ++ #endif ++ res = _FAIL; ++ goto exit; ++ } + -+ if (bmcast) -+ TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); -+ else -+ TKIP_IV(pattrib->iv, psta->dot11txpn, 0); ++ if (bmcast) ++ TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); ++ else ++ TKIP_IV(pattrib->iv, psta->dot11txpn, 0); + + -+ memcpy(pattrib->dot11tkiptxmickey.skey, psta->dot11tkiptxmickey.skey, 16); ++ memcpy(pattrib->dot11tkiptxmickey.skey, psta->dot11tkiptxmickey.skey, 16); + -+ break; ++ break; + -+ case _AES_: ++ case _AES_: + -+ pattrib->iv_len = 8; -+ pattrib->icv_len = 8; ++ pattrib->iv_len = 8; ++ pattrib->icv_len = 8; + -+ if (bmcast) -+ AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); -+ else -+ AES_IV(pattrib->iv, psta->dot11txpn, 0); ++ if (bmcast) ++ AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); ++ else ++ AES_IV(pattrib->iv, psta->dot11txpn, 0); + -+ break; ++ break; + -+ default: -+ pattrib->iv_len = 0; -+ pattrib->icv_len = 0; -+ break; ++ default: ++ pattrib->iv_len = 0; ++ pattrib->icv_len = 0; ++ break; + } + -+ if (pattrib->encrypt>0) ++ if (pattrib->encrypt > 0) + memcpy(pattrib->dot118021x_UncstKey.skey, psta->dot118021x_UncstKey.skey, 16); + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, @@ -31994,8 +30729,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pattrib->encrypt, padapter->securitypriv.sw_encrypt)); + + if (pattrib->encrypt && -+ ((padapter->securitypriv.sw_encrypt == true) || (psecuritypriv->hw_decrypted == false))) -+ { ++ ((padapter->securitypriv.sw_encrypt == true) || (psecuritypriv->hw_decrypted == false))) { + pattrib->bswenc = true; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("update_attrib: encrypt =%d securitypriv.hw_decrypted =%d bswenc =true\n", @@ -32015,29 +30749,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp +{ + u8 change_priority = priority; + -+ switch (priority) -+ { -+ case 0: -+ case 3: -+ if (acm_mask & BIT(1)) -+ change_priority = 1; -+ break; -+ case 1: -+ case 2: -+ break; -+ case 4: -+ case 5: -+ if (acm_mask & BIT(2)) -+ change_priority = 0; -+ break; -+ case 6: -+ case 7: -+ if (acm_mask & BIT(3)) -+ change_priority = 5; -+ break; -+ default: -+ DBG_871X("qos_acm(): invalid pattrib->priority: %d!!!\n", priority); -+ break; ++ switch (priority) { ++ case 0: ++ case 3: ++ if (acm_mask & BIT(1)) ++ change_priority = 1; ++ break; ++ case 1: ++ case 2: ++ break; ++ case 4: ++ case 5: ++ if (acm_mask & BIT(2)) ++ change_priority = 0; ++ break; ++ case 6: ++ case 7: ++ if (acm_mask & BIT(3)) ++ change_priority = 5; ++ break; ++ default: ++ DBG_871X("qos_acm(): invalid pattrib->priority: %d!!!\n", priority); ++ break; + } + + return change_priority; @@ -32051,7 +30784,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + + _rtw_open_pktfile(ppktfile->pkt, ppktfile); -+ _rtw_pktfile_read(ppktfile, (unsigned char*)ðerhdr, ETH_HLEN); ++ _rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN); + + /* get UserPriority from IP hdr */ + if (pattrib->ether_type == 0x0800) { @@ -32094,24 +30827,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_adhoc); -+ } -+ else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { ++ } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_sta); -+ } -+ else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { ++ } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN); + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_ap); -+ } -+ else ++ } else + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_unknown); + + pattrib->pktlen = pktfile.pkt_len; + -+ if (ETH_P_IP == pattrib->ether_type) -+ { ++ if (ETH_P_IP == pattrib->ether_type) { + /* The following is for DHCP and ARP packet, we use cck1M to tx these packets and let LPS awake some time */ + /* to prevent DHCP protocol fail */ + @@ -32138,8 +30867,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + struct iphdr *piphdr = (struct iphdr *)tmp; + + pattrib->icmp_pkt = 0; -+ if (piphdr->protocol == 0x1) /* protocol type in ip header 0x1 is ICMP */ -+ { ++ if (piphdr->protocol == 0x1) { /* protocol type in ip header 0x1 is ICMP */ + pattrib->icmp_pkt = 1; + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_icmp); + } @@ -32151,17 +30879,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + + if ((pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) -+ { + rtw_set_scan_deny(padapter, 3000); -+ } + + /* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */ + if (pattrib->icmp_pkt == 1) -+ { + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, 1); -+ } -+ else if (pattrib->dhcp_pkt == 1) -+ { ++ else if (pattrib->dhcp_pkt == 1) { + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_active); + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1); + } @@ -32181,17 +30904,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + #endif + res = _FAIL; + goto exit; -+ } -+ else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) ==true) && (!(psta->state & _FW_LINKED))) -+ { ++ } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) && (!(psta->state & _FW_LINKED))) { + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_ucast_ap_link); + res = _FAIL; + goto exit; + } + } + -+ if (psta == NULL) -+ { /* if we cannot get psta => drop the pkt */ ++ if (psta == NULL) { ++ /* if we cannot get psta => drop the pkt */ + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_sta); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:" MAC_FMT "\n", MAC_ARG(pattrib->ra))); + #ifdef DBG_TX_DROP_FRAME @@ -32201,8 +30922,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + goto exit; + } + -+ if (!(psta->state &_FW_LINKED)) -+ { ++ if (!(psta->state & _FW_LINKED)) { + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_link); + DBG_871X("%s, psta("MAC_FMT")->state(0x%x) != _FW_LINKED\n", __func__, MAC_ARG(psta->hwaddr), psta->state); + return _FAIL; @@ -32211,8 +30931,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + + /* TODO:_lock */ -+ if (update_attrib_sec_info(padapter, pattrib, psta) == _FAIL) -+ { ++ if (update_attrib_sec_info(padapter, pattrib, psta) == _FAIL) { + DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_sec); + res = _FAIL; + goto exit; @@ -32235,21 +30954,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pattrib->subtype = WIFI_DATA_TYPE; + pattrib->priority = 0; + -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (pattrib->qos_en) + set_qos(&pktfile, pattrib); -+ } -+ else -+ { -+ if (pqospriv->qos_option) -+ { ++ } else{ ++ if (pqospriv->qos_option) { + set_qos(&pktfile, pattrib); + + if (pmlmepriv->acm_mask != 0) -+ { + pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority); -+ } ++ + } + } + @@ -32261,15 +30975,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + return res; +} + -+static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe) { ++static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe) ++{ + sint curfragnum, length; + u8 *pframe, *payload, mic[8]; + struct mic_data micdata; + /* struct sta_info *stainfo; */ + struct pkt_attrib *pattrib = &pxmitframe->attrib; -+ struct security_priv *psecuritypriv =&padapter->securitypriv; -+ struct xmit_priv *pxmitpriv =&padapter->xmitpriv; -+ u8 priority[4]={0x0, 0x0, 0x0, 0x0}; ++ struct security_priv *psecuritypriv = &padapter->securitypriv; ++ struct xmit_priv *pxmitpriv = &padapter->xmitpriv; ++ u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; + u8 hw_hdr_offset = 0; + sint bmcst = IS_MCAST(pattrib->ra); + @@ -32299,17 +31014,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + hw_hdr_offset = TXDESC_OFFSET; + -+ if (pattrib->encrypt == _TKIP_)/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ -+ { ++ if (pattrib->encrypt == _TKIP_) { /* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ + /* encode mic code */ + /* if (stainfo!= NULL) */ + { -+ u8 null_key[16]={0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; ++ u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + + pframe = pxmitframe->buf_addr + hw_hdr_offset; + -+ if (bmcst) -+ { ++ if (bmcst) { + if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) { + /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ + /* msleep(10); */ @@ -32317,9 +31030,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + /* start to calculate the mic code */ + rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); -+ } -+ else -+ { ++ } else { + if (!memcmp(&pattrib->dot11tkiptxmickey.skey[0], null_key, 16)) { + /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ + /* msleep(10); */ @@ -32335,8 +31046,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + rtw_secmicappend(&micdata, &pframe[24], 6); + else + rtw_secmicappend(&micdata, &pframe[10], 6); -+ } -+ else { /* ToDS == 0 */ ++ } else { /* ToDS == 0 */ + rtw_secmicappend(&micdata, &pframe[4], 6); /* DA */ + if (pframe[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &pframe[16], 6); @@ -32345,35 +31055,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + } + -+ /* if (pqospriv->qos_option == 1) */ -+ if (pattrib->qos_en) -+ priority[0]=(u8)pxmitframe->attrib.priority; ++ /* if (pqospriv->qos_option == 1) */ ++ if (pattrib->qos_en) ++ priority[0] = (u8)pxmitframe->attrib.priority; + + + rtw_secmicappend(&micdata, &priority[0], 4); + -+ payload =pframe; ++ payload = pframe; + -+ for (curfragnum = 0;curfragnumnr_frags;curfragnum++) { -+ payload =(u8 *)RND4((SIZE_PTR)(payload)); ++ for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { ++ payload = (u8 *)RND4((SIZE_PTR)(payload)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("===curfragnum =%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n", -+ curfragnum,*payload, *(payload+1),*(payload+2),*(payload+3),*(payload+4),*(payload+5),*(payload+6),*(payload+7))); ++ curfragnum, *payload, *(payload+1), *(payload+2), *(payload+3), *(payload+4), *(payload+5), *(payload+6), *(payload+7))); + -+ payload =payload+pattrib->hdrlen+pattrib->iv_len; ++ payload = payload+pattrib->hdrlen+pattrib->iv_len; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum =%d pattrib->hdrlen =%d pattrib->iv_len =%d", curfragnum, pattrib->hdrlen, pattrib->iv_len)); -+ if ((curfragnum+1) ==pattrib->nr_frags) { -+ length =pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); ++ if ((curfragnum+1) == pattrib->nr_frags) { ++ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); + rtw_secmicappend(&micdata, payload, length); -+ payload =payload+length; -+ } -+ else { -+ length =pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); ++ payload = payload+length; ++ } else{ ++ length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); + rtw_secmicappend(&micdata, payload, length); -+ payload =payload+length+pattrib->icv_len; ++ payload = payload+length+pattrib->icv_len; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum =%d length =%d pattrib->icv_len =%d", curfragnum, length, pattrib->icv_len)); + } + } -+ rtw_secgetmic(&micdata,&(mic[0])); ++ rtw_secgetmic(&micdata, &(mic[0])); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: before add mic code!!!\n")); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: pattrib->last_txcmdsz =%d!!!\n", pattrib->last_txcmdsz)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: mic[0]= 0x%.2x , mic[1]= 0x%.2x , mic[2]= 0x%.2x , mic[3]= 0x%.2x\n\ @@ -32382,14 +31091,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* add mic code and add the mic code length in last_txcmdsz */ + + memcpy(payload, &(mic[0]), 8); -+ pattrib->last_txcmdsz+=8; ++ pattrib->last_txcmdsz += 8; + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ========last pkt ========\n")); -+ payload =payload-pattrib->last_txcmdsz+8; -+ for (curfragnum = 0;curfragnumlast_txcmdsz;curfragnum =curfragnum+8) ++ payload = payload-pattrib->last_txcmdsz+8; ++ for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz; curfragnum = curfragnum+8) + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, (" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ", -+ *(payload+curfragnum), *(payload+curfragnum+1), *(payload+curfragnum+2),*(payload+curfragnum+3), -+ *(payload+curfragnum+4),*(payload+curfragnum+5),*(payload+curfragnum+6),*(payload+curfragnum+7))); ++ *(payload+curfragnum), *(payload+curfragnum+1), *(payload+curfragnum+2), *(payload+curfragnum+3), ++ *(payload+curfragnum+4), *(payload+curfragnum+5), *(payload+curfragnum+6), *(payload+curfragnum+7))); + } +/* + else { @@ -32400,14 +31109,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + return _SUCCESS; +} + -+static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { ++static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) ++{ + + struct pkt_attrib *pattrib = &pxmitframe->attrib; + /* struct security_priv *psecuritypriv =&padapter->securitypriv; */ + + /* if ((psecuritypriv->sw_encrypt)||(pattrib->bswenc)) */ -+ if (pattrib->bswenc) -+ { ++ if (pattrib->bswenc) { + /* DBG_871X("start xmitframe_swencrypt\n"); */ + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n")); + switch (pattrib->encrypt) { @@ -32425,13 +31134,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + break; + } + -+ } else { ++ } else + RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); -+ } ++ + return _SUCCESS; +} + -+s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pattrib) ++s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) +{ + u16 *qc; + @@ -32446,8 +31155,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + SetFrameSubType(fctrl, pattrib->subtype); + -+ if (pattrib->subtype & WIFI_DATA_TYPE) -+ { ++ if (pattrib->subtype & WIFI_DATA_TYPE) { + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { + /* to_ds = 1, fr_ds = 0; */ + @@ -32463,8 +31171,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + if (pqospriv->qos_option) + qos_option = true; + -+ } -+ else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)) { ++ } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)) { + /* to_ds = 0, fr_ds = 1; */ + SetFrDs(fctrl); + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); @@ -32473,8 +31180,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + if (pattrib->qos_en) + qos_option = true; -+ } -+ else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || ++ } else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); @@ -32482,8 +31188,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + if (pattrib->qos_en) + qos_option = true; -+ } -+ else { ++ } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv))); + res = _FAIL; + goto exit; @@ -32495,8 +31200,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + if (pattrib->encrypt) + SetPrivacy(fctrl); + -+ if (qos_option) -+ { ++ if (qos_option) { + qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); + + if (pattrib->priority) @@ -32513,27 +31217,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + { + struct sta_info *psta; + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); -+ if (pattrib->psta != psta) -+ { ++ if (pattrib->psta != psta) { + DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta); + return _FAIL; + } + -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + DBG_871X("%s, psta ==NUL\n", __func__); + return _FAIL; + } + -+ if (!(psta->state &_FW_LINKED)) -+ { ++ if (!(psta->state & _FW_LINKED)) { + DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + return _FAIL; + } + + -+ if (psta) -+ { ++ if (psta) { + psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; + psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; + pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; @@ -32542,32 +31242,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + /* check if enable ampdu */ + if (pattrib->ht_en && psta->htpriv.ampdu_enable) -+ { + if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) + pattrib->ampdu_en = true; -+ } ++ + + /* re-check if enable ampdu by BA_starting_seqctrl */ -+ if (pattrib->ampdu_en == true) -+ { ++ if (pattrib->ampdu_en == true) { + u16 tx_seq; + + tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; + + /* check BA_starting_seqctrl */ -+ if (SN_LESS(pattrib->seqnum, tx_seq)) -+ { ++ if (SN_LESS(pattrib->seqnum, tx_seq)) { + /* DBG_871X("tx ampdu seqnum(%d) < tx_seq(%d)\n", pattrib->seqnum, tx_seq); */ + pattrib->ampdu_en = false;/* AGG BK */ -+ } -+ else if (SN_EQUAL(pattrib->seqnum, tx_seq)) -+ { ++ } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff; + + pattrib->ampdu_en = true;/* AGG EN */ -+ } -+ else -+ { ++ } else{ + /* DBG_871X("tx ampdu over run\n"); */ + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff; + pattrib->ampdu_en = true;/* AGG EN */ @@ -32577,9 +31270,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + } + -+ } -+ else -+ { ++ } else{ + + } + @@ -32608,7 +31299,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + len = pattrib->hdrlen + pattrib->iv_len; /* WLAN Header and IV */ + len += SNAP_SIZE + sizeof(u16); /* LLC */ + len += pattrib->pktlen; -+ if (pattrib->encrypt == _TKIP_) len += 8; /* MIC */ ++ if (pattrib->encrypt == _TKIP_) ++ len += 8; /* MIC */ + len += ((pattrib->bswenc) ? pattrib->icv_len : 0); /* ICV */ + + return len; @@ -32660,7 +31352,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + + if (psta == NULL) -+ { ++ { + + DBG_871X("%s, psta ==NUL\n", __func__); + return _FAIL; @@ -32696,8 +31388,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + frg_inx = 0; + frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */ + -+ while (1) -+ { ++ while (1) { + llc_sz = 0; + + mpdu_len = frg_len; @@ -32710,8 +31401,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + mpdu_len -= pattrib->hdrlen; + + /* adding icv, if necessary... */ -+ if (pattrib->iv_len) -+ { ++ if (pattrib->iv_len) { + memcpy(pframe, pattrib->iv, pattrib->iv_len); + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, @@ -32729,7 +31419,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + mpdu_len -= llc_sz; + } + -+ if ((pattrib->icv_len >0) && (pattrib->bswenc)) { ++ if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { + mpdu_len -= pattrib->icv_len; + } + @@ -32743,26 +31433,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + pframe += mem_sz; + -+ if ((pattrib->icv_len >0) && (pattrib->bswenc)) { ++ if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { + memcpy(pframe, pattrib->icv, pattrib->icv_len); + pframe += pattrib->icv_len; + } + + frg_inx++; + -+ if (bmcst || (rtw_endofpktfile(&pktfile) == true)) -+ { ++ if (bmcst || (rtw_endofpktfile(&pktfile) == true)) { + pattrib->nr_frags = frg_inx; + -+ pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags == 1)? llc_sz:0) + ++ pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags == 1) ? llc_sz:0) + + ((pattrib->bswenc) ? pattrib->icv_len : 0) + mem_sz; + + ClearMFrag(mem_start); + + break; -+ } else { ++ } else + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__)); -+ } + + addr = (SIZE_PTR)(pframe); + @@ -32771,8 +31459,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + } + -+ if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) -+ { ++ if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n")); + DBG_8192C("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"); + res = _FAIL; @@ -32794,7 +31481,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp +s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe) +{ + u8 *pframe, *mem_start = NULL, *tmp_buf = NULL; -+ u8 subtype ; ++ u8 subtype; + struct sta_info *psta = NULL; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + s32 bmcst = IS_MCAST(pattrib->ra); @@ -32823,14 +31510,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + goto xmitframe_coalesce_success; + + /* IGTK key is not install, it may not support 802.11w */ -+ if (padapter->securitypriv.binstallBIPkey != true) -+ { ++ if (padapter->securitypriv.binstallBIPkey != true) { + DBG_871X("no instll BIP key\n"); + goto xmitframe_coalesce_success; + } + /* station mode doesn't need TX BIP, just ready the code */ -+ if (bmcst) -+ { ++ if (bmcst) { + int frame_body_len; + u8 mic[16]; + @@ -32844,14 +31529,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pframe += pattrib->pktlen; + + /* octent 0 and 1 is key index , BIP keyid is 4 or 5, LSB only need octent 0 */ -+ MME[0]=padapter->securitypriv.dot11wBIPKeyid; ++ MME[0] = padapter->securitypriv.dot11wBIPKeyid; + /* copy packet number */ + memcpy(&MME[2], &pmlmeext->mgnt_80211w_IPN, 6); + /* increase the packet number */ + pmlmeext->mgnt_80211w_IPN++; + + /* add MME IE with MIC all zero, MME string doesn't include element id and length */ -+ pframe = rtw_set_ie(pframe, _MME_IE_ , 16 , MME, &(pattrib->pktlen)); ++ pframe = rtw_set_ie(pframe, _MME_IE_, 16, MME, &(pattrib->pktlen)); + pattrib->last_txcmdsz = pattrib->pktlen; + /* total frame length - header length */ + frame_body_len = pattrib->pktlen - sizeof(struct ieee80211_hdr_3addr); @@ -32872,29 +31557,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + /* copy right BIP mic value, total is 128bits, we use the 0~63 bits */ + memcpy(pframe-8, mic, 8); -+ } -+ else /* unicast mgmt frame TX */ -+ { ++ } else { /* unicast mgmt frame TX */ + /* start to encrypt mgmt frame */ + if (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC || -+ subtype == WIFI_REASSOCREQ || subtype == WIFI_ACTION) -+ { ++ subtype == WIFI_REASSOCREQ || subtype == WIFI_ACTION) { + if (pattrib->psta) + psta = pattrib->psta; + else -+ { + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); -+ } + -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + + DBG_871X("%s, psta ==NUL\n", __func__); + goto xmitframe_coalesce_fail; + } + -+ if (!(psta->state & _FW_LINKED) || pxmitframe->buf_addr == NULL) -+ { ++ if (!(psta->state & _FW_LINKED) || pxmitframe->buf_addr == NULL) { + DBG_871X("%s, not _FW_LINKED or addr null\n", __func__); + goto xmitframe_coalesce_fail; + } @@ -32909,7 +31587,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pframe[WLAN_HDR_A3_LEN] == RTW_WLAN_CATEGORY_P2P)) + goto xmitframe_coalesce_fail; + /* before encrypt dump the management packet content */ -+ if (pattrib->encrypt>0) ++ if (pattrib->encrypt > 0) + memcpy(pattrib->dot118021x_UncstKey.skey, psta->dot118021x_UncstKey.skey, 16); + /* bakeup original management packet */ + memcpy(tmp_buf, pframe, pattrib->pktlen); @@ -32921,14 +31599,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* it's MIC of AES */ + pattrib->icv_len = 8; + -+ switch (pattrib->encrypt) -+ { -+ case _AES_: -+ /* set AES IV header */ -+ AES_IV(pattrib->iv, psta->dot11wtxpn, 0); -+ break; -+ default: -+ goto xmitframe_coalesce_fail; ++ switch (pattrib->encrypt) { ++ case _AES_: ++ /* set AES IV header */ ++ AES_IV(pattrib->iv, psta->dot11wtxpn, 0); ++ break; ++ default: ++ goto xmitframe_coalesce_fail; + } + /* insert iv header into management frame */ + memcpy(pframe, pattrib->iv, pattrib->iv_len); @@ -32939,7 +31616,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pframe += pattrib->pktlen-pattrib->hdrlen; + /* add 8 bytes CCMP IV header to length */ + pattrib->pktlen += pattrib->iv_len; -+ if ((pattrib->icv_len >0) && (pattrib->bswenc)) { ++ if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { + memcpy(pframe, pattrib->icv, pattrib->icv_len); + pframe += pattrib->icv_len; + } @@ -33006,37 +31683,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + -+ switch (pxmitpriv->vcs_setting) -+ { -+ case DISABLE_VCS: ++ switch (pxmitpriv->vcs_setting) { ++ case DISABLE_VCS: ++ pxmitpriv->vcs = NONE_VCS; ++ break; ++ ++ case ENABLE_VCS: ++ break; ++ ++ case AUTO_VCS: ++ default: ++ perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); ++ if (perp == NULL) + pxmitpriv->vcs = NONE_VCS; -+ break; -+ -+ case ENABLE_VCS: -+ break; -+ -+ case AUTO_VCS: -+ default: -+ perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); -+ if (perp == NULL) -+ { -+ pxmitpriv->vcs = NONE_VCS; -+ } -+ else -+ { -+ protection = (*(perp + 2)) & BIT(1); -+ if (protection) -+ { -+ if (pregistrypriv->vcs_type == RTS_CTS) -+ pxmitpriv->vcs = RTS_CTS; -+ else -+ pxmitpriv->vcs = CTS_TO_SELF; -+ } ++ else{ ++ protection = (*(perp + 2)) & BIT(1); ++ if (protection) { ++ if (pregistrypriv->vcs_type == RTS_CTS) ++ pxmitpriv->vcs = RTS_CTS; + else -+ pxmitpriv->vcs = NONE_VCS; -+ } ++ pxmitpriv->vcs = CTS_TO_SELF; ++ } else ++ pxmitpriv->vcs = NONE_VCS; ++ } + -+ break; ++ break; + + } +} @@ -33049,8 +31720,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + u8 pkt_num = 1; + -+ if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) -+ { ++ if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) { + pkt_num = pxmitframe->agg_num; + + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod += pkt_num; @@ -33060,8 +31730,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pxmitpriv->tx_bytes += sz; + + psta = pxmitframe->attrib.psta; -+ if (psta) -+ { ++ if (psta) { + pstats = &psta->sta_stats; + + pstats->tx_pkts += pkt_num; @@ -33089,9 +31758,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); + } -+ } else { ++ } else + DBG_871X("%s fail, no xmitbuf available !!!\n", __func__); -+ } ++ + return pxmitbuf; +} + @@ -33101,13 +31770,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + struct xmit_frame *pcmdframe; + struct xmit_buf *pxmitbuf; + -+ if ((pcmdframe = rtw_alloc_xmitframe(pxmitpriv)) == NULL) -+ { ++ pcmdframe = rtw_alloc_xmitframe(pxmitpriv); ++ if (pcmdframe == NULL) { + DBG_871X("%s, alloc xmitframe fail\n", __func__); + return NULL; + } + -+ if ((pxmitbuf = __rtw_alloc_cmd_xmitbuf(pxmitpriv, buf_type)) == NULL) { ++ pxmitbuf = __rtw_alloc_cmd_xmitbuf(pxmitpriv, buf_type); ++ if (pxmitbuf == NULL) { + DBG_871X("%s, alloc xmitbuf fail\n", __func__); + rtw_free_xmitframe(pxmitpriv, pcmdframe); + return NULL; @@ -33147,8 +31817,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + list_del_init(&(pxmitbuf->list)); + } + -+ if (pxmitbuf != NULL) -+ { ++ if (pxmitbuf != NULL) { + pxmitpriv->free_xmit_extbuf_cnt--; + #ifdef DBG_XMIT_BUF_EXT + DBG_871X("DBG_XMIT_BUF_EXT ALLOC no =%d, free_xmit_extbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt); @@ -33179,9 +31848,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; + + if (pxmitbuf == NULL) -+ { + return _FAIL; -+ } + + spin_lock_irqsave(&pfree_queue->lock, irqL); + @@ -33190,7 +31857,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + list_add_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); + pxmitpriv->free_xmit_extbuf_cnt++; + #ifdef DBG_XMIT_BUF_EXT -+ DBG_871X("DBG_XMIT_BUF_EXT FREE no =%d, free_xmit_extbuf_cnt =%d\n", pxmitbuf->no , pxmitpriv->free_xmit_extbuf_cnt); ++ DBG_871X("DBG_XMIT_BUF_EXT FREE no =%d, free_xmit_extbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt); + #endif + + spin_unlock_irqrestore(&pfree_queue->lock, irqL); @@ -33222,8 +31889,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + list_del_init(&(pxmitbuf->list)); + } + -+ if (pxmitbuf != NULL) -+ { ++ if (pxmitbuf != NULL) { + pxmitpriv->free_xmitbuf_cnt--; + #ifdef DBG_XMIT_BUF + DBG_871X("DBG_XMIT_BUF ALLOC no =%d, free_xmitbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmitbuf_cnt); @@ -33244,9 +31910,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + #ifdef DBG_XMIT_BUF + else -+ { + DBG_871X("DBG_XMIT_BUF rtw_alloc_xmitbuf return NULL\n"); -+ } + #endif + + spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irqL); @@ -33262,9 +31926,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* DBG_871X("+rtw_free_xmitbuf\n"); */ + + if (pxmitbuf == NULL) -+ { + return _FAIL; -+ } + + if (pxmitbuf->sctx) { + DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__); @@ -33272,12 +31934,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + + if (pxmitbuf->buf_tag == XMITBUF_CMD) { -+ } -+ else if (pxmitbuf->buf_tag == XMITBUF_MGNT) { ++ } else if (pxmitbuf->buf_tag == XMITBUF_MGNT) { + rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf); -+ } -+ else -+ { ++ } else{ + spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irqL); + + list_del_init(&pxmitbuf->list); @@ -33287,7 +31946,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pxmitpriv->free_xmitbuf_cnt++; + /* DBG_871X("FREE, free_xmitbuf_cnt =%d\n", pxmitpriv->free_xmitbuf_cnt); */ + #ifdef DBG_XMIT_BUF -+ DBG_871X("DBG_XMIT_BUF FREE no =%d, free_xmitbuf_cnt =%d\n", pxmitbuf->no , pxmitpriv->free_xmitbuf_cnt); ++ DBG_871X("DBG_XMIT_BUF FREE no =%d, free_xmitbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmitbuf_cnt); + #endif + spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irqL); + } @@ -33296,8 +31955,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + +static void rtw_init_xmitframe(struct xmit_frame *pxframe) +{ -+ if (pxframe != NULL)/* default value setting */ -+ { ++ if (pxframe != NULL) { /* default value setting */ + pxframe->buf_addr = NULL; + pxframe->pxmitbuf = NULL; + @@ -33441,8 +32099,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + queue = &pxmitpriv->free_xmit_queue; + else if (pxmitframe->ext_tag == 1) + queue = &pxmitpriv->free_xframe_ext_queue; -+ else -+ {} ++ else { ++ ++ } + + spin_lock_bh(&queue->lock); + @@ -33478,8 +32137,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + phead = get_list_head(pframequeue); + plist = get_next(phead); + -+ while (phead != plist) -+ { ++ while (phead != plist) { + + pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + @@ -33494,8 +32152,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp +s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + DBG_COUNTER(padapter->tx_logs.core_tx_enqueue); -+ if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) -+ { ++ if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("rtw_xmitframe_enqueue: drop xmit pkt for classifier fail\n")); +/* pxmitframe->pkt = NULL; */ @@ -33509,37 +32166,36 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp +{ + struct tx_servq *ptxservq = NULL; + -+ switch (up) -+ { -+ case 1: -+ case 2: -+ ptxservq = &(psta->sta_xmitpriv.bk_q); -+ *(ac) = 3; -+ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n")); -+ break; -+ -+ case 4: -+ case 5: -+ ptxservq = &(psta->sta_xmitpriv.vi_q); -+ *(ac) = 1; -+ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n")); -+ break; -+ -+ case 6: -+ case 7: -+ ptxservq = &(psta->sta_xmitpriv.vo_q); -+ *(ac) = 0; -+ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n")); -+ break; -+ -+ case 0: -+ case 3: -+ default: -+ ptxservq = &(psta->sta_xmitpriv.be_q); -+ *(ac) = 2; -+ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); ++ switch (up) { ++ case 1: ++ case 2: ++ ptxservq = &(psta->sta_xmitpriv.bk_q); ++ *(ac) = 3; ++ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n")); + break; + ++ case 4: ++ case 5: ++ ptxservq = &(psta->sta_xmitpriv.vi_q); ++ *(ac) = 1; ++ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n")); ++ break; ++ ++ case 6: ++ case 7: ++ ptxservq = &(psta->sta_xmitpriv.vo_q); ++ *(ac) = 0; ++ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n")); ++ break; ++ ++ case 0: ++ case 3: ++ default: ++ ptxservq = &(psta->sta_xmitpriv.be_q); ++ *(ac) = 2; ++ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); ++ break; ++ + } + + return ptxservq; @@ -33571,8 +32227,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp +*/ + + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); -+ if (pattrib->psta != psta) -+ { ++ if (pattrib->psta != psta) { + DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class_err_sta); + DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta); + return _FAIL; @@ -33586,8 +32241,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + goto exit; + } + -+ if (!(psta->state &_FW_LINKED)) -+ { ++ if (!(psta->state & _FW_LINKED)) { + DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class_err_fwlink); + DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + return _FAIL; @@ -33625,18 +32279,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + pxmitpriv->hwxmits = NULL; + -+ pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof (struct hw_xmit) * pxmitpriv->hwxmit_entry); ++ pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); + -+ if (pxmitpriv->hwxmits == NULL) -+ { ++ if (pxmitpriv->hwxmits == NULL) { + DBG_871X("alloc hwxmits fail!...\n"); + return; + } + + hwxmits = pxmitpriv->hwxmits; + -+ if (pxmitpriv->hwxmit_entry == 5) -+ { ++ if (pxmitpriv->hwxmit_entry == 5) { + /* pxmitpriv->bmc_txqueue.head = 0; */ + /* hwxmits[0] .phwtxqueue = &pxmitpriv->bmc_txqueue; */ + hwxmits[0] .sta_queue = &pxmitpriv->bm_pending; @@ -33657,9 +32309,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* hwxmits[4] .phwtxqueue = &pxmitpriv->be_txqueue; */ + hwxmits[4] .sta_queue = &pxmitpriv->be_pending; + -+ } -+ else if (pxmitpriv->hwxmit_entry == 4) -+ { ++ } else if (pxmitpriv->hwxmit_entry == 4) { + + /* pxmitpriv->vo_txqueue.head = 0; */ + /* hwxmits[0] .phwtxqueue = &pxmitpriv->vo_txqueue; */ @@ -33676,10 +32326,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* pxmitpriv->bk_txqueue.head = 0; */ + /* hwxmits[3] .phwtxqueue = &pxmitpriv->bk_txqueue; */ + hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; -+ } -+ else -+ { -+ ++ } else { + + } + @@ -33699,9 +32346,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp +void rtw_init_hwxmits(struct hw_xmit *phwxmit, sint entry) +{ + sint i; -+ -+ for (i = 0; i < entry; i++, phwxmit++) -+ { ++ ++ for (i = 0; i < entry; i++, phwxmit++) { + /* spin_lock_init(&phwxmit->xmit_lock); */ + /* INIT_LIST_HEAD(&phwxmit->pending); */ + /* phwxmit->txcmdcnt = 0; */ @@ -33714,34 +32360,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + u32 addr; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + -+ switch (pattrib->qsel) -+ { -+ case 0: -+ case 3: -+ addr = BE_QUEUE_INX; -+ break; -+ case 1: -+ case 2: -+ addr = BK_QUEUE_INX; -+ break; -+ case 4: -+ case 5: -+ addr = VI_QUEUE_INX; -+ break; -+ case 6: -+ case 7: -+ addr = VO_QUEUE_INX; -+ break; -+ case 0x10: -+ addr = BCN_QUEUE_INX; -+ break; -+ case 0x11:/* BC/MC in PS (HIQ) */ -+ addr = HIGH_QUEUE_INX; -+ break; -+ case 0x12: -+ default: -+ addr = MGT_QUEUE_INX; -+ break; ++ switch (pattrib->qsel) { ++ case 0: ++ case 3: ++ addr = BE_QUEUE_INX; ++ break; ++ case 1: ++ case 2: ++ addr = BK_QUEUE_INX; ++ break; ++ case 4: ++ case 5: ++ addr = VI_QUEUE_INX; ++ break; ++ case 6: ++ case 7: ++ addr = VO_QUEUE_INX; ++ break; ++ case 0x10: ++ addr = BCN_QUEUE_INX; ++ break; ++ case 0x11:/* BC/MC in PS (HIQ) */ ++ addr = HIGH_QUEUE_INX; ++ break; ++ case 0x12: ++ default: ++ addr = MGT_QUEUE_INX; ++ break; + + } + @@ -33754,7 +32399,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + u8 qsel; + + qsel = pattrib->priority; -+ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("### do_queue_select priority =%d , qsel = %d\n", pattrib->priority , qsel)); ++ RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("### do_queue_select priority =%d , qsel = %d\n", pattrib->priority, qsel)); + + pattrib->qsel = qsel; +} @@ -33792,7 +32437,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + + if (pxmitframe == NULL) { -+ drop_cnt ++; ++ drop_cnt++; + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: no more pxmitframe\n")); + DBG_COUNTER(padapter->tx_logs.core_tx_err_pxmitframe); + return -1; @@ -33813,8 +32458,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + do_queue_select(padapter, &pxmitframe->attrib); + + spin_lock_bh(&pxmitpriv->lock); -+ if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe) == true) -+ { ++ if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe) == true) { + spin_unlock_bh(&pxmitpriv->lock); + DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue); + return 1; @@ -33850,22 +32494,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + , attrib->ether_type, attrib->dhcp_pkt?" DHCP":""); + allow = true; + } -+ } -+ else if (registry->hiq_filter == RTW_HIQ_FILTER_ALLOW_ALL) { ++ } else if (registry->hiq_filter == RTW_HIQ_FILTER_ALLOW_ALL) + allow = true; -+ } + else if (registry->hiq_filter == RTW_HIQ_FILTER_DENY_ALL) { -+ } -+ else { ++ } else + rtw_warn_on(1); -+ } + + return allow; +} + +sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ -+ sint ret =false; ++ sint ret = false; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; @@ -33873,8 +32513,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + sint bmcst = IS_MCAST(pattrib->ra); + bool update_tim = false; + -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false) { + DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_fwstate); + return ret; + } @@ -33890,29 +32529,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } +*/ + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); -+ if (pattrib->psta != psta) -+ { ++ if (pattrib->psta != psta) { + DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_sta); + DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta); + return false; + } + -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_nosta); + DBG_871X("%s, psta ==NUL\n", __func__); + return false; + } + -+ if (!(psta->state &_FW_LINKED)) -+ { ++ if (!(psta->state & _FW_LINKED)) { + DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_link); + DBG_871X("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + return false; + } + -+ if (pattrib->triggered == 1) -+ { ++ if (pattrib->triggered == 1) { + DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_trigger); + /* DBG_871X("directly xmit pspoll_triggered packet\n"); */ + @@ -33924,12 +32559,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + } + + -+ if (bmcst) -+ { ++ if (bmcst) { + spin_lock_bh(&psta->sleep_q.lock); + -+ if (pstapriv->sta_dz_bitmap)/* if anyone sta is in ps mode */ -+ { ++ if (pstapriv->sta_dz_bitmap) { /* if anyone sta is in ps mode */ + /* pattrib->qsel = 0x11;HIQ */ + + list_del_init(&pxmitframe->list); @@ -33971,12 +32604,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + spin_lock_bh(&psta->sleep_q.lock); + -+ if (psta->state&WIFI_SLEEP_STATE) -+ { ++ if (psta->state&WIFI_SLEEP_STATE) { + u8 wmmps_ac = 0; + -+ if (pstapriv->sta_dz_bitmap&BIT(psta->aid)) -+ { ++ if (pstapriv->sta_dz_bitmap & BIT(psta->aid)) { + list_del_init(&pxmitframe->list); + + /* spin_lock_bh(&psta->sleep_q.lock); */ @@ -33985,32 +32616,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + psta->sleepq_len++; + -+ switch (pattrib->priority) -+ { -+ case 1: -+ case 2: -+ wmmps_ac = psta->uapsd_bk&BIT(0); -+ break; -+ case 4: -+ case 5: -+ wmmps_ac = psta->uapsd_vi&BIT(0); -+ break; -+ case 6: -+ case 7: -+ wmmps_ac = psta->uapsd_vo&BIT(0); -+ break; -+ case 0: -+ case 3: -+ default: -+ wmmps_ac = psta->uapsd_be&BIT(0); -+ break; ++ switch (pattrib->priority) { ++ case 1: ++ case 2: ++ wmmps_ac = psta->uapsd_bk&BIT(0); ++ break; ++ case 4: ++ case 5: ++ wmmps_ac = psta->uapsd_vi&BIT(0); ++ break; ++ case 6: ++ case 7: ++ wmmps_ac = psta->uapsd_vo&BIT(0); ++ break; ++ case 0: ++ case 3: ++ default: ++ wmmps_ac = psta->uapsd_be&BIT(0); ++ break; + } + + if (wmmps_ac) + psta->sleepq_ac_len++; + -+ if (((psta->has_legacy_ac) && (!wmmps_ac)) ||((!psta->has_legacy_ac) && (wmmps_ac))) -+ { ++ if (((psta->has_legacy_ac) && (!wmmps_ac)) || ((!psta->has_legacy_ac) && (wmmps_ac))) { + if (!(pstapriv->tim_bitmap & BIT(psta->aid))) + update_tim = true; + @@ -34019,11 +32648,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + /* DBG_871X("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */ + + if (update_tim == true) -+ { + /* DBG_871X("sleepq_len == 1, update BCNTIM\n"); */ + /* upate BCN for TIM IE */ + update_beacon(padapter, _TIM_IE_, NULL, true); -+ } + } + + /* spin_unlock_bh(&psta->sleep_q.lock); */ @@ -34059,8 +32686,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + phead = get_list_head(pframequeue); + plist = get_next(phead); + -+ while (phead != plist) -+ { ++ while (phead != plist) { + pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + + plist = get_next(plist); @@ -34071,15 +32697,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + ret = xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe); + -+ if (true == ret) -+ { ++ if (true == ret) { + ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); + + ptxservq->qcnt--; + phwxmits[ac_index].accnt--; -+ } -+ else -+ { ++ } else { + /* DBG_871X("xmitframe_enqueue_for_sleeping_sta return false\n"); */ + } + @@ -34149,51 +32772,45 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + -+ while (xmitframe_phead != xmitframe_plist) -+ { ++ while (xmitframe_phead != xmitframe_plist) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); + + list_del_init(&pxmitframe->list); + -+ switch (pxmitframe->attrib.priority) -+ { -+ case 1: -+ case 2: -+ wmmps_ac = psta->uapsd_bk&BIT(1); -+ break; -+ case 4: -+ case 5: -+ wmmps_ac = psta->uapsd_vi&BIT(1); -+ break; -+ case 6: -+ case 7: -+ wmmps_ac = psta->uapsd_vo&BIT(1); -+ break; -+ case 0: -+ case 3: -+ default: -+ wmmps_ac = psta->uapsd_be&BIT(1); -+ break; ++ switch (pxmitframe->attrib.priority) { ++ case 1: ++ case 2: ++ wmmps_ac = psta->uapsd_bk&BIT(1); ++ break; ++ case 4: ++ case 5: ++ wmmps_ac = psta->uapsd_vi&BIT(1); ++ break; ++ case 6: ++ case 7: ++ wmmps_ac = psta->uapsd_vo&BIT(1); ++ break; ++ case 0: ++ case 3: ++ default: ++ wmmps_ac = psta->uapsd_be&BIT(1); ++ break; + } + + psta->sleepq_len--; -+ if (psta->sleepq_len>0) ++ if (psta->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + -+ if (wmmps_ac) -+ { ++ if (wmmps_ac) { + psta->sleepq_ac_len--; -+ if (psta->sleepq_ac_len>0) -+ { ++ if (psta->sleepq_ac_len > 0) { + pxmitframe->attrib.mdata = 1; + pxmitframe->attrib.eosp = 0; -+ } -+ else -+ { ++ } else{ + pxmitframe->attrib.mdata = 0; + pxmitframe->attrib.eosp = 1; + } @@ -34214,8 +32831,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + } + -+ if (psta->sleepq_len == 0) -+ { ++ if (psta->sleepq_len == 0) { + if (pstapriv->tim_bitmap & BIT(psta->aid)) { + /* DBG_871X("wakeup to xmit, qlen == 0, update_BCNTIM, tim =%x\n", pstapriv->tim_bitmap); */ + /* upate BCN for TIM IE */ @@ -34228,8 +32844,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + if (psta->state&WIFI_SLEEP_STATE) + psta->state ^= WIFI_SLEEP_STATE; + -+ if (psta->state & WIFI_STA_ALIVE_CHK_STATE) -+ { ++ if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { + DBG_871X("%s alive check\n", __func__); + psta->expire_to = pstapriv->expire_to; + psta->state ^= WIFI_STA_ALIVE_CHK_STATE; @@ -34242,13 +32857,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + if (!psta_bmc) + goto _exit; + -+ if ((pstapriv->sta_dz_bitmap&0xfffe) == 0x0)/* no any sta in ps mode */ -+ { ++ if ((pstapriv->sta_dz_bitmap&0xfffe) == 0x0) { /* no any sta in ps mode */ + xmitframe_phead = get_list_head(&psta_bmc->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + -+ while (xmitframe_phead != xmitframe_plist) -+ { ++ while (xmitframe_phead != xmitframe_plist) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); @@ -34256,7 +32869,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + list_del_init(&pxmitframe->list); + + psta_bmc->sleepq_len--; -+ if (psta_bmc->sleepq_len>0) ++ if (psta_bmc->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; @@ -34276,8 +32889,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + } + -+ if (psta_bmc->sleepq_len == 0) -+ { ++ if (psta_bmc->sleepq_len == 0) { + if (pstapriv->tim_bitmap & BIT(0)) { + /* DBG_871X("wakeup to xmit, qlen == 0, update_BCNTIM, tim =%x\n", pstapriv->tim_bitmap); */ + /* upate BCN for TIM IE */ @@ -34296,11 +32908,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + spin_unlock_bh(&pxmitpriv->lock); + + if (update_mask) -+ { + /* update_BCNTIM(padapter); */ + /* printk("%s => call update_beacon\n", __func__); */ + update_beacon(padapter, _TIM_IE_, NULL, true); -+ } + +} + @@ -34319,31 +32929,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + -+ while (xmitframe_phead != xmitframe_plist) -+ { ++ while (xmitframe_phead != xmitframe_plist) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); + -+ switch (pxmitframe->attrib.priority) -+ { -+ case 1: -+ case 2: -+ wmmps_ac = psta->uapsd_bk&BIT(1); -+ break; -+ case 4: -+ case 5: -+ wmmps_ac = psta->uapsd_vi&BIT(1); -+ break; -+ case 6: -+ case 7: -+ wmmps_ac = psta->uapsd_vo&BIT(1); -+ break; -+ case 0: -+ case 3: -+ default: -+ wmmps_ac = psta->uapsd_be&BIT(1); -+ break; ++ switch (pxmitframe->attrib.priority) { ++ case 1: ++ case 2: ++ wmmps_ac = psta->uapsd_bk&BIT(1); ++ break; ++ case 4: ++ case 5: ++ wmmps_ac = psta->uapsd_vi&BIT(1); ++ break; ++ case 6: ++ case 7: ++ wmmps_ac = psta->uapsd_vo&BIT(1); ++ break; ++ case 0: ++ case 3: ++ default: ++ wmmps_ac = psta->uapsd_be&BIT(1); ++ break; + } + + if (!wmmps_ac) @@ -34354,13 +32962,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + psta->sleepq_len--; + psta->sleepq_ac_len--; + -+ if (psta->sleepq_ac_len>0) -+ { ++ if (psta->sleepq_ac_len > 0) { + pxmitframe->attrib.mdata = 1; + pxmitframe->attrib.eosp = 0; -+ } -+ else -+ { ++ } else{ + pxmitframe->attrib.mdata = 0; + pxmitframe->attrib.eosp = 1; + } @@ -34368,8 +32973,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + pxmitframe->attrib.triggered = 1; + rtw_hal_xmitframe_enqueue(padapter, pxmitframe); + -+ if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) -+ { ++ if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + /* DBG_871X("wakeup to xmit, qlen == 0, update_BCNTIM, tim =%x\n", pstapriv->tim_bitmap); */ @@ -34418,7 +33022,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + spin_unlock_bh(&pqueue->lock); +} + -+struct xmit_buf* dequeue_pending_xmitbuf( ++struct xmit_buf *dequeue_pending_xmitbuf( + struct xmit_priv *pxmitpriv) +{ + struct xmit_buf *pxmitbuf; @@ -34430,8 +33034,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + spin_lock_bh(&pqueue->lock); + -+ if (!list_empty(&pqueue->queue)) -+ { ++ if (!list_empty(&pqueue->queue)) { + struct list_head *plist, *phead; + + phead = get_list_head(pqueue); @@ -34445,7 +33048,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + return pxmitbuf; +} + -+struct xmit_buf* dequeue_pending_xmitbuf_under_survey( ++struct xmit_buf *dequeue_pending_xmitbuf_under_survey( + struct xmit_priv *pxmitpriv) +{ + struct xmit_buf *pxmitbuf; @@ -34457,8 +33060,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + spin_lock_bh(&pqueue->lock); + -+ if (!list_empty(&pqueue->queue)) -+ { ++ if (!list_empty(&pqueue->queue)) { + struct list_head *plist, *phead; + u8 type; + @@ -34466,7 +33068,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + plist = phead; + do { + plist = get_next(plist); -+ if (plist == phead) break; ++ if (plist == phead) ++ break; + + pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + @@ -34474,8 +33077,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + + if ((type == WIFI_PROBEREQ) || + (type == WIFI_DATA_NULL) || -+ (type == WIFI_QOS_DATA_NULL)) -+ { ++ (type == WIFI_QOS_DATA_NULL)) { + list_del_init(&pxmitbuf->list); + break; + } @@ -34609,10 +33211,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/core/rtw_xmit.c linux-4.3-rtl8723bs/3rdp + DBG_871X("%s ack_tx not set\n", __func__); + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c ---- linux-4.3/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,115 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c linux/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c +--- linux.old/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,138 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -34628,109 +33230,132 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/Hal8723BPwrSeq.c linux-4.3-rtl8723bs + * + ******************************************************************************/ + -+/*++ -+ This file includes all kinds of Power Action event for RTL8723B and corresponding hardware configurtions which are released from HW SD. ++/* ++* ++This file includes all kinds of Power Action event for RTL8723B ++and corresponding hardware configurtions which are released from HW SD. + +Major Change History: + When Who What + ---------- --------------- ------------------------------- + 2011-08-08 Roger Create. + -+--*/ ++*/ + +#include "Hal8723BPwrSeq.h" + -+/* -+ drivers should parse below arrays and do the corresponding actions -+*/ ++/* drivers should parse below arrays and do the corresponding actions */ +/* 3 Power on Array */ -+WLAN_PWR_CFG rtl8723B_power_on_flow[RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_power_on_flow[ ++ RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS+ ++ RTL8723B_TRANS_END_STEPS ++] = { + RTL8723B_TRANS_CARDEMU_TO_ACT + RTL8723B_TRANS_END +}; + +/* 3Radio off GPIO Array */ -+WLAN_PWR_CFG rtl8723B_radio_off_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_radio_off_flow[ ++ RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+ ++ RTL8723B_TRANS_END_STEPS ++] = { + RTL8723B_TRANS_ACT_TO_CARDEMU + RTL8723B_TRANS_END +}; + +/* 3Card Disable Array */ -+WLAN_PWR_CFG rtl8723B_card_disable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_card_disable_flow[ ++ RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+ ++ RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+ ++ RTL8723B_TRANS_END_STEPS ++] = { + RTL8723B_TRANS_ACT_TO_CARDEMU + RTL8723B_TRANS_CARDEMU_TO_CARDDIS + RTL8723B_TRANS_END +}; + +/* 3 Card Enable Array */ -+WLAN_PWR_CFG rtl8723B_card_enable_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_card_enable_flow[ ++ RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+ ++ RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+ ++ RTL8723B_TRANS_END_STEPS ++] = { + RTL8723B_TRANS_CARDDIS_TO_CARDEMU + RTL8723B_TRANS_CARDEMU_TO_ACT + RTL8723B_TRANS_END +}; + +/* 3Suspend Array */ -+WLAN_PWR_CFG rtl8723B_suspend_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_suspend_flow[ ++ RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+ ++ RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+ ++ RTL8723B_TRANS_END_STEPS ++] = { + RTL8723B_TRANS_ACT_TO_CARDEMU + RTL8723B_TRANS_CARDEMU_TO_SUS + RTL8723B_TRANS_END +}; + +/* 3 Resume Array */ -+WLAN_PWR_CFG rtl8723B_resume_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_resume_flow[ ++ RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+ ++ RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS+ ++ RTL8723B_TRANS_END_STEPS ++] = { + RTL8723B_TRANS_SUS_TO_CARDEMU + RTL8723B_TRANS_CARDEMU_TO_ACT + RTL8723B_TRANS_END +}; + +/* 3HWPDN Array */ -+WLAN_PWR_CFG rtl8723B_hwpdn_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_hwpdn_flow[ ++ RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS+ ++ RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS+ ++ RTL8723B_TRANS_END_STEPS ++] = { + RTL8723B_TRANS_ACT_TO_CARDEMU + RTL8723B_TRANS_CARDEMU_TO_PDN + RTL8723B_TRANS_END +}; + +/* 3 Enter LPS */ -+WLAN_PWR_CFG rtl8723B_enter_lps_flow[RTL8723B_TRANS_ACT_TO_LPS_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_enter_lps_flow[ ++ RTL8723B_TRANS_ACT_TO_LPS_STEPS+RTL8723B_TRANS_END_STEPS ++] = { + /* FW behavior */ + RTL8723B_TRANS_ACT_TO_LPS + RTL8723B_TRANS_END +}; + +/* 3 Leave LPS */ -+WLAN_PWR_CFG rtl8723B_leave_lps_flow[RTL8723B_TRANS_LPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_leave_lps_flow[ ++ RTL8723B_TRANS_LPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS ++] = { + /* FW behavior */ + RTL8723B_TRANS_LPS_TO_ACT + RTL8723B_TRANS_END +}; + +/* 3 Enter SW LPS */ -+WLAN_PWR_CFG rtl8723B_enter_swlps_flow[RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_enter_swlps_flow[ ++ RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS ++] = { + /* SW behavior */ + RTL8723B_TRANS_ACT_TO_SWLPS + RTL8723B_TRANS_END +}; + +/* 3 Leave SW LPS */ -+WLAN_PWR_CFG rtl8723B_leave_swlps_flow[RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS]= -+{ ++WLAN_PWR_CFG rtl8723B_leave_swlps_flow[ ++ RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS ++] = { + /* SW behavior */ + RTL8723B_TRANS_SWLPS_TO_ACT + RTL8723B_TRANS_END +}; -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/Hal8723BReg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/Hal8723BReg.h ---- linux-4.3/3rdparty/rtl8723bs/hal/Hal8723BReg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/Hal8723BReg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/Hal8723BReg.h linux/3rdparty/rtl8723bs/hal/Hal8723BReg.h +--- linux.old/3rdparty/rtl8723bs/hal/Hal8723BReg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/Hal8723BReg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,442 @@ +/***************************************************************************** + *Copyright(c) 2009, RealTEK Technology Inc. All Right Reserved. @@ -35174,10 +33799,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/Hal8723BReg.h linux-4.3-rtl8723bs/3r +#define RCR_TCPOFLD_EN BIT25 /* Enable TCP checksum offload */ + +#endif /* #ifndef __INC_HAL8723BREG_H */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c ---- linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,3547 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c +--- linux.old/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,3779 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -35196,116 +33821,139 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b +#include "Mp_Precomp.h" + +/* Global variables, these are static variables */ -+static COEX_DM_8723B_1ANT GLCoexDm8723b1Ant; -+static PCOEX_DM_8723B_1ANT pCoexDm =&GLCoexDm8723b1Ant; -+static COEX_STA_8723B_1ANT GLCoexSta8723b1Ant; -+static PCOEX_STA_8723B_1ANT pCoexSta =&GLCoexSta8723b1Ant; ++static COEX_DM_8723B_1ANT GLCoexDm8723b1Ant; ++static PCOEX_DM_8723B_1ANT pCoexDm = &GLCoexDm8723b1Ant; ++static COEX_STA_8723B_1ANT GLCoexSta8723b1Ant; ++static PCOEX_STA_8723B_1ANT pCoexSta = &GLCoexSta8723b1Ant; + -+static const char *const GLBtInfoSrc8723b1Ant[]={ ++static const char *const GLBtInfoSrc8723b1Ant[] = { + "BT Info[wifi fw]", + "BT Info[bt rsp]", + "BT Info[bt auto report]", +}; + -+static u32 GLCoexVerDate8723b1Ant =20140507; ++static u32 GLCoexVerDate8723b1Ant = 20140507; +static u32 GLCoexVer8723b1Ant = 0x4e; + +/* local function proto type if needed */ +/* local function start with halbtc8723b1ant_ */ -+static u8 -+halbtc8723b1ant_BtRssiState( -+ u8 levelNum, -+ u8 rssiThresh, -+ u8 rssiThresh1 -+ ) ++static u8 halbtc8723b1ant_BtRssiState( ++ u8 levelNum, u8 rssiThresh, u8 rssiThresh1 ++) +{ -+ s32 btRssi = 0; -+ u8 btRssiState =pCoexSta->preBtRssiState; ++ s32 btRssi = 0; ++ u8 btRssiState = pCoexSta->preBtRssiState; + + btRssi = pCoexSta->btRssi; + -+ if (levelNum == 2) -+ { -+ if ((pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || -+ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) -+ { -+ if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) -+ { ++ if (levelNum == 2) { ++ if ( ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW) ++ ) { ++ if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) { ++ + btRssiState = BTC_RSSI_STATE_HIGH; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n")); -+ } -+ else -+ { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state switch to High\n") ++ ); ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_LOW; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state stay at Low\n") ++ ); + } -+ } -+ else -+ { -+ if (btRssi < rssiThresh) -+ { ++ } else { ++ if (btRssi < rssiThresh) { + btRssiState = BTC_RSSI_STATE_LOW; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n")); -+ } -+ else -+ { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state switch to Low\n") ++ ); ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_HIGH; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state stay at High\n") ++ ); + } + } -+ } -+ else if (levelNum == 3) -+ { -+ if (rssiThresh > rssiThresh1) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n")); ++ } else if (levelNum == 3) { ++ if (rssiThresh > rssiThresh1) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi thresh error!!\n") ++ ); + return pCoexSta->preBtRssiState; + } + -+ if ((pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || -+ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) -+ { -+ if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) -+ { ++ if ( ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW) ++ ) { ++ if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) { + btRssiState = BTC_RSSI_STATE_MEDIUM; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n")); -+ } -+ else -+ { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state switch to Medium\n") ++ ); ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_LOW; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state stay at Low\n") ++ ); + } -+ } -+ else if ((pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || -+ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) -+ { -+ if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) -+ { ++ } else if ( ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM) ++ ) { ++ if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) { + btRssiState = BTC_RSSI_STATE_HIGH; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n")); -+ } -+ else if (btRssi < rssiThresh) -+ { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state switch to High\n") ++ ); ++ } else if (btRssi < rssiThresh) { + btRssiState = BTC_RSSI_STATE_LOW; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n")); -+ } -+ else -+ { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state switch to Low\n") ++ ); ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state stay at Medium\n") ++ ); + } -+ } -+ else -+ { -+ if (btRssi < rssiThresh1) -+ { ++ } else { ++ if (btRssi < rssiThresh1) { + btRssiState = BTC_RSSI_STATE_MEDIUM; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n")); -+ } -+ else -+ { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state switch to Medium\n") ++ ); ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_HIGH; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_RSSI_STATE, ++ ("[BTCoex], BT Rssi state stay at High\n") ++ ); + } + } + } @@ -35315,139 +33963,133 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + return btRssiState; +} + -+static void -+halbtc8723b1ant_UpdateRaMask( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u32 disRateMask -+ ) ++static void halbtc8723b1ant_UpdateRaMask( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u32 disRateMask ++) +{ + pCoexDm->curRaMask = disRateMask; + + if (bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) -+ { -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); -+ } ++ pBtCoexist->fBtcSet( ++ pBtCoexist, ++ BTC_SET_ACT_UPDATE_RAMASK, ++ &pCoexDm->curRaMask ++ ); + pCoexDm->preRaMask = pCoexDm->curRaMask; +} + -+static void -+halbtc8723b1ant_AutoRateFallbackRetry( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 type -+ ) ++static void halbtc8723b1ant_AutoRateFallbackRetry( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type ++) +{ -+ bool bWifiUnderBMode =false; ++ bool bWifiUnderBMode = false; + + pCoexDm->curArfrType = type; + -+ if (bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) -+ { -+ switch (pCoexDm->curArfrType) -+ { -+ case 0: /* normal mode */ -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); -+ break; -+ case 1: -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); -+ if (bWifiUnderBMode) -+ { -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); -+ } -+ else -+ { -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); -+ } -+ break; -+ default: -+ break; ++ if (bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) { ++ switch (pCoexDm->curArfrType) { ++ case 0: /* normal mode */ ++ pBtCoexist->fBtcWrite4Byte( ++ pBtCoexist, 0x430, pCoexDm->backupArfrCnt1 ++ ); ++ pBtCoexist->fBtcWrite4Byte( ++ pBtCoexist, 0x434, pCoexDm->backupArfrCnt2 ++ ); ++ break; ++ case 1: ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode ++ ); ++ if (bWifiUnderBMode) { ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); ++ } else { ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); ++ } ++ break; ++ default: ++ break; + } + } + + pCoexDm->preArfrType = pCoexDm->curArfrType; +} + -+static void -+halbtc8723b1ant_RetryLimit( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 type -+ ) ++static void halbtc8723b1ant_RetryLimit( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type ++) +{ + pCoexDm->curRetryLimitType = type; + -+ if (bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) -+ { -+ switch (pCoexDm->curRetryLimitType) -+ { -+ case 0: /* normal mode */ -+ pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); -+ break; -+ case 1: /* retry limit =8 */ -+ pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); -+ break; -+ default: -+ break; ++ if ( ++ bForceExec || ++ (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType) ++ ) { ++ switch (pCoexDm->curRetryLimitType) { ++ case 0: /* normal mode */ ++ pBtCoexist->fBtcWrite2Byte( ++ pBtCoexist, 0x42a, pCoexDm->backupRetryLimit ++ ); ++ break; ++ case 1: /* retry limit =8 */ ++ pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); ++ break; ++ default: ++ break; + } + } + + pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; +} + -+static void -+halbtc8723b1ant_AmpduMaxTime( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 type -+ ) ++static void halbtc8723b1ant_AmpduMaxTime( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type ++) +{ + pCoexDm->curAmpduTimeType = type; + -+ if (bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) -+ { -+ switch (pCoexDm->curAmpduTimeType) -+ { -+ case 0: /* normal mode */ -+ pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); -+ break; -+ case 1: /* AMPDU timw = 0x38 * 32us */ -+ pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); -+ break; -+ default: -+ break; ++ if ( ++ bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType) ++ ) { ++ switch (pCoexDm->curAmpduTimeType) { ++ case 0: /* normal mode */ ++ pBtCoexist->fBtcWrite1Byte( ++ pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime ++ ); ++ break; ++ case 1: /* AMPDU timw = 0x38 * 32us */ ++ pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); ++ break; ++ default: ++ break; + } + } + + pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; +} + -+static void -+halbtc8723b1ant_LimitedTx( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 raMaskType, -+u8 arfrType, -+u8 retryLimitType, -+u8 ampduTimeType -+ ) ++static void halbtc8723b1ant_LimitedTx( ++ PBTC_COEXIST pBtCoexist, ++ bool bForceExec, ++ u8 raMaskType, ++ u8 arfrType, ++ u8 retryLimitType, ++ u8 ampduTimeType ++) +{ -+ switch (raMaskType) -+ { -+ case 0: /* normal mode */ -+ halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0); -+ break; -+ case 1: /* disable cck 1/2 */ -+ halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003); -+ break; -+ case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */ -+ halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7); -+ break; -+ default: -+ break; ++ switch (raMaskType) { ++ case 0: /* normal mode */ ++ halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0); ++ break; ++ case 1: /* disable cck 1/2 */ ++ halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003); ++ break; ++ case 2: /* disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 */ ++ halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7); ++ break; ++ default: ++ break; + } + + halbtc8723b1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); @@ -35455,25 +34097,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + halbtc8723b1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); +} + -+static void -+halbtc8723b1ant_LimitedRx( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bRejApAggPkt, -+bool bBtCtrlAggBufSize, -+u8 aggBufSize -+ ) ++static void halbtc8723b1ant_LimitedRx( ++ PBTC_COEXIST pBtCoexist, ++ bool bForceExec, ++ bool bRejApAggPkt, ++ bool bBtCtrlAggBufSize, ++ u8 aggBufSize ++) +{ -+ bool bRejectRxAgg =bRejApAggPkt; -+ bool bBtCtrlRxAggSize =bBtCtrlAggBufSize; -+ u8 rxAggSize =aggBufSize; ++ bool bRejectRxAgg = bRejApAggPkt; ++ bool bBtCtrlRxAggSize = bBtCtrlAggBufSize; ++ u8 rxAggSize = aggBufSize; + + /* */ + /* Rx Aggregation related setting */ + /* */ -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); ++ pBtCoexist->fBtcSet( ++ pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg ++ ); + /* decide BT control aggregation buf size or not */ -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); ++ pBtCoexist->fBtcSet( ++ pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize ++ ); + /* aggregation buf size, only work when BT control Rx aggregation size. */ + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); + /* real update aggregation setting */ @@ -35482,37 +34127,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + +} + -+static void -+halbtc8723b1ant_QueryBtInfo( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_QueryBtInfo(PBTC_COEXIST pBtCoexist) +{ -+ u8 H2C_Parameter[1] ={0}; ++ u8 H2C_Parameter[1] = {0}; + + pCoexSta->bC2hBtInfoReqSent = true; + + H2C_Parameter[0] |= BIT0; /* trigger */ + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", -+ H2C_Parameter[0])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ("[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", H2C_Parameter[0]) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); +} + -+static void -+halbtc8723b1ant_MonitorBtCtr( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist) +{ -+ u32 regHPTxRx, regLPTxRx, u4Tmp; -+ u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0; ++ u32 regHPTxRx, regLPTxRx, u4Tmp; ++ u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0; + static u8 NumOfBtCounterChk; + + /* to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS */ + /* if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8)) */ + -+ if (pCoexSta->bUnderIps) -+ { ++ if (pCoexSta->bUnderIps) { + pCoexSta->highPriorityTx = 65535; + pCoexSta->highPriorityRx = 65535; + pCoexSta->lowPriorityTx = 65535; @@ -35536,20 +34177,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexSta->lowPriorityTx = regLPTx; + pCoexSta->lowPriorityRx = regLPRx; + -+ if ((pCoexSta->lowPriorityTx >= 1050) && (!pCoexSta->bC2hBtInquiryPage)) ++ if ((pCoexSta->lowPriorityTx >= 1050) && (!pCoexSta->bC2hBtInquiryPage)) + pCoexSta->popEventCnt++; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n", -+ regHPRx, regHPTx, regLPRx, regLPTx)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ( ++ "[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n", ++ regHPRx, ++ regHPTx, ++ regLPRx, ++ regLPTx ++ ) ++ ); + + /* reset counter */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); + -+ if ((regHPTx == 0) && (regHPRx == 0) && (regLPTx == 0) && (regLPRx == 0)) -+ { ++ if ((regHPTx == 0) && (regHPRx == 0) && (regLPTx == 0) && (regLPRx == 0)) { + NumOfBtCounterChk++; -+ if (NumOfBtCounterChk >= 3) -+{ ++ if (NumOfBtCounterChk >= 3) { + halbtc8723b1ant_QueryBtInfo(pBtCoexist); + NumOfBtCounterChk = 0; + } @@ -35557,10 +34205,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b +} + + -+static void -+halbtc8723b1ant_MonitorWiFiCtr( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_MonitorWiFiCtr(PBTC_COEXIST pBtCoexist) +{ + s32 wifiRssi = 0; + bool bWifiBusy = false, bWifiUnderBMode = false; @@ -35568,10 +34213,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode ++ ); + -+ if (pCoexSta->bUnderIps) -+ { ++ if (pCoexSta->bUnderIps) { + pCoexSta->nCRCOK_CCK = 0; + pCoexSta->nCRCOK_11g = 0; + pCoexSta->nCRCOK_11n = 0; @@ -35581,9 +34227,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexSta->nCRCErr_11g = 0; + pCoexSta->nCRCErr_11n = 0; + pCoexSta->nCRCErr_11nAgg = 0; -+ } -+ else -+ { ++ } else { + pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88); + pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94); + pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90); @@ -35600,47 +34244,42 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1); + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0); + -+ if ((bWifiBusy) && (wifiRssi >= 30) && (!bWifiUnderBMode)) -+ { -+ if ((pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) || ++ if (bWifiBusy && (wifiRssi >= 30) && !bWifiUnderBMode) { ++ if ( ++ (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) || + (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) || -+ (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_SCO_BUSY)) -+ { -+ if (pCoexSta->nCRCOK_CCK >(pCoexSta->nCRCOK_11g + pCoexSta->nCRCOK_11n + -+ pCoexSta->nCRCOK_11nAgg)) -+ { ++ (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_SCO_BUSY) ++ ) { ++ if ( ++ pCoexSta->nCRCOK_CCK > ( ++ pCoexSta->nCRCOK_11g + ++ pCoexSta->nCRCOK_11n + ++ pCoexSta->nCRCOK_11nAgg ++ ) ++ ) { + if (nCCKLockCounter < 5) + nCCKLockCounter++; -+ } -+ else -+ { ++ } else { + if (nCCKLockCounter > 0) + nCCKLockCounter--; + } + -+ } -+ else -+ { ++ } else { + if (nCCKLockCounter > 0) + nCCKLockCounter--; + } -+ } -+ else -+ { ++ } else { + if (nCCKLockCounter > 0) + nCCKLockCounter--; + } + -+ if (!pCoexSta->bPreCCKLock) -+ { ++ if (!pCoexSta->bPreCCKLock) { + + if (nCCKLockCounter >= 5) + pCoexSta->bCCKLock = true; + else + pCoexSta->bCCKLock = false; -+ } -+ else -+ { ++ } else { + if (nCCKLockCounter == 0) + pCoexSta->bCCKLock = false; + else @@ -35652,34 +34291,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + +} + -+static bool -+halbtc8723b1ant_IsWifiStatusChanged( -+PBTC_COEXIST pBtCoexist -+ ) ++static bool halbtc8723b1ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist) +{ -+ static bool bPreWifiBusy =false, bPreUnder4way =false, bPreBtHsOn =false; -+ bool bWifiBusy =false, bUnder4way =false, bBtHsOn =false; -+ bool bWifiConnected =false; ++ static bool bPreWifiBusy = false, bPreUnder4way = false, bPreBtHsOn = false; ++ bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false; ++ bool bWifiConnected = false; + -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected ++ ); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way ++ ); + -+ if (bWifiConnected) -+ { -+ if (bWifiBusy != bPreWifiBusy) -+ { ++ if (bWifiConnected) { ++ if (bWifiBusy != bPreWifiBusy) { + bPreWifiBusy = bWifiBusy; + return true; + } -+ if (bUnder4way != bPreUnder4way) -+ { ++ ++ if (bUnder4way != bPreUnder4way) { + bPreUnder4way = bUnder4way; + return true; + } -+ if (bBtHsOn != bPreBtHsOn) -+ { ++ ++ if (bBtHsOn != bPreBtHsOn) { + bPreBtHsOn = bBtHsOn; + return true; + } @@ -35688,13 +34326,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + return false; +} + -+static void -+halbtc8723b1ant_UpdateBtLinkInfo( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ bool bBtHsOn =false; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ bool bBtHsOn = false; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); + @@ -35705,64 +34340,71 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pBtLinkInfo->bHidExist = pCoexSta->bHidExist; + + /* work around for HS mode. */ -+ if (bBtHsOn) -+ { ++ if (bBtHsOn) { + pBtLinkInfo->bPanExist = true; + pBtLinkInfo->bBtLinkExist = true; + } + + /* check if Sco only */ -+ if (pBtLinkInfo->bScoExist && ++ if ( ++ pBtLinkInfo->bScoExist && + !pBtLinkInfo->bA2dpExist && + !pBtLinkInfo->bPanExist && -+ !pBtLinkInfo->bHidExist) ++ !pBtLinkInfo->bHidExist ++ ) + pBtLinkInfo->bScoOnly = true; + else + pBtLinkInfo->bScoOnly = false; + + /* check if A2dp only */ -+ if (!pBtLinkInfo->bScoExist && ++ if ( ++ !pBtLinkInfo->bScoExist && + pBtLinkInfo->bA2dpExist && + !pBtLinkInfo->bPanExist && -+ !pBtLinkInfo->bHidExist) ++ !pBtLinkInfo->bHidExist ++ ) + pBtLinkInfo->bA2dpOnly = true; + else + pBtLinkInfo->bA2dpOnly = false; + + /* check if Pan only */ -+ if (!pBtLinkInfo->bScoExist && ++ if ( ++ !pBtLinkInfo->bScoExist && + !pBtLinkInfo->bA2dpExist && + pBtLinkInfo->bPanExist && -+ !pBtLinkInfo->bHidExist) ++ !pBtLinkInfo->bHidExist ++ ) + pBtLinkInfo->bPanOnly = true; + else + pBtLinkInfo->bPanOnly = false; + + /* check if Hid only */ -+ if (!pBtLinkInfo->bScoExist && ++ if ( ++ !pBtLinkInfo->bScoExist && + !pBtLinkInfo->bA2dpExist && + !pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bHidExist) ++ pBtLinkInfo->bHidExist ++ ) + pBtLinkInfo->bHidOnly = true; + else + pBtLinkInfo->bHidOnly = false; +} + -+static u8 -+halbtc8723b1ant_ActionAlgorithm( -+PBTC_COEXIST pBtCoexist -+ ) ++static u8 halbtc8723b1ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ bool bBtHsOn =false; -+ u8 algorithm =BT_8723B_1ANT_COEX_ALGO_UNDEFINED; -+ u8 numOfDiffProfile = 0; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ bool bBtHsOn = false; ++ u8 algorithm = BT_8723B_1ANT_COEX_ALGO_UNDEFINED; ++ u8 numOfDiffProfile = 0; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); + -+ if (!pBtLinkInfo->bBtLinkExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n")); ++ if (!pBtLinkInfo->bBtLinkExist) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], No BT link exists!!!\n") ++ ); + return algorithm; + } + @@ -35775,180 +34417,197 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + if (pBtLinkInfo->bA2dpExist) + numOfDiffProfile++; + -+ if (numOfDiffProfile == 1) -+ { -+ if (pBtLinkInfo->bScoExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO only\n")); ++ if (numOfDiffProfile == 1) { ++ if (pBtLinkInfo->bScoExist) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = SCO only\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; -+ } -+ else -+ { -+ if (pBtLinkInfo->bHidExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID only\n")); ++ } else { ++ if (pBtLinkInfo->bHidExist) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = HID only\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID; -+ } -+ else if (pBtLinkInfo->bA2dpExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP only\n")); ++ } else if (pBtLinkInfo->bA2dpExist) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = A2DP only\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP; -+ } -+ else if (pBtLinkInfo->bPanExist) -+ { -+ if (bBtHsOn) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = PAN(HS) only\n")); ++ } else if (pBtLinkInfo->bPanExist) { ++ if (bBtHsOn) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = PAN(HS) only\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_PANHS; -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = PAN(EDR) only\n")); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = PAN(EDR) only\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR; + } + } + } -+ } -+ else if (numOfDiffProfile == 2) -+ { -+ if (pBtLinkInfo->bScoExist) -+ { -+ if (pBtLinkInfo->bHidExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID\n")); ++ } else if (numOfDiffProfile == 2) { ++ if (pBtLinkInfo->bScoExist) { ++ if (pBtLinkInfo->bHidExist) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = SCO + HID\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID; -+ } -+ else if (pBtLinkInfo->bA2dpExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n")); ++ } else if (pBtLinkInfo->bA2dpExist) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; -+ } -+ else if (pBtLinkInfo->bPanExist) -+ { -+ if (bBtHsOn) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + PAN(HS)\n")); ++ } else if (pBtLinkInfo->bPanExist) { ++ if (bBtHsOn) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = SCO + PAN(HS)\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n")); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = SCO + PAN(EDR)\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } + } -+ } -+ else -+ { -+ if (pBtLinkInfo->bHidExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP\n")); ++ } else { ++ if (pBtLinkInfo->bHidExist && pBtLinkInfo->bA2dpExist) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = HID + A2DP\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; -+ } -+ else if (pBtLinkInfo->bHidExist && -+ pBtLinkInfo->bPanExist) -+ { -+ if (bBtHsOn) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + PAN(HS)\n")); ++ } else if (pBtLinkInfo->bHidExist && pBtLinkInfo->bPanExist) { ++ if (bBtHsOn) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = HID + PAN(HS)\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + PAN(EDR)\n")); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = HID + PAN(EDR)\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } -+ } -+ else if (pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ if (bBtHsOn) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n")); ++ } else if (pBtLinkInfo->bPanExist && pBtLinkInfo->bA2dpExist) { ++ if (bBtHsOn) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = A2DP + PAN(HS)\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS; -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n")); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP; + } + } + } -+ } -+ else if (numOfDiffProfile == 3) -+ { -+ if (pBtLinkInfo->bScoExist) -+ { -+ if (pBtLinkInfo->bHidExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n")); ++ } else if (numOfDiffProfile == 3) { ++ if (pBtLinkInfo->bScoExist) { ++ if (pBtLinkInfo->bHidExist && pBtLinkInfo->bA2dpExist) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID; -+ } -+ else if (pBtLinkInfo->bHidExist && -+ pBtLinkInfo->bPanExist) -+ { -+ if (bBtHsOn) -+ { ++ } else if ( ++ pBtLinkInfo->bHidExist && pBtLinkInfo->bPanExist ++ ) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n")); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n")); + algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } -+ } -+ else if (pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ if (bBtHsOn) -+ { ++ } else if (pBtLinkInfo->bPanExist && pBtLinkInfo->bA2dpExist) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n")); + algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n")); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } + } -+ } -+ else -+ { -+ if (pBtLinkInfo->bHidExist && ++ } else { ++ if ( ++ pBtLinkInfo->bHidExist && + pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ if (bBtHsOn) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n")); ++ pBtLinkInfo->bA2dpExist ++ ) { ++ if (bBtHsOn) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n")); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR; + } + } + } -+ } -+ else if (numOfDiffProfile >= 3) -+ { -+ if (pBtLinkInfo->bScoExist) -+ { -+ if (pBtLinkInfo->bHidExist && ++ } else if (numOfDiffProfile >= 3) { ++ if (pBtLinkInfo->bScoExist) { ++ if ( ++ pBtLinkInfo->bHidExist && + pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ if (bBtHsOn) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n")); ++ pBtLinkInfo->bA2dpExist ++ ) { ++ if (bBtHsOn) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n") ++ ); + -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n")); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n") ++ ); + algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; + } + } @@ -35958,18 +34617,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + return algorithm; +} + -+static void -+halbtc8723b1ant_SetSwPenaltyTxRateAdaptive( -+PBTC_COEXIST pBtCoexist, -+bool bLowPenaltyRa -+ ) ++static void halbtc8723b1ant_SetSwPenaltyTxRateAdaptive( ++ PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa ++) +{ -+ u8 H2C_Parameter[6] ={0}; ++ u8 H2C_Parameter[6] = {0}; + + H2C_Parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */ + -+ if (bLowPenaltyRa) -+ { ++ if (bLowPenaltyRa) { + H2C_Parameter[1] |= BIT0; + H2C_Parameter[2] = 0x00; /* normal rate except MCS7/6/5, OFDM54/48/36 */ + H2C_Parameter[3] = 0xf7; /* MCS7 or OFDM54 */ @@ -35977,78 +34633,108 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + H2C_Parameter[5] = 0xf9; /* MCS5 or OFDM36 */ + } + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set WiFi Low-Penalty Retry: %s", -+ (bLowPenaltyRa? "ON!!":"OFF!!"))); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], set WiFi Low-Penalty Retry: %s", ++ (bLowPenaltyRa ? "ON!!" : "OFF!!") ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); +} + -+static void -+halbtc8723b1ant_LowPenaltyRa( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bLowPenaltyRa -+ ) ++static void halbtc8723b1ant_LowPenaltyRa( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa ++) +{ + pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; + -+ if (!bForceExec) -+ { ++ if (!bForceExec) { + if (pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) + return; + } -+ halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); ++ halbtc8723b1ant_SetSwPenaltyTxRateAdaptive( ++ pBtCoexist, pCoexDm->bCurLowPenaltyRa ++ ); + + pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; +} + -+static void -+halbtc8723b1ant_SetCoexTable( -+PBTC_COEXIST pBtCoexist, -+u32 val0x6c0, -+u32 val0x6c4, -+u32 val0x6c8, -+u8 val0x6cc -+ ) ++static void halbtc8723b1ant_SetCoexTable( ++ PBTC_COEXIST pBtCoexist, ++ u32 val0x6c0, ++ u32 val0x6c4, ++ u32 val0x6c8, ++ u8 val0x6cc ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0) ++ ); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4) ++ ); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8) ++ ); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc) ++ ); + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); +} + -+static void -+halbtc8723b1ant_CoexTable( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u32 val0x6c0, -+u32 val0x6c4, -+u32 val0x6c8, -+u8 val0x6cc -+ ) ++static void halbtc8723b1ant_CoexTable( ++ PBTC_COEXIST pBtCoexist, ++ bool bForceExec, ++ u32 val0x6c0, ++ u32 val0x6c4, ++ u32 val0x6c8, ++ u8 val0x6cc ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6cc = 0x%x\n", -+ (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6cc)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW, ++ ( ++ "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6cc = 0x%x\n", ++ (bForceExec ? "force to" : ""), ++ val0x6c0, val0x6c4, val0x6cc ++ ) ++ ); + pCoexDm->curVal0x6c0 = val0x6c0; + pCoexDm->curVal0x6c4 = val0x6c4; + pCoexDm->curVal0x6c8 = val0x6c8; + pCoexDm->curVal0x6cc = val0x6cc; + + if (!bForceExec) { -+ if ((pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && ++ if ( ++ (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && + (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && + (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && -+ (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc)) ++ (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ++ ) + return; + } -+ halbtc8723b1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); ++ ++ halbtc8723b1ant_SetCoexTable( ++ pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc ++ ); + + pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; + pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; @@ -36056,82 +34742,110 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; +} + -+static void -+halbtc8723b1ant_CoexTableWithType( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 type -+ ) ++static void halbtc8723b1ant_CoexTableWithType( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** CoexTable(%d) **********\n", type)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], ********** CoexTable(%d) **********\n", type) ++ ); + + pCoexSta->nCoexTableType = type; + -+ switch (type) -+ { -+ case 0: -+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3); -+ break; -+ case 1: -+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); -+ break; -+ case 2: -+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3); -+ break; -+ case 3: -+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaa5555, 0xaaaa5a5a, 0xffffff, 0x3); -+ break; -+ case 4: -+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3); -+ break; -+ case 5: -+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaa5a5a, 0xffffff, 0x3); -+ break; -+ case 6: -+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3); -+ break; -+ case 7: -+ halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3); -+ break; -+ default: -+ break; ++ switch (type) { ++ case 0: ++ halbtc8723b1ant_CoexTable( ++ pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3 ++ ); ++ break; ++ case 1: ++ halbtc8723b1ant_CoexTable( ++ pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3 ++ ); ++ break; ++ case 2: ++ halbtc8723b1ant_CoexTable( ++ pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3 ++ ); ++ break; ++ case 3: ++ halbtc8723b1ant_CoexTable( ++ pBtCoexist, bForceExec, 0xaaaa5555, 0xaaaa5a5a, 0xffffff, 0x3 ++ ); ++ break; ++ case 4: ++ halbtc8723b1ant_CoexTable( ++ pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3 ++ ); ++ break; ++ case 5: ++ halbtc8723b1ant_CoexTable( ++ pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaa5a5a, 0xffffff, 0x3 ++ ); ++ break; ++ case 6: ++ halbtc8723b1ant_CoexTable( ++ pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3 ++ ); ++ break; ++ case 7: ++ halbtc8723b1ant_CoexTable( ++ pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3 ++ ); ++ break; ++ default: ++ break; + } +} + -+static void -+halbtc8723b1ant_SetFwIgnoreWlanAct( -+PBTC_COEXIST pBtCoexist, -+bool bEnable -+ ) ++static void halbtc8723b1ant_SetFwIgnoreWlanAct( ++ PBTC_COEXIST pBtCoexist, bool bEnable ++) +{ -+ u8 H2C_Parameter[1] ={0}; ++ u8 H2C_Parameter[1] = {0}; + + if (bEnable) -+ { -+ H2C_Parameter[0] |= BIT0; /* function enable */ -+ } ++ H2C_Parameter[0] |= BIT0; /* function enable */ + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", -+ H2C_Parameter[0])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", ++ H2C_Parameter[0] ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); +} + -+static void -+halbtc8723b1ant_IgnoreWlanAct( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bEnable -+ ) ++static void halbtc8723b1ant_IgnoreWlanAct( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n", -+ (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW, ++ ( ++ "[BTCoex], %s turn Ignore WlanAct %s\n", ++ (bForceExec ? "force to" : ""), ++ (bEnable ? "ON" : "OFF") ++ ) ++ ); + pCoexDm->bCurIgnoreWlanAct = bEnable; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n", -+ pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n", ++ pCoexDm->bPreIgnoreWlanAct, ++ pCoexDm->bCurIgnoreWlanAct ++ ) ++ ); + + if (pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) + return; @@ -36141,43 +34855,58 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; +} + -+static void -+halbtc8723b1ant_SetLpsRpwm( -+PBTC_COEXIST pBtCoexist, -+u8 lpsVal, -+u8 rpwmVal -+ ) ++static void halbtc8723b1ant_SetLpsRpwm( ++ PBTC_COEXIST pBtCoexist, u8 lpsVal, u8 rpwmVal ++) +{ -+ u8 lps =lpsVal; -+ u8 rpwm =rpwmVal; ++ u8 lps = lpsVal; ++ u8 rpwm = rpwmVal; + + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); +} + -+static void -+halbtc8723b1ant_LpsRpwm( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 lpsVal, -+u8 rpwmVal -+ ) ++static void halbtc8723b1ant_LpsRpwm( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u8 lpsVal, u8 rpwmVal ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set lps/rpwm = 0x%x/0x%x\n", -+ (bForceExec? "force to":""), lpsVal, rpwmVal)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW, ++ ( ++ "[BTCoex], %s set lps/rpwm = 0x%x/0x%x\n", ++ (bForceExec ? "force to" : ""), ++ lpsVal, ++ rpwmVal ++ ) ++ ); + pCoexDm->curLps = lpsVal; + pCoexDm->curRpwm = rpwmVal; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], LPS-RxBeaconMode = 0x%x , LPS-RPWM = 0x%x!!\n", -+ pCoexDm->curLps, pCoexDm->curRpwm)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], LPS-RxBeaconMode = 0x%x , LPS-RPWM = 0x%x!!\n", ++ pCoexDm->curLps, ++ pCoexDm->curRpwm ++ ) ++ ); + -+ if ((pCoexDm->preLps == pCoexDm->curLps) && -+ (pCoexDm->preRpwm == pCoexDm->curRpwm)) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], LPS-RPWM_Last = 0x%x , LPS-RPWM_Now = 0x%x!!\n", -+ pCoexDm->preRpwm, pCoexDm->curRpwm)); ++ if ( ++ (pCoexDm->preLps == pCoexDm->curLps) && ++ (pCoexDm->preRpwm == pCoexDm->curRpwm) ++ ) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], LPS-RPWM_Last = 0x%x , LPS-RPWM_Now = 0x%x!!\n", ++ pCoexDm->preRpwm, ++ pCoexDm->curRpwm ++ ) ++ ); + + return; + } @@ -36188,55 +34917,47 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexDm->preRpwm = pCoexDm->curRpwm; +} + -+static void -+halbtc8723b1ant_SwMechanism( -+PBTC_COEXIST pBtCoexist, -+bool bLowPenaltyRA -+ ) ++static void halbtc8723b1ant_SwMechanism( ++ PBTC_COEXIST pBtCoexist, bool bLowPenaltyRA ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], SM[LpRA] = %d\n", -+ bLowPenaltyRA)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_MONITOR, ++ ("[BTCoex], SM[LpRA] = %d\n", bLowPenaltyRA) ++ ); + + halbtc8723b1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); +} + -+static void -+halbtc8723b1ant_SetAntPath( -+PBTC_COEXIST pBtCoexist, -+u8 antPosType, -+bool bInitHwCfg, -+bool bWifiOff -+ ) ++static void halbtc8723b1ant_SetAntPath( ++ PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff ++) +{ -+ PBTC_BOARD_INFO pBoardInfo =&pBtCoexist->boardInfo; -+ u32 fwVer = 0, u4Tmp = 0, cntBtCalChk = 0; -+ bool bPgExtSwitch =false; -+ bool bUseExtSwitch =false; -+ bool bIsInMpMode = false; -+ u8 H2C_Parameter[2] ={0}, u1Tmp = 0; ++ PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo; ++ u32 fwVer = 0, u4Tmp = 0, cntBtCalChk = 0; ++ bool bPgExtSwitch = false; ++ bool bUseExtSwitch = false; ++ bool bIsInMpMode = false; ++ u8 H2C_Parameter[2] = {0}, u1Tmp = 0; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch); -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); /* [31:16]=fw ver, [15:0]=fw sub ver */ ++ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); /* [31:16]=fw ver, [15:0]=fw sub ver */ + -+ if ((fwVer>0 && fwVer<0xc0000) || bPgExtSwitch) ++ if ((fwVer > 0 && fwVer < 0xc0000) || bPgExtSwitch) + bUseExtSwitch = true; + -+ if (bInitHwCfg) -+ { ++ if (bInitHwCfg) { + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); /* WiFi TRx Mask on */ + pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); /* BT TRx Mask on */ + -+ if (fwVer >= 0x180000) -+ { -+ /* Use H2C to set GNT_BT to HIGH */ -+ H2C_Parameter[0] = 1; -+ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); -+ } -+ else -+ { -+ /* set grant_bt to high */ ++ if (fwVer >= 0x180000) { ++ /* Use H2C to set GNT_BT to HIGH */ ++ H2C_Parameter[0] = 1; ++ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); ++ } else /* set grant_bt to high */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); -+ } ++ + /* set wlan_act control by PTA */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); + @@ -36246,20 +34967,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff); + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3); + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77); -+ } -+ else if (bWifiOff) -+ { -+ if (fwVer >= 0x180000) -+ { -+ /* Use H2C to set GNT_BT to HIGH */ -+ H2C_Parameter[0] = 1; -+ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); -+ } -+ else -+ { -+ /* set grant_bt to high */ ++ } else if (bWifiOff) { ++ if (fwVer >= 0x180000) { ++ /* Use H2C to set GNT_BT to HIGH */ ++ H2C_Parameter[0] = 1; ++ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); ++ } else /* set grant_bt to high */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); -+ } ++ + /* set wlan_act to always low */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); + @@ -36274,32 +34989,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + u4Tmp &= ~BIT23; + u4Tmp &= ~BIT24; + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); -+ } -+ else -+ { ++ } else { + /* Use H2C to set GNT_BT to LOW */ -+ if (fwVer >= 0x180000) -+ { -+ if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765) != 0) -+ { -+ H2C_Parameter[0] = 0; -+ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); -+ } -+ } -+ else -+ { ++ if (fwVer >= 0x180000) { ++ if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765) != 0) { ++ H2C_Parameter[0] = 0; ++ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); ++ } ++ } else { + /* BT calibration check */ -+ while (cntBtCalChk <= 20) -+ { ++ while (cntBtCalChk <= 20) { + u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49d); + cntBtCalChk++; -+ if (u1Tmp & BIT0) -+ { ++ ++ if (u1Tmp & BIT0) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ########### BT is calibrating (wait cnt =%d) ###########\n", cntBtCalChk)); + mdelay(50); -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ********** BT is NOT calibrating (wait cnt =%d)**********\n", cntBtCalChk)); + break; + } @@ -36310,33 +35016,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } + + if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) != 0xc) -+ { + /* set wlan_act control by PTA */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -+ } + } + -+ if (bUseExtSwitch) -+ { -+ if (bInitHwCfg) -+ { ++ if (bUseExtSwitch) { ++ if (bInitHwCfg) { + /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */ + u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); -+ u4Tmp &=~BIT23; ++ u4Tmp &= ~BIT23; + u4Tmp |= BIT24; + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); + + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */ + -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ { ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) { + /* tell firmware "no antenna inverse" */ + H2C_Parameter[0] = 0; + H2C_Parameter[1] = 1; /* ext switch type */ + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); -+ } -+ else -+ { ++ } else { + /* tell firmware "antenna inverse" */ + H2C_Parameter[0] = 1; + H2C_Parameter[1] = 1; /* ext switch type */ @@ -36346,53 +35045,46 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + + /* ext switch setting */ -+ switch (antPosType) -+ { -+ case BTC_ANT_PATH_WIFI: -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); -+ else -+ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); -+ break; -+ case BTC_ANT_PATH_BT: -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); -+ else -+ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); -+ break; -+ default: -+ case BTC_ANT_PATH_PTA: -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); -+ else -+ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); -+ break; ++ switch (antPosType) { ++ case BTC_ANT_PATH_WIFI: ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) ++ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); ++ else ++ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); ++ break; ++ case BTC_ANT_PATH_BT: ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) ++ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); ++ else ++ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); ++ break; ++ default: ++ case BTC_ANT_PATH_PTA: ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) ++ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); ++ else ++ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); ++ break; + } + -+ } -+ else -+ { -+ if (bInitHwCfg) -+ { ++ } else { ++ if (bInitHwCfg) { + /* 0x4c[23]= 1, 0x4c[24]= 0 Antenna control by 0x64 */ + u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); + u4Tmp |= BIT23; -+ u4Tmp &=~BIT24; ++ u4Tmp &= ~BIT24; + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); + + /* Fix Ext switch Main->S1, Aux->S0 */ + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); + -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ { ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) { + + /* tell firmware "no antenna inverse" */ + H2C_Parameter[0] = 0; + H2C_Parameter[1] = 0; /* internal switch type */ + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); -+ } -+ else -+ { ++ } else { + + /* tell firmware "antenna inverse" */ + H2C_Parameter[0] = 1; @@ -36403,52 +35095,47 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + + /* internal switch setting */ -+ switch (antPosType) -+ { -+ case BTC_ANT_PATH_WIFI: -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); -+ else -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); -+ break; -+ case BTC_ANT_PATH_BT: -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); -+ else -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); -+ break; -+ default: -+ case BTC_ANT_PATH_PTA: -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x200); -+ else -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x80); -+ break; ++ switch (antPosType) { ++ case BTC_ANT_PATH_WIFI: ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); ++ else ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); ++ break; ++ case BTC_ANT_PATH_BT: ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); ++ else ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); ++ break; ++ default: ++ case BTC_ANT_PATH_PTA: ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x200); ++ else ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x80); ++ break; + } + } +} + -+static void -+halbtc8723b1ant_SetFwPstdma( -+PBTC_COEXIST pBtCoexist, -+u8 byte1, -+u8 byte2, -+u8 byte3, -+u8 byte4, -+u8 byte5 -+ ) ++static void halbtc8723b1ant_SetFwPstdma( ++ PBTC_COEXIST pBtCoexist, u8 byte1, u8 byte2, u8 byte3, u8 byte4, u8 byte5 ++) +{ -+ u8 H2C_Parameter[5] ={0}; -+ u8 realByte1 =byte1, realByte5 =byte5; -+ bool bApEnable =false; ++ u8 H2C_Parameter[5] = {0}; ++ u8 realByte1 = byte1, realByte5 = byte5; ++ bool bApEnable = false; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); + -+ if (bApEnable) -+ { -+ if (byte1&BIT4 && !(byte1&BIT5)) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], FW for 1Ant AP mode\n")); ++ if (bApEnable) { ++ if (byte1&BIT4 && !(byte1&BIT5)) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ("[BTCoex], FW for 1Ant AP mode\n") ++ ); + realByte1 &= ~BIT4; + realByte1 |= BIT5; + @@ -36469,27 +35156,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexDm->psTdmaPara[3] = byte4; + pCoexDm->psTdmaPara[4] = realByte5; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], PS-TDMA H2C cmd = 0x%x%08x\n", -+ H2C_Parameter[0], -+ H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], PS-TDMA H2C cmd = 0x%x%08x\n", ++ H2C_Parameter[0], ++ H2C_Parameter[1]<<24| ++ H2C_Parameter[2]<<16| ++ H2C_Parameter[3]<<8| ++ H2C_Parameter[4] ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); +} + + -+static void -+halbtc8723b1ant_PsTdma( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bTurnOn, -+u8 type -+ ) ++static void halbtc8723b1ant_PsTdma( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type ++) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ bool bWifiBusy =false; -+ u8 rssiAdjustVal = 0; -+ u8 psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10; -+ s8 nWiFiDurationAdjust = 0x0; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ bool bWifiBusy = false; ++ u8 rssiAdjustVal = 0; ++ u8 psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10; ++ s8 nWiFiDurationAdjust = 0x0; + /* u32 fwVer = 0; */ + + /* BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type =%d\n", */ @@ -36499,21 +35191,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + -+ if (pCoexDm->bCurPsTdmaOn) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** TDMA(on, %d) **********\n", -+ pCoexDm->curPsTdma)); -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ********** TDMA(off, %d) **********\n", -+ pCoexDm->curPsTdma)); ++ if (pCoexDm->bCurPsTdmaOn) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ( ++ "[BTCoex], ********** TDMA(on, %d) **********\n", ++ pCoexDm->curPsTdma ++ ) ++ ); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ( ++ "[BTCoex], ********** TDMA(off, %d) **********\n", ++ pCoexDm->curPsTdma ++ ) ++ ); + } + -+ if (!bForceExec) -+ { -+ if ((pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && -+ (pCoexDm->prePsTdma == pCoexDm->curPsTdma)) ++ if (!bForceExec) { ++ if ( ++ (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && ++ (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ++ ) + return; + } + @@ -36524,228 +35226,335 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + else if (pCoexSta->nScanAPNum >= 20) + nWiFiDurationAdjust = -10; + -+ if (!pCoexSta->bForceLpsOn) /* only for A2DP-only case 1/2/9/11 */ -+ { ++ if (!pCoexSta->bForceLpsOn) { /* only for A2DP-only case 1/2/9/11 */ + psTdmaByte0Val = 0x61; /* no null-pkt */ + psTdmaByte3Val = 0x11; /* no tx-pause at BT-slot */ + psTdmaByte4Val = 0x10; /* 0x778 = d/1 toggle */ + } + + -+ if (bTurnOn) -+ { ++ if (bTurnOn) { + if (pBtLinkInfo->bSlaveRole == true) -+ { + psTdmaByte4Val = psTdmaByte4Val | 0x1; /* 0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) */ -+ } + + -+ switch (type) -+ { -+ default: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val); -+ break; -+ case 1: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); -+ break; -+ case 2: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); -+ break; -+ case 3: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, 0x10); -+ break; -+ case 4: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0); -+ break; -+ case 5: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x10); -+ break; -+ case 6: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x11); -+ break; -+ case 7: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0); -+ break; -+ case 8: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); -+ break; -+ case 9: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); -+ break; -+ case 10: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40); -+ break; -+ case 11: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val); -+ break; -+ case 12: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50); -+ break; -+ case 13: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, 0x10); -+ break; -+ case 14: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, psTdmaByte4Val); -+ break; -+ case 15: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0); -+ break; -+ case 16: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0); -+ break; -+ case 18: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); -+ break; -+ case 20: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x3f, 0x03, 0x11, 0x10); -+ break; -+ case 21: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11); -+ break; -+ case 22: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10); -+ break; -+ case 23: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18); -+ break; -+ case 24: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18); -+ break; -+ case 25: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); -+ break; -+ case 26: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); -+ break; -+ case 27: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98); -+ break; -+ case 28: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0); -+ break; -+ case 29: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10); -+ break; -+ case 30: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10); -+ break; -+ case 31: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58); -+ break; -+ case 32: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11); -+ break; -+ case 33: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90); -+ break; -+ case 34: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10); -+ break; -+ case 35: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10); -+ break; -+ case 36: -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50); -+ break; -+ case 40: /* SoftAP only with no sta associated, BT disable , TDMA mode for power saving */ -+ /* here softap mode screen off will cost 70-80mA for phone */ -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24); -+ break; ++ switch (type) { ++ default: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val ++ ); ++ break; ++ case 1: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, ++ psTdmaByte0Val, ++ 0x3a+nWiFiDurationAdjust, ++ 0x03, ++ psTdmaByte3Val, ++ psTdmaByte4Val ++ ); ++ break; ++ case 2: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, ++ psTdmaByte0Val, ++ 0x2d+nWiFiDurationAdjust, ++ 0x03, ++ psTdmaByte3Val, ++ psTdmaByte4Val ++ ); ++ break; ++ case 3: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, 0x10 ++ ); ++ break; ++ case 4: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0 ++ ); ++ break; ++ case 5: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x10 ++ ); ++ break; ++ case 6: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x11 ++ ); ++ break; ++ case 7: ++ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0); ++ break; ++ case 8: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0 ++ ); ++ break; ++ case 9: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, ++ psTdmaByte0Val, ++ 0x21, ++ 0x3, ++ psTdmaByte3Val, ++ psTdmaByte4Val ++ ); ++ break; ++ case 10: ++ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40); ++ break; ++ case 11: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, ++ psTdmaByte0Val, ++ 0x21, ++ 0x03, ++ psTdmaByte3Val, ++ psTdmaByte4Val ++ ); ++ break; ++ case 12: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50 ++ ); ++ break; ++ case 13: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x51, 0x12, 0x12, 0x0, 0x10 ++ ); ++ break; ++ case 14: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x51, 0x21, 0x3, 0x10, psTdmaByte4Val ++ ); ++ break; ++ case 15: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0 ++ ); ++ break; ++ case 16: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0 ++ ); ++ break; ++ case 18: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0 ++ ); ++ break; ++ case 20: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x61, 0x3f, 0x03, 0x11, 0x10 ++ ++ ); ++ break; ++ case 21: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11 ++ ); ++ break; ++ case 22: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10 ++ ); ++ break; ++ case 23: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18 ++ ); ++ break; ++ case 24: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18 ++ ); ++ break; ++ case 25: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18 ++ ); ++ break; ++ case 26: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18 ++ ); ++ break; ++ case 27: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98 ++ ); ++ break; ++ case 28: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0 ++ ); ++ break; ++ case 29: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10 ++ ); ++ break; ++ case 30: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10 ++ ); ++ break; ++ case 31: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xd3, 0x1a, 0x1a, 0x0, 0x58 ++ ); ++ break; ++ case 32: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11 ++ ); ++ break; ++ case 33: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90 ++ ); ++ break; ++ case 34: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10 ++ ); ++ break; ++ case 35: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10 ++ ); ++ break; ++ case 36: ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50 ++ ); ++ break; ++ case 40: /* SoftAP only with no sta associated, BT disable , TDMA mode for power saving */ ++ /* here softap mode screen off will cost 70-80mA for phone */ ++ halbtc8723b1ant_SetFwPstdma( ++ pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24 ++ ); ++ break; + } -+ } -+ else -+ { ++ } else { + + /* disable PS tdma */ -+ switch (type) -+ { -+ case 8: /* PTA Control */ -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); -+ halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, false, false); -+ break; -+ case 0: -+ default: /* Software control, Antenna at BT side */ -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); -+ halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, false, false); -+ break; -+ case 9: /* Software control, Antenna at WiFi side */ -+ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); -+ halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, false, false); -+ break; ++ switch (type) { ++ case 8: /* PTA Control */ ++ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); ++ halbtc8723b1ant_SetAntPath( ++ pBtCoexist, BTC_ANT_PATH_PTA, false, false ++ ); ++ break; ++ case 0: ++ default: /* Software control, Antenna at BT side */ ++ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); ++ halbtc8723b1ant_SetAntPath( ++ pBtCoexist, BTC_ANT_PATH_BT, false, false ++ ); ++ break; ++ case 9: /* Software control, Antenna at WiFi side */ ++ halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); ++ halbtc8723b1ant_SetAntPath( ++ pBtCoexist, BTC_ANT_PATH_WIFI, false, false ++ ); ++ break; + } + } ++ + rssiAdjustVal = 0; -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal); ++ pBtCoexist->fBtcSet( ++ pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal ++ ); + + /* update pre state */ + pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; + pCoexDm->prePsTdma = pCoexDm->curPsTdma; +} + -+static bool -+halbtc8723b1ant_IsCommonAction( -+PBTC_COEXIST pBtCoexist -+ ) ++static bool halbtc8723b1ant_IsCommonAction(PBTC_COEXIST pBtCoexist) +{ -+ bool bCommon =false, bWifiConnected =false, bWifiBusy =false; ++ bool bCommon = false, bWifiConnected = false, bWifiBusy = false; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + -+ if (!bWifiConnected && -+ BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n")); ++ if ( ++ !bWifiConnected && ++ BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus ++ ) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n") ++ ); + + /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */ + + bCommon = true; -+ } -+ else if (bWifiConnected && -+ (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); ++ } else if ( ++ bWifiConnected && ++ (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ++ ) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], Wifi connected + BT non connected-idle!!\n") ++ ); + + /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */ + + bCommon = true; -+ } -+ else if (!bWifiConnected && -+ (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n")); ++ } else if ( ++ !bWifiConnected && ++ (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ++ ) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n") ++ ); + + /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */ + + bCommon = true; -+ } -+ else if (bWifiConnected && -+ (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)) -+ { ++ } else if ( ++ bWifiConnected && ++ (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ++ ) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); + + /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */ + + bCommon = true; -+ } -+ else if (!bWifiConnected && -+ (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus)) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); ++ } else if ( ++ !bWifiConnected && ++ (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) ++ ) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], Wifi non connected-idle + BT Busy!!\n") ++ ); + + /* halbtc8723b1ant_SwMechanism(pBtCoexist, false); */ + + bCommon = true; -+ } -+ else -+ { -+ if (bWifiBusy) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); -+ } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); ++ } else { ++ if (bWifiBusy) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n") ++ ); ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n") ++ ); + } + + bCommon = false; @@ -36755,33 +35564,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b +} + + -+static void -+halbtc8723b1ant_TdmaDurationAdjustForAcl( -+PBTC_COEXIST pBtCoexist, -+u8 wifiStatus -+ ) ++static void halbtc8723b1ant_TdmaDurationAdjustForAcl( ++ PBTC_COEXIST pBtCoexist, u8 wifiStatus ++) +{ -+ static s32 up, dn, m, n, WaitCount; -+ s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */ -+ u8 retryCount = 0, btInfoExt; -+ bool bWifiBusy = false; ++ static s32 up, dn, m, n, WaitCount; ++ s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */ ++ u8 retryCount = 0, btInfoExt; ++ bool bWifiBusy = false; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjustForAcl()\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW, ++ ("[BTCoex], TdmaDurationAdjustForAcl()\n") ++ ); + + if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus) + bWifiBusy = true; + else + bWifiBusy = false; + -+ if ((BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || ++ if ( ++ (BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || + (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) || -+ (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus)) -+ { -+ if (pCoexDm->curPsTdma != 1 && ++ (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) ++ ) { ++ if ( ++ pCoexDm->curPsTdma != 1 && + pCoexDm->curPsTdma != 2 && + pCoexDm->curPsTdma != 3 && -+ pCoexDm->curPsTdma != 9) -+ { ++ pCoexDm->curPsTdma != 9 ++ ) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); + pCoexDm->psTdmaDuAdjType = 9; + @@ -36795,10 +35608,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + return; + } + -+ if (!pCoexDm->bAutoTdmaAdjust) -+ { ++ if (!pCoexDm->bAutoTdmaAdjust) { + pCoexDm->bAutoTdmaAdjust = true; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ("[BTCoex], first run TdmaDurationAdjust()!!\n") ++ ); + + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; @@ -36809,9 +35625,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + n = 3; + result = 0; + WaitCount = 0; -+ } -+ else -+ { ++ } else { + /* accquire the BT TRx retry count from BT_Info byte2 */ + retryCount = pCoexSta->btRetryCnt; + btInfoExt = pCoexSta->btInfoExt; @@ -36819,40 +35633,39 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + /* BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up =%d, dn =%d, m =%d, n =%d, WaitCount =%d\n", */ + /* up, dn, m, n, WaitCount)); */ + -+ if ((pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250) ++ if (pCoexSta->lowPriorityTx > 1050 || pCoexSta->lowPriorityRx > 1250) + retryCount++; + + result = 0; + WaitCount++; + -+ if (retryCount == 0) /* no retry in the last 2-second duration */ -+ { ++ if (retryCount == 0) { /* no retry in the last 2-second duration */ + up++; + dn--; + + if (dn <= 0) + dn = 0; + -+ if (up >= n) /* if 連續 n 個2秒 retry count為0, 則調寬WiFi duration */ -+ { ++ if (up >= n) { /* if 連續 n 個2秒 retry count為0, 則調寬WiFi duration */ + WaitCount = 0; + n = 3; + up = 0; + dn = 0; + result = 1; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ("[BTCoex], Increase wifi duration!!\n") ++ ); + } -+ } -+ else if (retryCount <= 3) /* <=3 retry in the last 2-second duration */ -+ { ++ } else if (retryCount <= 3) { /* <=3 retry in the last 2-second duration */ + up--; + dn++; + + if (up <= 0) + up = 0; + -+ if (dn == 2) /* if 連續 2 個2秒 retry count< 3, 則調窄WiFi duration */ -+ { ++ if (dn == 2) { /* if 連續 2 個2秒 retry count< 3, 則調窄WiFi duration */ + if (WaitCount <= 2) + m++; /* 避免一直在兩個level中來回 */ + else @@ -36868,9 +35681,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); + } -+ } -+ else /* retry count > 3, 只要1次 retry count > 3, 則調窄WiFi duration */ -+ { ++ } else { /* retry count > 3, 只要1次 retry count > 3, 則調窄WiFi duration */ + if (WaitCount == 1) + m++; /* 避免一直在兩個level中來回 */ + else @@ -36884,146 +35695,127 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + dn = 0; + WaitCount = 0; + result = -1; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n") ++ ); + } + -+ if (result == -1) -+ { -+ if ((BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt)) && -+ ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2))) -+ { ++ if (result == -1) { ++ if ( ++ BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt) && ++ ((pCoexDm->curPsTdma == 1) || (pCoexDm->curPsTdma == 2)) ++ ) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); + pCoexDm->psTdmaDuAdjType = 9; -+ } -+ else if (pCoexDm->curPsTdma == 1) -+ { ++ } else if (pCoexDm->curPsTdma == 1) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); + pCoexDm->psTdmaDuAdjType = 9; -+ } -+ else if (pCoexDm->curPsTdma == 9) -+ { ++ } else if (pCoexDm->curPsTdma == 9) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; + } -+ } -+ else if (result == 1) -+ { -+ if ((BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt)) && -+ ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2))) -+ { ++ } else if (result == 1) { ++ if ( ++ BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt) && ++ ((pCoexDm->curPsTdma == 1) || (pCoexDm->curPsTdma == 2)) ++ ) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); + pCoexDm->psTdmaDuAdjType = 9; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); + pCoexDm->psTdmaDuAdjType = 9; -+ } -+ else if (pCoexDm->curPsTdma == 9) -+ { ++ } else if (pCoexDm->curPsTdma == 9) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1); + pCoexDm->psTdmaDuAdjType = 1; + } -+ } -+ else /* no change */ -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], ********** TDMA(on, %d) **********\n", -+ pCoexDm->curPsTdma)); ++ } else { /* no change */ ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], ********** TDMA(on, %d) **********\n", ++ pCoexDm->curPsTdma ++ ) ++ ); + } + -+ if (pCoexDm->curPsTdma != 1 && ++ if ( ++ pCoexDm->curPsTdma != 1 && + pCoexDm->curPsTdma != 2 && + pCoexDm->curPsTdma != 9 && -+ pCoexDm->curPsTdma != 11) -+ { -+ /* recover to previous adjust type */ -+ halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType); -+ } ++ pCoexDm->curPsTdma != 11 ++ ) /* recover to previous adjust type */ ++ halbtc8723b1ant_PsTdma( ++ pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType ++ ); + } +} + -+static void -+halbtc8723b1ant_PsTdmaCheckForPowerSaveState( -+PBTC_COEXIST pBtCoexist, -+bool bNewPsState -+ ) ++static void halbtc8723b1ant_PsTdmaCheckForPowerSaveState( ++ PBTC_COEXIST pBtCoexist, bool bNewPsState ++) +{ + u8 lpsMode = 0x0; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); + -+ if (lpsMode) /* already under LPS state */ -+ { -+ if (bNewPsState) -+ { ++ if (lpsMode) { /* already under LPS state */ ++ if (bNewPsState) { + /* keep state under LPS, do nothing. */ -+ } -+ else -+ { -+ /* will leave LPS state, turn off psTdma first */ ++ } else /* will leave LPS state, turn off psTdma first */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0); -+ } -+ } -+ else /* NO PS state */ -+ { -+ if (bNewPsState) -+ { -+ /* will enter LPS state, turn off psTdma first */ ++ } else { /* NO PS state */ ++ if (bNewPsState) /* will enter LPS state, turn off psTdma first */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0); -+ } -+ else -+ { ++ else { + /* keep state under NO PS state, do nothing. */ + } + } +} + -+static void -+halbtc8723b1ant_PowerSaveState( -+PBTC_COEXIST pBtCoexist, -+u8 psType, -+u8 lpsVal, -+u8 rpwmVal -+ ) ++static void halbtc8723b1ant_PowerSaveState( ++ PBTC_COEXIST pBtCoexist, u8 psType, u8 lpsVal, u8 rpwmVal ++) +{ -+ bool bLowPwrDisable =false; ++ bool bLowPwrDisable = false; + -+ switch (psType) -+ { -+ case BTC_PS_WIFI_NATIVE: -+ /* recover to original 32k low power setting */ -+ bLowPwrDisable = false; -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); -+ pCoexSta->bForceLpsOn = false; -+ break; -+ case BTC_PS_LPS_ON: -+ halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, true); -+ halbtc8723b1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); -+ /* when coex force to enter LPS, do not enter 32k low power. */ -+ bLowPwrDisable = true; -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); -+ /* power save must executed before psTdma. */ -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); -+ pCoexSta->bForceLpsOn = true; -+ break; -+ case BTC_PS_LPS_OFF: -+ halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, false); -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); -+ pCoexSta->bForceLpsOn = false; -+ break; -+ default: -+ break; ++ switch (psType) { ++ case BTC_PS_WIFI_NATIVE: ++ /* recover to original 32k low power setting */ ++ bLowPwrDisable = false; ++ pBtCoexist->fBtcSet( ++ pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable ++ ); ++ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); ++ pCoexSta->bForceLpsOn = false; ++ break; ++ case BTC_PS_LPS_ON: ++ halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, true); ++ halbtc8723b1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); ++ /* when coex force to enter LPS, do not enter 32k low power. */ ++ bLowPwrDisable = true; ++ pBtCoexist->fBtcSet( ++ pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable ++ ); ++ /* power save must executed before psTdma. */ ++ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); ++ pCoexSta->bForceLpsOn = true; ++ break; ++ case BTC_PS_LPS_OFF: ++ halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, false); ++ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); ++ pCoexSta->bForceLpsOn = false; ++ break; ++ default: ++ break; + } +} + @@ -37038,10 +35830,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b +/* Non-Software Coex Mechanism start */ +/* */ +/* */ -+static void -+halbtc8723b1ant_ActionWifiMultiPort( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionWifiMultiPort(PBTC_COEXIST pBtCoexist) +{ + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + @@ -37049,52 +35838,46 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); +} + -+static void -+halbtc8723b1ant_ActionHs( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionHs(PBTC_COEXIST pBtCoexist) +{ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); +} + -+static void -+halbtc8723b1ant_ActionBtInquiry( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ bool bWifiConnected =false, bApEnable =false, bWifiBusy =false, bBtBusy =false; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ bool bWifiConnected = false; ++ bool bApEnable = false; ++ bool bWifiBusy = false; ++ bool bBtBusy = false; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); + -+ if ((!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask)) -+ { ++ if (!bWifiConnected && !pCoexSta->bWiFiIsHighPriTask) { + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8); + + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -+ } -+ else if ((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) ) -+ { ++ } else if ( ++ pBtLinkInfo->bScoExist || ++ pBtLinkInfo->bHidExist || ++ pBtLinkInfo->bA2dpExist ++ ) { + /* SCO/HID/A2DP busy */ + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32); + + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else if ((pBtLinkInfo->bPanExist) || (bWifiBusy)) -+ { ++ } else if (pBtLinkInfo->bPanExist || bWifiBusy) { + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20); + + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else -+ { ++ } else { + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8); + @@ -37102,94 +35885,74 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } +} + -+static void -+halbtc8723b1ant_ActionBtScoHidOnlyBusy( -+PBTC_COEXIST pBtCoexist, -+u8 wifiStatus -+ ) ++static void halbtc8723b1ant_ActionBtScoHidOnlyBusy( ++ PBTC_COEXIST pBtCoexist, u8 wifiStatus ++) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ bool bWifiConnected =false; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ bool bWifiConnected = false; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); + + /* tdma and coex table */ + -+ if (pBtLinkInfo->bScoExist) -+ { ++ if (pBtLinkInfo->bScoExist) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); -+ } -+ else /* HID */ -+ { ++ } else { /* HID */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); + } +} + -+static void -+halbtc8723b1ant_ActionWifiConnectedBtAclBusy( -+PBTC_COEXIST pBtCoexist, -+u8 wifiStatus -+ ) ++static void halbtc8723b1ant_ActionWifiConnectedBtAclBusy( ++ PBTC_COEXIST pBtCoexist, u8 wifiStatus ++) +{ + u8 btRssiState; + -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; + btRssiState = halbtc8723b1ant_BtRssiState(2, 28, 0); + -+ if ((pCoexSta->lowPriorityRx >= 1000) && (pCoexSta->lowPriorityRx != 65535)) -+ { ++ if ((pCoexSta->lowPriorityRx >= 1000) && (pCoexSta->lowPriorityRx != 65535)) + pBtLinkInfo->bSlaveRole = true; -+ } + else -+ { + pBtLinkInfo->bSlaveRole = false; -+ } + -+ if (pBtLinkInfo->bHidOnly) /* HID */ -+ { ++ if (pBtLinkInfo->bHidOnly) { /* HID */ + halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus); + pCoexDm->bAutoTdmaAdjust = false; + return; -+ } -+ else if (pBtLinkInfo->bA2dpOnly) /* A2DP */ -+ { -+ if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) -+ { ++ } else if (pBtLinkInfo->bA2dpOnly) { /* A2DP */ ++ if (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); + pCoexDm->bAutoTdmaAdjust = false; -+ } -+ else -+ { ++ } else { + halbtc8723b1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); + pCoexDm->bAutoTdmaAdjust = true; + } -+ } -+ else if (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) /* HID+A2DP */ -+ { ++ } else if (pBtLinkInfo->bHidExist && pBtLinkInfo->bA2dpExist) { /* HID+A2DP */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->bAutoTdmaAdjust = false; + + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else if ((pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist)) /* PAN(OPP, FTP), HID+PAN(OPP, FTP) */ -+ { ++ } else if ( ++ pBtLinkInfo->bPanOnly || ++ (pBtLinkInfo->bHidExist && pBtLinkInfo->bPanExist) ++ ) { /* PAN(OPP, FTP), HID+PAN(OPP, FTP) */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); + pCoexDm->bAutoTdmaAdjust = false; -+ } -+ else if (((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) || -+ (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist)) /* A2DP+PAN(OPP, FTP), HID+A2DP+PAN(OPP, FTP) */ -+ { ++ } else if ( ++ (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) || ++ (pBtLinkInfo->bHidExist && pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) ++ ) { /* A2DP+PAN(OPP, FTP), HID+A2DP+PAN(OPP, FTP) */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); + pCoexDm->bAutoTdmaAdjust = false; -+ } -+ else -+ { ++ } else { + /* BT no-profile busy (0x9) */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); @@ -37197,10 +35960,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } +} + -+static void -+halbtc8723b1ant_ActionWifiNotConnected( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionWifiNotConnected(PBTC_COEXIST pBtCoexist) +{ + /* power save state */ + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); @@ -37210,173 +35970,158 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); +} + -+static void -+halbtc8723b1ant_ActionWifiNotConnectedScan( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionWifiNotConnectedScan( ++ PBTC_COEXIST pBtCoexist ++) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; + + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ -+ if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) -+ { -+ if (pBtLinkInfo->bA2dpExist) -+ { ++ if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) { ++ if (pBtLinkInfo->bA2dpExist) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) -+ { ++ } else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 22); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else -+ { ++ } else { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); + } -+ } -+ else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || -+ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)) -+ { -+ halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); -+ } -+ else -+ { ++ } else if ( ++ (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || ++ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ++ ) { ++ halbtc8723b1ant_ActionBtScoHidOnlyBusy( ++ pBtCoexist, BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN ++ ); ++ } else { + /* Bryant Add */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); + } +} + -+static void -+halbtc8723b1ant_ActionWifiNotConnectedAssoAuth( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionWifiNotConnectedAssoAuth( ++ PBTC_COEXIST pBtCoexist ++) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; + + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ -+ if ((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist)) -+ { ++ if ( ++ (pBtLinkInfo->bScoExist) || ++ (pBtLinkInfo->bHidExist) || ++ (pBtLinkInfo->bA2dpExist) ++ ) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else if (pBtLinkInfo->bPanExist) -+ { ++ } else if (pBtLinkInfo->bPanExist) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else -+ { ++ } else { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); + } +} + -+static void -+halbtc8723b1ant_ActionWifiConnectedScan( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionWifiConnectedScan(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; + + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ -+ if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) -+ { -+ if (pBtLinkInfo->bA2dpExist) -+ { ++ if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) { ++ if (pBtLinkInfo->bA2dpExist) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) -+ { ++ } else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 22); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else -+ { ++ } else { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); + } -+ } -+ else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || -+ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)) -+ { -+ halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); -+ } -+ else -+ { ++ } else if ( ++ (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || ++ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ++ ) { ++ halbtc8723b1ant_ActionBtScoHidOnlyBusy( ++ pBtCoexist, BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN ++ ); ++ } else { + /* Bryant Add */ + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); + } +} + -+static void -+halbtc8723b1ant_ActionWifiConnectedSpecialPacket( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionWifiConnectedSpecialPacket( ++ PBTC_COEXIST pBtCoexist ++) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; + + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ -+ if ((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist)) -+ { ++ if ( ++ (pBtLinkInfo->bScoExist) || ++ (pBtLinkInfo->bHidExist) || ++ (pBtLinkInfo->bA2dpExist) ++ ) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 32); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else if (pBtLinkInfo->bPanExist) -+ { ++ } else if (pBtLinkInfo->bPanExist) { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 20); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); -+ } -+ else -+ { ++ } else { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); + } +} + -+static void -+halbtc8723b1ant_ActionWifiConnected( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_ActionWifiConnected(PBTC_COEXIST pBtCoexist) +{ -+ bool bWifiBusy =false; -+ bool bScan =false, bLink =false, bRoam =false; -+ bool bUnder4way =false, bApEnable =false; ++ bool bWifiBusy = false; ++ bool bScan = false, bLink = false, bRoam = false; ++ bool bUnder4way = false, bApEnable = false; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect() ===>\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], CoexForWifiConnect() ===>\n") ++ ); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); -+ if (bUnder4way) -+ { ++ if (bUnder4way) { + halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n") ++ ); + return; + } + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); -+ if (bScan || bLink || bRoam) -+ { ++ if (bScan || bLink || bRoam) { + if (bScan) + halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist); + else + halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n") ++ ); + return; + } + @@ -37384,48 +36129,51 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + + /* power save state */ -+ if (!bApEnable && BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly) -+ { -+ if (pBtCoexist->btLinkInfo.bA2dpOnly) /* A2DP */ -+ { ++ if ( ++ !bApEnable && ++ BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && ++ !pBtCoexist->btLinkInfo.bHidOnly ++ ) { ++ if (pBtCoexist->btLinkInfo.bA2dpOnly) { /* A2DP */ + if (!bWifiBusy) -+ halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); -+ else /* busy */ -+ { ++ halbtc8723b1ant_PowerSaveState( ++ pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0 ++ ); ++ else { /* busy */ + if (pCoexSta->nScanAPNum >= BT_8723B_1ANT_WIFI_NOISY_THRESH) /* no force LPS, no PS-TDMA, use pure TDMA */ -+ { -+ halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); -+ } ++ halbtc8723b1ant_PowerSaveState( ++ pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0 ++ ); + else -+ { -+ halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); -+ } ++ halbtc8723b1ant_PowerSaveState( ++ pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4 ++ ); + } -+ } -+ else if ((pCoexSta->bPanExist == false) && (pCoexSta->bA2dpExist == false) && (pCoexSta->bHidExist == false)) ++ } else if ( ++ (pCoexSta->bPanExist == false) && ++ (pCoexSta->bA2dpExist == false) && ++ (pCoexSta->bHidExist == false) ++ ) + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + else + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); -+ } -+ else ++ } else + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); + + /* tdma and coex table */ -+ if (!bWifiBusy) -+ { -+ if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) -+ { -+ halbtc8723b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); -+ } -+ else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || -+ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)) -+ { ++ if (!bWifiBusy) { ++ if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) { ++ halbtc8723b1ant_ActionWifiConnectedBtAclBusy( ++ pBtCoexist, ++ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE ++ ); ++ } else if ( ++ (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || ++ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ++ ) { + halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, + BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); -+ } -+ else -+ { ++ } else { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8); + + if ((pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60) @@ -37433,22 +36181,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + else + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); + } -+ } -+ else -+ { -+ if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) -+ { -+ halbtc8723b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); -+ } -+ else if ((BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || -+ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)) -+ { -+ halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); -+ } -+ else -+ { ++ } else { ++ if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) { ++ halbtc8723b1ant_ActionWifiConnectedBtAclBusy( ++ pBtCoexist, ++ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY ++ ); ++ } else if ( ++ (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || ++ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ++ ) { ++ halbtc8723b1ant_ActionBtScoHidOnlyBusy( ++ pBtCoexist, ++ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY ++ ); ++ } else { + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 8); + + if ((pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60) @@ -37459,137 +36206,145 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } +} + -+static void -+halbtc8723b1ant_RunSwCoexistMechanism( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_RunSwCoexistMechanism(PBTC_COEXIST pBtCoexist) +{ -+ u8 algorithm = 0; ++ u8 algorithm = 0; + + algorithm = halbtc8723b1ant_ActionAlgorithm(pBtCoexist); + pCoexDm->curAlgorithm = algorithm; + -+ if (halbtc8723b1ant_IsCommonAction(pBtCoexist)) -+ { ++ if (halbtc8723b1ant_IsCommonAction(pBtCoexist)) { + -+ } -+ else -+ { -+ switch (pCoexDm->curAlgorithm) -+ { -+ case BT_8723B_1ANT_COEX_ALGO_SCO: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n")); -+ /* halbtc8723b1ant_ActionSco(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_HID: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n")); -+ /* halbtc8723b1ant_ActionHid(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_A2DP: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n")); -+ /* halbtc8723b1ant_ActionA2dp(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n")); -+ /* halbtc8723b1ant_ActionA2dpPanHs(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_PANEDR: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n")); -+ /* halbtc8723b1ant_ActionPanEdr(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_PANHS: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n")); -+ /* halbtc8723b1ant_ActionPanHs(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n")); -+ /* halbtc8723b1ant_ActionPanEdrA2dp(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n")); -+ /* halbtc8723b1ant_ActionPanEdrHid(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n")); -+ /* halbtc8723b1ant_ActionHidA2dpPanEdr(pBtCoexist); */ -+ break; -+ case BT_8723B_1ANT_COEX_ALGO_HID_A2DP: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n")); -+ /* halbtc8723b1ant_ActionHidA2dp(pBtCoexist); */ -+ break; -+ default: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n")); -+ break; ++ } else { ++ switch (pCoexDm->curAlgorithm) { ++ case BT_8723B_1ANT_COEX_ALGO_SCO: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = SCO.\n")); ++ /* halbtc8723b1ant_ActionSco(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_HID: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID.\n")); ++ /* halbtc8723b1ant_ActionHid(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_A2DP: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP.\n")); ++ /* halbtc8723b1ant_ActionA2dp(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n")); ++ /* halbtc8723b1ant_ActionA2dpPanHs(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_PANEDR: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR).\n")); ++ /* halbtc8723b1ant_ActionPanEdr(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_PANHS: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HS mode.\n")); ++ /* halbtc8723b1ant_ActionPanHs(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN+A2DP.\n")); ++ /* halbtc8723b1ant_ActionPanEdrA2dp(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n")); ++ /* halbtc8723b1ant_ActionPanEdrHid(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n")); ++ /* halbtc8723b1ant_ActionHidA2dpPanEdr(pBtCoexist); */ ++ break; ++ case BT_8723B_1ANT_COEX_ALGO_HID_A2DP: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = HID+A2DP.\n")); ++ /* halbtc8723b1ant_ActionHidA2dp(pBtCoexist); */ ++ break; ++ default: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action algorithm = coexist All Off!!\n")); ++ break; + } + pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; + } +} + -+static void -+halbtc8723b1ant_RunCoexistMechanism( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ bool bWifiConnected =false, bBtHsOn =false; -+ bool bIncreaseScanDevNum =false; -+ bool bBtCtrlAggBufSize =false; -+ u8 aggBufSize =5; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ bool bWifiConnected = false, bBtHsOn = false; ++ bool bIncreaseScanDevNum = false; ++ bool bBtCtrlAggBufSize = false; ++ u8 aggBufSize = 5; + u32 wifiLinkStatus = 0; + u32 numOfWifiLink = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism() ===>\n")); + -+ if (pBtCoexist->bManualControl) -+ { ++ if (pBtCoexist->bManualControl) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); + return; + } + -+ if (pBtCoexist->bStopCoexDm) -+ { ++ if (pBtCoexist->bStopCoexDm) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n")); + return; + } + -+ if (pCoexSta->bUnderIps) -+ { ++ if (pCoexSta->bUnderIps) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n")); + return; + } + -+ if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || ++ if ( ++ (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || + (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || -+ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)) -+ { ++ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ++ ){ + bIncreaseScanDevNum = true; + } + -+ pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum); -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); ++ pBtCoexist->fBtcSet( ++ pBtCoexist, ++ BTC_SET_BL_INC_SCAN_DEV_NUM, ++ &bIncreaseScanDevNum ++ ); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, ++ BTC_GET_BL_WIFI_CONNECTED, ++ &bWifiConnected ++ ); + -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, ++ BTC_GET_U4_WIFI_LINK_STATUS, ++ &wifiLinkStatus ++ ); + numOfWifiLink = wifiLinkStatus>>16; + -+ if ((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink, wifiLinkStatus)); ++ if ((numOfWifiLink >= 2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ( ++ "############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", ++ numOfWifiLink, ++ wifiLinkStatus ++ ) ++ ); + halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); + halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize); + -+ if ((pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage)) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], BT Is Inquirying\n")); ++ if ((pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage)) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ("############# [BTCoex], BT Is Inquirying\n") ++ ); + halbtc8723b1ant_ActionBtInquiry(pBtCoexist); -+ } -+ else -+ halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); ++ } else ++ halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); + + return; + } + -+ if ((pBtLinkInfo->bBtLinkExist) && (bWifiConnected)) -+ { ++ if ((pBtLinkInfo->bBtLinkExist) && (bWifiConnected)) { + halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); + + if (pBtLinkInfo->bScoExist) @@ -37599,9 +36354,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + halbtc8723b1ant_SwMechanism(pBtCoexist, true); + halbtc8723b1ant_RunSwCoexistMechanism(pBtCoexist); /* just print debug message */ -+ } -+ else -+ { ++ } else { + halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); + + halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x5); @@ -37611,22 +36364,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); -+ if (pCoexSta->bC2hBtInquiryPage) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], BT Is Inquirying\n")); ++ if (pCoexSta->bC2hBtInquiryPage) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ("############# [BTCoex], BT Is Inquirying\n") ++ ); + halbtc8723b1ant_ActionBtInquiry(pBtCoexist); + return; -+ } -+ else if (bBtHsOn) -+ { ++ } else if (bBtHsOn) { + halbtc8723b1ant_ActionHs(pBtCoexist); + return; + } + + -+ if (!bWifiConnected) -+ { -+ bool bScan =false, bLink =false, bRoam =false; ++ if (!bWifiConnected) { ++ bool bScan = false, bLink = false, bRoam = false; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is non connected-idle !!!\n")); + @@ -37634,26 +36387,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); + -+ if (bScan || bLink || bRoam) -+ { ++ if (bScan || bLink || bRoam) { + if (bScan) + halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist); + else + halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); -+ } -+ else ++ } else + halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist); -+ } -+ else /* wifi LPS/Busy */ -+ { ++ } else /* wifi LPS/Busy */ + halbtc8723b1ant_ActionWifiConnected(pBtCoexist); -+ } +} + -+static void -+halbtc8723b1ant_InitCoexDm( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist) +{ + /* force to reset coex mechanism */ + @@ -37666,17 +36411,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexSta->popEventCnt = 0; +} + -+static void -+halbtc8723b1ant_InitHwConfig( -+PBTC_COEXIST pBtCoexist, -+bool bBackUp, -+bool bWifiOnly -+ ) ++static void halbtc8723b1ant_InitHwConfig( ++ PBTC_COEXIST pBtCoexist, ++ bool bBackUp, ++ bool bWifiOnly ++) +{ -+ u32 u4Tmp = 0;/* fwVer; */ -+ u8 u1Tmpa = 0, u1Tmpb = 0; ++ u32 u4Tmp = 0;/* fwVer; */ ++ u8 u1Tmpa = 0, u1Tmpb = 0; + -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], 1Ant Init HW Config!!\n")); ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_INIT, ++ ("[BTCoex], 1Ant Init HW Config!!\n") ++ ); + + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x550, 0x8, 0x1); /* enable TBTT nterrupt */ + @@ -37688,12 +36436,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1); + + /* Antenna config */ -+ if (bWifiOnly) -+ { ++ if (bWifiOnly) { + halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, true, false); + halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 9); -+ } -+ else ++ } else + halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, true, false); + + /* PTA parameter */ @@ -37703,8 +36449,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); + u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); + -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("############# [BTCoex], 0x948 = 0x%x, 0x765 = 0x%x, 0x67 = 0x%x\n", -+ u4Tmp, u1Tmpa, u1Tmpb)); ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ( ++ "############# [BTCoex], 0x948 = 0x%x, 0x765 = 0x%x, 0x67 = 0x%x\n", ++ u4Tmp, ++ u1Tmpa, ++ u1Tmpb ++ ) ++ ); +} + +/* */ @@ -37713,12 +36467,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b +/* */ +/* extern function start with EXhalbtc8723b1ant_ */ +/* */ -+void -+EXhalbtc8723b1ant_PowerOnSetting( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BOARD_INFO pBoardInfo =&pBtCoexist->boardInfo; ++ PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo; + u8 u1Tmp = 0x0; + u16 u2Tmp = 0x0; + @@ -37740,8 +36491,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + /* BIT1: "0" for internal switch; "1" for external switch */ + /* BIT2: "0" for one antenna; "1" for two antenna */ + /* NOTE: here default all internal switch and 1-antenna ==> BIT1 = 0 and BIT2 = 0 */ -+ if (pBtCoexist->chipInterface == BTC_INTF_USB) -+ { ++ if (pBtCoexist->chipInterface == BTC_INTF_USB) { + /* fixed at S0 for USB interface */ + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); + @@ -37749,18 +36499,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); + + pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; -+ } -+ else -+ { ++ } else { + /* for PCIE and SDIO interface, we check efuse 0xc3[6] */ -+ if (pBoardInfo->singleAntPath == 0) -+ { ++ if (pBoardInfo->singleAntPath == 0) { + /* set to S1 */ + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); + pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; -+ } -+ else if (pBoardInfo->singleAntPath == 1) -+ { ++ } else if (pBoardInfo->singleAntPath == 1) { + /* set to S0 */ + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); + u1Tmp |= 0x1; /* antenna inverse */ @@ -37768,31 +36513,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } + + if (pBtCoexist->chipInterface == BTC_INTF_PCI) -+ { + pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp); -+ } + else if (pBtCoexist->chipInterface == BTC_INTF_SDIO) -+ { + pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); -+ } + } +} + -+void -+EXhalbtc8723b1ant_InitHwConfig( -+PBTC_COEXIST pBtCoexist, -+bool bWifiOnly -+ ) ++void EXhalbtc8723b1ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly) +{ + halbtc8723b1ant_InitHwConfig(pBtCoexist, true, bWifiOnly); +} + -+void -+EXhalbtc8723b1ant_InitCoexDm( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist) +{ -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n")); ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_INIT, ++ ("[BTCoex], Coex Mechanism Init!!\n") ++ ); + + pBtCoexist->bStopCoexDm = false; + @@ -37801,174 +36539,282 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + halbtc8723b1ant_QueryBtInfo(pBtCoexist); +} + -+void -+EXhalbtc8723b1ant_DisplayCoexInfo( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BOARD_INFO pBoardInfo =&pBtCoexist->boardInfo; -+ PBTC_STACK_INFO pStackInfo =&pBtCoexist->stackInfo; -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ u8 * cliBuf =pBtCoexist->cliBuf; -+ u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0; -+ u16 u2Tmp[4]; -+ u32 u4Tmp[4]; -+ bool bRoam =false, bScan =false, bLink =false, bWifiUnder5G =false, bWifiUnderBMode = false; -+ bool bBtHsOn =false, bWifiBusy =false; -+ s32 wifiRssi = 0, btHsRssi = 0; -+ u32 wifiBw, wifiTrafficDir, faOfdm, faCck, wifiLinkStatus; -+ u8 wifiDot11Chnl, wifiHsChnl; -+ u32 fwVer = 0, btPatchVer = 0; -+ static u8 PopReportIn10s = 0; ++ PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo; ++ PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ u8 *cliBuf = pBtCoexist->cliBuf; ++ u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0; ++ u16 u2Tmp[4]; ++ u32 u4Tmp[4]; ++ bool bRoam = false; ++ bool bScan = false; ++ bool bLink = false; ++ bool bWifiUnder5G = false; ++ bool bWifiUnderBMode = false; ++ bool bBtHsOn = false; ++ bool bWifiBusy = false; ++ s32 wifiRssi = 0, btHsRssi = 0; ++ u32 wifiBw, wifiTrafficDir, faOfdm, faCck, wifiLinkStatus; ++ u8 wifiDot11Chnl, wifiHsChnl; ++ u32 fwVer = 0, btPatchVer = 0; ++ static u8 PopReportIn10s = 0; + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n ============[BT Coexist info]============" ++ ); + CL_PRINTF(cliBuf); + -+ if (pBtCoexist->bManualControl) -+ { -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); ++ if (pBtCoexist->bManualControl) { ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n ============[Under Manual Control]============" ++ ); + CL_PRINTF(cliBuf); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); ++ CL_SPRINTF(cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n ==========================================" ++ ); + CL_PRINTF(cliBuf); + } -+ if (pBtCoexist->bStopCoexDm) -+ { -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============"); ++ if (pBtCoexist->bStopCoexDm) { ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n ============[Coex is STOPPED]============" ++ ); + CL_PRINTF(cliBuf); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n ==========================================" ++ ); + CL_PRINTF(cliBuf); + } + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Ant Mech/ Ant Pos:", \ -+ pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Ant Mech/ Ant Pos:", \ ++ pBoardInfo->pgAntNum, ++ pBoardInfo->btdmAntNum, ++ pBoardInfo->btdmAntPos ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ -+ ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ ++ ((pStackInfo->bProfileNotified) ? "Yes" : "No"), ++ pStackInfo->hciVersion ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ -+ GLCoexVerDate8723b1Ant, GLCoexVer8723b1Ant, fwVer, btPatchVer, btPatchVer); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ ++ GLCoexVerDate8723b1Ant, ++ GLCoexVer8723b1Ant, ++ fwVer, ++ btPatchVer, ++ btPatchVer ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \ -+ wifiDot11Chnl, wifiHsChnl, bBtHsOn); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \ ++ wifiDot11Chnl, ++ wifiHsChnl, ++ bBtHsOn ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \ -+ pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], -+ pCoexDm->wifiChnlInfo[2]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \ ++ pCoexDm->wifiChnlInfo[0], ++ pCoexDm->wifiChnlInfo[1], ++ pCoexDm->wifiChnlInfo[2] ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \ -+ wifiRssi-100, btHsRssi-100); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \ ++ wifiRssi-100, btHsRssi-100 ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %s", "Wifi bLink/ bRoam/ bScan/ bHi-Pri", \ -+ bLink, bRoam, bScan, ((pCoexSta->bWiFiIsHighPriTask)? "1":"0")); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d/ %s", "Wifi bLink/ bRoam/ bScan/ bHi-Pri", \ ++ bLink, bRoam, bScan, ((pCoexSta->bWiFiIsHighPriTask) ? "1" : "0") ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir ++ ); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode ++ ); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s/ AP =%d/ %s ", "Wifi status", \ -+ (bWifiUnder5G? "5G":"2.4G"), -+ ((bWifiUnderBMode)? "11b": ((BTC_WIFI_BW_LEGACY ==wifiBw)? "11bg": (((BTC_WIFI_BW_HT40 ==wifiBw)? "HT40":"HT20")))), -+ ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX ==wifiTrafficDir)? "uplink":"downlink")), pCoexSta->nScanAPNum, (pCoexSta->bCCKLock)? "Lock":"noLock"); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s / %s/ %s/ AP =%d/ %s ", "Wifi status", \ ++ (bWifiUnder5G ? "5G" : "2.4G"), ++ ((bWifiUnderBMode) ? "11b" : ((BTC_WIFI_BW_LEGACY == wifiBw) ? "11bg" : (((BTC_WIFI_BW_HT40 == wifiBw) ? "HT40" : "HT20")))), ++ ((!bWifiBusy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) ? "uplink" : "downlink")), ++ pCoexSta->nScanAPNum, ++ (pCoexSta->bCCKLock) ? "Lock" : "noLock" ++ ); + CL_PRINTF(cliBuf); + -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "sta/vwifi/hs/p2pGo/p2pGc", \ -+ ((wifiLinkStatus&WIFI_STA_CONNECTED)? 1:0), ((wifiLinkStatus&WIFI_AP_CONNECTED)? 1:0), -+ ((wifiLinkStatus&WIFI_HS_CONNECTED)? 1:0), ((wifiLinkStatus&WIFI_P2P_GO_CONNECTED)? 1:0), -+ ((wifiLinkStatus&WIFI_P2P_GC_CONNECTED)? 1:0)); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus ++ ); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "sta/vwifi/hs/p2pGo/p2pGc", \ ++ ((wifiLinkStatus&WIFI_STA_CONNECTED) ? 1 : 0), ++ ((wifiLinkStatus&WIFI_AP_CONNECTED) ? 1 : 0), ++ ((wifiLinkStatus&WIFI_HS_CONNECTED) ? 1 : 0), ++ ((wifiLinkStatus&WIFI_P2P_GO_CONNECTED) ? 1 : 0), ++ ((wifiLinkStatus&WIFI_P2P_GC_CONNECTED) ? 1 : 0) ++ ); + CL_PRINTF(cliBuf); + + + PopReportIn10s++; -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d/ %d] ", "BT [status/ rssi/ retryCnt/ popCnt]", \ -+ ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": -+ ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), -+ pCoexSta->btRssi, pCoexSta->btRetryCnt, pCoexSta->popEventCnt); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = [%s/ %d/ %d/ %d] ", "BT [status/ rssi/ retryCnt/ popCnt]", \ ++ ((pBtCoexist->btInfo.bBtDisabled) ? ("disabled") : ((pCoexSta->bC2hBtInquiryPage) ? ("inquiry/page scan") : ((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ? "non-connected idle" : ++ ((BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ? "connected-idle" : "busy")))), ++ pCoexSta->btRssi, pCoexSta->btRetryCnt, pCoexSta->popEventCnt ++ ); + CL_PRINTF(cliBuf); + -+ if (PopReportIn10s >= 5) -+ { ++ if (PopReportIn10s >= 5) { + pCoexSta->popEventCnt = 0; + PopReportIn10s = 0; + } + + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ -+ pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ ++ pBtLinkInfo->bScoExist, ++ pBtLinkInfo->bHidExist, ++ pBtLinkInfo->bPanExist, ++ pBtLinkInfo->bA2dpExist ++ ); + CL_PRINTF(cliBuf); + -+ if (pStackInfo->bProfileNotified) -+ { -+ pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); -+ } -+ else -+ { ++ if (pStackInfo->bProfileNotified) { ++ pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); ++ } else { + CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \ -+ (pBtLinkInfo->bSlaveRole)? "Slave":"Master"); ++ (pBtLinkInfo->bSlaveRole) ? "Slave" : "Master"); + CL_PRINTF(cliBuf); + } + + + btInfoExt = pCoexSta->btInfoExt; -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ -+ (btInfoExt&BIT0)? "Basic rate":"EDR rate"); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s", "BT Info A2DP rate", \ ++ (btInfoExt&BIT0) ? "Basic rate" : "EDR rate" ++ ); + CL_PRINTF(cliBuf); + -+ for (i = 0; ibtInfoC2hCnt[i]) -+ { -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b1Ant[i], \ ++ for (i = 0; i < BT_INFO_SRC_8723B_1ANT_MAX; i++) { ++ if (pCoexSta->btInfoC2hCnt[i]) { ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b1Ant[i], \ + pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], + pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], + pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], -+ pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); ++ pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i] ++ ); + CL_PRINTF(cliBuf); + } + } -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \ -+ ((pCoexSta->bUnderIps? "IPS ON":"IPS OFF")), -+ ((pCoexSta->bUnderLps? "LPS ON":"LPS OFF")), ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", \ ++ (pCoexSta->bUnderIps ? "IPS ON" : "IPS OFF"), ++ (pCoexSta->bUnderLps ? "LPS ON" : "LPS OFF"), + pBtCoexist->btInfo.lpsVal, -+ pBtCoexist->btInfo.rpwmVal); ++ pBtCoexist->btInfo.rpwmVal ++ ); + CL_PRINTF(cliBuf); + pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); + -+ if (!pBtCoexist->bManualControl) -+ { ++ if (!pBtCoexist->bManualControl) { + /* Sw mechanism */ -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s", "============[Sw mechanism]============" ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "SM[LowPenaltyRA]", \ -+ pCoexDm->bCurLowPenaltyRa); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d", "SM[LowPenaltyRA]", \ ++ pCoexDm->bCurLowPenaltyRa ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \ -+ (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"), -+ pBtCoexist->btInfo.aggBufSize); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \ ++ (pBtCoexist->btInfo.bRejectAggPkt ? "Yes" : "No"), ++ (pBtCoexist->btInfo.bBtCtrlAggBufSize ? "Yes" : "No"), ++ pBtCoexist->btInfo.aggBufSize ++ ); + CL_PRINTF(cliBuf); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \ -+ pBtCoexist->btInfo.raMask); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x ", "Rate Mask", \ ++ pBtCoexist->btInfo.raMask ++ ); + CL_PRINTF(cliBuf); + + /* Fw mechanism */ @@ -38016,43 +36862,69 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc); + u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/0x880[29:25]", \ -+ u1Tmp[0], u4Tmp[0], (u4Tmp[1]&0x3e000000) >> 25); ++ CL_SPRINTF( ++ cliBuf, BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/0x880[29:25]", \ ++ u1Tmp[0], u4Tmp[0], (u4Tmp[1]&0x3e000000) >> 25 ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); + u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x764); + u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x764 / 0x76e", \ -+ u4Tmp[0], ((u1Tmp[0]&0x20)>> 5), (u4Tmp[1] & 0xffff), u1Tmp[1]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x764 / 0x76e", \ ++ u4Tmp[0], ((u1Tmp[0]&0x20) >> 5), (u4Tmp[1] & 0xffff), u1Tmp[1] ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c); + u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); + u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \ -+ u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \ ++ u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3 ++ ); + CL_PRINTF(cliBuf); + + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39); + u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); + u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \ -+ ((u1Tmp[0] & 0x8)>>3), u1Tmp[1], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[2]&0x1); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \ ++ ((u1Tmp[0] & 0x8)>>3), ++ u1Tmp[1], ++ ((u4Tmp[0]&0x01800000)>>23), ++ u1Tmp[2]&0x1 ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ -+ u4Tmp[0], u1Tmp[0]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ ++ u4Tmp[0], u1Tmp[0] ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ -+ u4Tmp[0]&0xff, u1Tmp[0]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ ++ u4Tmp[0]&0xff, u1Tmp[0] ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); @@ -38063,62 +36935,91 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); + u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); + -+ faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ -+ ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ; ++ faOfdm = ++ ((u4Tmp[0]&0xffff0000) >> 16) + ++ ((u4Tmp[1]&0xffff0000) >> 16) + ++ (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ ++ ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff); + faCck = (u1Tmp[0] << 8) + u1Tmp[1]; + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ -+ u4Tmp[0]&0xffff, faOfdm, faCck); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ ++ u4Tmp[0]&0xffff, faOfdm, faCck ++ ); + CL_PRINTF(cliBuf); + + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \ -+ pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \ ++ pCoexSta->nCRCOK_CCK, ++ pCoexSta->nCRCOK_11g, ++ pCoexSta->nCRCOK_11n, ++ pCoexSta->nCRCOK_11nAgg ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \ -+ pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \ ++ pCoexSta->nCRCErr_CCK, ++ pCoexSta->nCRCErr_11g, ++ pCoexSta->nCRCErr_11n, ++ pCoexSta->nCRCErr_11nAgg ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); + u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); + u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \ ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \ + u4Tmp[0], u4Tmp[1], u4Tmp[2]); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ -+ pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ ++ pCoexSta->highPriorityRx, pCoexSta->highPriorityTx ++ ); + CL_PRINTF(cliBuf); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ -+ pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ ++ pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); +} + + -+void -+EXhalbtc8723b1ant_IpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ + if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) + return; + -+ if (BTC_IPS_ENTER == type) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n")); ++ if (BTC_IPS_ENTER == type) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n") ++ ); + pCoexSta->bUnderIps = true; + + halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0); + halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); + halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, false, true); -+ } -+ else if (BTC_IPS_LEAVE == type) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n")); ++ } else if (BTC_IPS_LEAVE == type) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n") ++ ); + pCoexSta->bUnderIps = false; + + halbtc8723b1ant_InitHwConfig(pBtCoexist, false, false); @@ -38127,50 +37028,43 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } +} + -+void -+EXhalbtc8723b1ant_LpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ + if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) + return; + -+ if (BTC_LPS_ENABLE == type) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n")); ++ if (BTC_LPS_ENABLE == type) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n") ++ ); + pCoexSta->bUnderLps = true; -+ } -+ else if (BTC_LPS_DISABLE == type) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n")); ++ } else if (BTC_LPS_DISABLE == type) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n") ++ ); + pCoexSta->bUnderLps = false; + } +} + -+void -+EXhalbtc8723b1ant_ScanNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ bool bWifiConnected =false, bBtHsOn =false; ++ bool bWifiConnected = false, bBtHsOn = false; + u32 wifiLinkStatus = 0; + u32 numOfWifiLink = 0; -+ bool bBtCtrlAggBufSize =false; -+ u8 aggBufSize =5; ++ bool bBtCtrlAggBufSize = false; ++ u8 aggBufSize = 5; + + u8 u1Tmpa, u1Tmpb; + u32 u4Tmp; + -+ if (pBtCoexist->bManualControl || -+ pBtCoexist->bStopCoexDm) ++ if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) + return; + -+ if (BTC_SCAN_START == type) -+ { ++ if (BTC_SCAN_START == type) { + pCoexSta->bWiFiIsHighPriTask = true; -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n")); ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n") ++ ); + + halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, false, 8); /* Force antenna setup for no scan result issue */ + u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); @@ -38178,15 +37072,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); + + -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], 0x948 = 0x%x, 0x765 = 0x%x, 0x67 = 0x%x\n", -+ u4Tmp, u1Tmpa, u1Tmpb)); -+ } -+ else -+ { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ( ++ "[BTCoex], 0x948 = 0x%x, 0x765 = 0x%x, 0x67 = 0x%x\n", ++ u4Tmp, ++ u1Tmpa, ++ u1Tmpb ++ ) ++ ); ++ } else { + pCoexSta->bWiFiIsHighPriTask = false; -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n")); ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n") ++ ); + -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum ++ ); + } + + if (pBtCoexist->btInfo.bBtDisabled) @@ -38199,76 +37103,59 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); + numOfWifiLink = wifiLinkStatus>>16; -+ if (numOfWifiLink >= 2) -+ { ++ ++ if (numOfWifiLink >= 2) { + halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); -+ halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize); ++ halbtc8723b1ant_LimitedRx( ++ pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize ++ ); + halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); + return; + } + -+ if (pCoexSta->bC2hBtInquiryPage) -+ { ++ if (pCoexSta->bC2hBtInquiryPage) { + halbtc8723b1ant_ActionBtInquiry(pBtCoexist); + return; -+ } -+ else if (bBtHsOn) -+ { ++ } else if (bBtHsOn) { + halbtc8723b1ant_ActionHs(pBtCoexist); + return; + } + -+ if (BTC_SCAN_START == type) -+ { ++ if (BTC_SCAN_START == type) { + /* BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n")); */ + if (!bWifiConnected) /* non-connected scan */ -+ { + halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist); -+ } + else /* wifi is connected */ -+ { + halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist); -+ } -+ } -+ else if (BTC_SCAN_FINISH == type) -+ { ++ } else if (BTC_SCAN_FINISH == type) { + /* BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n")); */ + if (!bWifiConnected) /* non-connected scan */ -+ { + halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist); -+ } + else -+ { + halbtc8723b1ant_ActionWifiConnected(pBtCoexist); -+ } + } +} + -+void -+EXhalbtc8723b1ant_ConnectNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ bool bWifiConnected =false, bBtHsOn =false; ++ bool bWifiConnected = false, bBtHsOn = false; + u32 wifiLinkStatus = 0; + u32 numOfWifiLink = 0; -+ bool bBtCtrlAggBufSize =false; -+ u8 aggBufSize =5; ++ bool bBtCtrlAggBufSize = false; ++ u8 aggBufSize = 5; + -+ if (pBtCoexist->bManualControl || ++ if ( ++ pBtCoexist->bManualControl || + pBtCoexist->bStopCoexDm || -+ pBtCoexist->btInfo.bBtDisabled) ++ pBtCoexist->btInfo.bBtDisabled ++ ) + return; + -+ if (BTC_ASSOCIATE_START == type) -+ { ++ if (BTC_ASSOCIATE_START == type) { + pCoexSta->bWiFiIsHighPriTask = true; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n")); + pCoexDm->nArpCnt = 0; -+ } -+ else -+ { ++ } else { + pCoexSta->bWiFiIsHighPriTask = false; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n")); + /* pCoexDm->nArpCnt = 0; */ @@ -38276,8 +37163,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); + numOfWifiLink = wifiLinkStatus>>16; -+ if (numOfWifiLink >= 2) -+ { ++ if (numOfWifiLink >= 2) { + halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); + halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize); + halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); @@ -38285,68 +37171,52 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); -+ if (pCoexSta->bC2hBtInquiryPage) -+ { ++ if (pCoexSta->bC2hBtInquiryPage) { + halbtc8723b1ant_ActionBtInquiry(pBtCoexist); + return; -+ } -+ else if (bBtHsOn) -+ { ++ } else if (bBtHsOn) { + halbtc8723b1ant_ActionHs(pBtCoexist); + return; + } + -+ if (BTC_ASSOCIATE_START == type) -+ { ++ if (BTC_ASSOCIATE_START == type) { + /* BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n")); */ + halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); -+ } -+ else if (BTC_ASSOCIATE_FINISH == type) -+ { ++ } else if (BTC_ASSOCIATE_FINISH == type) { + /* BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n")); */ + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); + if (!bWifiConnected) /* non-connected scan */ -+ { + halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist); -+ } + else -+ { + halbtc8723b1ant_ActionWifiConnected(pBtCoexist); -+ } + } +} + -+void -+EXhalbtc8723b1ant_MediaStatusNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ u8 H2C_Parameter[3] ={0}; -+ u32 wifiBw; -+ u8 wifiCentralChnl; -+ bool bWifiUnderBMode = false; ++ u8 H2C_Parameter[3] = {0}; ++ u32 wifiBw; ++ u8 wifiCentralChnl; ++ bool bWifiUnderBMode = false; + -+ if (pBtCoexist->bManualControl || ++ if ( ++ pBtCoexist->bManualControl || + pBtCoexist->bStopCoexDm || -+ pBtCoexist->btInfo.bBtDisabled) ++ pBtCoexist->btInfo.bBtDisabled ++ ) + return; + -+ if (BTC_MEDIA_CONNECT == type) -+ { ++ if (BTC_MEDIA_CONNECT == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n")); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); + + /* Set CCK Tx/Rx high Pri except 11b mode */ -+ if (bWifiUnderBMode) -+ { ++ if (bWifiUnderBMode) { + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); /* CCK Tx */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); /* CCK Rx */ -+ } -+ else -+ { ++ } else { + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); /* CCK Tx */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); /* CCK Rx */ + } @@ -38355,9 +37225,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); + pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); + pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n")); + pCoexDm->nArpCnt = 0; + @@ -38367,13 +37235,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + /* only 2.4G we need to inform bt the chnl mask */ + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); -+ if ((BTC_MEDIA_CONNECT == type) && -+ (wifiCentralChnl <= 14)) -+ { ++ if ((BTC_MEDIA_CONNECT == type) && (wifiCentralChnl <= 14)) { + /* H2C_Parameter[0] = 0x1; */ + H2C_Parameter[0] = 0x0; + H2C_Parameter[1] = wifiCentralChnl; + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); ++ + if (BTC_WIFI_BW_HT40 == wifiBw) + H2C_Parameter[2] = 0x30; + else @@ -38384,104 +37251,114 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; + pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x66 = 0x%x\n", -+ H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], FW write 0x66 = 0x%x\n", ++ H2C_Parameter[0]<<16 | H2C_Parameter[1]<<8 | H2C_Parameter[2] ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); +} + -+void -+EXhalbtc8723b1ant_SpecialPacketNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ bool bBtHsOn =false; ++ bool bBtHsOn = false; + u32 wifiLinkStatus = 0; + u32 numOfWifiLink = 0; -+ bool bBtCtrlAggBufSize =false; -+ u8 aggBufSize =5; ++ bool bBtCtrlAggBufSize = false; ++ u8 aggBufSize = 5; + -+ if (pBtCoexist->bManualControl || ++ if ( ++ pBtCoexist->bManualControl || + pBtCoexist->bStopCoexDm || -+ pBtCoexist->btInfo.bBtDisabled) ++ pBtCoexist->btInfo.bBtDisabled ++ ) + return; + -+ if (BTC_PACKET_DHCP == type || ++ if ( ++ BTC_PACKET_DHCP == type || + BTC_PACKET_EAPOL == type || -+ BTC_PACKET_ARP == type) -+ { -+ if (BTC_PACKET_ARP == type) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet ARP notify\n")); ++ BTC_PACKET_ARP == type ++ ) { ++ if (BTC_PACKET_ARP == type) { ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ("[BTCoex], special Packet ARP notify\n") ++ ); + + pCoexDm->nArpCnt++; -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt)); ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt) ++ ); + + if (pCoexDm->nArpCnt >= 10) /* if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist) */ -+ { + pCoexSta->bWiFiIsHighPriTask = false; -+ } + else -+ { + pCoexSta->bWiFiIsHighPriTask = true; -+ } -+ } -+ else -+ { ++ } else { + pCoexSta->bWiFiIsHighPriTask = true; -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet DHCP or EAPOL notify\n")); ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ("[BTCoex], special Packet DHCP or EAPOL notify\n") ++ ); + } -+ } -+ else -+ { ++ } else { + pCoexSta->bWiFiIsHighPriTask = false; -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], special Packet [Type = %d] notify\n", type)); ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, ++ INTF_NOTIFY, ++ ("[BTCoex], special Packet [Type = %d] notify\n", type) ++ ); + } + + pCoexSta->specialPktPeriodCnt = 0; + -+ pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); ++ pBtCoexist->fBtcGet( ++ pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus ++ ); + numOfWifiLink = wifiLinkStatus>>16; -+ if (numOfWifiLink >= 2) -+ { ++ ++ if (numOfWifiLink >= 2) { + halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); -+ halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize); ++ halbtc8723b1ant_LimitedRx( ++ pBtCoexist, NORMAL_EXEC, false, bBtCtrlAggBufSize, aggBufSize ++ ); + halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); + return; + } + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); -+ if (pCoexSta->bC2hBtInquiryPage) -+ { ++ if (pCoexSta->bC2hBtInquiryPage) { + halbtc8723b1ant_ActionBtInquiry(pBtCoexist); + return; -+ } -+ else if (bBtHsOn) -+ { ++ } else if (bBtHsOn) { + halbtc8723b1ant_ActionHs(pBtCoexist); + return; + } + -+ if (BTC_PACKET_DHCP == type || ++ if ( ++ BTC_PACKET_DHCP == type || + BTC_PACKET_EAPOL == type || -+ ((BTC_PACKET_ARP == type) && (pCoexSta->bWiFiIsHighPriTask))) -+ { ++ ((BTC_PACKET_ARP == type) && (pCoexSta->bWiFiIsHighPriTask)) ++ ) + halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); -+ } +} + -+void -+EXhalbtc8723b1ant_BtInfoNotify( -+PBTC_COEXIST pBtCoexist, -+u8 * tmpBuf, -+u8 length -+ ) ++void EXhalbtc8723b1ant_BtInfoNotify( ++ PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length ++) +{ -+ u8 btInfo = 0; -+ u8 i, rspSource = 0; -+ bool bWifiConnected =false; -+ bool bBtBusy =false; ++ u8 btInfo = 0; ++ u8 i, rspSource = 0; ++ bool bWifiConnected = false; ++ bool bBtBusy = false; + + pCoexSta->bC2hBtInfoReqSent = false; + @@ -38490,26 +37367,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + rspSource = BT_INFO_SRC_8723B_1ANT_WIFI_FW; + pCoexSta->btInfoC2hCnt[rspSource]++; + -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length =%d, hex data =[", rspSource, length)); -+ for (i = 0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; + if (i == 1) + btInfo = tmpBuf[i]; + if (i == length-1) -+ { -+ BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i])); -+ } ++ BTC_PRINT( ++ BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i]) ++ ); + else -+ { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i])); -+ } + } + -+ if (BT_INFO_SRC_8723B_1ANT_WIFI_FW != rspSource) -+ { -+ pCoexSta->btRetryCnt = /* [3:0] */ -+ pCoexSta->btInfoC2h[rspSource][2]&0xf; ++ if (BT_INFO_SRC_8723B_1ANT_WIFI_FW != rspSource) { ++ pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2]&0xf; + + if (pCoexSta->btRetryCnt >= 1) + pCoexSta->popEventCnt++; @@ -38519,17 +37397,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + else + pCoexSta->bC2hBtPage = false; + -+ pCoexSta->btRssi = -+ pCoexSta->btInfoC2h[rspSource][3]*2-90; -+ /* pCoexSta->btInfoC2h[rspSource][3]*2+10; */ ++ pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3]*2-90; ++ /* pCoexSta->btInfoC2h[rspSource][3]*2+10; */ + -+ pCoexSta->btInfoExt = -+ pCoexSta->btInfoC2h[rspSource][4]; ++ pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4]; + + pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); -+ if (!pCoexSta->bBtTxRxMask) -+ { ++ ++ if (!pCoexSta->bBtTxRxMask) { + /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n")); + pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); @@ -38537,30 +37413,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + /* Here we need to resend some wifi info to BT */ + /* because bt is reset and loss of the info. */ -+ if (pCoexSta->btInfoExt & BIT1) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); ++ if (pCoexSta->btInfoExt & BIT1) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n") ++ ); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); + if (bWifiConnected) -+ { + EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); -+ } + else -+ { + EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -+ } + } + -+ if (pCoexSta->btInfoExt & BIT3) -+ { -+ if (!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); ++ if (pCoexSta->btInfoExt & BIT3) { ++ if (!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n") ++ ); + halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, false); + } -+ } -+ else -+ { ++ } else { + /* BT already NOT ignore Wlan active, do nothing here. */ + } + } @@ -38572,29 +37447,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pCoexSta->bC2hBtInquiryPage = false; + + /* set link exist status */ -+ if (!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) -+ { ++ if (!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) { + pCoexSta->bBtLinkExist = false; + pCoexSta->bPanExist = false; + pCoexSta->bA2dpExist = false; + pCoexSta->bHidExist = false; + pCoexSta->bScoExist = false; -+ } -+ else /* connection exists */ -+ { ++ } else { /* connection exists */ + pCoexSta->bBtLinkExist = true; + if (btInfo & BT_INFO_8723B_1ANT_B_FTP) + pCoexSta->bPanExist = true; + else + pCoexSta->bPanExist = false; ++ + if (btInfo & BT_INFO_8723B_1ANT_B_A2DP) + pCoexSta->bA2dpExist = true; + else + pCoexSta->bA2dpExist = false; ++ + if (btInfo & BT_INFO_8723B_1ANT_B_HID) + pCoexSta->bHidExist = true; + else + pCoexSta->bHidExist = false; ++ + if (btInfo & BT_INFO_8723B_1ANT_B_SCO_ESCO) + pCoexSta->bScoExist = true; + else @@ -38605,38 +37480,35 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + + btInfo = btInfo & 0x1f; /* mask profile bit for connect-ilde identification (for CSR case: A2DP idle --> 0x41) */ + -+ if (!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) -+ { ++ if (!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) { + pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); -+ } -+ else if (btInfo == BT_INFO_8723B_1ANT_B_CONNECTION) /* connection exists but no busy */ -+ { ++ } else if (btInfo == BT_INFO_8723B_1ANT_B_CONNECTION) { ++ /* connection exists but no busy */ + pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); -+ } -+ else if ((btInfo&BT_INFO_8723B_1ANT_B_SCO_ESCO) || -+ (btInfo&BT_INFO_8723B_1ANT_B_SCO_BUSY)) -+ { ++ } else if ( ++ (btInfo&BT_INFO_8723B_1ANT_B_SCO_ESCO) || ++ (btInfo&BT_INFO_8723B_1ANT_B_SCO_BUSY) ++ ) { + pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_SCO_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); -+ } -+ else if (btInfo&BT_INFO_8723B_1ANT_B_ACL_BUSY) -+ { ++ } else if (btInfo&BT_INFO_8723B_1ANT_B_ACL_BUSY) { + if (BT_8723B_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus) + pCoexDm->bAutoTdmaAdjust = false; ++ + pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_ACL_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); -+ } -+ else -+ { ++ } else { + pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_MAX; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); + } + -+ if ((BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || ++ if ( ++ (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || + (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || -+ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)) ++ (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ++ ) + bBtBusy = true; + else + bBtBusy = false; @@ -38645,10 +37517,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + halbtc8723b1ant_RunCoexistMechanism(pBtCoexist); +} + -+void -+EXhalbtc8723b1ant_HaltNotify( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n")); + @@ -38663,16 +37532,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + pBtCoexist->bStopCoexDm = true; +} + -+void -+EXhalbtc8723b1ant_PnpNotify( -+PBTC_COEXIST pBtCoexist, -+u8 pnpState -+ ) ++void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n")); + -+ if (BTC_WIFI_PNP_SLEEP == pnpState) -+ { ++ if (BTC_WIFI_PNP_SLEEP == pnpState) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to SLEEP\n")); + + halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); @@ -38681,9 +37545,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, false, true); + + pBtCoexist->bStopCoexDm = true; -+ } -+ else if (BTC_WIFI_PNP_WAKE_UP == pnpState) -+ { ++ } else if (BTC_WIFI_PNP_WAKE_UP == pnpState) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to WAKE UP\n")); + pBtCoexist->bStopCoexDm = false; + halbtc8723b1ant_InitHwConfig(pBtCoexist, false, false); @@ -38692,18 +37554,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + } +} + -+void -+EXhalbtc8723b1ant_Periodical( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b1ant_Periodical(PBTC_COEXIST pBtCoexist) +{ + static u8 disVerInfoCnt = 0; -+ u32 fwVer = 0, btPatchVer = 0; ++ u32 fwVer = 0, btPatchVer = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical ===========================\n")); + -+ if (disVerInfoCnt <= 5) -+ { ++ if (disVerInfoCnt <= 5) { + disVerInfoCnt += 1; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n")); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); @@ -38716,19 +37574,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.c linux-4.3-rtl8723b + halbtc8723b1ant_MonitorBtCtr(pBtCoexist); + halbtc8723b1ant_MonitorWiFiCtr(pBtCoexist); + -+ if (halbtc8723b1ant_IsWifiStatusChanged(pBtCoexist) || -+ pCoexDm->bAutoTdmaAdjust) -+ { -+ ++ if ( ++ halbtc8723b1ant_IsWifiStatusChanged(pBtCoexist) || ++ pCoexDm->bAutoTdmaAdjust ++ ) + halbtc8723b1ant_RunCoexistMechanism(pBtCoexist); -+ } + + pCoexSta->specialPktPeriodCnt++; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h ---- linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,243 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h linux/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h +--- linux.old/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,193 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -38754,20 +37611,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h linux-4.3-rtl8723b +#define BT_INFO_8723B_1ANT_B_CONNECTION BIT0 + +#define BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ -+ (((_BT_INFO_EXT_&BIT0))? true:false) ++ (((_BT_INFO_EXT_&BIT0)) ? true : false) + -+#define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT 2 ++#define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT 2 + -+#define BT_8723B_1ANT_WIFI_NOISY_THRESH 30 /* max: 255 */ ++#define BT_8723B_1ANT_WIFI_NOISY_THRESH 30 /* max: 255 */ + -+typedef enum _BT_INFO_SRC_8723B_1ANT{ ++typedef enum _BT_INFO_SRC_8723B_1ANT { + BT_INFO_SRC_8723B_1ANT_WIFI_FW = 0x0, + BT_INFO_SRC_8723B_1ANT_BT_RSP = 0x1, + BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND = 0x2, + BT_INFO_SRC_8723B_1ANT_MAX -+}BT_INFO_SRC_8723B_1ANT,*PBT_INFO_SRC_8723B_1ANT; ++} BT_INFO_SRC_8723B_1ANT, *PBT_INFO_SRC_8723B_1ANT; + -+typedef enum _BT_8723B_1ANT_BT_STATUS{ ++typedef enum _BT_8723B_1ANT_BT_STATUS { + BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, + BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, + BT_8723B_1ANT_BT_STATUS_INQ_PAGE = 0x2, @@ -38775,67 +37632,67 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h linux-4.3-rtl8723b + BT_8723B_1ANT_BT_STATUS_SCO_BUSY = 0x4, + BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, + BT_8723B_1ANT_BT_STATUS_MAX -+}BT_8723B_1ANT_BT_STATUS,*PBT_8723B_1ANT_BT_STATUS; ++} BT_8723B_1ANT_BT_STATUS, *PBT_8723B_1ANT_BT_STATUS; + -+typedef enum _BT_8723B_1ANT_WIFI_STATUS{ -+ BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, -+ BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, -+ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, ++typedef enum _BT_8723B_1ANT_WIFI_STATUS { ++ BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, ++ BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, ++ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, ++ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, ++ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, ++ BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, + BT_8723B_1ANT_WIFI_STATUS_MAX -+}BT_8723B_1ANT_WIFI_STATUS,*PBT_8723B_1ANT_WIFI_STATUS; ++} BT_8723B_1ANT_WIFI_STATUS, *PBT_8723B_1ANT_WIFI_STATUS; + -+typedef enum _BT_8723B_1ANT_COEX_ALGO{ -+ BT_8723B_1ANT_COEX_ALGO_UNDEFINED = 0x0, ++typedef enum _BT_8723B_1ANT_COEX_ALGO { ++ BT_8723B_1ANT_COEX_ALGO_UNDEFINED = 0x0, + BT_8723B_1ANT_COEX_ALGO_SCO = 0x1, + BT_8723B_1ANT_COEX_ALGO_HID = 0x2, -+ BT_8723B_1ANT_COEX_ALGO_A2DP = 0x3, ++ BT_8723B_1ANT_COEX_ALGO_A2DP = 0x3, + BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, + BT_8723B_1ANT_COEX_ALGO_PANEDR = 0x5, + BT_8723B_1ANT_COEX_ALGO_PANHS = 0x6, + BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, + BT_8723B_1ANT_COEX_ALGO_PANEDR_HID = 0x8, + BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, -+ BT_8723B_1ANT_COEX_ALGO_HID_A2DP = 0xa, ++ BT_8723B_1ANT_COEX_ALGO_HID_A2DP = 0xa, + BT_8723B_1ANT_COEX_ALGO_MAX = 0xb, -+}BT_8723B_1ANT_COEX_ALGO,*PBT_8723B_1ANT_COEX_ALGO; ++} BT_8723B_1ANT_COEX_ALGO, *PBT_8723B_1ANT_COEX_ALGO; + -+typedef struct _COEX_DM_8723B_1ANT{ ++typedef struct _COEX_DM_8723B_1ANT { + /* fw mechanism */ -+ bool bCurIgnoreWlanAct; -+ bool bPreIgnoreWlanAct; ++ bool bCurIgnoreWlanAct; ++ bool bPreIgnoreWlanAct; + u8 prePsTdma; + u8 curPsTdma; + u8 psTdmaPara[5]; + u8 psTdmaDuAdjType; -+ bool bAutoTdmaAdjust; -+ bool bPrePsTdmaOn; -+ bool bCurPsTdmaOn; -+ bool bPreBtAutoReport; -+ bool bCurBtAutoReport; ++ bool bAutoTdmaAdjust; ++ bool bPrePsTdmaOn; ++ bool bCurPsTdmaOn; ++ bool bPreBtAutoReport; ++ bool bCurBtAutoReport; + u8 preLps; + u8 curLps; + u8 preRpwm; + u8 curRpwm; + + /* sw mechanism */ -+ bool bPreLowPenaltyRa; -+ bool bCurLowPenaltyRa; -+ u32 preVal0x6c0; -+ u32 curVal0x6c0; -+ u32 preVal0x6c4; -+ u32 curVal0x6c4; -+ u32 preVal0x6c8; -+ u32 curVal0x6c8; ++ bool bPreLowPenaltyRa; ++ bool bCurLowPenaltyRa; ++ u32 preVal0x6c0; ++ u32 curVal0x6c0; ++ u32 preVal0x6c4; ++ u32 curVal0x6c4; ++ u32 preVal0x6c8; ++ u32 curVal0x6c8; + u8 preVal0x6cc; + u8 curVal0x6cc; -+ bool bLimitedDig; ++ bool bLimitedDig; + -+ u32 backupArfrCnt1; /* Auto Rate Fallback Retry cnt */ -+ u32 backupArfrCnt2; /* Auto Rate Fallback Retry cnt */ -+ u16 backupRetryLimit; ++ u32 backupArfrCnt1; /* Auto Rate Fallback Retry cnt */ ++ u32 backupArfrCnt2; /* Auto Rate Fallback Retry cnt */ ++ u16 backupRetryLimit; + u8 backupAmpduMaxTime; + + /* algorithm related */ @@ -38844,138 +37701,88 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b1Ant.h linux-4.3-rtl8723b + u8 btStatus; + u8 wifiChnlInfo[3]; + -+ u32 preRaMask; -+ u32 curRaMask; ++ u32 preRaMask; ++ u32 curRaMask; + u8 preArfrType; + u8 curArfrType; + u8 preRetryLimitType; + u8 curRetryLimitType; + u8 preAmpduTimeType; + u8 curAmpduTimeType; -+ u32 nArpCnt; ++ u32 nArpCnt; + + u8 errorCondition; +} COEX_DM_8723B_1ANT, *PCOEX_DM_8723B_1ANT; + -+typedef struct _COEX_STA_8723B_1ANT{ -+ bool bBtLinkExist; -+ bool bScoExist; -+ bool bA2dpExist; -+ bool bHidExist; -+ bool bPanExist; ++typedef struct _COEX_STA_8723B_1ANT { ++ bool bBtLinkExist; ++ bool bScoExist; ++ bool bA2dpExist; ++ bool bHidExist; ++ bool bPanExist; + -+ bool bUnderLps; -+ bool bUnderIps; -+ u32 specialPktPeriodCnt; -+ u32 highPriorityTx; -+ u32 highPriorityRx; -+ u32 lowPriorityTx; -+ u32 lowPriorityRx; -+ s8 btRssi; -+ bool bBtTxRxMask; -+ u8 preBtRssiState; -+ u8 preWifiRssiState[4]; -+ bool bC2hBtInfoReqSent; -+ u8 btInfoC2h[BT_INFO_SRC_8723B_1ANT_MAX][10]; -+ u32 btInfoC2hCnt[BT_INFO_SRC_8723B_1ANT_MAX]; -+ bool bC2hBtInquiryPage; -+ bool bC2hBtPage; /* Add for win8.1 page out issue */ -+ bool bWiFiIsHighPriTask; /* Add for win8.1 page out issue */ -+ u8 btRetryCnt; -+ u8 btInfoExt; -+ u32 popEventCnt; -+ u8 nScanAPNum; ++ bool bUnderLps; ++ bool bUnderIps; ++ u32 specialPktPeriodCnt; ++ u32 highPriorityTx; ++ u32 highPriorityRx; ++ u32 lowPriorityTx; ++ u32 lowPriorityRx; ++ s8 btRssi; ++ bool bBtTxRxMask; ++ u8 preBtRssiState; ++ u8 preWifiRssiState[4]; ++ bool bC2hBtInfoReqSent; ++ u8 btInfoC2h[BT_INFO_SRC_8723B_1ANT_MAX][10]; ++ u32 btInfoC2hCnt[BT_INFO_SRC_8723B_1ANT_MAX]; ++ bool bC2hBtInquiryPage; ++ bool bC2hBtPage; /* Add for win8.1 page out issue */ ++ bool bWiFiIsHighPriTask; /* Add for win8.1 page out issue */ ++ u8 btRetryCnt; ++ u8 btInfoExt; ++ u32 popEventCnt; ++ u8 nScanAPNum; + -+ u32 nCRCOK_CCK; -+ u32 nCRCOK_11g; -+ u32 nCRCOK_11n; -+ u32 nCRCOK_11nAgg; ++ u32 nCRCOK_CCK; ++ u32 nCRCOK_11g; ++ u32 nCRCOK_11n; ++ u32 nCRCOK_11nAgg; + -+ u32 nCRCErr_CCK; -+ u32 nCRCErr_11g; -+ u32 nCRCErr_11n; -+ u32 nCRCErr_11nAgg; ++ u32 nCRCErr_CCK; ++ u32 nCRCErr_11g; ++ u32 nCRCErr_11n; ++ u32 nCRCErr_11nAgg; + -+ bool bCCKLock; -+ bool bPreCCKLock; -+ u8 nCoexTableType; ++ bool bCCKLock; ++ bool bPreCCKLock; ++ u8 nCoexTableType; + -+ bool bForceLpsOn; -+}COEX_STA_8723B_1ANT, *PCOEX_STA_8723B_1ANT; ++ bool bForceLpsOn; ++} COEX_STA_8723B_1ANT, *PCOEX_STA_8723B_1ANT; + +/* */ +/* The following is interface which will notify coex module. */ +/* */ -+void -+EXhalbtc8723b1ant_PowerOnSetting( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtc8723b1ant_InitHwConfig( -+PBTC_COEXIST pBtCoexist, -+bool bWifiOnly -+ ); -+void -+EXhalbtc8723b1ant_InitCoexDm( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtc8723b1ant_IpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b1ant_LpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b1ant_ScanNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b1ant_ConnectNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b1ant_MediaStatusNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b1ant_SpecialPacketNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b1ant_BtInfoNotify( -+PBTC_COEXIST pBtCoexist, -+u8 * tmpBuf, -+u8 length -+ ); -+void -+EXhalbtc8723b1ant_HaltNotify( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtc8723b1ant_PnpNotify( -+PBTC_COEXIST pBtCoexist, -+u8 pnpState -+ ); -+void -+EXhalbtc8723b1ant_Periodical( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtc8723b1ant_DisplayCoexInfo( -+PBTC_COEXIST pBtCoexist -+ ); -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c ---- linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,4077 @@ ++void EXhalbtc8723b1ant_PowerOnSetting(PBTC_COEXIST pBtCoexist); ++void EXhalbtc8723b1ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly); ++void EXhalbtc8723b1ant_InitCoexDm(PBTC_COEXIST pBtCoexist); ++void EXhalbtc8723b1ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b1ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b1ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b1ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b1ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b1ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b1ant_BtInfoNotify( ++ PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length ++); ++void EXhalbtc8723b1ant_HaltNotify(PBTC_COEXIST pBtCoexist); ++void EXhalbtc8723b1ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState); ++void EXhalbtc8723b1ant_Periodical(PBTC_COEXIST pBtCoexist); ++void EXhalbtc8723b1ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist); +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c +--- linux.old/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,3729 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -38994,113 +37801,87 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b +#include "Mp_Precomp.h" + +/* Global variables, these are static variables */ -+static COEX_DM_8723B_2ANT GLCoexDm8723b2Ant; -+static PCOEX_DM_8723B_2ANT pCoexDm =&GLCoexDm8723b2Ant; -+static COEX_STA_8723B_2ANT GLCoexSta8723b2Ant; -+static PCOEX_STA_8723B_2ANT pCoexSta =&GLCoexSta8723b2Ant; ++static COEX_DM_8723B_2ANT GLCoexDm8723b2Ant; ++static PCOEX_DM_8723B_2ANT pCoexDm = &GLCoexDm8723b2Ant; ++static COEX_STA_8723B_2ANT GLCoexSta8723b2Ant; ++static PCOEX_STA_8723B_2ANT pCoexSta = &GLCoexSta8723b2Ant; + -+static const char *const GLBtInfoSrc8723b2Ant[]={ ++static const char *const GLBtInfoSrc8723b2Ant[] = { + "BT Info[wifi fw]", + "BT Info[bt rsp]", + "BT Info[bt auto report]", +}; + -+static u32 GLCoexVerDate8723b2Ant =20131211; ++static u32 GLCoexVerDate8723b2Ant = 20131211; +static u32 GLCoexVer8723b2Ant = 0x40; + +/* local function start with halbtc8723b2ant_ */ -+static u8 -+halbtc8723b2ant_BtRssiState( -+ u8 levelNum, -+ u8 rssiThresh, -+ u8 rssiThresh1 -+ ) ++static u8 halbtc8723b2ant_BtRssiState( ++ u8 levelNum, u8 rssiThresh, u8 rssiThresh1 ++) +{ -+ s32 btRssi = 0; -+ u8 btRssiState =pCoexSta->preBtRssiState; ++ s32 btRssi = 0; ++ u8 btRssiState = pCoexSta->preBtRssiState; + + btRssi = pCoexSta->btRssi; + -+ if (levelNum == 2) -+ { -+ if ((pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || -+ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) -+ { -+ if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) -+ { ++ if (levelNum == 2) { ++ if ( ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW) ++ ) { ++ if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) { + btRssiState = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n")); -+ } -+ else -+ { ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n")); + } -+ } -+ else -+ { -+ if (btRssi < rssiThresh) -+ { ++ } else { ++ if (btRssi < rssiThresh) { + btRssiState = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n")); -+ } -+ else -+ { ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n")); + } + } -+ } -+ else if (levelNum == 3) -+ { -+ if (rssiThresh > rssiThresh1) -+ { ++ } else if (levelNum == 3) { ++ if (rssiThresh > rssiThresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi thresh error!!\n")); + return pCoexSta->preBtRssiState; + } + -+ if ((pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || -+ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) -+ { -+ if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) -+ { ++ if ( ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW) ++ ) { ++ if (btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) { + btRssiState = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n")); -+ } -+ else -+ { ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Low\n")); + } -+ } -+ else if ((pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || -+ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) -+ { -+ if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) -+ { ++ } else if ( ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || ++ (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM) ++ ) { ++ if (btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) { + btRssiState = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to High\n")); -+ } -+ else if (btRssi < rssiThresh) -+ { ++ } else if (btRssi < rssiThresh) { + btRssiState = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Low\n")); -+ } -+ else -+ { ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at Medium\n")); + } -+ } -+ else -+ { -+ if (btRssi < rssiThresh1) -+ { ++ } else { ++ if (btRssi < rssiThresh1) { + btRssiState = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state switch to Medium\n")); -+ } -+ else -+ { ++ } else { + btRssiState = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_RSSI_STATE, ("[BTCoex], BT Rssi state stay at High\n")); + } @@ -39112,100 +37893,76 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + return btRssiState; +} + -+static u8 -+halbtc8723b2ant_WifiRssiState( -+PBTC_COEXIST pBtCoexist, -+u8 index, -+u8 levelNum, -+u8 rssiThresh, -+u8 rssiThresh1 -+ ) ++static u8 halbtc8723b2ant_WifiRssiState( ++ PBTC_COEXIST pBtCoexist, ++ u8 index, ++ u8 levelNum, ++ u8 rssiThresh, ++ u8 rssiThresh1 ++) +{ -+ s32 wifiRssi = 0; -+ u8 wifiRssiState =pCoexSta->preWifiRssiState[index]; ++ s32 wifiRssi = 0; ++ u8 wifiRssiState = pCoexSta->preWifiRssiState[index]; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); + -+ if (levelNum == 2) -+ { -+ if ((pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || -+ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) -+ { -+ if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) -+ { ++ if (levelNum == 2) { ++ if ( ++ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || ++ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW) ++ ) { ++ if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) { + wifiRssiState = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n")); -+ } -+ else -+ { ++ } else { + wifiRssiState = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n")); + } -+ } -+ else -+ { -+ if (wifiRssi < rssiThresh) -+ { ++ } else { ++ if (wifiRssi < rssiThresh) { + wifiRssiState = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n")); -+ } -+ else -+ { ++ } else { + wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n")); + } + } -+ } -+ else if (levelNum == 3) -+ { -+ if (rssiThresh > rssiThresh1) -+ { ++ } else if (levelNum == 3) { ++ if (rssiThresh > rssiThresh1) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI thresh error!!\n")); + return pCoexSta->preWifiRssiState[index]; + } + -+ if ((pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || -+ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) -+ { -+ if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) -+ { ++ if ( ++ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || ++ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW) ++ ) { ++ if (wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) { + wifiRssiState = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n")); -+ } -+ else -+ { ++ } else { + wifiRssiState = BTC_RSSI_STATE_STAY_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Low\n")); + } -+ } -+ else if ((pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || -+ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) -+ { -+ if (wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) -+ { ++ } else if ( ++ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || ++ (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM) ++ ) { ++ if (wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) { + wifiRssiState = BTC_RSSI_STATE_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to High\n")); -+ } -+ else if (wifiRssi < rssiThresh) -+ { ++ } else if (wifiRssi < rssiThresh) { + wifiRssiState = BTC_RSSI_STATE_LOW; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Low\n")); -+ } -+ else -+ { ++ } else { + wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at Medium\n")); + } -+ } -+ else -+ { -+ if (wifiRssi < rssiThresh1) -+ { ++ } else { ++ if (wifiRssi < rssiThresh1) { + wifiRssiState = BTC_RSSI_STATE_MEDIUM; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state switch to Medium\n")); -+ } -+ else -+ { ++ } else { + wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_WIFI_RSSI_STATE, ("[BTCoex], wifi RSSI state stay at High\n")); + } @@ -39217,18 +37974,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + return wifiRssiState; +} + -+static void -+halbtc8723b2ant_LimitedRx( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bRejApAggPkt, -+bool bBtCtrlAggBufSize, -+u8 aggBufSize -+ ) ++static void halbtc8723b2ant_LimitedRx( ++ PBTC_COEXIST pBtCoexist, ++ bool bForceExec, ++ bool bRejApAggPkt, ++ bool bBtCtrlAggBufSize, ++ u8 aggBufSize ++) +{ -+ bool bRejectRxAgg =bRejApAggPkt; -+ bool bBtCtrlRxAggSize =bBtCtrlAggBufSize; -+ u8 rxAggSize =aggBufSize; ++ bool bRejectRxAgg = bRejApAggPkt; ++ bool bBtCtrlRxAggSize = bBtCtrlAggBufSize; ++ u8 rxAggSize = aggBufSize; + + /* */ + /* Rx Aggregation related setting */ @@ -39242,13 +37998,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); +} + -+static void -+halbtc8723b2ant_MonitorBtCtr( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_MonitorBtCtr(PBTC_COEXIST pBtCoexist) +{ -+ u32 regHPTxRx, regLPTxRx, u4Tmp; -+ u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0; ++ u32 regHPTxRx, regLPTxRx, u4Tmp; ++ u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0; + + regHPTxRx = 0x770; + regLPTxRx = 0x774; @@ -39266,60 +38019,75 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexSta->lowPriorityTx = regLPTx; + pCoexSta->lowPriorityRx = regLPRx; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", -+ regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_BT_MONITOR, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", -+ regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_MONITOR, ++ ( ++ "[BTCoex], High Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", ++ regHPTxRx, ++ regHPTx, ++ regHPTx, ++ regHPRx, ++ regHPRx ++ ) ++ ); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_BT_MONITOR, ++ ( ++ "[BTCoex], Low Priority Tx/Rx (reg 0x%x) = 0x%x(%d)/0x%x(%d)\n", ++ regLPTxRx, ++ regLPTx, ++ regLPTx, ++ regLPRx, ++ regLPRx ++ ) ++ ); + + /* reset counter */ + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); +} + -+static void -+halbtc8723b2ant_QueryBtInfo( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_QueryBtInfo(PBTC_COEXIST pBtCoexist) +{ -+ u8 H2C_Parameter[1] ={0}; ++ u8 H2C_Parameter[1] = {0}; + + pCoexSta->bC2hBtInfoReqSent = true; + + H2C_Parameter[0] |= BIT0; /* trigger */ + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", -+ H2C_Parameter[0])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ("[BTCoex], Query Bt Info, FW write 0x61 = 0x%x\n", H2C_Parameter[0]) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); +} + -+static bool -+halbtc8723b2ant_IsWifiStatusChanged( -+PBTC_COEXIST pBtCoexist -+ ) ++static bool halbtc8723b2ant_IsWifiStatusChanged(PBTC_COEXIST pBtCoexist) +{ -+ static bool bPreWifiBusy =false, bPreUnder4way =false, bPreBtHsOn =false; -+ bool bWifiBusy =false, bUnder4way =false, bBtHsOn =false; -+ bool bWifiConnected =false; ++ static bool bPreWifiBusy = false, bPreUnder4way = false, bPreBtHsOn = false; ++ bool bWifiBusy = false, bUnder4way = false, bBtHsOn = false; ++ bool bWifiConnected = false; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); + -+ if (bWifiConnected) -+ { -+ if (bWifiBusy != bPreWifiBusy) -+ { ++ if (bWifiConnected) { ++ if (bWifiBusy != bPreWifiBusy) { + bPreWifiBusy = bWifiBusy; + return true; + } -+ if (bUnder4way != bPreUnder4way) -+ { ++ ++ if (bUnder4way != bPreUnder4way) { + bPreUnder4way = bUnder4way; + return true; + } -+ if (bBtHsOn != bPreBtHsOn) -+ { ++ ++ if (bBtHsOn != bPreBtHsOn) { + bPreBtHsOn = bBtHsOn; + return true; + } @@ -39328,13 +38096,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + return false; +} + -+static void -+halbtc8723b2ant_UpdateBtLinkInfo( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_UpdateBtLinkInfo(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ bool bBtHsOn =false; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ bool bBtHsOn = false; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); + @@ -39345,248 +38110,220 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtLinkInfo->bHidExist = pCoexSta->bHidExist; + + /* work around for HS mode. */ -+ if (bBtHsOn) -+ { ++ if (bBtHsOn) { + pBtLinkInfo->bPanExist = true; + pBtLinkInfo->bBtLinkExist = true; + } ++ + /* check if Sco only */ -+ if (pBtLinkInfo->bScoExist && ++ if ( ++ pBtLinkInfo->bScoExist && + !pBtLinkInfo->bA2dpExist && + !pBtLinkInfo->bPanExist && -+ !pBtLinkInfo->bHidExist) ++ !pBtLinkInfo->bHidExist ++ ) + pBtLinkInfo->bScoOnly = true; + else + pBtLinkInfo->bScoOnly = false; + + /* check if A2dp only */ -+ if (!pBtLinkInfo->bScoExist && ++ if ( ++ !pBtLinkInfo->bScoExist && + pBtLinkInfo->bA2dpExist && + !pBtLinkInfo->bPanExist && -+ !pBtLinkInfo->bHidExist) ++ !pBtLinkInfo->bHidExist ++ ) + pBtLinkInfo->bA2dpOnly = true; + else + pBtLinkInfo->bA2dpOnly = false; + + /* check if Pan only */ -+ if (!pBtLinkInfo->bScoExist && ++ if ( ++ !pBtLinkInfo->bScoExist && + !pBtLinkInfo->bA2dpExist && + pBtLinkInfo->bPanExist && -+ !pBtLinkInfo->bHidExist) ++ !pBtLinkInfo->bHidExist ++ ) + pBtLinkInfo->bPanOnly = true; + else + pBtLinkInfo->bPanOnly = false; + + /* check if Hid only */ -+ if (!pBtLinkInfo->bScoExist && ++ if ( ++ !pBtLinkInfo->bScoExist && + !pBtLinkInfo->bA2dpExist && + !pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bHidExist) ++ pBtLinkInfo->bHidExist ++ ) + pBtLinkInfo->bHidOnly = true; + else + pBtLinkInfo->bHidOnly = false; +} + -+static u8 -+halbtc8723b2ant_ActionAlgorithm( -+PBTC_COEXIST pBtCoexist -+ ) ++static u8 halbtc8723b2ant_ActionAlgorithm(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ bool bBtHsOn =false; -+ u8 algorithm =BT_8723B_2ANT_COEX_ALGO_UNDEFINED; -+ u8 numOfDiffProfile = 0; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ bool bBtHsOn = false; ++ u8 algorithm = BT_8723B_2ANT_COEX_ALGO_UNDEFINED; ++ u8 numOfDiffProfile = 0; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); + -+ if (!pBtLinkInfo->bBtLinkExist) -+ { ++ if (!pBtLinkInfo->bBtLinkExist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], No BT link exists!!!\n")); + return algorithm; + } + + if (pBtLinkInfo->bScoExist) + numOfDiffProfile++; ++ + if (pBtLinkInfo->bHidExist) + numOfDiffProfile++; ++ + if (pBtLinkInfo->bPanExist) + numOfDiffProfile++; ++ + if (pBtLinkInfo->bA2dpExist) + numOfDiffProfile++; + -+ if (numOfDiffProfile == 1) -+ { -+ if (pBtLinkInfo->bScoExist) -+ { ++ if (numOfDiffProfile == 1) { ++ if (pBtLinkInfo->bScoExist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO only\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_SCO; -+ } -+ else -+ { -+ if (pBtLinkInfo->bHidExist) -+ { ++ } else { ++ if (pBtLinkInfo->bHidExist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID only\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_HID; -+ } -+ else if (pBtLinkInfo->bA2dpExist) -+ { ++ } else if (pBtLinkInfo->bA2dpExist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP only\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP; -+ } -+ else if (pBtLinkInfo->bPanExist) -+ { -+ if (bBtHsOn) -+ { ++ } else if (pBtLinkInfo->bPanExist) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(HS) only\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANHS; -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], PAN(EDR) only\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR; + } + } + } -+ } -+ else if (numOfDiffProfile == 2) -+ { -+ if (pBtLinkInfo->bScoExist) -+ { -+ if (pBtLinkInfo->bHidExist) -+ { ++ } else if (numOfDiffProfile == 2) { ++ if (pBtLinkInfo->bScoExist) { ++ if (pBtLinkInfo->bHidExist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; -+ } -+ else if (pBtLinkInfo->bA2dpExist) -+ { ++ } else if (pBtLinkInfo->bA2dpExist) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP ==> SCO\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; -+ } -+ else if (pBtLinkInfo->bPanExist) -+ { -+ if (bBtHsOn) -+ { ++ } else if (pBtLinkInfo->bPanExist) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(HS)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_SCO; -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + PAN(EDR)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } + } -+ } -+ else -+ { -+ if (pBtLinkInfo->bHidExist && -+ pBtLinkInfo->bA2dpExist) -+ { ++ } else { ++ if ( ++ pBtLinkInfo->bHidExist && ++ pBtLinkInfo->bA2dpExist ++ ) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP; -+ } -+ else if (pBtLinkInfo->bHidExist && -+ pBtLinkInfo->bPanExist) -+ { -+ if (bBtHsOn) -+ { ++ } else if ( ++ pBtLinkInfo->bHidExist && ++ pBtLinkInfo->bPanExist ++ ) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(HS)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_HID; -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + PAN(EDR)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } -+ } -+ else if (pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ if (bBtHsOn) -+ { ++ } else if ( ++ pBtLinkInfo->bPanExist && ++ pBtLinkInfo->bA2dpExist ++ ) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(HS)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS; -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], A2DP + PAN(EDR)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP; + } + } + } -+ } -+ else if (numOfDiffProfile == 3) -+ { -+ if (pBtLinkInfo->bScoExist) -+ { -+ if (pBtLinkInfo->bHidExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP ==> HID\n")); ++ } else if (numOfDiffProfile == 3) { ++ if (pBtLinkInfo->bScoExist) { ++ if ( ++ pBtLinkInfo->bHidExist && ++ pBtLinkInfo->bA2dpExist ++ ) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], SCO + HID + A2DP ==> HID\n") ++ ); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; -+ } -+ else if (pBtLinkInfo->bHidExist && -+ pBtLinkInfo->bPanExist) -+ { -+ if (bBtHsOn) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(HS)\n")); ++ } else if ( ++ pBtLinkInfo->bHidExist && ++ pBtLinkInfo->bPanExist ++ ) { ++ if (bBtHsOn) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], SCO + HID + PAN(HS)\n") ++ ); ++ algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; ++ } else { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ("[BTCoex], SCO + HID + PAN(EDR)\n") ++ ); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } -+ else -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + PAN(EDR)\n")); -+ algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; -+ } -+ } -+ else if (pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ if (bBtHsOn) -+ { ++ } else if ( ++ pBtLinkInfo->bPanExist && ++ pBtLinkInfo->bA2dpExist ++ ) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(HS)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } + } -+ } -+ else -+ { -+ if (pBtLinkInfo->bHidExist && ++ } else { ++ if ( ++ pBtLinkInfo->bHidExist && + pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ if (bBtHsOn) -+ { ++ pBtLinkInfo->bA2dpExist ++ ) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(HS)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP; -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], HID + A2DP + PAN(EDR)\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR; + } + } + } -+ } -+ else if (numOfDiffProfile >= 3) -+ { -+ if (pBtLinkInfo->bScoExist) -+ { -+ if (pBtLinkInfo->bHidExist && ++ } else if (numOfDiffProfile >= 3) { ++ if (pBtLinkInfo->bScoExist) { ++ if ( ++ pBtLinkInfo->bHidExist && + pBtLinkInfo->bPanExist && -+ pBtLinkInfo->bA2dpExist) -+ { -+ if (bBtHsOn) -+ { ++ pBtLinkInfo->bA2dpExist ++ ) { ++ if (bBtHsOn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n")); + -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], SCO + HID + A2DP + PAN(EDR) ==>PAN(EDR)+HID\n")); + algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; + } @@ -39597,55 +38334,76 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + return algorithm; +} + -+static void -+halbtc8723b2ant_SetFwDacSwingLevel( -+PBTC_COEXIST pBtCoexist, -+u8 dacSwingLvl -+ ) ++static void halbtc8723b2ant_SetFwDacSwingLevel( ++ PBTC_COEXIST pBtCoexist, u8 dacSwingLvl ++) +{ -+ u8 H2C_Parameter[1] ={0}; ++ u8 H2C_Parameter[1] = {0}; + + /* There are several type of dacswing */ + /* 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 */ + H2C_Parameter[0] = dacSwingLvl; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], Set Dac Swing Level = 0x%x\n", dacSwingLvl)); -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x64 = 0x%x\n", H2C_Parameter[0])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ("[BTCoex], Set Dac Swing Level = 0x%x\n", dacSwingLvl) ++ ); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ("[BTCoex], FW write 0x64 = 0x%x\n", H2C_Parameter[0]) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter); +} + -+static void -+halbtc8723b2ant_SetFwDecBtPwr( -+PBTC_COEXIST pBtCoexist, -+u8 decBtPwrLvl -+ ) ++static void halbtc8723b2ant_SetFwDecBtPwr( ++ PBTC_COEXIST pBtCoexist, u8 decBtPwrLvl ++) +{ -+ u8 H2C_Parameter[1] ={0}; ++ u8 H2C_Parameter[1] = {0}; + + H2C_Parameter[0] = decBtPwrLvl; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62 = 0x%x\n", -+ decBtPwrLvl, H2C_Parameter[0])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], decrease Bt Power level = %d, FW write 0x62 = 0x%x\n", ++ decBtPwrLvl, ++ H2C_Parameter[0] ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter); +} + -+static void -+halbtc8723b2ant_DecBtPwr( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 decBtPwrLvl -+ ) ++static void halbtc8723b2ant_DecBtPwr( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u8 decBtPwrLvl ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s Dec BT power level = %d\n", -+ (bForceExec? "force to":""), decBtPwrLvl)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW, ++ ( ++ "[BTCoex], %s Dec BT power level = %d\n", ++ (bForceExec ? "force to" : ""), ++ decBtPwrLvl ++ ) ++ ); + pCoexDm->curBtDecPwrLvl = decBtPwrLvl; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preBtDecPwrLvl =%d, curBtDecPwrLvl =%d\n", -+ pCoexDm->preBtDecPwrLvl, pCoexDm->curBtDecPwrLvl)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], preBtDecPwrLvl =%d, curBtDecPwrLvl =%d\n", ++ pCoexDm->preBtDecPwrLvl, ++ pCoexDm->curBtDecPwrLvl ++ ) ++ ); + + if (pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl) + return; @@ -39655,21 +38413,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl; +} + -+static void -+halbtc8723b2ant_FwDacSwingLvl( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 fwDacSwingLvl -+ ) ++static void halbtc8723b2ant_FwDacSwingLvl( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u8 fwDacSwingLvl ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s set FW Dac Swing level = %d\n", -+ (bForceExec? "force to":""), fwDacSwingLvl)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW, ++ ( ++ "[BTCoex], %s set FW Dac Swing level = %d\n", ++ (bForceExec ? "force to" : ""), ++ fwDacSwingLvl ++ ) ++ ); + pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], preFwDacSwingLvl =%d, curFwDacSwingLvl =%d\n", -+ pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], preFwDacSwingLvl =%d, curFwDacSwingLvl =%d\n", ++ pCoexDm->preFwDacSwingLvl, ++ pCoexDm->curFwDacSwingLvl ++ ) ++ ); + + if (pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) + return; @@ -39680,45 +38448,54 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; +} + -+static void -+halbtc8723b2ant_SetSwRfRxLpfCorner( -+PBTC_COEXIST pBtCoexist, -+bool bRxRfShrinkOn -+ ) ++static void halbtc8723b2ant_SetSwRfRxLpfCorner( ++ PBTC_COEXIST pBtCoexist, ++ bool bRxRfShrinkOn ++) +{ -+ if (bRxRfShrinkOn) -+ { ++ if (bRxRfShrinkOn) { + /* Shrink RF Rx LPF corner */ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], Shrink RF Rx LPF corner!!\n") ++ ); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc); -+ } -+ else -+ { ++ } else { + /* Resume RF Rx LPF corner */ + /* After initialized, we can use pCoexDm->btRf0x1eBackup */ -+ if (pBtCoexist->bInitilized) -+ { ++ if (pBtCoexist->bInitilized) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Resume RF Rx LPF corner!!\n")); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); + } + } +} + -+static void -+halbtc8723b2ant_RfShrink( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bRxRfShrinkOn -+ ) ++static void halbtc8723b2ant_RfShrink( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, bool bRxRfShrinkOn ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn Rx RF Shrink = %s\n", -+ (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW, ++ ( ++ "[BTCoex], %s turn Rx RF Shrink = %s\n", ++ (bForceExec ? "force to" : ""), ++ (bRxRfShrinkOn ? "ON" : "OFF") ++ ) ++ ); + pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreRfRxLpfShrink =%d, bCurRfRxLpfShrink =%d\n", -+ pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_DETAIL, ++ ( ++ "[BTCoex], bPreRfRxLpfShrink =%d, bCurRfRxLpfShrink =%d\n", ++ pCoexDm->bPreRfRxLpfShrink, ++ pCoexDm->bCurRfRxLpfShrink ++ ) ++ ); + + if (pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) + return; @@ -39728,18 +38505,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; +} + -+static void -+halbtc8723b2ant_SetSwPenaltyTxRateAdaptive( -+PBTC_COEXIST pBtCoexist, -+bool bLowPenaltyRa -+ ) ++static void halbtc8723b2ant_SetSwPenaltyTxRateAdaptive( ++ PBTC_COEXIST pBtCoexist, bool bLowPenaltyRa ++) +{ -+ u8 H2C_Parameter[6] ={0}; ++ u8 H2C_Parameter[6] = {0}; + + H2C_Parameter[0] = 0x6; /* opCode, 0x6 = Retry_Penalty */ + -+ if (bLowPenaltyRa) -+ { ++ if (bLowPenaltyRa) { + H2C_Parameter[1] |= BIT0; + H2C_Parameter[2] = 0x00; /* normal rate except MCS7/6/5, OFDM54/48/36 */ + H2C_Parameter[3] = 0xf7; /* MCS7 or OFDM54 */ @@ -39747,28 +38521,44 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + H2C_Parameter[5] = 0xf9; /* MCS5 or OFDM36 */ + } + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set WiFi Low-Penalty Retry: %s", -+ (bLowPenaltyRa? "ON!!":"OFF!!"))); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], set WiFi Low-Penalty Retry: %s", ++ (bLowPenaltyRa ? "ON!!" : "OFF!!") ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); +} + -+static void -+halbtc8723b2ant_LowPenaltyRa( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bLowPenaltyRa -+ ) ++static void halbtc8723b2ant_LowPenaltyRa( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, bool bLowPenaltyRa ++) +{ + /* return; */ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn LowPenaltyRA = %s\n", -+ (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW, ++ ( ++ "[BTCoex], %s turn LowPenaltyRA = %s\n", ++ (bForceExec ? "force to" : ""), ++ (bLowPenaltyRa ? "ON" : "OFF") ++ ) ++ ); + pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreLowPenaltyRa =%d, bCurLowPenaltyRa =%d\n", -+ pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_DETAIL, ++ ( ++ "[BTCoex], bPreLowPenaltyRa =%d, bCurLowPenaltyRa =%d\n", ++ pCoexDm->bPreLowPenaltyRa, ++ pCoexDm->bCurLowPenaltyRa ++ ) ++ ); + + if (pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) + return; @@ -39778,54 +38568,61 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; +} + -+static void -+halbtc8723b2ant_SetDacSwingReg( -+PBTC_COEXIST pBtCoexist, -+u32 level -+ ) ++static void halbtc8723b2ant_SetDacSwingReg(PBTC_COEXIST pBtCoexist, u32 level) +{ -+ u8 val =(u8)level; ++ u8 val = (u8)level; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Write SwDacSwing = 0x%x\n", level)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], Write SwDacSwing = 0x%x\n", level) ++ ); + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val); +} + -+static void -+halbtc8723b2ant_SetSwFullTimeDacSwing( -+PBTC_COEXIST pBtCoexist, -+bool bSwDacSwingOn, -+u32 swDacSwingLvl -+ ) ++static void halbtc8723b2ant_SetSwFullTimeDacSwing( ++ PBTC_COEXIST pBtCoexist, bool bSwDacSwingOn, u32 swDacSwingLvl ++) +{ + if (bSwDacSwingOn) -+ { + halbtc8723b2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl); -+ } + else -+ { + halbtc8723b2ant_SetDacSwingReg(pBtCoexist, 0x18); -+ } +} + + -+static void -+halbtc8723b2ant_DacSwing( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bDacSwingOn, -+u32 dacSwingLvl -+ ) ++static void halbtc8723b2ant_DacSwing( ++ PBTC_COEXIST pBtCoexist, ++ bool bForceExec, ++ bool bDacSwingOn, ++ u32 dacSwingLvl ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s turn DacSwing =%s, dacSwingLvl = 0x%x\n", -+ (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW, ++ ( ++ "[BTCoex], %s turn DacSwing =%s, dacSwingLvl = 0x%x\n", ++ (bForceExec ? "force to" : ""), ++ (bDacSwingOn ? "ON" : "OFF"), ++ dacSwingLvl ++ ) ++ ); + pCoexDm->bCurDacSwingOn = bDacSwingOn; + pCoexDm->curDacSwingLvl = dacSwingLvl; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreDacSwingOn =%d, preDacSwingLvl = 0x%x, bCurDacSwingOn =%d, curDacSwingLvl = 0x%x\n", -+ pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl, -+ pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_DETAIL, ++ ( ++ "[BTCoex], bPreDacSwingOn =%d, preDacSwingLvl = 0x%x, bCurDacSwingOn =%d, curDacSwingLvl = 0x%x\n", ++ pCoexDm->bPreDacSwingOn, ++ pCoexDm->preDacSwingLvl, ++ pCoexDm->bCurDacSwingOn, ++ pCoexDm->curDacSwingLvl ++ ) ++ ); + + if ((pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && + (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl)) @@ -39838,17 +38635,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; +} + -+static void -+halbtc8723b2ant_SetAgcTable( -+PBTC_COEXIST pBtCoexist, -+bool bAgcTableEn -+ ) ++static void halbtc8723b2ant_SetAgcTable( ++ PBTC_COEXIST pBtCoexist, bool bAgcTableEn ++) +{ + u8 rssiAdjustVal = 0; + + /* BB AGC Gain Table */ -+ if (bAgcTableEn) -+ { ++ if (bAgcTableEn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB Agc Table On!\n")); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001); @@ -39857,9 +38651,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001); -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], BB Agc Table Off!\n")); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001); @@ -39873,14 +38665,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + /* RF Gain */ + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000); -+ if (bAgcTableEn) -+ { ++ if (bAgcTableEn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n")); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe); -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n")); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6); @@ -39888,14 +38677,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); + + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1); -+ if (bAgcTableEn) -+ { ++ if (bAgcTableEn) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table On!\n")); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe); -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], Agc Table Off!\n")); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6); @@ -39904,27 +38690,36 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + /* set rssiAdjustVal for wifi module. */ + if (bAgcTableEn) -+ { + rssiAdjustVal = 8; -+ } ++ + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); +} + -+static void -+halbtc8723b2ant_AgcTable( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bAgcTableEn -+ ) ++static void halbtc8723b2ant_AgcTable( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, bool bAgcTableEn ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s %s Agc Table\n", -+ (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW, ++ ( ++ "[BTCoex], %s %s Agc Table\n", ++ (bForceExec ? "force to" : ""), ++ (bAgcTableEn ? "Enable" : "Disable") ++ ) ++ ); + pCoexDm->bCurAgcTableEn = bAgcTableEn; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], bPreAgcTableEn =%d, bCurAgcTableEn =%d\n", -+ pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_DETAIL, ++ ( ++ "[BTCoex], bPreAgcTableEn =%d, bCurAgcTableEn =%d\n", ++ pCoexDm->bPreAgcTableEn, ++ pCoexDm->bCurAgcTableEn ++ ) ++ ); + + if (pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) + return; @@ -39934,56 +38729,99 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; +} + -+static void -+halbtc8723b2ant_SetCoexTable( -+PBTC_COEXIST pBtCoexist, -+u32 val0x6c0, -+u32 val0x6c4, -+u32 val0x6c8, -+u8 val0x6cc -+ ) ++static void halbtc8723b2ant_SetCoexTable( ++ PBTC_COEXIST pBtCoexist, ++ u32 val0x6c0, ++ u32 val0x6c4, ++ u32 val0x6c8, ++ u8 val0x6cc ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], set coex table, set 0x6c0 = 0x%x\n", val0x6c0) ++ ); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], set coex table, set 0x6c4 = 0x%x\n", val0x6c4) ++ ); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], set coex table, set 0x6c8 = 0x%x\n", val0x6c8) ++ ); + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_EXEC, ("[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_EXEC, ++ ("[BTCoex], set coex table, set 0x6cc = 0x%x\n", val0x6cc) ++ ); + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); +} + -+static void -+halbtc8723b2ant_CoexTable( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u32 val0x6c0, -+u32 val0x6c4, -+u32 val0x6c8, -+u8 val0x6cc -+ ) ++static void halbtc8723b2ant_CoexTable( ++ PBTC_COEXIST pBtCoexist, ++ bool bForceExec, ++ u32 val0x6c0, ++ u32 val0x6c4, ++ u32 val0x6c8, ++ u8 val0x6cc ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW, ("[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n", -+ (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW, ++ ( ++ "[BTCoex], %s write Coex Table 0x6c0 = 0x%x, 0x6c4 = 0x%x, 0x6c8 = 0x%x, 0x6cc = 0x%x\n", ++ (bForceExec ? "force to" : ""), ++ val0x6c0, ++ val0x6c4, ++ val0x6c8, ++ val0x6cc ++ ) ++ ); + pCoexDm->curVal0x6c0 = val0x6c0; + pCoexDm->curVal0x6c4 = val0x6c4; + pCoexDm->curVal0x6c8 = val0x6c8; + pCoexDm->curVal0x6cc = val0x6cc; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], preVal0x6c0 = 0x%x, preVal0x6c4 = 0x%x, preVal0x6c8 = 0x%x, preVal0x6cc = 0x%x !!\n", -+ pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc)); -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_SW_DETAIL, ("[BTCoex], curVal0x6c0 = 0x%x, curVal0x6c4 = 0x%x, curVal0x6c8 = 0x%x, curVal0x6cc = 0x%x !!\n", -+ pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_DETAIL, ++ ( ++ "[BTCoex], preVal0x6c0 = 0x%x, preVal0x6c4 = 0x%x, preVal0x6c8 = 0x%x, preVal0x6cc = 0x%x !!\n", ++ pCoexDm->preVal0x6c0, ++ pCoexDm->preVal0x6c4, ++ pCoexDm->preVal0x6c8, ++ pCoexDm->preVal0x6cc ++ ) ++ ); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_SW_DETAIL, ++ ( ++ "[BTCoex], curVal0x6c0 = 0x%x, curVal0x6c4 = 0x%x, curVal0x6c8 = 0x%x, curVal0x6cc = 0x%x !!\n", ++ pCoexDm->curVal0x6c0, ++ pCoexDm->curVal0x6c4, ++ pCoexDm->curVal0x6c8, ++ pCoexDm->curVal0x6cc ++ ) ++ ); + -+ if ((pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && ++ if ( ++ (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && + (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && + (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && -+ (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc)) ++ (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ++ ) + return; + } + halbtc8723b2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); @@ -39994,91 +38832,93 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; +} + -+static void -+halbtc8723b2ant_CoexTableWithType( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+u8 type -+ ) ++static void halbtc8723b2ant_CoexTableWithType( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, u8 type ++) +{ -+ switch (type) -+ { -+ case 0: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffff, 0x3); -+ break; -+ case 1: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffff, 0x3); -+ break; -+ case 2: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3); -+ break; -+ case 3: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3); -+ break; -+ case 4: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffff, 0x3); -+ break; -+ case 5: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3); -+ break; -+ case 6: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3); -+ break; -+ case 7: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0xfafafafa, 0xffff, 0x3); -+ break; -+ case 8: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3); -+ break; -+ case 9: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aea5aea, 0xffff, 0x3); -+ break; -+ case 10: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3); -+ break; -+ case 11: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5f5a5f, 0xffff, 0x3); -+ break; -+ case 12: -+ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5f5f5f5f, 0xffff, 0x3); -+ break; -+ default: -+ break; ++ switch (type) { ++ case 0: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffff, 0x3); ++ break; ++ case 1: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffff, 0x3); ++ break; ++ case 2: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3); ++ break; ++ case 3: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff, 0x3); ++ break; ++ case 4: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffff, 0x3); ++ break; ++ case 5: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffff, 0x3); ++ break; ++ case 6: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3); ++ break; ++ case 7: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0xfafafafa, 0xffff, 0x3); ++ break; ++ case 8: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3); ++ break; ++ case 9: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aea5aea, 0xffff, 0x3); ++ break; ++ case 10: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3); ++ break; ++ case 11: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5f5a5f, 0xffff, 0x3); ++ break; ++ case 12: ++ halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5f5f5f5f, 0xffff, 0x3); ++ break; ++ default: ++ break; + } +} + -+static void -+halbtc8723b2ant_SetFwIgnoreWlanAct( -+PBTC_COEXIST pBtCoexist, -+bool bEnable -+ ) ++static void halbtc8723b2ant_SetFwIgnoreWlanAct( ++ PBTC_COEXIST pBtCoexist, bool bEnable ++) +{ -+ u8 H2C_Parameter[1] ={0}; ++ u8 H2C_Parameter[1] = {0}; + + if (bEnable) -+ { + H2C_Parameter[0] |= BIT0; /* function enable */ -+ } + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", -+ H2C_Parameter[0])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63 = 0x%x\n", ++ H2C_Parameter[0] ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); +} + -+static void -+halbtc8723b2ant_IgnoreWlanAct( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bEnable -+ ) ++static void halbtc8723b2ant_IgnoreWlanAct( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, bool bEnable ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn Ignore WlanAct %s\n", -+ (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW, ++ ( ++ "[BTCoex], %s turn Ignore WlanAct %s\n", ++ (bForceExec ? "force to" : ""), ++ (bEnable ? "ON" : "OFF") ++ ) ++ ); ++ + pCoexDm->bCurIgnoreWlanAct = bEnable; + -+ if (!bForceExec) -+ { ++ if (!bForceExec) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n", + pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct)); + @@ -40090,17 +38930,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; +} + -+static void -+halbtc8723b2ant_SetFwPstdma( -+PBTC_COEXIST pBtCoexist, -+u8 byte1, -+u8 byte2, -+u8 byte3, -+u8 byte4, -+u8 byte5 -+ ) ++static void halbtc8723b2ant_SetFwPstdma( ++ PBTC_COEXIST pBtCoexist, ++ u8 byte1, ++ u8 byte2, ++ u8 byte3, ++ u8 byte4, ++ u8 byte5 ++) +{ -+ u8 H2C_Parameter[5] ={0}; ++ u8 H2C_Parameter[5] = {0}; + + H2C_Parameter[0] = byte1; + H2C_Parameter[1] = byte2; @@ -40114,75 +38953,74 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->psTdmaPara[3] = byte4; + pCoexDm->psTdmaPara[4] = byte5; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n", -+ H2C_Parameter[0], -+ H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], FW write 0x60(5bytes) = 0x%x%08x\n", ++ H2C_Parameter[0], ++ H2C_Parameter[1]<<24| ++ H2C_Parameter[2]<<16| ++ H2C_Parameter[3]<<8| ++ H2C_Parameter[4] ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); +} + -+static void -+halbtc8723b2ant_SwMechanism1( -+PBTC_COEXIST pBtCoexist, -+bool bShrinkRxLPF, -+bool bLowPenaltyRA, -+bool bLimitedDIG, -+bool bBTLNAConstrain -+ ) ++static void halbtc8723b2ant_SwMechanism1( ++ PBTC_COEXIST pBtCoexist, ++ bool bShrinkRxLPF, ++ bool bLowPenaltyRA, ++ bool bLimitedDIG, ++ bool bBTLNAConstrain ++) +{ + halbtc8723b2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF); + halbtc8723b2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); +} + -+static void -+halbtc8723b2ant_SwMechanism2( -+PBTC_COEXIST pBtCoexist, -+bool bAGCTableShift, -+bool bADCBackOff, -+bool bSWDACSwing, -+u32 dacSwingLvl -+ ) ++static void halbtc8723b2ant_SwMechanism2( ++ PBTC_COEXIST pBtCoexist, ++ bool bAGCTableShift, ++ bool bADCBackOff, ++ bool bSWDACSwing, ++ u32 dacSwingLvl ++) +{ + halbtc8723b2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift); + halbtc8723b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl); +} + -+static void -+halbtc8723b2ant_SetAntPath( -+PBTC_COEXIST pBtCoexist, -+u8 antPosType, -+bool bInitHwCfg, -+bool bWifiOff -+ ) ++static void halbtc8723b2ant_SetAntPath( ++ PBTC_COEXIST pBtCoexist, u8 antPosType, bool bInitHwCfg, bool bWifiOff ++) +{ -+ PBTC_BOARD_INFO pBoardInfo =&pBtCoexist->boardInfo; -+ u32 fwVer = 0, u4Tmp = 0; -+ bool bPgExtSwitch =false; -+ bool bUseExtSwitch =false; -+ u8 H2C_Parameter[2] ={0}; ++ PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo; ++ u32 fwVer = 0, u4Tmp = 0; ++ bool bPgExtSwitch = false; ++ bool bUseExtSwitch = false; ++ u8 H2C_Parameter[2] = {0}; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); /* [31:16]=fw ver, [15:0]=fw sub ver */ + -+ if ((fwVer>0 && fwVer<0xc0000) || bPgExtSwitch) ++ if ((fwVer > 0 && fwVer < 0xc0000) || bPgExtSwitch) + bUseExtSwitch = true; + -+ if (bInitHwCfg) -+ { ++ if (bInitHwCfg) { + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1); + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff); + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3); + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77); + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); + -+ if (fwVer >= 0x180000) -+ { -+ /* Use H2C to set GNT_BT to LOW */ -+ H2C_Parameter[0] = 0; -+ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); -+ } -+ else -+ { ++ if (fwVer >= 0x180000) { ++ /* Use H2C to set GNT_BT to LOW */ ++ H2C_Parameter[0] = 0; ++ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); ++ } else { + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0); + } + @@ -40191,24 +39029,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); /* WiFi TRx Mask off */ + pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); /* BT TRx Mask off */ + -+ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) -+ { ++ if (pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) { + /* tell firmware "no antenna inverse" */ + H2C_Parameter[0] = 0; -+ } -+ else -+ { ++ } else { + /* tell firmware "antenna inverse" */ + H2C_Parameter[0] = 1; + } + -+ if (bUseExtSwitch) -+ { ++ if (bUseExtSwitch) { + /* ext switch type */ + H2C_Parameter[1] = 1; -+ } -+ else -+ { ++ } else { + /* int switch type */ + H2C_Parameter[1] = 0; + } @@ -40216,163 +39048,170 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + } + + /* ext switch setting */ -+ if (bUseExtSwitch) -+ { -+ if (bInitHwCfg) -+ { ++ if (bUseExtSwitch) { ++ if (bInitHwCfg) { + /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */ + u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); -+ u4Tmp &=~BIT23; ++ u4Tmp &= ~BIT23; + u4Tmp |= BIT24; + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); + } + + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */ -+ switch (antPosType) -+ { -+ case BTC_ANT_WIFI_AT_MAIN: -+ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); /* ext switch main at wifi */ -+ break; -+ case BTC_ANT_WIFI_AT_AUX: -+ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); /* ext switch aux at wifi */ -+ break; ++ switch (antPosType) { ++ case BTC_ANT_WIFI_AT_MAIN: ++ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); /* ext switch main at wifi */ ++ break; ++ case BTC_ANT_WIFI_AT_AUX: ++ pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); /* ext switch aux at wifi */ ++ break; + } -+ } -+ else /* internal switch */ -+ { -+ if (bInitHwCfg) -+ { ++ } else { /* internal switch */ ++ if (bInitHwCfg) { + /* 0x4c[23]= 0, 0x4c[24]= 1 Antenna control by WL/BT */ + u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); + u4Tmp |= BIT23; -+ u4Tmp &=~BIT24; ++ u4Tmp &= ~BIT24; + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); + } + + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); /* fixed external switch S1->Main, S0->Aux */ -+ switch (antPosType) -+ { -+ case BTC_ANT_WIFI_AT_MAIN: -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */ -+ break; -+ case BTC_ANT_WIFI_AT_AUX: -+ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); /* fixed internal switch S0->WiFi, S1->BT */ -+ break; ++ switch (antPosType) { ++ case BTC_ANT_WIFI_AT_MAIN: ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); /* fixed internal switch S1->WiFi, S0->BT */ ++ break; ++ case BTC_ANT_WIFI_AT_AUX: ++ pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); /* fixed internal switch S0->WiFi, S1->BT */ ++ break; + } + } +} + -+static void -+halbtc8723b2ant_PsTdma( -+PBTC_COEXIST pBtCoexist, -+bool bForceExec, -+bool bTurnOn, -+u8 type -+ ) ++static void halbtc8723b2ant_PsTdma( ++ PBTC_COEXIST pBtCoexist, bool bForceExec, bool bTurnOn, u8 type ++) +{ -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], %s turn %s PS TDMA, type =%d\n", -+ (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW, ++ ( ++ "[BTCoex], %s turn %s PS TDMA, type =%d\n", ++ (bForceExec ? "force to" : ""), ++ (bTurnOn ? "ON" : "OFF"), ++ type ++ ) ++ ); + pCoexDm->bCurPsTdmaOn = bTurnOn; + pCoexDm->curPsTdma = type; + -+ if (!bForceExec) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n", -+ pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn)); -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n", -+ pCoexDm->prePsTdma, pCoexDm->curPsTdma)); ++ if (!bForceExec) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n", ++ pCoexDm->bPrePsTdmaOn, ++ pCoexDm->bCurPsTdmaOn ++ ) ++ ); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n", ++ pCoexDm->prePsTdma, pCoexDm->curPsTdma ++ ) ++ ); + -+ if ((pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && -+ (pCoexDm->prePsTdma == pCoexDm->curPsTdma)) ++ if ( ++ (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && ++ (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ++ ) + return; + } -+ if (bTurnOn) -+ { -+ switch (type) -+ { -+ case 1: -+ default: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); -+ break; -+ case 2: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); -+ break; -+ case 3: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90); -+ break; -+ case 4: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90); -+ break; -+ case 5: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); -+ break; -+ case 6: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); -+ break; -+ case 7: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90); -+ break; -+ case 8: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90); -+ break; -+ case 9: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); -+ break; -+ case 10: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); -+ break; -+ case 11: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90); -+ break; -+ case 12: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); -+ break; -+ case 13: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); -+ break; -+ case 14: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); -+ break; -+ case 15: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90); -+ break; -+ case 16: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90); -+ break; -+ case 17: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90); -+ break; -+ case 18: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); -+ break; -+ case 19: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); -+ break; -+ case 20: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); -+ break; -+ case 21: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); -+ break; -+ case 71: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); -+ break; ++ ++ if (bTurnOn) { ++ switch (type) { ++ case 1: ++ default: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); ++ break; ++ case 2: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); ++ break; ++ case 3: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90); ++ break; ++ case 4: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90); ++ break; ++ case 5: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); ++ break; ++ case 6: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); ++ break; ++ case 7: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90); ++ break; ++ case 8: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90); ++ break; ++ case 9: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); ++ break; ++ case 10: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); ++ break; ++ case 11: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90); ++ break; ++ case 12: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); ++ break; ++ case 13: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); ++ break; ++ case 14: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); ++ break; ++ case 15: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90); ++ break; ++ case 16: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90); ++ break; ++ case 17: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90); ++ break; ++ case 18: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); ++ break; ++ case 19: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); ++ break; ++ case 20: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); ++ break; ++ case 21: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); ++ break; ++ case 71: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); ++ break; + } -+ } -+ else -+ { ++ } else { + /* disable PS tdma */ -+ switch (type) -+ { -+ case 0: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); -+ break; -+ case 1: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0); -+ break; -+ default: -+ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); -+ break; ++ switch (type) { ++ case 0: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); ++ break; ++ case 1: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0); ++ break; ++ default: ++ halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); ++ break; + } + } + @@ -40381,10 +39220,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->prePsTdma = pCoexDm->curPsTdma; +} + -+static void -+halbtc8723b2ant_CoexAllOff( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_CoexAllOff(PBTC_COEXIST pBtCoexist) +{ + /* fw all off */ + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1); @@ -40400,10 +39236,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); +} + -+static void -+halbtc8723b2ant_InitCoexDm( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist) +{ + /* force to reset coex mechanism */ + @@ -40415,27 +39248,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); +} + -+static void -+halbtc8723b2ant_ActionBtInquiry( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionBtInquiry(PBTC_COEXIST pBtCoexist) +{ -+ bool bWifiConnected =false; -+ bool bLowPwrDisable =true; ++ bool bWifiConnected = false; ++ bool bLowPwrDisable = true; + + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); + -+ if (bWifiConnected) -+ { ++ if (bWifiConnected) { + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1); + } ++ + halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); + @@ -40448,21 +39276,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, false, false); +} + -+static bool -+halbtc8723b2ant_IsCommonAction( -+PBTC_COEXIST pBtCoexist -+ ) ++static bool halbtc8723b2ant_IsCommonAction(PBTC_COEXIST pBtCoexist) +{ -+ u8 btRssiState =BTC_RSSI_STATE_HIGH; -+ bool bCommon =false, bWifiConnected =false, bWifiBusy =false; -+ bool bBtHsOn =false, bLowPwrDisable =false; ++ u8 btRssiState = BTC_RSSI_STATE_HIGH; ++ bool bCommon = false, bWifiConnected = false, bWifiBusy = false; ++ bool bBtHsOn = false, bLowPwrDisable = false; + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + -+ if (!bWifiConnected) -+ { ++ if (!bWifiConnected) { + bLowPwrDisable = false; + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); + halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8); @@ -40479,11 +39303,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + + bCommon = true; -+ } -+ else -+ { -+ if (BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) -+ { ++ } else { ++ if (BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) { + bLowPwrDisable = false; + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); + halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8); @@ -40500,14 +39321,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + + bCommon = true; -+ } -+ else if (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) -+ { ++ } else if (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) { + bLowPwrDisable = true; + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); + + if (bBtHsOn) + return false; ++ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); + halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8); + @@ -40521,19 +39341,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + + bCommon = true; -+ } -+ else -+ { ++ } else { + bLowPwrDisable = true; + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); + -+ if (bWifiBusy) -+ { ++ if (bWifiBusy) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); + bCommon = false; -+ } -+ else -+ { ++ } else { + if (bBtHsOn) + return false; + @@ -40545,10 +39360,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 21); + halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb); ++ + if (BTC_RSSI_HIGH(btRssiState)) + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); + else + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); ++ + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + bCommon = true; @@ -40559,118 +39376,76 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + return bCommon; +} + -+static void -+halbtc8723b2ant_TdmaDurationAdjust( -+PBTC_COEXIST pBtCoexist, -+bool bScoHid, -+bool bTxPause, -+u8 maxInterval -+ ) ++static void halbtc8723b2ant_TdmaDurationAdjust( ++ PBTC_COEXIST pBtCoexist, bool bScoHid, bool bTxPause, u8 maxInterval ++) +{ -+ static s32 up, dn, m, n, WaitCount; -+ s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */ -+ u8 retryCount = 0; ++ static s32 up, dn, m, n, WaitCount; ++ s32 result; /* 0: no change, +1: increase WiFi duration, -1: decrease WiFi duration */ ++ u8 retryCount = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW, ("[BTCoex], TdmaDurationAdjust()\n")); + -+ if (!pCoexDm->bAutoTdmaAdjust) -+ { ++ if (!pCoexDm->bAutoTdmaAdjust) { + pCoexDm->bAutoTdmaAdjust = true; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); + { -+ if (bScoHid) -+ { -+ if (bTxPause) -+ { -+ if (maxInterval == 1) -+ { ++ if (bScoHid) { ++ if (bTxPause) { ++ if (maxInterval == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13); + pCoexDm->psTdmaDuAdjType = 13; -+ } -+ else if (maxInterval == 2) -+ { ++ } else if (maxInterval == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; -+ } -+ else if (maxInterval == 3) -+ { ++ } else if (maxInterval == 3) { ++ halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); ++ pCoexDm->psTdmaDuAdjType = 15; ++ } else { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; + } -+ else -+ { -+ halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); -+ pCoexDm->psTdmaDuAdjType = 15; -+ } -+ } -+ else -+ { -+ if (maxInterval == 1) -+ { ++ } else { ++ if (maxInterval == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); + pCoexDm->psTdmaDuAdjType = 9; -+ } -+ else if (maxInterval == 2) -+ { ++ } else if (maxInterval == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; -+ } -+ else if (maxInterval == 3) -+ { ++ } else if (maxInterval == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; + } + } -+ } -+ else -+ { -+ if (bTxPause) -+ { -+ if (maxInterval == 1) -+ { ++ } else { ++ if (bTxPause) { ++ if (maxInterval == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); + pCoexDm->psTdmaDuAdjType = 5; -+ } -+ else if (maxInterval == 2) -+ { ++ } else if (maxInterval == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (maxInterval == 3) -+ { ++ } else if (maxInterval == 3) { ++ halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); ++ pCoexDm->psTdmaDuAdjType = 7; ++ } else { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; + } -+ else -+ { -+ halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); -+ pCoexDm->psTdmaDuAdjType = 7; -+ } -+ } -+ else -+ { -+ if (maxInterval == 1) -+ { ++ } else { ++ if (maxInterval == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1); + pCoexDm->psTdmaDuAdjType = 1; -+ } -+ else if (maxInterval == 2) -+ { ++ } else if (maxInterval == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (maxInterval == 3) -+ { ++ } else if (maxInterval == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; + } @@ -40684,27 +39459,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + n = 3; + result = 0; + WaitCount = 0; -+ } -+ else -+ { ++ } else { + /* accquire the BT TRx retry count from BT_Info byte2 */ + retryCount = pCoexSta->btRetryCnt; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], retryCount = %d\n", retryCount)); -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], up =%d, dn =%d, m =%d, n =%d, WaitCount =%d\n", -+ up, dn, m, n, WaitCount)); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], up =%d, dn =%d, m =%d, n =%d, WaitCount =%d\n", ++ up, dn, m, n, WaitCount ++ ) ++ ); + result = 0; + WaitCount++; + -+ if (retryCount == 0) /* no retry in the last 2-second duration */ -+ { ++ if (retryCount == 0) { /* no retry in the last 2-second duration */ + up++; + dn--; + + if (dn <= 0) + dn = 0; + -+ if (up >= n) /* if 連續 n 個2秒 retry count為0, 則調寬WiFi duration */ -+ { ++ if (up >= n) { /* if 連續 n 個2秒 retry count為0, 則調寬WiFi duration */ + WaitCount = 0; + n = 3; + up = 0; @@ -40712,17 +39489,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + result = 1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Increase wifi duration!!\n")); + } -+ } -+ else if (retryCount <= 3) /* <=3 retry in the last 2-second duration */ -+ { ++ } else if (retryCount <= 3) { /* <=3 retry in the last 2-second duration */ + up--; + dn++; + + if (up <= 0) + up = 0; + -+ if (dn == 2) /* if 連續 2 個2秒 retry count< 3, 則調窄WiFi duration */ -+ { ++ if (dn == 2) { /* if 連續 2 個2秒 retry count< 3, 則調窄WiFi duration */ + if (WaitCount <= 2) + m++; /* 避免一直在兩個level中來回 */ + else @@ -40738,9 +39512,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + result = -1; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); + } -+ } -+ else /* retry count > 3, 只要1次 retry count > 3, 則調窄WiFi duration */ -+ { ++ } else { /* retry count > 3, 只要1次 retry count > 3, 則調窄WiFi duration */ + if (WaitCount == 1) + m++; /* 避免一直在兩個level中來回 */ + else @@ -40758,687 +39530,443 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + } + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], max Interval = %d\n", maxInterval)); -+ if (maxInterval == 1) -+ { -+ if (bTxPause) -+ { ++ if (maxInterval == 1) { ++ if (bTxPause) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n")); + -+ if (pCoexDm->curPsTdma == 71) -+ { ++ if (pCoexDm->curPsTdma == 71) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); + pCoexDm->psTdmaDuAdjType = 5; -+ } -+ else if (pCoexDm->curPsTdma == 1) -+ { ++ } else if (pCoexDm->curPsTdma == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); + pCoexDm->psTdmaDuAdjType = 5; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 4) -+ { ++ } else if (pCoexDm->curPsTdma == 4) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); + pCoexDm->psTdmaDuAdjType = 8; + } -+ if (pCoexDm->curPsTdma == 9) -+ { ++ ++ if (pCoexDm->curPsTdma == 9) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13); + pCoexDm->psTdmaDuAdjType = 13; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 12) -+ { ++ } else if (pCoexDm->curPsTdma == 12) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); + pCoexDm->psTdmaDuAdjType = 16; + } + -+ if (result == -1) -+ { -+ if (pCoexDm->curPsTdma == 5) -+ { ++ if (result == -1) { ++ if (pCoexDm->curPsTdma == 5) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); + pCoexDm->psTdmaDuAdjType = 8; -+ } -+ else if (pCoexDm->curPsTdma == 13) -+ { ++ } else if (pCoexDm->curPsTdma == 13) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); + pCoexDm->psTdmaDuAdjType = 16; + } -+ } -+ else if (result == 1) -+ { -+ if (pCoexDm->curPsTdma == 8) -+ { ++ } else if (result == 1) { ++ if (pCoexDm->curPsTdma == 8) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); + pCoexDm->psTdmaDuAdjType = 5; -+ } -+ else if (pCoexDm->curPsTdma == 16) -+ { ++ } else if (pCoexDm->curPsTdma == 16) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13); + pCoexDm->psTdmaDuAdjType = 13; + } + } -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n")); -+ if (pCoexDm->curPsTdma == 5) -+ { ++ if (pCoexDm->curPsTdma == 5) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 71); + pCoexDm->psTdmaDuAdjType = 71; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 8) -+ { ++ } else if (pCoexDm->curPsTdma == 8) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); + pCoexDm->psTdmaDuAdjType = 4; + } -+ if (pCoexDm->curPsTdma == 13) -+ { ++ ++ if (pCoexDm->curPsTdma == 13) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); + pCoexDm->psTdmaDuAdjType = 9; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 16) -+ { ++ } else if (pCoexDm->curPsTdma == 16) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); + pCoexDm->psTdmaDuAdjType = 12; + } + -+ if (result == -1) -+ { -+ if (pCoexDm->curPsTdma == 71) -+ { ++ if (result == -1) { ++ if (pCoexDm->curPsTdma == 71) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1); + pCoexDm->psTdmaDuAdjType = 1; -+ } -+ else if (pCoexDm->curPsTdma == 1) -+ { ++ } else if (pCoexDm->curPsTdma == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); + pCoexDm->psTdmaDuAdjType = 4; -+ } -+ else if (pCoexDm->curPsTdma == 9) -+ { ++ } else if (pCoexDm->curPsTdma == 9) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); + pCoexDm->psTdmaDuAdjType = 12; + } -+ } -+ else if (result == 1) -+ { -+ if (pCoexDm->curPsTdma == 4) -+ { ++ } else if (result == 1) { ++ if (pCoexDm->curPsTdma == 4) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1); + pCoexDm->psTdmaDuAdjType = 1; -+ } -+ else if (pCoexDm->curPsTdma == 1) -+ { ++ } else if (pCoexDm->curPsTdma == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 71); + pCoexDm->psTdmaDuAdjType = 71; -+ } -+ else if (pCoexDm->curPsTdma == 12) -+ { ++ } else if (pCoexDm->curPsTdma == 12) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); + pCoexDm->psTdmaDuAdjType = 9; + } + } + } -+ } -+ else if (maxInterval == 2) -+ { -+ if (bTxPause) -+ { ++ } else if (maxInterval == 2) { ++ if (bTxPause) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n")); -+ if (pCoexDm->curPsTdma == 1) -+ { ++ if (pCoexDm->curPsTdma == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 4) -+ { ++ } else if (pCoexDm->curPsTdma == 4) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); + pCoexDm->psTdmaDuAdjType = 8; + } -+ if (pCoexDm->curPsTdma == 9) -+ { ++ ++ if (pCoexDm->curPsTdma == 9) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 12) -+ { ++ } else if (pCoexDm->curPsTdma == 12) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); + pCoexDm->psTdmaDuAdjType = 16; + } -+ if (result == -1) -+ { -+ if (pCoexDm->curPsTdma == 5) -+ { ++ ++ if (result == -1) { ++ if (pCoexDm->curPsTdma == 5) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); + pCoexDm->psTdmaDuAdjType = 8; -+ } -+ else if (pCoexDm->curPsTdma == 13) -+ { ++ } else if (pCoexDm->curPsTdma == 13) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); + pCoexDm->psTdmaDuAdjType = 16; + } -+ } -+ else if (result == 1) -+ { -+ if (pCoexDm->curPsTdma == 8) -+ { ++ } else if (result == 1) { ++ if (pCoexDm->curPsTdma == 8) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); + pCoexDm->psTdmaDuAdjType = 6; -+ } -+ else if (pCoexDm->curPsTdma == 16) -+ { ++ } else if (pCoexDm->curPsTdma == 16) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); + pCoexDm->psTdmaDuAdjType = 14; + } + } -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n")); -+ if (pCoexDm->curPsTdma == 5) -+ { ++ if (pCoexDm->curPsTdma == 5) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 8) -+ { ++ } else if (pCoexDm->curPsTdma == 8) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); + pCoexDm->psTdmaDuAdjType = 4; + } -+ if (pCoexDm->curPsTdma == 13) -+ { ++ ++ if (pCoexDm->curPsTdma == 13) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 16) -+ { ++ } else if (pCoexDm->curPsTdma == 16) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); + pCoexDm->psTdmaDuAdjType = 12; + } -+ if (result == -1) -+ { -+ if (pCoexDm->curPsTdma == 1) -+ { ++ ++ if (result == -1) { ++ if (pCoexDm->curPsTdma == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); + pCoexDm->psTdmaDuAdjType = 4; -+ } -+ else if (pCoexDm->curPsTdma == 9) -+ { ++ } else if (pCoexDm->curPsTdma == 9) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); + pCoexDm->psTdmaDuAdjType = 12; + } -+ } -+ else if (result == 1) -+ { -+ if (pCoexDm->curPsTdma == 4) -+ { ++ } else if (result == 1) { ++ if (pCoexDm->curPsTdma == 4) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); + pCoexDm->psTdmaDuAdjType = 2; -+ } -+ else if (pCoexDm->curPsTdma == 12) -+ { ++ } else if (pCoexDm->curPsTdma == 12) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); + pCoexDm->psTdmaDuAdjType = 10; + } + } + } -+ } -+ else if (maxInterval == 3) -+ { -+ if (bTxPause) -+ { ++ } else if (maxInterval == 3) { ++ if (bTxPause) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n")); -+ if (pCoexDm->curPsTdma == 1) -+ { ++ if (pCoexDm->curPsTdma == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 4) -+ { ++ } else if (pCoexDm->curPsTdma == 4) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); + pCoexDm->psTdmaDuAdjType = 8; + } -+ if (pCoexDm->curPsTdma == 9) -+ { ++ ++ if (pCoexDm->curPsTdma == 9) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 12) -+ { ++ } else if (pCoexDm->curPsTdma == 12) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); + pCoexDm->psTdmaDuAdjType = 16; + } -+ if (result == -1) -+ { -+ if (pCoexDm->curPsTdma == 5) -+ { ++ ++ if (result == -1) { ++ if (pCoexDm->curPsTdma == 5) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); + pCoexDm->psTdmaDuAdjType = 8; -+ } -+ else if (pCoexDm->curPsTdma == 13) -+ { ++ } else if (pCoexDm->curPsTdma == 13) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); + pCoexDm->psTdmaDuAdjType = 16; + } -+ } -+ else if (result == 1) -+ { -+ if (pCoexDm->curPsTdma == 8) -+ { ++ } else if (result == 1) { ++ if (pCoexDm->curPsTdma == 8) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); + pCoexDm->psTdmaDuAdjType = 7; -+ } -+ else if (pCoexDm->curPsTdma == 16) -+ { ++ } else if (pCoexDm->curPsTdma == 16) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); + pCoexDm->psTdmaDuAdjType = 15; + } + } -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n")); -+ if (pCoexDm->curPsTdma == 5) -+ { ++ if (pCoexDm->curPsTdma == 5) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 6) -+ { ++ } else if (pCoexDm->curPsTdma == 6) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 7) -+ { ++ } else if (pCoexDm->curPsTdma == 7) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 8) -+ { ++ } else if (pCoexDm->curPsTdma == 8) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); + pCoexDm->psTdmaDuAdjType = 4; + } -+ if (pCoexDm->curPsTdma == 13) -+ { ++ ++ if (pCoexDm->curPsTdma == 13) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 14) -+ { ++ } else if (pCoexDm->curPsTdma == 14) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 15) -+ { ++ } else if (pCoexDm->curPsTdma == 15) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 16) -+ { ++ } else if (pCoexDm->curPsTdma == 16) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); + pCoexDm->psTdmaDuAdjType = 12; + } -+ if (result == -1) -+ { -+ if (pCoexDm->curPsTdma == 1) -+ { ++ ++ if (result == -1) { ++ if (pCoexDm->curPsTdma == 1) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); + pCoexDm->psTdmaDuAdjType = 4; -+ } -+ else if (pCoexDm->curPsTdma == 9) -+ { ++ } else if (pCoexDm->curPsTdma == 9) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); + pCoexDm->psTdmaDuAdjType = 12; + } -+ } -+ else if (result == 1) -+ { -+ if (pCoexDm->curPsTdma == 4) -+ { ++ } else if (result == 1) { ++ if (pCoexDm->curPsTdma == 4) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 3) -+ { ++ } else if (pCoexDm->curPsTdma == 3) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 2) -+ { ++ } else if (pCoexDm->curPsTdma == 2) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); + pCoexDm->psTdmaDuAdjType = 3; -+ } -+ else if (pCoexDm->curPsTdma == 12) -+ { ++ } else if (pCoexDm->curPsTdma == 12) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 11) -+ { ++ } else if (pCoexDm->curPsTdma == 11) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; -+ } -+ else if (pCoexDm->curPsTdma == 10) -+ { ++ } else if (pCoexDm->curPsTdma == 10) { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); + pCoexDm->psTdmaDuAdjType = 11; + } @@ -41449,32 +39977,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + /* if current PsTdma not match with the recorded one (when scan, dhcp...), */ + /* then we have to adjust it back to the previous record one. */ -+ if (pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) -+ { -+ bool bScan =false, bLink =false, bRoam =false; -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma =%d, recordPsTdma =%d\n", -+ pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); ++ if (pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) { ++ bool bScan = false, bLink = false, bRoam = false; ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_DETAIL, ++ ( ++ "[BTCoex], PsTdma type dismatch!!!, curPsTdma =%d, recordPsTdma =%d\n", ++ pCoexDm->curPsTdma, ++ pCoexDm->psTdmaDuAdjType ++ ) ++ ); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); + + if (!bScan && !bLink && !bRoam) -+ { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, pCoexDm->psTdmaDuAdjType); -+ } -+ else -+ { ++ else { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); + } + } +} + +/* SCO only or SCO+PAN(HS) */ -+static void -+halbtc8723b2ant_ActionSco( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionSco(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; + u32 wifiBw; @@ -41496,41 +40024,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); + + if (BTC_WIFI_BW_LEGACY == wifiBw) /* for SCO quality at 11b/g mode */ -+ { + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -+ } + else /* for SCO quality & wifi performance balance at 11n mode */ -+ { + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); -+ } + + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 0); /* for voice quality */ + + /* sw mechanism */ -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x4); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, true, 0x4); + } @@ -41538,10 +40057,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b +} + + -+static void -+halbtc8723b2ant_ActionHid( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionHid(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; + u32 wifiBw; @@ -41563,49 +40079,38 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); + + if (BTC_WIFI_BW_LEGACY == wifiBw) /* for HID at 11b/g mode */ -+ { + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); -+ } + else /* for HID quality & wifi performance balance at 11n mode */ -+ { + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 9); -+ } + -+ if ((btRssiState == BTC_RSSI_STATE_HIGH) || -+ (btRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if ( ++ (btRssiState == BTC_RSSI_STATE_HIGH) || ++ (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); -+ } + else -+ { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13); -+ } + + /* sw mechanism */ -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } @@ -41613,13 +40118,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b +} + +/* A2DP only / PAN(EDR) only/ A2DP+PAN(HS) */ -+static void -+halbtc8723b2ant_ActionA2dp( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionA2dp(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, wifiRssiState1, btRssiState; -+ u32 wifiBw; ++ u32 wifiBw; + u8 apNum = 0; + + wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); @@ -41629,8 +40131,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); + + /* define the office environment */ -+ if (apNum >= 10 && BTC_RSSI_HIGH(wifiRssiState1)) -+ { ++ if (apNum >= 10 && BTC_RSSI_HIGH(wifiRssiState1)) { + /* DbgPrint(" AP#>10(%d)\n", apNum); */ + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, false, false, 0x8); @@ -41641,13 +40142,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + /* sw mechanism */ + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, true, 0x18); + } @@ -41666,55 +40164,45 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); + -+ if ((btRssiState == BTC_RSSI_STATE_HIGH) || -+ (btRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if ( ++ (btRssiState == BTC_RSSI_STATE_HIGH) || ++ (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 1); -+ } + else -+ { + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 1); -+ } + + /* sw mechanism */ + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } + } +} + -+static void -+halbtc8723b2ant_ActionA2dpPanHs( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionA2dpPanHs(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; -+ u32 wifiBw; ++ u32 wifiBw; + + wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); + btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); @@ -41736,43 +40224,35 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + /* sw mechanism */ + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } + } +} + -+static void -+halbtc8723b2ant_ActionPanEdr( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionPanEdr(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; -+ u32 wifiBw; ++ u32 wifiBw; + + wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); + btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); @@ -41790,42 +40270,35 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10); + -+ if ((btRssiState == BTC_RSSI_STATE_HIGH) || -+ (btRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if ( ++ (btRssiState == BTC_RSSI_STATE_HIGH) || ++ (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1); -+ } + else -+ { + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); -+ } + + /* sw mechanism */ + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } @@ -41834,13 +40307,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + +/* PAN(HS) only */ -+static void -+halbtc8723b2ant_ActionPanHs( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionPanHs(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; -+ u32 wifiBw; ++ u32 wifiBw; + + wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); + btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); @@ -41861,30 +40331,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, false, 1); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } @@ -41892,13 +40357,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b +} + +/* PAN(EDR)+A2DP */ -+static void -+halbtc8723b2ant_ActionPanEdrA2dp( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionPanEdrA2dp(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; -+ u32 wifiBw; ++ u32 wifiBw; + + wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); + btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); @@ -41916,59 +40378,50 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); + -+ if ((btRssiState == BTC_RSSI_STATE_HIGH) || -+ (btRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if ( ++ (btRssiState == BTC_RSSI_STATE_HIGH) || ++ (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12); + if (BTC_WIFI_BW_HT40 == wifiBw) + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3); + else + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, false, 3); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, false, true, 3); + } + + /* sw mechanism */ -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, false, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } + } +} + -+static void -+halbtc8723b2ant_ActionPanEdrHid( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionPanEdrHid(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; -+ u32 wifiBw; ++ u32 wifiBw; + + wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); + btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); @@ -41981,25 +40434,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + else + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); + -+ if ((btRssiState == BTC_RSSI_STATE_HIGH) || -+ (btRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { ++ if ( ++ (btRssiState == BTC_RSSI_STATE_HIGH) || ++ (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { + halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3); + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); + } + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11); + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); @@ -42007,30 +40456,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + } + + /* sw mechanism */ -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } @@ -42038,13 +40482,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b +} + +/* HID+A2DP+PAN(EDR) */ -+static void -+halbtc8723b2ant_ActionHidA2dpPanEdr( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionHidA2dpPanEdr(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; -+ u32 wifiBw; ++ u32 wifiBw; + + wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); + btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); @@ -42064,57 +40505,47 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); + -+ if ((btRssiState == BTC_RSSI_STATE_HIGH) || -+ (btRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if ( ++ (btRssiState == BTC_RSSI_STATE_HIGH) || ++ (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + if (BTC_WIFI_BW_HT40 == wifiBw) + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2); + else + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 3); -+ } -+ else -+ { ++ } else + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 3); -+ } + + /* sw mechanism */ -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } + } +} + -+static void -+halbtc8723b2ant_ActionHidA2dp( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_ActionHidA2dp(PBTC_COEXIST pBtCoexist) +{ + u8 wifiRssiState, btRssiState; -+ u32 wifiBw; ++ u32 wifiBw; + u8 apNum = 0; + + wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); @@ -42128,27 +40559,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); -+ if (BTC_WIFI_BW_LEGACY == wifiBw) -+ { ++ if (BTC_WIFI_BW_LEGACY == wifiBw) { + if (BTC_RSSI_HIGH(btRssiState)) + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); + else if (BTC_RSSI_MEDIUM(btRssiState)) + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); -+ else ++ else + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); -+ } -+ else -+ { /* only 802.11N mode we have to dec bt power to 4 degree */ -+ if (BTC_RSSI_HIGH(btRssiState)) -+ { ++ } else { ++ /* only 802.11N mode we have to dec bt power to 4 degree */ ++ if (BTC_RSSI_HIGH(btRssiState)) { + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); + /* need to check ap Number of Not */ + if (apNum < 10) + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); + else + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); -+ } -+ else if (BTC_RSSI_MEDIUM(btRssiState)) ++ } else if (BTC_RSSI_MEDIUM(btRssiState)) + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); + else + halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); @@ -42156,79 +40583,63 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); + -+ if ((btRssiState == BTC_RSSI_STATE_HIGH) || -+ (btRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if ( ++ (btRssiState == BTC_RSSI_STATE_HIGH) || ++ (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, false, 2); -+ } + else -+ { + halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, true, true, 2); -+ } + + /* sw mechanism */ -+ if (BTC_WIFI_BW_HT40 == wifiBw) -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ if (BTC_WIFI_BW_HT40 == wifiBw) { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, true, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } -+ } -+ else -+ { -+ if ((wifiRssiState == BTC_RSSI_STATE_HIGH) || -+ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH)) -+ { ++ } else { ++ if ( ++ (wifiRssiState == BTC_RSSI_STATE_HIGH) || ++ (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ++ ) { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, true, false, false, 0x18); -+ } -+ else -+ { ++ } else { + halbtc8723b2ant_SwMechanism1(pBtCoexist, false, true, false, false); + halbtc8723b2ant_SwMechanism2(pBtCoexist, false, false, false, 0x18); + } + } +} + -+static void -+halbtc8723b2ant_RunCoexistMechanism( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_RunCoexistMechanism(PBTC_COEXIST pBtCoexist) +{ -+ u8 algorithm = 0; ++ u8 algorithm = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism() ===>\n")); + -+ if (pBtCoexist->bManualControl) -+ { ++ if (pBtCoexist->bManualControl) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); + return; + } + -+ if (pCoexSta->bUnderIps) -+ { ++ if (pCoexSta->bUnderIps) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], wifi is under IPS !!!\n")); + return; + } + + algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist); -+ if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS!=algorithm)) -+ { ++ if (pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS != algorithm)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT is under inquiry/page scan !!\n")); + halbtc8723b2ant_ActionBtInquiry(pBtCoexist); + return; -+ } -+ else -+ { -+ if (pCoexDm->bNeedRecover0x948) -+ { ++ } else { ++ if (pCoexDm->bNeedRecover0x948) { + pCoexDm->bNeedRecover0x948 = false; + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, pCoexDm->backup0x948); + } @@ -42237,77 +40648,78 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexDm->curAlgorithm = algorithm; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Algorithm = %d\n", pCoexDm->curAlgorithm)); + -+ if (halbtc8723b2ant_IsCommonAction(pBtCoexist)) -+ { ++ if (halbtc8723b2ant_IsCommonAction(pBtCoexist)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant common.\n")); + pCoexDm->bAutoTdmaAdjust = false; -+ } -+ else -+ { -+ if (pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) -+ { -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], preAlgorithm =%d, curAlgorithm =%d\n", -+ pCoexDm->preAlgorithm, pCoexDm->curAlgorithm)); ++ } else { ++ if (pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) { ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE, ++ ( ++ "[BTCoex], preAlgorithm =%d, curAlgorithm =%d\n", ++ pCoexDm->preAlgorithm, ++ pCoexDm->curAlgorithm ++ ) ++ ); + pCoexDm->bAutoTdmaAdjust = false; + } -+ switch (pCoexDm->curAlgorithm) -+ { -+ case BT_8723B_2ANT_COEX_ALGO_SCO: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); -+ halbtc8723b2ant_ActionSco(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_HID: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); -+ halbtc8723b2ant_ActionHid(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_A2DP: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); -+ halbtc8723b2ant_ActionA2dp(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n")); -+ halbtc8723b2ant_ActionA2dpPanHs(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_PANEDR: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); -+ halbtc8723b2ant_ActionPanEdr(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_PANHS: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); -+ halbtc8723b2ant_ActionPanHs(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); -+ halbtc8723b2ant_ActionPanEdrA2dp(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); -+ halbtc8723b2ant_ActionPanEdrHid(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); -+ halbtc8723b2ant_ActionHidA2dpPanEdr(pBtCoexist); -+ break; -+ case BT_8723B_2ANT_COEX_ALGO_HID_A2DP: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); -+ halbtc8723b2ant_ActionHidA2dp(pBtCoexist); -+ break; -+ default: -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n")); -+ halbtc8723b2ant_CoexAllOff(pBtCoexist); -+ break; ++ ++ ++ switch (pCoexDm->curAlgorithm) { ++ case BT_8723B_2ANT_COEX_ALGO_SCO: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); ++ halbtc8723b2ant_ActionSco(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_HID: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); ++ halbtc8723b2ant_ActionHid(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_A2DP: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); ++ halbtc8723b2ant_ActionA2dp(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n")); ++ halbtc8723b2ant_ActionA2dpPanHs(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_PANEDR: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); ++ halbtc8723b2ant_ActionPanEdr(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_PANHS: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); ++ halbtc8723b2ant_ActionPanHs(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); ++ halbtc8723b2ant_ActionPanEdrA2dp(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); ++ halbtc8723b2ant_ActionPanEdrHid(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); ++ halbtc8723b2ant_ActionHidA2dpPanEdr(pBtCoexist); ++ break; ++ case BT_8723B_2ANT_COEX_ALGO_HID_A2DP: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); ++ halbtc8723b2ant_ActionHidA2dp(pBtCoexist); ++ break; ++ default: ++ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n")); ++ halbtc8723b2ant_CoexAllOff(pBtCoexist); ++ break; + } + pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; + } +} + -+static void -+halbtc8723b2ant_WifiOffHwCfg( -+PBTC_COEXIST pBtCoexist -+ ) ++static void halbtc8723b2ant_WifiOffHwCfg(PBTC_COEXIST pBtCoexist) +{ -+ bool bIsInMpMode = false; -+ u8 H2C_Parameter[2] ={0}; ++ bool bIsInMpMode = false; ++ u8 H2C_Parameter[2] = {0}; + u32 fwVer = 0; + + /* set wlan_act to low */ @@ -42315,16 +40727,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); /* WiFi goto standby while GNT_BT 0-->1 */ + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); -+ if (fwVer >= 0x180000) -+ { -+ /* Use H2C to set GNT_BT to HIGH */ -+ H2C_Parameter[0] = 1; -+ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); -+ } -+ else -+ { ++ if (fwVer >= 0x180000) { ++ /* Use H2C to set GNT_BT to HIGH */ ++ H2C_Parameter[0] = 1; ++ pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); ++ } else + pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); -+ } + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode); + if (!bIsInMpMode) @@ -42333,11 +40741,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */ +} + -+static void -+halbtc8723b2ant_InitHwConfig( -+PBTC_COEXIST pBtCoexist, -+bool bBackUp -+ ) ++static void halbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bBackUp) +{ + u8 u1Tmp = 0; + @@ -42371,12 +40775,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b +/* */ +/* extern function start with EXhalbtc8723b2ant_ */ +/* */ -+void -+EXhalbtc8723b2ant_PowerOnSetting( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BOARD_INFO pBoardInfo =&pBtCoexist->boardInfo; ++ PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo; + u8 u1Tmp = 0x4; /* Set BIT2 by default since it's 2ant case */ + u16 u2Tmp = 0x0; + @@ -42398,8 +40799,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + /* BIT1: "0" for internal switch; "1" for external switch */ + /* BIT2: "0" for one antenna; "1" for two antenna */ + /* NOTE: here default all internal switch and 1-antenna ==> BIT1 = 0 and BIT2 = 0 */ -+ if (pBtCoexist->chipInterface == BTC_INTF_USB) -+ { ++ if (pBtCoexist->chipInterface == BTC_INTF_USB) { + /* fixed at S0 for USB interface */ + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); + @@ -42407,18 +40807,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); + + pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; -+ } -+ else -+ { ++ } else { + /* for PCIE and SDIO interface, we check efuse 0xc3[6] */ -+ if (pBoardInfo->singleAntPath == 0) -+ { ++ if (pBoardInfo->singleAntPath == 0) { + /* set to S1 */ + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); + pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; -+ } -+ else if (pBoardInfo->singleAntPath == 1) -+ { ++ } else if (pBoardInfo->singleAntPath == 1) { + /* set to S0 */ + pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); + u1Tmp |= 0x1; /* antenna inverse */ @@ -42426,71 +40821,66 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + } + + if (pBtCoexist->chipInterface == BTC_INTF_PCI) -+ { + pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp); -+ } + else if (pBtCoexist->chipInterface == BTC_INTF_SDIO) -+ { + pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); -+ } + } +} + -+void -+EXhalbtc8723b2ant_InitHwConfig( -+PBTC_COEXIST pBtCoexist, -+bool bWifiOnly -+ ) ++void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly) +{ + halbtc8723b2ant_InitHwConfig(pBtCoexist, true); +} + -+void -+EXhalbtc8723b2ant_InitCoexDm( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], Coex Mechanism Init!!\n")); + + halbtc8723b2ant_InitCoexDm(pBtCoexist); +} + -+void -+EXhalbtc8723b2ant_DisplayCoexInfo( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist) +{ -+ PBTC_BOARD_INFO pBoardInfo =&pBtCoexist->boardInfo; -+ PBTC_STACK_INFO pStackInfo =&pBtCoexist->stackInfo; -+ PBTC_BT_LINK_INFO pBtLinkInfo =&pBtCoexist->btLinkInfo; -+ u8 * cliBuf =pBtCoexist->cliBuf; -+ u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0; -+ u32 u4Tmp[4]; -+ bool bRoam =false, bScan =false, bLink =false, bWifiUnder5G =false; -+ bool bBtHsOn =false, bWifiBusy =false; -+ s32 wifiRssi = 0, btHsRssi = 0; -+ u32 wifiBw, wifiTrafficDir, faOfdm, faCck; -+ u8 wifiDot11Chnl, wifiHsChnl; -+ u32 fwVer = 0, btPatchVer = 0; -+ u8 apNum = 0; ++ PBTC_BOARD_INFO pBoardInfo = &pBtCoexist->boardInfo; ++ PBTC_STACK_INFO pStackInfo = &pBtCoexist->stackInfo; ++ PBTC_BT_LINK_INFO pBtLinkInfo = &pBtCoexist->btLinkInfo; ++ u8 *cliBuf = pBtCoexist->cliBuf; ++ u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0; ++ u32 u4Tmp[4]; ++ bool bRoam = false, bScan = false, bLink = false, bWifiUnder5G = false; ++ bool bBtHsOn = false, bWifiBusy = false; ++ s32 wifiRssi = 0, btHsRssi = 0; ++ u32 wifiBw, wifiTrafficDir, faOfdm, faCck; ++ u8 wifiDot11Chnl, wifiHsChnl; ++ u32 fwVer = 0, btPatchVer = 0; ++ u8 apNum = 0; + + CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); + CL_PRINTF(cliBuf); + -+ if (pBtCoexist->bManualControl) -+ { ++ if (pBtCoexist->bManualControl) { + CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); + CL_PRINTF(cliBuf); + CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); + CL_PRINTF(cliBuf); + } + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ -+ pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ ++ pBoardInfo->pgAntNum, ++ pBoardInfo->btdmAntNum ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ -+ ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ ++ (pStackInfo->bProfileNotified ? "Yes" : "No"), ++ pStackInfo->hciVersion ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); @@ -42502,82 +40892,153 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \ -+ wifiDot11Chnl, wifiHsChnl, bBtHsOn); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \ ++ wifiDot11Chnl, ++ wifiHsChnl, ++ bBtHsOn ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \ -+ pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], -+ pCoexDm->wifiChnlInfo[2]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \ ++ pCoexDm->wifiChnlInfo[0], ++ pCoexDm->wifiChnlInfo[1], ++ pCoexDm->wifiChnlInfo[2] ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Wifi rssi/ HS rssi/ AP#", \ -+ wifiRssi, btHsRssi, apNum); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d", "Wifi rssi/ HS rssi/ AP#", \ ++ wifiRssi, ++ btHsRssi, ++ apNum ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \ -+ bLink, bRoam, bScan); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \ ++ bLink, ++ bRoam, ++ bScan ++ ); + CL_PRINTF(cliBuf); + + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s ", "Wifi status", \ -+ (bWifiUnder5G? "5G":"2.4G"), -+ ((BTC_WIFI_BW_LEGACY ==wifiBw)? "Legacy": (((BTC_WIFI_BW_HT40 ==wifiBw)? "HT40":"HT20"))), -+ ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX ==wifiTrafficDir)? "uplink":"downlink"))); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s / %s/ %s ", "Wifi status", \ ++ (bWifiUnder5G ? "5G" : "2.4G"), ++ ((BTC_WIFI_BW_LEGACY == wifiBw) ? "Legacy" : (((BTC_WIFI_BW_HT40 == wifiBw) ? "HT40" : "HT20"))), ++ ((!bWifiBusy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) ? "uplink" : "downlink")) ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ -+ ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": -+ ((BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), -+ pCoexSta->btRssi, pCoexSta->btRetryCnt); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ ++ ((pBtCoexist->btInfo.bBtDisabled) ? ("disabled") : ((pCoexSta->bC2hBtInquiryPage) ? ("inquiry/page scan") : ((BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ? "non-connected idle" : ++ ((BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ? "connected-idle" : "busy")))), ++ pCoexSta->btRssi, ++ pCoexSta->btRetryCnt ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ -+ pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ ++ pBtLinkInfo->bScoExist, ++ pBtLinkInfo->bHidExist, ++ pBtLinkInfo->bPanExist, ++ pBtLinkInfo->bA2dpExist ++ ); + CL_PRINTF(cliBuf); + pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); + + btInfoExt = pCoexSta->btInfoExt; -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ -+ (btInfoExt&BIT0)? "Basic rate":"EDR rate"); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s", "BT Info A2DP rate", \ ++ (btInfoExt&BIT0) ? "Basic rate" : "EDR rate" ++ ); + CL_PRINTF(cliBuf); + -+ for (i = 0; ibtInfoC2hCnt[i]) -+ { -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b2Ant[i], \ -+ pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], -+ pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], -+ pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], -+ pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); ++ for (i = 0; i < BT_INFO_SRC_8723B_2ANT_MAX; i++) { ++ if (pCoexSta->btInfoC2hCnt[i]) { ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b2Ant[i], \ ++ pCoexSta->btInfoC2h[i][0], ++ pCoexSta->btInfoC2h[i][1], ++ pCoexSta->btInfoC2h[i][2], ++ pCoexSta->btInfoC2h[i][3], ++ pCoexSta->btInfoC2h[i][4], ++ pCoexSta->btInfoC2h[i][5], ++ pCoexSta->btInfoC2h[i][6], ++ pCoexSta->btInfoC2hCnt[i] ++ ); + CL_PRINTF(cliBuf); + } + } + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/%s", "PS state, IPS/LPS", \ -+ ((pCoexSta->bUnderIps? "IPS ON":"IPS OFF")), -+ ((pCoexSta->bUnderLps? "LPS ON":"LPS OFF"))); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %s/%s", "PS state, IPS/LPS", \ ++ ((pCoexSta->bUnderIps ? "IPS ON" : "IPS OFF")), ++ ((pCoexSta->bUnderLps ? "LPS ON" : "LPS OFF")) ++ ); + CL_PRINTF(cliBuf); + pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); + + /* Sw mechanism */ -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s", "============[Sw mechanism]============" ++ ); + CL_PRINTF(cliBuf); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ -+ pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ ++ pCoexDm->bCurRfRxLpfShrink, ++ pCoexDm->bCurLowPenaltyRa, ++ pCoexDm->bLimitedDig ++ ); + CL_PRINTF(cliBuf); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ -+ pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d/ %d(0x%x) ", ++ "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ ++ pCoexDm->bCurAgcTableEn, ++ pCoexDm->bCurAdcBackOff, ++ pCoexDm->bCurDacSwingOn, ++ pCoexDm->curDacSwingLvl ++ ); + CL_PRINTF(cliBuf); + + /* Fw mechanism */ @@ -42585,43 +41046,76 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + CL_PRINTF(cliBuf); + + psTdmaCase = pCoexDm->curPsTdma; -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \ -+ pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], -+ pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], -+ pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \ ++ pCoexDm->psTdmaPara[0], ++ pCoexDm->psTdmaPara[1], ++ pCoexDm->psTdmaPara[2], ++ pCoexDm->psTdmaPara[3], ++ pCoexDm->psTdmaPara[4], ++ psTdmaCase, pCoexDm->bAutoTdmaAdjust ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ -+ pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ ++ pCoexDm->curBtDecPwrLvl, ++ pCoexDm->bCurIgnoreWlanAct ++ ); + CL_PRINTF(cliBuf); + + /* Hw setting */ + CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ -+ pCoexDm->btRf0x1eBackup); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ ++ pCoexDm->btRf0x1eBackup ++ ); + CL_PRINTF(cliBuf); + + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \ -+ u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \ ++ u1Tmp[0], ++ (u4Tmp[0]&0x3e000000) >> 25 ++ ); + CL_PRINTF(cliBuf); + + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); + u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \ -+ u4Tmp[0], ((u1Tmp[0]&0x20)>> 5), u1Tmp[1]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \ ++ u4Tmp[0], ++ ((u1Tmp[0]&0x20)>>5), ++ u1Tmp[1] ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c); + u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); + u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \ -+ u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \ ++ u4Tmp[0]&0x3, ++ u4Tmp[1]&0xff, ++ u4Tmp[2]&0x3 ++ ); + CL_PRINTF(cliBuf); + + @@ -42629,20 +41123,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); + u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \ -+ ((u1Tmp[0] & 0x8)>>3), u1Tmp[1], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[2]&0x1); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \ ++ ((u1Tmp[0] & 0x8)>>3), ++ u1Tmp[1], ++ ((u4Tmp[0]&0x01800000)>>23), ++ u1Tmp[2]&0x1 ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ -+ u4Tmp[0], u1Tmp[0]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ ++ u4Tmp[0], ++ u1Tmp[0] ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ -+ u4Tmp[0]&0xff, u1Tmp[0]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ ++ u4Tmp[0]&0xff, ++ u1Tmp[0] ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); @@ -42653,27 +41164,55 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); + u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); + -+ faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ -+ ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ; ++ faOfdm = ++ ((u4Tmp[0]&0xffff0000) >> 16) + ++ ((u4Tmp[1]&0xffff0000) >> 16) + ++ (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ ++ ((u4Tmp[3]&0xffff0000) >> 16) + ++ (u4Tmp[3] & 0xffff); ++ + faCck = (u1Tmp[0] << 8) + u1Tmp[1]; + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ -+ u4Tmp[0]&0xffff, faOfdm, faCck); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ ++ u4Tmp[0]&0xffff, ++ faOfdm, ++ faCck ++ ); + CL_PRINTF(cliBuf); + + u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); + u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); + u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); + u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ -+ u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ ++ u4Tmp[0], ++ u4Tmp[1], ++ u4Tmp[2], ++ u1Tmp[0] ++ ); + CL_PRINTF(cliBuf); + -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ -+ pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ ++ pCoexSta->highPriorityRx, ++ pCoexSta->highPriorityTx ++ ); + CL_PRINTF(cliBuf); -+ CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ -+ pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); ++ CL_SPRINTF( ++ cliBuf, ++ BT_TMP_BUF_SIZE, ++ "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ ++ pCoexSta->lowPriorityRx, ++ pCoexSta->lowPriorityTx ++ ); + CL_PRINTF(cliBuf); + + halbtc8723b2ant_MonitorBtCtr(pBtCoexist); @@ -42681,22 +41220,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b +} + + -+void -+EXhalbtc8723b2ant_IpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ if (BTC_IPS_ENTER == type) -+ { ++ if (BTC_IPS_ENTER == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS ENTER notify\n")); + pCoexSta->bUnderIps = true; + halbtc8723b2ant_WifiOffHwCfg(pBtCoexist); + halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, true); + halbtc8723b2ant_CoexAllOff(pBtCoexist); -+ } -+ else if (BTC_IPS_LEAVE == type) -+ { ++ } else if (BTC_IPS_LEAVE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], IPS LEAVE notify\n")); + pCoexSta->bUnderIps = false; + halbtc8723b2ant_InitHwConfig(pBtCoexist, false); @@ -42705,174 +41237,133 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + } +} + -+void -+EXhalbtc8723b2ant_LpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ if (BTC_LPS_ENABLE == type) -+ { ++ if (BTC_LPS_ENABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS ENABLE notify\n")); + pCoexSta->bUnderLps = true; -+ } -+ else if (BTC_LPS_DISABLE == type) -+ { ++ } else if (BTC_LPS_DISABLE == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], LPS DISABLE notify\n")); + pCoexSta->bUnderLps = false; + } +} + -+void -+EXhalbtc8723b2ant_ScanNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ if (BTC_SCAN_START == type) -+ { ++ if (BTC_SCAN_START == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN START notify\n")); -+ } -+ else if (BTC_SCAN_FINISH == type) -+ { ++ } else if (BTC_SCAN_FINISH == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], SCAN FINISH notify\n")); + } +} + -+void -+EXhalbtc8723b2ant_ConnectNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ if (BTC_ASSOCIATE_START == type) -+ { ++ if (BTC_ASSOCIATE_START == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT START notify\n")); -+ } -+ else if (BTC_ASSOCIATE_FINISH == type) -+ { ++ } else if (BTC_ASSOCIATE_FINISH == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], CONNECT FINISH notify\n")); + } +} + -+void -+EXhalbtc8723b2ant_MediaStatusNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ u8 H2C_Parameter[3] ={0}; -+ u32 wifiBw; -+ u8 wifiCentralChnl; -+ u8 apNum = 0; ++ u8 H2C_Parameter[3] = {0}; ++ u32 wifiBw; ++ u8 wifiCentralChnl; ++ u8 apNum = 0; + -+ if (BTC_MEDIA_CONNECT == type) -+ { ++ if (BTC_MEDIA_CONNECT == type) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA connect notify\n")); -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], MEDIA disconnect notify\n")); + } + + /* only 2.4G we need to inform bt the chnl mask */ + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); -+ if ((BTC_MEDIA_CONNECT == type) && -+ (wifiCentralChnl <= 14)) -+ { ++ if ((BTC_MEDIA_CONNECT == type) && (wifiCentralChnl <= 14)) { + H2C_Parameter[0] = 0x1; + H2C_Parameter[1] = wifiCentralChnl; + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); + if (BTC_WIFI_BW_HT40 == wifiBw) + H2C_Parameter[2] = 0x30; -+ else -+ { ++ else { + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); + if (apNum < 10) + H2C_Parameter[2] = 0x30; + else + H2C_Parameter[2] = 0x20; -+ } ++ } + } + + pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; + pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; + pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; + -+ BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_EXEC, ("[BTCoex], FW write 0x66 = 0x%x\n", -+ H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); ++ BTC_PRINT( ++ BTC_MSG_ALGORITHM, ++ ALGO_TRACE_FW_EXEC, ++ ( ++ "[BTCoex], FW write 0x66 = 0x%x\n", ++ H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2] ++ ) ++ ); + + pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); +} + -+void -+EXhalbtc8723b2ant_SpecialPacketNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ) ++void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type) +{ -+ if (type == BTC_PACKET_DHCP) -+ { ++ if (type == BTC_PACKET_DHCP) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], DHCP Packet notify\n")); + } +} + -+void -+EXhalbtc8723b2ant_BtInfoNotify( -+PBTC_COEXIST pBtCoexist, -+u8 * tmpBuf, -+u8 length -+ ) ++void EXhalbtc8723b2ant_BtInfoNotify( ++ PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length ++) +{ + u8 btInfo = 0; + u8 i, rspSource = 0; -+ bool bBtBusy =false, bLimitedDig =false; -+ bool bWifiConnected =false; ++ bool bBtBusy = false, bLimitedDig = false; ++ bool bWifiConnected = false; + + pCoexSta->bC2hBtInfoReqSent = false; + + rspSource = tmpBuf[0]&0xf; + if (rspSource >= BT_INFO_SRC_8723B_2ANT_MAX) + rspSource = BT_INFO_SRC_8723B_2ANT_WIFI_FW; ++ + pCoexSta->btInfoC2hCnt[rspSource]++; + + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Bt info[%d], length =%d, hex data =[", rspSource, length)); -+ for (i = 0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; + if (i == 1) + btInfo = tmpBuf[i]; -+ if (i == length-1) -+ { ++ ++ if (i == length-1) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x]\n", tmpBuf[i])); -+ } -+ else -+ { ++ } else { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("0x%02x, ", tmpBuf[i])); + } + } + -+ if (pBtCoexist->bManualControl) -+ { ++ if (pBtCoexist->bManualControl) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n")); + return; + } + -+ if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) -+ { -+ pCoexSta->btRetryCnt = /* [3:0] */ -+ pCoexSta->btInfoC2h[rspSource][2]&0xf; ++ if (BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) { ++ pCoexSta->btRetryCnt = pCoexSta->btInfoC2h[rspSource][2]&0xf; /* [3:0] */ + -+ pCoexSta->btRssi = -+ pCoexSta->btInfoC2h[rspSource][3]*2+10; ++ pCoexSta->btRssi = pCoexSta->btInfoC2h[rspSource][3]*2+10; + -+ pCoexSta->btInfoExt = -+ pCoexSta->btInfoC2h[rspSource][4]; ++ pCoexSta->btInfoExt = pCoexSta->btInfoC2h[rspSource][4]; + + pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); + pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); -+ if (pCoexSta->bBtTxRxMask) -+ { ++ if (pCoexSta->bBtTxRxMask) { + /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */ + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n")); + pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); @@ -42880,27 +41371,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + /* Here we need to resend some wifi info to BT */ + /* because bt is reset and loss of the info. */ -+ if ((pCoexSta->btInfoExt & BIT1)) -+ { ++ if ((pCoexSta->btInfoExt & BIT1)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); ++ + if (bWifiConnected) -+ { + EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); -+ } + else -+ { + EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -+ } + } + -+ if ((pCoexSta->btInfoExt & BIT3)) -+ { ++ if ((pCoexSta->btInfoExt & BIT3)) { + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); + halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, false); -+ } -+ else -+ { ++ } else { + /* BT already NOT ignore Wlan active, do nothing here. */ + } + } @@ -42912,16 +41396,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + pCoexSta->bC2hBtInquiryPage = false; + + /* set link exist status */ -+ if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) -+ { ++ if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) { + pCoexSta->bBtLinkExist = false; + pCoexSta->bPanExist = false; + pCoexSta->bA2dpExist = false; + pCoexSta->bHidExist = false; + pCoexSta->bScoExist = false; -+ } -+ else /* connection exists */ -+ { ++ } else { /* connection exists */ + pCoexSta->bBtLinkExist = true; + if (btInfo & BT_INFO_8723B_2ANT_B_FTP) + pCoexSta->bPanExist = true; @@ -42943,42 +41424,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + + halbtc8723b2ant_UpdateBtLinkInfo(pBtCoexist); + -+ if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) -+ { ++ if (!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) { + pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); -+ } -+ else if (btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) /* connection exists but no busy */ -+ { ++ } else if (btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) { /* connection exists but no busy */ + pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); -+ } -+ else if ((btInfo&BT_INFO_8723B_2ANT_B_SCO_ESCO) || -+ (btInfo&BT_INFO_8723B_2ANT_B_SCO_BUSY)) -+ { ++ } else if ( ++ (btInfo&BT_INFO_8723B_2ANT_B_SCO_ESCO) || ++ (btInfo&BT_INFO_8723B_2ANT_B_SCO_BUSY) ++ ) { + pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_SCO_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); -+ } -+ else if (btInfo&BT_INFO_8723B_2ANT_B_ACL_BUSY) -+ { ++ } else if (btInfo&BT_INFO_8723B_2ANT_B_ACL_BUSY) { + pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_ACL_BUSY; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); -+ } -+ else -+ { ++ } else { + pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_MAX; + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); + } + -+ if ((BT_8723B_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || ++ if ( ++ (BT_8723B_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || + (BT_8723B_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || -+ (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus)) -+ { ++ (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ++ ) { + bBtBusy = true; + bLimitedDig = true; -+ } -+ else -+ { ++ } else { + bBtBusy = false; + bLimitedDig = false; + } @@ -42991,10 +41464,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + halbtc8723b2ant_RunCoexistMechanism(pBtCoexist); +} + -+void -+EXhalbtc8723b2ant_HaltNotify( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Halt notify\n")); + @@ -43005,20 +41475,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); +} + -+void -+EXhalbtc8723b2ant_PnpNotify( -+PBTC_COEXIST pBtCoexist, -+u8 pnpState -+ ) ++void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState) +{ + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify\n")); + -+ if (BTC_WIFI_PNP_SLEEP == pnpState) -+ { ++ if (BTC_WIFI_PNP_SLEEP == pnpState) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to SLEEP\n")); -+ } -+ else if (BTC_WIFI_PNP_WAKE_UP == pnpState) -+ { ++ } else if (BTC_WIFI_PNP_WAKE_UP == pnpState) { + BTC_PRINT(BTC_MSG_INTERFACE, INTF_NOTIFY, ("[BTCoex], Pnp notify to WAKE UP\n")); + halbtc8723b2ant_InitHwConfig(pBtCoexist, false); + halbtc8723b2ant_InitCoexDm(pBtCoexist); @@ -43026,18 +41489,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + } +} + -+void -+EXhalbtc8723b2ant_Periodical( -+PBTC_COEXIST pBtCoexist -+ ) ++void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist) +{ + static u8 disVerInfoCnt = 0; -+ u32 fwVer = 0, btPatchVer = 0; ++ u32 fwVer = 0, btPatchVer = 0; + + BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE, ("[BTCoex], ==========================Periodical ===========================\n")); + -+ if (disVerInfoCnt <= 5) -+ { ++ if (disVerInfoCnt <= 5) { + disVerInfoCnt += 1; + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n")); + pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); @@ -43047,16 +41506,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.c linux-4.3-rtl8723b + BTC_PRINT(BTC_MSG_INTERFACE, INTF_INIT, ("[BTCoex], ****************************************************************\n")); + } + -+ if (halbtc8723b2ant_IsWifiStatusChanged(pBtCoexist) || -+ pCoexDm->bAutoTdmaAdjust) -+ { ++ if ( ++ halbtc8723b2ant_IsWifiStatusChanged(pBtCoexist) || ++ pCoexDm->bAutoTdmaAdjust ++ ) + halbtc8723b2ant_RunCoexistMechanism(pBtCoexist); -+ } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h ---- linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,205 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h linux/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h +--- linux.old/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,155 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -43083,80 +41542,80 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h linux-4.3-rtl8723b + +#define BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT 2 + -+typedef enum _BT_INFO_SRC_8723B_2ANT{ -+ BT_INFO_SRC_8723B_2ANT_WIFI_FW = 0x0, -+ BT_INFO_SRC_8723B_2ANT_BT_RSP = 0x1, -+ BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND = 0x2, ++typedef enum _BT_INFO_SRC_8723B_2ANT { ++ BT_INFO_SRC_8723B_2ANT_WIFI_FW = 0x0, ++ BT_INFO_SRC_8723B_2ANT_BT_RSP = 0x1, ++ BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND = 0x2, + BT_INFO_SRC_8723B_2ANT_MAX -+}BT_INFO_SRC_8723B_2ANT,*PBT_INFO_SRC_8723B_2ANT; ++} BT_INFO_SRC_8723B_2ANT, *PBT_INFO_SRC_8723B_2ANT; + -+typedef enum _BT_8723B_2ANT_BT_STATUS{ -+ BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, -+ BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, -+ BT_8723B_2ANT_BT_STATUS_INQ_PAGE = 0x2, -+ BT_8723B_2ANT_BT_STATUS_ACL_BUSY = 0x3, -+ BT_8723B_2ANT_BT_STATUS_SCO_BUSY = 0x4, -+ BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, ++typedef enum _BT_8723B_2ANT_BT_STATUS { ++ BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, ++ BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, ++ BT_8723B_2ANT_BT_STATUS_INQ_PAGE = 0x2, ++ BT_8723B_2ANT_BT_STATUS_ACL_BUSY = 0x3, ++ BT_8723B_2ANT_BT_STATUS_SCO_BUSY = 0x4, ++ BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, + BT_8723B_2ANT_BT_STATUS_MAX -+}BT_8723B_2ANT_BT_STATUS,*PBT_8723B_2ANT_BT_STATUS; ++} BT_8723B_2ANT_BT_STATUS, *PBT_8723B_2ANT_BT_STATUS; + -+typedef enum _BT_8723B_2ANT_COEX_ALGO{ -+ BT_8723B_2ANT_COEX_ALGO_UNDEFINED = 0x0, -+ BT_8723B_2ANT_COEX_ALGO_SCO = 0x1, -+ BT_8723B_2ANT_COEX_ALGO_HID = 0x2, -+ BT_8723B_2ANT_COEX_ALGO_A2DP = 0x3, -+ BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, -+ BT_8723B_2ANT_COEX_ALGO_PANEDR = 0x5, -+ BT_8723B_2ANT_COEX_ALGO_PANHS = 0x6, -+ BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, -+ BT_8723B_2ANT_COEX_ALGO_PANEDR_HID = 0x8, ++typedef enum _BT_8723B_2ANT_COEX_ALGO { ++ BT_8723B_2ANT_COEX_ALGO_UNDEFINED = 0x0, ++ BT_8723B_2ANT_COEX_ALGO_SCO = 0x1, ++ BT_8723B_2ANT_COEX_ALGO_HID = 0x2, ++ BT_8723B_2ANT_COEX_ALGO_A2DP = 0x3, ++ BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, ++ BT_8723B_2ANT_COEX_ALGO_PANEDR = 0x5, ++ BT_8723B_2ANT_COEX_ALGO_PANHS = 0x6, ++ BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, ++ BT_8723B_2ANT_COEX_ALGO_PANEDR_HID = 0x8, + BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, -+ BT_8723B_2ANT_COEX_ALGO_HID_A2DP = 0xa, -+ BT_8723B_2ANT_COEX_ALGO_MAX = 0xb, -+}BT_8723B_2ANT_COEX_ALGO,*PBT_8723B_2ANT_COEX_ALGO; ++ BT_8723B_2ANT_COEX_ALGO_HID_A2DP = 0xa, ++ BT_8723B_2ANT_COEX_ALGO_MAX = 0xb, ++} BT_8723B_2ANT_COEX_ALGO, *PBT_8723B_2ANT_COEX_ALGO; + -+typedef struct _COEX_DM_8723B_2ANT{ ++typedef struct _COEX_DM_8723B_2ANT { + /* fw mechanism */ + u8 preBtDecPwrLvl; + u8 curBtDecPwrLvl; + u8 preFwDacSwingLvl; + u8 curFwDacSwingLvl; -+ bool bCurIgnoreWlanAct; -+ bool bPreIgnoreWlanAct; ++ bool bCurIgnoreWlanAct; ++ bool bPreIgnoreWlanAct; + u8 prePsTdma; + u8 curPsTdma; + u8 psTdmaPara[5]; + u8 psTdmaDuAdjType; -+ bool bResetTdmaAdjust; -+ bool bAutoTdmaAdjust; -+ bool bPrePsTdmaOn; -+ bool bCurPsTdmaOn; -+ bool bPreBtAutoReport; -+ bool bCurBtAutoReport; ++ bool bResetTdmaAdjust; ++ bool bAutoTdmaAdjust; ++ bool bPrePsTdmaOn; ++ bool bCurPsTdmaOn; ++ bool bPreBtAutoReport; ++ bool bCurBtAutoReport; + + /* sw mechanism */ -+ bool bPreRfRxLpfShrink; -+ bool bCurRfRxLpfShrink; -+ u32 btRf0x1eBackup; -+ bool bPreLowPenaltyRa; -+ bool bCurLowPenaltyRa; -+ bool bPreDacSwingOn; -+ u32 preDacSwingLvl; -+ bool bCurDacSwingOn; -+ u32 curDacSwingLvl; -+ bool bPreAdcBackOff; -+ bool bCurAdcBackOff; -+ bool bPreAgcTableEn; -+ bool bCurAgcTableEn; -+ u32 preVal0x6c0; -+ u32 curVal0x6c0; -+ u32 preVal0x6c4; -+ u32 curVal0x6c4; -+ u32 preVal0x6c8; -+ u32 curVal0x6c8; ++ bool bPreRfRxLpfShrink; ++ bool bCurRfRxLpfShrink; ++ u32 btRf0x1eBackup; ++ bool bPreLowPenaltyRa; ++ bool bCurLowPenaltyRa; ++ bool bPreDacSwingOn; ++ u32 preDacSwingLvl; ++ bool bCurDacSwingOn; ++ u32 curDacSwingLvl; ++ bool bPreAdcBackOff; ++ bool bCurAdcBackOff; ++ bool bPreAgcTableEn; ++ bool bCurAgcTableEn; ++ u32 preVal0x6c0; ++ u32 curVal0x6c0; ++ u32 preVal0x6c4; ++ u32 curVal0x6c4; ++ u32 preVal0x6c8; ++ u32 curVal0x6c8; + u8 preVal0x6cc; + u8 curVal0x6cc; -+ bool bLimitedDig; ++ bool bLimitedDig; + + /* algorithm related */ + u8 preAlgorithm; @@ -43164,108 +41623,58 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtc8723b2Ant.h linux-4.3-rtl8723b + u8 btStatus; + u8 wifiChnlInfo[3]; + -+ bool bNeedRecover0x948; -+ u32 backup0x948; ++ bool bNeedRecover0x948; ++ u32 backup0x948; +} COEX_DM_8723B_2ANT, *PCOEX_DM_8723B_2ANT; + -+typedef struct _COEX_STA_8723B_2ANT{ -+ bool bBtLinkExist; -+ bool bScoExist; -+ bool bA2dpExist; -+ bool bHidExist; -+ bool bPanExist; ++typedef struct _COEX_STA_8723B_2ANT { ++ bool bBtLinkExist; ++ bool bScoExist; ++ bool bA2dpExist; ++ bool bHidExist; ++ bool bPanExist; + -+ bool bUnderLps; -+ bool bUnderIps; -+ u32 highPriorityTx; -+ u32 highPriorityRx; -+ u32 lowPriorityTx; -+ u32 lowPriorityRx; -+ u8 btRssi; -+ bool bBtTxRxMask; -+ u8 preBtRssiState; -+ u8 preWifiRssiState[4]; -+ bool bC2hBtInfoReqSent; -+ u8 btInfoC2h[BT_INFO_SRC_8723B_2ANT_MAX][10]; -+ u32 btInfoC2hCnt[BT_INFO_SRC_8723B_2ANT_MAX]; -+ bool bC2hBtInquiryPage; -+ u8 btRetryCnt; -+ u8 btInfoExt; -+}COEX_STA_8723B_2ANT, *PCOEX_STA_8723B_2ANT; ++ bool bUnderLps; ++ bool bUnderIps; ++ u32 highPriorityTx; ++ u32 highPriorityRx; ++ u32 lowPriorityTx; ++ u32 lowPriorityRx; ++ u8 btRssi; ++ bool bBtTxRxMask; ++ u8 preBtRssiState; ++ u8 preWifiRssiState[4]; ++ bool bC2hBtInfoReqSent; ++ u8 btInfoC2h[BT_INFO_SRC_8723B_2ANT_MAX][10]; ++ u32 btInfoC2hCnt[BT_INFO_SRC_8723B_2ANT_MAX]; ++ bool bC2hBtInquiryPage; ++ u8 btRetryCnt; ++ u8 btInfoExt; ++} COEX_STA_8723B_2ANT, *PCOEX_STA_8723B_2ANT; + +/* */ +/* The following is interface which will notify coex module. */ +/* */ -+void -+EXhalbtc8723b2ant_PowerOnSetting( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtc8723b2ant_InitHwConfig( -+PBTC_COEXIST pBtCoexist, -+bool bWifiOnly -+ ); -+void -+EXhalbtc8723b2ant_InitCoexDm( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtc8723b2ant_IpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b2ant_LpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b2ant_ScanNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b2ant_ConnectNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b2ant_MediaStatusNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b2ant_SpecialPacketNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtc8723b2ant_BtInfoNotify( -+PBTC_COEXIST pBtCoexist, -+u8 * tmpBuf, -+u8 length -+ ); -+void -+EXhalbtc8723b2ant_HaltNotify( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtc8723b2ant_PnpNotify( -+PBTC_COEXIST pBtCoexist, -+u8 pnpState -+ ); -+void -+EXhalbtc8723b2ant_Periodical( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtc8723b2ant_DisplayCoexInfo( -+PBTC_COEXIST pBtCoexist -+ ); -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_btcoex.c ---- linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_btcoex.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1754 @@ ++void EXhalbtc8723b2ant_PowerOnSetting(PBTC_COEXIST pBtCoexist); ++void EXhalbtc8723b2ant_InitHwConfig(PBTC_COEXIST pBtCoexist, bool bWifiOnly); ++void EXhalbtc8723b2ant_InitCoexDm(PBTC_COEXIST pBtCoexist); ++void EXhalbtc8723b2ant_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b2ant_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b2ant_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b2ant_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b2ant_MediaStatusNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b2ant_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtc8723b2ant_BtInfoNotify( ++ PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length ++); ++void EXhalbtc8723b2ant_HaltNotify(PBTC_COEXIST pBtCoexist); ++void EXhalbtc8723b2ant_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState); ++void EXhalbtc8723b2ant_Periodical(PBTC_COEXIST pBtCoexist); ++void EXhalbtc8723b2ant_DisplayCoexInfo(PBTC_COEXIST pBtCoexist); +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/hal_btcoex.c linux/3rdparty/rtl8723bs/hal/hal_btcoex.c +--- linux.old/3rdparty/rtl8723bs/hal/hal_btcoex.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/hal_btcoex.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1720 @@ +/****************************************************************************** + * + * Copyright(c) 2013 Realtek Corporation. All rights reserved. @@ -43288,8 +41697,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd +#include + +/* Global variables */ -+static const char *const BtProfileString[] = -+{ ++static const char *const BtProfileString[] = { + "NONE", + "A2DP", + "PAN", @@ -43297,8 +41705,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + "SCO", +}; + -+static const char *const BtSpecString[] = -+{ ++static const char *const BtSpecString[] = { + "1.0b", + "1.1", + "1.2", @@ -43308,22 +41715,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + "4.0", +}; + -+static const char *const BtLinkRoleString[] = -+{ ++static const char *const BtLinkRoleString[] = { + "Master", + "Slave", +}; + -+static const char *const h2cStaString[] = -+{ ++static const char *const h2cStaString[] = { + "successful", + "h2c busy", + "rf off", + "fw not read", +}; + -+static const char *const ioStaString[] = -+{ ++static const char *const ioStaString[] = { + "success", + "can not IO", + "rf off", @@ -43344,8 +41748,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd +u32 GLBtcDbgType[BTC_MSG_MAX]; +static u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE]; + -+typedef struct _btcoexdbginfo -+{ ++typedef struct _btcoexdbginfo { + u8 *info; + u32 size; /* buffer total size */ + u32 len; /* now used length */ @@ -43357,7 +41760,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + +static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size) +{ -+ if (NULL == pinfo) return; ++ if (NULL == pinfo) ++ return; + + memset(pinfo, 0, sizeof(BTCDBGINFO)); + @@ -43394,8 +41798,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd +static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist) +{ + if (!pBtCoexist->bBinded || -+ NULL == pBtCoexist->Adapter) -+ { ++ NULL == pBtCoexist->Adapter){ + return false; + } + return true; @@ -43405,7 +41808,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd +{ + u8 i; + -+ for (i = 0; iAdapter; + -+ if (pBtCoexist->btInfo.bBtCtrlLps) -+ { ++ if (pBtCoexist->btInfo.bBtCtrlLps) { + pBtCoexist->btInfo.bBtLpsOn = false; + rtw_btcoex_LPS_Leave(padapter); + pBtCoexist->btInfo.bBtCtrlLps = false; @@ -43542,27 +41944,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + + if (pBtCoexist->btInfo.bRejectAggPkt) + rtw_btcoex_RejectApAggregatedPacket(padapter, true); -+ else -+ { ++ else{ ++ + if (pBtCoexist->btInfo.bPreBtCtrlAggBufSize != -+ pBtCoexist->btInfo.bBtCtrlAggBufSize) -+ { ++ pBtCoexist->btInfo.bBtCtrlAggBufSize){ ++ + bNeedToAct = true; + pBtCoexist->btInfo.bPreBtCtrlAggBufSize = pBtCoexist->btInfo.bBtCtrlAggBufSize; + } + -+ if (pBtCoexist->btInfo.bBtCtrlAggBufSize) -+ { ++ if (pBtCoexist->btInfo.bBtCtrlAggBufSize) { + if (pBtCoexist->btInfo.preAggBufSize != -+ pBtCoexist->btInfo.aggBufSize) -+ { ++ pBtCoexist->btInfo.aggBufSize){ + bNeedToAct = true; + } + pBtCoexist->btInfo.preAggBufSize = pBtCoexist->btInfo.aggBufSize; + } + -+ if (bNeedToAct) -+ { ++ if (bNeedToAct) { + rtw_btcoex_RejectApAggregatedPacket(padapter, true); + rtw_btcoex_RejectApAggregatedPacket(padapter, false); + } @@ -43576,8 +41975,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + + pmlmepriv = &padapter->mlmepriv; + -+ if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + return true; + if (true == pmlmepriv->LinkDetectInfo.bBusyTraffic) @@ -43598,17 +41996,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + bp2p = false; + portConnectedStatus = 0; + -+ if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) -+ { -+ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) { ++ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (true == bp2p) + portConnectedStatus |= WIFI_P2P_GO_CONNECTED; + else + portConnectedStatus |= WIFI_AP_CONNECTED; -+ } -+ else -+ { ++ } else { + if (true == bp2p) + portConnectedStatus |= WIFI_P2P_GC_CONNECTED; + else @@ -43637,8 +42031,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + numOfConnectedPort = 0; + + retVal = _halbtcoutsrc_GetWifiLinkStatus(padapter); -+ if (retVal) -+ { ++ if (retVal) { + portConnectedStatus |= retVal; + numOfConnectedPort++; + } @@ -43704,153 +42097,152 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + pHalData = GET_HAL_DATA(padapter); + mlmeext = &padapter->mlmeextpriv; + pu8 = (u8 *)pOutBuf; -+ pS4Tmp = (s32*)pOutBuf; -+ pU4Tmp = (u32*)pOutBuf; ++ pS4Tmp = (s32 *)pOutBuf; ++ pU4Tmp = (u32 *)pOutBuf; + pU1Tmp = (u8 *)pOutBuf; + ret = true; + -+ switch (getType) -+ { -+ case BTC_GET_BL_HS_OPERATION: ++ switch (getType) { ++ case BTC_GET_BL_HS_OPERATION: ++ *pu8 = false; ++ ret = false; ++ break; ++ ++ case BTC_GET_BL_HS_CONNECTING: ++ *pu8 = false; ++ ret = false; ++ break; ++ ++ case BTC_GET_BL_WIFI_CONNECTED: ++ *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE); ++ break; ++ ++ case BTC_GET_BL_WIFI_BUSY: ++ *pu8 = halbtcoutsrc_IsWifiBusy(padapter); ++ break; ++ ++ case BTC_GET_BL_WIFI_SCAN: ++ /* Use the value of the new variable GLBtcWiFiInScanState to judge whether WiFi is in scan state or not, since the originally used flag ++ WIFI_SITE_MONITOR in fwstate may not be cleared in time */ ++ *pu8 = GLBtcWiFiInScanState; ++ break; ++ ++ case BTC_GET_BL_WIFI_LINK: ++ *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING); ++ break; ++ ++ case BTC_GET_BL_WIFI_ROAM: ++ *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING); ++ break; ++ ++ case BTC_GET_BL_WIFI_4_WAY_PROGRESS: ++ *pu8 = false; ++ break; ++ ++ case BTC_GET_BL_WIFI_UNDER_5G: ++ *pu8 = (pHalData->CurrentBandType == 1) ? true : false; ++ break; ++ ++ case BTC_GET_BL_WIFI_AP_MODE_ENABLE: ++ *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE); ++ break; ++ ++ case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION: ++ *pu8 = padapter->securitypriv.dot11PrivacyAlgrthm == 0 ? false : true; ++ break; ++ ++ case BTC_GET_BL_WIFI_UNDER_B_MODE: ++ if (mlmeext->cur_wireless_mode == WIRELESS_11B) ++ *pu8 = true; ++ else + *pu8 = false; -+ ret = false; -+ break; ++ break; + -+ case BTC_GET_BL_HS_CONNECTING: -+ *pu8 = false; -+ ret = false; -+ break; ++ case BTC_GET_BL_WIFI_IS_IN_MP_MODE: ++ *pu8 = false; ++ break; + -+ case BTC_GET_BL_WIFI_CONNECTED: -+ *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE); -+ break; ++ case BTC_GET_BL_EXT_SWITCH: ++ *pu8 = false; ++ break; + -+ case BTC_GET_BL_WIFI_BUSY: -+ *pu8 = halbtcoutsrc_IsWifiBusy(padapter); -+ break; ++ case BTC_GET_S4_WIFI_RSSI: ++ *pS4Tmp = halbtcoutsrc_GetWifiRssi(padapter); ++ break; + -+ case BTC_GET_BL_WIFI_SCAN: -+ /* Use the value of the new variable GLBtcWiFiInScanState to judge whether WiFi is in scan state or not, since the originally used flag -+ WIFI_SITE_MONITOR in fwstate may not be cleared in time */ -+ *pu8 = GLBtcWiFiInScanState; -+ break; ++ case BTC_GET_S4_HS_RSSI: ++ *pS4Tmp = 0; ++ ret = false; ++ break; + -+ case BTC_GET_BL_WIFI_LINK: -+ *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING); -+ break; ++ case BTC_GET_U4_WIFI_BW: ++ if (IsLegacyOnly(mlmeext->cur_wireless_mode)) ++ *pU4Tmp = BTC_WIFI_BW_LEGACY; ++ else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_20) ++ *pU4Tmp = BTC_WIFI_BW_HT20; ++ else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) ++ *pU4Tmp = BTC_WIFI_BW_HT40; ++ else ++ *pU4Tmp = BTC_WIFI_BW_HT40; /* todo */ ++ break; + -+ case BTC_GET_BL_WIFI_ROAM: -+ *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING); -+ break; ++ case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION: ++ { ++ PRT_LINK_DETECT_T plinkinfo; ++ plinkinfo = &padapter->mlmepriv.LinkDetectInfo; + -+ case BTC_GET_BL_WIFI_4_WAY_PROGRESS: -+ *pu8 = false; -+ break; -+ -+ case BTC_GET_BL_WIFI_UNDER_5G: -+ *pu8 = (pHalData->CurrentBandType == 1)? true : false; -+ break; -+ -+ case BTC_GET_BL_WIFI_AP_MODE_ENABLE: -+ *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE); -+ break; -+ -+ case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION: -+ *pu8 = padapter->securitypriv.dot11PrivacyAlgrthm == 0? false: true; -+ break; -+ -+ case BTC_GET_BL_WIFI_UNDER_B_MODE: -+ if (mlmeext->cur_wireless_mode == WIRELESS_11B) -+ *pu8 = true; ++ if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod) ++ *pU4Tmp = BTC_WIFI_TRAFFIC_TX; + else -+ *pu8 = false; -+ break; ++ *pU4Tmp = BTC_WIFI_TRAFFIC_RX; ++ } ++ break; + -+ case BTC_GET_BL_WIFI_IS_IN_MP_MODE: -+ *pu8 = false; -+ break; ++ case BTC_GET_U4_WIFI_FW_VER: ++ *pU4Tmp = pHalData->FirmwareVersion << 16; ++ *pU4Tmp |= pHalData->FirmwareSubVersion; ++ break; + -+ case BTC_GET_BL_EXT_SWITCH: -+ *pu8 = false; -+ break; ++ case BTC_GET_U4_WIFI_LINK_STATUS: ++ *pU4Tmp = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist); ++ break; + -+ case BTC_GET_S4_WIFI_RSSI: -+ *pS4Tmp = halbtcoutsrc_GetWifiRssi(padapter); -+ break; ++ case BTC_GET_U4_BT_PATCH_VER: ++ *pU4Tmp = halbtcoutsrc_GetBtPatchVer(pBtCoexist); ++ break; + -+ case BTC_GET_S4_HS_RSSI: -+ *pS4Tmp = 0; -+ ret = false; -+ break; ++ case BTC_GET_U1_WIFI_DOT11_CHNL: ++ *pU1Tmp = padapter->mlmeextpriv.cur_channel; ++ break; + -+ case BTC_GET_U4_WIFI_BW: -+ if (IsLegacyOnly(mlmeext->cur_wireless_mode)) -+ *pU4Tmp = BTC_WIFI_BW_LEGACY; -+ else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_20) -+ *pU4Tmp = BTC_WIFI_BW_HT20; -+ else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) -+ *pU4Tmp = BTC_WIFI_BW_HT40; -+ else -+ *pU4Tmp = BTC_WIFI_BW_HT40; /* todo */ -+ break; ++ case BTC_GET_U1_WIFI_CENTRAL_CHNL: ++ *pU1Tmp = pHalData->CurrentChannel; ++ break; + -+ case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION: -+ { -+ PRT_LINK_DETECT_T plinkinfo; -+ plinkinfo = &padapter->mlmepriv.LinkDetectInfo; ++ case BTC_GET_U1_WIFI_HS_CHNL: ++ *pU1Tmp = 0; ++ ret = false; ++ break; + -+ if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod) -+ *pU4Tmp = BTC_WIFI_TRAFFIC_TX; -+ else -+ *pU4Tmp = BTC_WIFI_TRAFFIC_RX; -+ } -+ break; -+ -+ case BTC_GET_U4_WIFI_FW_VER: -+ *pU4Tmp = pHalData->FirmwareVersion << 16; -+ *pU4Tmp |= pHalData->FirmwareSubVersion; -+ break; -+ -+ case BTC_GET_U4_WIFI_LINK_STATUS: -+ *pU4Tmp = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist); -+ break; -+ -+ case BTC_GET_U4_BT_PATCH_VER: -+ *pU4Tmp = halbtcoutsrc_GetBtPatchVer(pBtCoexist); -+ break; -+ -+ case BTC_GET_U1_WIFI_DOT11_CHNL: -+ *pU1Tmp = padapter->mlmeextpriv.cur_channel; -+ break; -+ -+ case BTC_GET_U1_WIFI_CENTRAL_CHNL: -+ *pU1Tmp = pHalData->CurrentChannel; -+ break; -+ -+ case BTC_GET_U1_WIFI_HS_CHNL: -+ *pU1Tmp = 0; -+ ret = false; -+ break; -+ -+ case BTC_GET_U1_MAC_PHY_MODE: -+ *pU1Tmp = BTC_SMSP; ++ case BTC_GET_U1_MAC_PHY_MODE: ++ *pU1Tmp = BTC_SMSP; +/* *pU1Tmp = BTC_DMSP; */ +/* *pU1Tmp = BTC_DMDP; */ +/* *pU1Tmp = BTC_MP_UNKNOWN; */ -+ break; ++ break; + -+ case BTC_GET_U1_AP_NUM: -+ *pU1Tmp = halbtcoutsrc_GetWifiScanAPNum(padapter); -+ break; ++ case BTC_GET_U1_AP_NUM: ++ *pU1Tmp = halbtcoutsrc_GetWifiScanAPNum(padapter); ++ break; + -+ /* 1Ant =========== */ -+ case BTC_GET_U1_LPS_MODE: -+ *pU1Tmp = padapter->dvobj->pwrctl_priv.pwr_mode; -+ break; ++ /* 1Ant =========== */ ++ case BTC_GET_U1_LPS_MODE: ++ *pU1Tmp = padapter->dvobj->pwrctl_priv.pwr_mode; ++ break; + -+ default: -+ ret = false; -+ break; ++ default: ++ ret = false; ++ break; + } + + return ret; @@ -43872,128 +42264,126 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + pHalData = GET_HAL_DATA(padapter); + pu8 = (u8 *)pInBuf; + pU1Tmp = (u8 *)pInBuf; -+ pU4Tmp = (u32*)pInBuf; ++ pU4Tmp = (u32 *)pInBuf; + ret = true; + + if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) + return false; + -+ switch (setType) -+ { -+ /* set some u8 type variables. */ -+ case BTC_SET_BL_BT_DISABLE: -+ pBtCoexist->btInfo.bBtDisabled = *pu8; -+ break; ++ switch (setType) { ++ /* set some u8 type variables. */ ++ case BTC_SET_BL_BT_DISABLE: ++ pBtCoexist->btInfo.bBtDisabled = *pu8; ++ break; + -+ case BTC_SET_BL_BT_TRAFFIC_BUSY: -+ pBtCoexist->btInfo.bBtBusy = *pu8; -+ break; ++ case BTC_SET_BL_BT_TRAFFIC_BUSY: ++ pBtCoexist->btInfo.bBtBusy = *pu8; ++ break; + -+ case BTC_SET_BL_BT_LIMITED_DIG: -+ pBtCoexist->btInfo.bLimitedDig = *pu8; -+ break; ++ case BTC_SET_BL_BT_LIMITED_DIG: ++ pBtCoexist->btInfo.bLimitedDig = *pu8; ++ break; + -+ case BTC_SET_BL_FORCE_TO_ROAM: -+ pBtCoexist->btInfo.bForceToRoam = *pu8; -+ break; ++ case BTC_SET_BL_FORCE_TO_ROAM: ++ pBtCoexist->btInfo.bForceToRoam = *pu8; ++ break; + -+ case BTC_SET_BL_TO_REJ_AP_AGG_PKT: -+ pBtCoexist->btInfo.bRejectAggPkt = *pu8; -+ break; ++ case BTC_SET_BL_TO_REJ_AP_AGG_PKT: ++ pBtCoexist->btInfo.bRejectAggPkt = *pu8; ++ break; + -+ case BTC_SET_BL_BT_CTRL_AGG_SIZE: -+ pBtCoexist->btInfo.bBtCtrlAggBufSize = *pu8; -+ break; ++ case BTC_SET_BL_BT_CTRL_AGG_SIZE: ++ pBtCoexist->btInfo.bBtCtrlAggBufSize = *pu8; ++ break; + -+ case BTC_SET_BL_INC_SCAN_DEV_NUM: -+ pBtCoexist->btInfo.bIncreaseScanDevNum = *pu8; -+ break; ++ case BTC_SET_BL_INC_SCAN_DEV_NUM: ++ pBtCoexist->btInfo.bIncreaseScanDevNum = *pu8; ++ break; + -+ case BTC_SET_BL_BT_TX_RX_MASK: -+ pBtCoexist->btInfo.bBtTxRxMask = *pu8; -+ break; ++ case BTC_SET_BL_BT_TX_RX_MASK: ++ pBtCoexist->btInfo.bBtTxRxMask = *pu8; ++ break; + -+ /* set some u8 type variables. */ -+ case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON: -+ pBtCoexist->btInfo.rssiAdjustForAgcTableOn = *pU1Tmp; -+ break; ++ /* set some u8 type variables. */ ++ case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON: ++ pBtCoexist->btInfo.rssiAdjustForAgcTableOn = *pU1Tmp; ++ break; + -+ case BTC_SET_U1_AGG_BUF_SIZE: -+ pBtCoexist->btInfo.aggBufSize = *pU1Tmp; -+ break; ++ case BTC_SET_U1_AGG_BUF_SIZE: ++ pBtCoexist->btInfo.aggBufSize = *pU1Tmp; ++ break; + -+ /* the following are some action which will be triggered */ -+ case BTC_SET_ACT_GET_BT_RSSI: -+ ret = false; -+ break; ++ /* the following are some action which will be triggered */ ++ case BTC_SET_ACT_GET_BT_RSSI: ++ ret = false; ++ break; + -+ case BTC_SET_ACT_AGGREGATE_CTRL: -+ halbtcoutsrc_AggregationCheck(pBtCoexist); -+ break; ++ case BTC_SET_ACT_AGGREGATE_CTRL: ++ halbtcoutsrc_AggregationCheck(pBtCoexist); ++ break; + -+ /* 1Ant =========== */ -+ /* set some u8 type variables. */ -+ case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE: -+ pBtCoexist->btInfo.rssiAdjustFor1AntCoexType = *pU1Tmp; -+ break; ++ /* 1Ant =========== */ ++ /* set some u8 type variables. */ ++ case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE: ++ pBtCoexist->btInfo.rssiAdjustFor1AntCoexType = *pU1Tmp; ++ break; + -+ case BTC_SET_U1_LPS_VAL: -+ pBtCoexist->btInfo.lpsVal = *pU1Tmp; -+ break; ++ case BTC_SET_U1_LPS_VAL: ++ pBtCoexist->btInfo.lpsVal = *pU1Tmp; ++ break; + -+ case BTC_SET_U1_RPWM_VAL: -+ pBtCoexist->btInfo.rpwmVal = *pU1Tmp; -+ break; ++ case BTC_SET_U1_RPWM_VAL: ++ pBtCoexist->btInfo.rpwmVal = *pU1Tmp; ++ break; + -+ /* the following are some action which will be triggered */ -+ case BTC_SET_ACT_LEAVE_LPS: -+ halbtcoutsrc_LeaveLps(pBtCoexist); -+ break; ++ /* the following are some action which will be triggered */ ++ case BTC_SET_ACT_LEAVE_LPS: ++ halbtcoutsrc_LeaveLps(pBtCoexist); ++ break; + -+ case BTC_SET_ACT_ENTER_LPS: -+ halbtcoutsrc_EnterLps(pBtCoexist); -+ break; ++ case BTC_SET_ACT_ENTER_LPS: ++ halbtcoutsrc_EnterLps(pBtCoexist); ++ break; + -+ case BTC_SET_ACT_NORMAL_LPS: -+ halbtcoutsrc_NormalLps(pBtCoexist); -+ break; ++ case BTC_SET_ACT_NORMAL_LPS: ++ halbtcoutsrc_NormalLps(pBtCoexist); ++ break; + -+ case BTC_SET_ACT_DISABLE_LOW_POWER: -+ halbtcoutsrc_DisableLowPower(pBtCoexist, *pu8); -+ break; ++ case BTC_SET_ACT_DISABLE_LOW_POWER: ++ halbtcoutsrc_DisableLowPower(pBtCoexist, *pu8); ++ break; + -+ case BTC_SET_ACT_UPDATE_RAMASK: -+ pBtCoexist->btInfo.raMask = *pU4Tmp; ++ case BTC_SET_ACT_UPDATE_RAMASK: ++ pBtCoexist->btInfo.raMask = *pU4Tmp; + -+ if (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == true) -+ { -+ struct sta_info *psta; -+ struct wlan_bssid_ex * cur_network; ++ if (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == true) { ++ struct sta_info *psta; ++ struct wlan_bssid_ex *cur_network; + -+ cur_network = &padapter->mlmeextpriv.mlmext_info.network; -+ psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress); -+ rtw_hal_update_ra_mask(psta, 0); -+ } -+ break; ++ cur_network = &padapter->mlmeextpriv.mlmext_info.network; ++ psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress); ++ rtw_hal_update_ra_mask(psta, 0); ++ } ++ break; + -+ case BTC_SET_ACT_SEND_MIMO_PS: -+ ret = false; -+ break; ++ case BTC_SET_ACT_SEND_MIMO_PS: ++ ret = false; ++ break; + -+ case BTC_SET_ACT_CTRL_BT_INFO: -+ ret = false; -+ break; ++ case BTC_SET_ACT_CTRL_BT_INFO: ++ ret = false; ++ break; + -+ case BTC_SET_ACT_CTRL_BT_COEX: -+ ret = false; -+ break; -+ case BTC_SET_ACT_CTRL_8723B_ANT: -+ ret = false; -+ break; -+ /* */ -+ default: -+ ret = false; -+ break; ++ case BTC_SET_ACT_CTRL_BT_COEX: ++ ret = false; ++ break; ++ case BTC_SET_ACT_CTRL_8723B_ANT: ++ ret = false; ++ break; ++ /* */ ++ default: ++ ret = false; ++ break; + } + + return ret; @@ -44074,12 +42464,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + originalValue = 0; + bitShift = 0; + -+ if (bitMask != 0xFF) -+ { ++ if (bitMask != 0xFF) { + originalValue = rtw_read8(padapter, regAddr); + -+ for (i = 0; i<=7; i++) -+ { ++ for (i = 0; i <= 7; i++) { + if ((bitMask>>i)&0x1) + break; + } @@ -44117,15 +42505,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + +static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data) +{ -+ PBTC_COEXIST pBtCoexist =(PBTC_COEXIST)pBtcContext; -+ struct adapter * Adapter =pBtCoexist->Adapter; ++ PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext; ++ struct adapter *Adapter = pBtCoexist->Adapter; + -+ if (BTC_INTF_SDIO == pBtCoexist->chipInterface) -+ { ++ if (BTC_INTF_SDIO == pBtCoexist->chipInterface) { + rtw_write8(Adapter, SDIO_LOCAL_BASE | RegAddr, Data); -+ } -+ else -+ { ++ } else { + rtw_write8(Adapter, RegAddr, Data); + } +} @@ -44233,17 +42618,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + + + pBtCoexist = (PBTC_COEXIST)pBtcContext; -+ switch (dispType) -+ { -+ case BTC_DBG_DISP_COEX_STATISTICS: -+ break; -+ case BTC_DBG_DISP_BT_LINK_INFO: -+ break; -+ case BTC_DBG_DISP_FW_PWR_MODE_CMD: -+ halbtcoutsrc_DisplayFwPwrModeCmd(pBtCoexist); -+ break; -+ default: -+ break; ++ switch (dispType) { ++ case BTC_DBG_DISP_COEX_STATISTICS: ++ break; ++ case BTC_DBG_DISP_BT_LINK_INFO: ++ break; ++ case BTC_DBG_DISP_FW_PWR_MODE_CMD: ++ halbtcoutsrc_DisplayFwPwrModeCmd(pBtCoexist); ++ break; ++ default: ++ break; + } +} + @@ -44252,7 +42636,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd +/* */ +static u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter) +{ -+ PBTC_COEXIST pBtCoexist =&GLBtCoexist; ++ PBTC_COEXIST pBtCoexist = &GLBtCoexist; + + if (pBtCoexist->bBinded) + return false; @@ -44422,13 +42806,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + if (pBtCoexist->bManualControl) + return; + -+ if (type) -+ { ++ if (type) { + scanType = BTC_SCAN_START; + GLBtcWiFiInScanState = true; -+ } -+ else -+ { ++ } else { + scanType = BTC_SCAN_FINISH; + GLBtcWiFiInScanState = false; + } @@ -44513,8 +42894,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + packetType = BTC_PACKET_EAPOL; + else if (PACKET_ARP == pktType) + packetType = BTC_PACKET_ARP; -+ else -+ { ++ else{ + packetType = BTC_PACKET_UNKNOWN; + return; + } @@ -44602,18 +42982,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + +void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum) +{ -+ if (BT_COEX_ANT_TYPE_PG == type) -+ { ++ if (BT_COEX_ANT_TYPE_PG == type) { + GLBtCoexist.boardInfo.pgAntNum = antNum; + GLBtCoexist.boardInfo.btdmAntNum = antNum; -+ } -+ else if (BT_COEX_ANT_TYPE_ANTDIV == type) -+ { ++ } else if (BT_COEX_ANT_TYPE_ANTDIV == type) { + GLBtCoexist.boardInfo.btdmAntNum = antNum; + /* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */ -+ } -+ else if (BT_COEX_ANT_TYPE_DETECTED == type) -+ { ++ } else if (BT_COEX_ANT_TYPE_DETECTED == type) { + GLBtCoexist.boardInfo.btdmAntNum = antNum; + /* GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; */ + } @@ -44718,8 +43093,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + + + memset(&GLBtCoexist, 0, sizeof(GLBtCoexist)); -+ ret1 = EXhalbtcoutsrc_InitlizeVariables((void*)padapter); -+ ret2 = (ret1 ==true) ? true : false; ++ ret1 = EXhalbtcoutsrc_InitlizeVariables((void *)padapter); ++ ret2 = (ret1 == true) ? true : false; + + return ret2; +} @@ -44891,7 +43266,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_btcoex.c linux-4.3-rtl8723bs/3rd + if (NULL == pDbgModule) + return; + -+ for (i = 0; is0, 0 =>s1 */ ++ u8 btChipType; ++ u8 pgAntNum; /* pg ant number */ ++ u8 btdmAntNum; /* ant number for btdm */ ++ u8 btdmAntPos; /* Bryant Add to indicate Antenna Position for (pgAntNum = 2) && (btdmAntNum = 1) (DPDT+1Ant case) */ ++ u8 singleAntPath; /* current used for 8723b only, 1 =>s0, 0 =>s1 */ + /* bool bBtExist; */ +} BTC_BOARD_INFO, *PBTC_BOARD_INFO; + -+typedef enum _BTC_DBG_OPCODE{ -+ BTC_DBG_SET_COEX_NORMAL = 0x0, -+ BTC_DBG_SET_COEX_WIFI_ONLY = 0x1, -+ BTC_DBG_SET_COEX_BT_ONLY = 0x2, -+ BTC_DBG_SET_COEX_DEC_BT_PWR = 0x3, -+ BTC_DBG_SET_COEX_BT_AFH_MAP = 0x4, ++typedef enum _BTC_DBG_OPCODE { ++ BTC_DBG_SET_COEX_NORMAL = 0x0, ++ BTC_DBG_SET_COEX_WIFI_ONLY = 0x1, ++ BTC_DBG_SET_COEX_BT_ONLY = 0x2, ++ BTC_DBG_SET_COEX_DEC_BT_PWR = 0x3, ++ BTC_DBG_SET_COEX_BT_AFH_MAP = 0x4, + BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT = 0x5, + BTC_DBG_MAX -+}BTC_DBG_OPCODE,*PBTC_DBG_OPCODE; ++} BTC_DBG_OPCODE, *PBTC_DBG_OPCODE; + -+typedef enum _BTC_RSSI_STATE{ -+ BTC_RSSI_STATE_HIGH = 0x0, ++typedef enum _BTC_RSSI_STATE { ++ BTC_RSSI_STATE_HIGH = 0x0, + BTC_RSSI_STATE_MEDIUM = 0x1, -+ BTC_RSSI_STATE_LOW = 0x2, ++ BTC_RSSI_STATE_LOW = 0x2, + BTC_RSSI_STATE_STAY_HIGH = 0x3, + BTC_RSSI_STATE_STAY_MEDIUM = 0x4, + BTC_RSSI_STATE_STAY_LOW = 0x5, + BTC_RSSI_MAX -+}BTC_RSSI_STATE,*PBTC_RSSI_STATE; -+#define BTC_RSSI_HIGH(_rssi_) ((_rssi_==BTC_RSSI_STATE_HIGH||_rssi_==BTC_RSSI_STATE_STAY_HIGH)? true:false) -+#define BTC_RSSI_MEDIUM(_rssi_) ((_rssi_==BTC_RSSI_STATE_MEDIUM||_rssi_==BTC_RSSI_STATE_STAY_MEDIUM)? true:false) -+#define BTC_RSSI_LOW(_rssi_) ((_rssi_==BTC_RSSI_STATE_LOW||_rssi_==BTC_RSSI_STATE_STAY_LOW)? true:false) ++} BTC_RSSI_STATE, *PBTC_RSSI_STATE; ++#define BTC_RSSI_HIGH(_rssi_) ((_rssi_ == BTC_RSSI_STATE_HIGH || _rssi_ == BTC_RSSI_STATE_STAY_HIGH) ? true : false) ++#define BTC_RSSI_MEDIUM(_rssi_) ((_rssi_ == BTC_RSSI_STATE_MEDIUM || _rssi_ == BTC_RSSI_STATE_STAY_MEDIUM) ? true : false) ++#define BTC_RSSI_LOW(_rssi_) ((_rssi_ == BTC_RSSI_STATE_LOW || _rssi_ == BTC_RSSI_STATE_STAY_LOW) ? true : false) + -+typedef enum _BTC_WIFI_ROLE{ ++typedef enum _BTC_WIFI_ROLE { + BTC_ROLE_STATION = 0x0, -+ BTC_ROLE_AP = 0x1, ++ BTC_ROLE_AP = 0x1, + BTC_ROLE_IBSS = 0x2, + BTC_ROLE_HS_MODE = 0x3, + BTC_ROLE_MAX -+}BTC_WIFI_ROLE,*PBTC_WIFI_ROLE; ++} BTC_WIFI_ROLE, *PBTC_WIFI_ROLE; + -+typedef enum _BTC_WIFI_BW_MODE{ ++typedef enum _BTC_WIFI_BW_MODE { + BTC_WIFI_BW_LEGACY = 0x0, + BTC_WIFI_BW_HT20 = 0x1, + BTC_WIFI_BW_HT40 = 0x2, + BTC_WIFI_BW_MAX -+}BTC_WIFI_BW_MODE,*PBTC_WIFI_BW_MODE; ++} BTC_WIFI_BW_MODE, *PBTC_WIFI_BW_MODE; + -+typedef enum _BTC_WIFI_TRAFFIC_DIR{ ++typedef enum _BTC_WIFI_TRAFFIC_DIR { + BTC_WIFI_TRAFFIC_TX = 0x0, + BTC_WIFI_TRAFFIC_RX = 0x1, + BTC_WIFI_TRAFFIC_MAX -+}BTC_WIFI_TRAFFIC_DIR,*PBTC_WIFI_TRAFFIC_DIR; ++} BTC_WIFI_TRAFFIC_DIR, *PBTC_WIFI_TRAFFIC_DIR; + -+typedef enum _BTC_WIFI_PNP{ -+ BTC_WIFI_PNP_WAKE_UP = 0x0, ++typedef enum _BTC_WIFI_PNP { ++ BTC_WIFI_PNP_WAKE_UP = 0x0, + BTC_WIFI_PNP_SLEEP = 0x1, + BTC_WIFI_PNP_MAX -+}BTC_WIFI_PNP,*PBTC_WIFI_PNP; ++} BTC_WIFI_PNP, *PBTC_WIFI_PNP; + +/* for 8723b-d cut large current issue */ -+typedef enum _BT_WIFI_COEX_STATE{ ++typedef enum _BT_WIFI_COEX_STATE { + BTC_WIFI_STAT_INIT, + BTC_WIFI_STAT_IQK, + BTC_WIFI_STAT_NORMAL_OFF, @@ -45271,10 +43641,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtcOutSrc.h linux-4.3-rtl8723bs/3 + BTC_WIFI_STAT_NORMAL, + BTC_WIFI_STAT_ANT_DIV, + BTC_WIFI_STAT_MAX -+}BT_WIFI_COEX_STATE,*PBT_WIFI_COEX_STATE; ++} BT_WIFI_COEX_STATE, *PBT_WIFI_COEX_STATE; + +/* defined for BFP_BTC_GET */ -+typedef enum _BTC_GET_TYPE{ ++typedef enum _BTC_GET_TYPE { + /* type bool */ + BTC_GET_BL_HS_OPERATION, + BTC_GET_BL_HS_CONNECTING, @@ -45313,10 +43683,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtcOutSrc.h linux-4.3-rtl8723bs/3 + BTC_GET_U1_LPS_MODE, + + BTC_GET_MAX -+}BTC_GET_TYPE,*PBTC_GET_TYPE; ++} BTC_GET_TYPE, *PBTC_GET_TYPE; + +/* defined for BFP_BTC_SET */ -+typedef enum _BTC_SET_TYPE{ ++typedef enum _BTC_SET_TYPE { + /* type bool */ + BTC_SET_BL_BT_DISABLE, + BTC_SET_BL_BT_TRAFFIC_BUSY, @@ -45354,386 +43724,250 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalBtcOutSrc.h linux-4.3-rtl8723bs/3 + BTC_SET_ACT_CTRL_8723B_ANT, + /* */ + BTC_SET_MAX -+}BTC_SET_TYPE,*PBTC_SET_TYPE; ++} BTC_SET_TYPE, *PBTC_SET_TYPE; + -+typedef enum _BTC_DBG_DISP_TYPE{ -+ BTC_DBG_DISP_COEX_STATISTICS = 0x0, -+ BTC_DBG_DISP_BT_LINK_INFO = 0x1, -+ BTC_DBG_DISP_FW_PWR_MODE_CMD = 0x2, ++typedef enum _BTC_DBG_DISP_TYPE { ++ BTC_DBG_DISP_COEX_STATISTICS = 0x0, ++ BTC_DBG_DISP_BT_LINK_INFO = 0x1, ++ BTC_DBG_DISP_FW_PWR_MODE_CMD = 0x2, + BTC_DBG_DISP_MAX -+}BTC_DBG_DISP_TYPE,*PBTC_DBG_DISP_TYPE; ++} BTC_DBG_DISP_TYPE, *PBTC_DBG_DISP_TYPE; + -+typedef enum _BTC_NOTIFY_TYPE_IPS{ -+ BTC_IPS_LEAVE = 0x0, -+ BTC_IPS_ENTER = 0x1, ++typedef enum _BTC_NOTIFY_TYPE_IPS { ++ BTC_IPS_LEAVE = 0x0, ++ BTC_IPS_ENTER = 0x1, + BTC_IPS_MAX -+}BTC_NOTIFY_TYPE_IPS,*PBTC_NOTIFY_TYPE_IPS; -+typedef enum _BTC_NOTIFY_TYPE_LPS{ -+ BTC_LPS_DISABLE = 0x0, -+ BTC_LPS_ENABLE = 0x1, ++} BTC_NOTIFY_TYPE_IPS, *PBTC_NOTIFY_TYPE_IPS; ++ ++typedef enum _BTC_NOTIFY_TYPE_LPS { ++ BTC_LPS_DISABLE = 0x0, ++ BTC_LPS_ENABLE = 0x1, + BTC_LPS_MAX -+}BTC_NOTIFY_TYPE_LPS,*PBTC_NOTIFY_TYPE_LPS; -+typedef enum _BTC_NOTIFY_TYPE_SCAN{ -+ BTC_SCAN_FINISH = 0x0, -+ BTC_SCAN_START = 0x1, ++} BTC_NOTIFY_TYPE_LPS, *PBTC_NOTIFY_TYPE_LPS; ++ ++typedef enum _BTC_NOTIFY_TYPE_SCAN { ++ BTC_SCAN_FINISH = 0x0, ++ BTC_SCAN_START = 0x1, + BTC_SCAN_MAX -+}BTC_NOTIFY_TYPE_SCAN,*PBTC_NOTIFY_TYPE_SCAN; -+typedef enum _BTC_NOTIFY_TYPE_ASSOCIATE{ -+ BTC_ASSOCIATE_FINISH = 0x0, -+ BTC_ASSOCIATE_START = 0x1, ++} BTC_NOTIFY_TYPE_SCAN, *PBTC_NOTIFY_TYPE_SCAN; ++ ++typedef enum _BTC_NOTIFY_TYPE_ASSOCIATE { ++ BTC_ASSOCIATE_FINISH = 0x0, ++ BTC_ASSOCIATE_START = 0x1, + BTC_ASSOCIATE_MAX -+}BTC_NOTIFY_TYPE_ASSOCIATE,*PBTC_NOTIFY_TYPE_ASSOCIATE; -+typedef enum _BTC_NOTIFY_TYPE_MEDIA_STATUS{ -+ BTC_MEDIA_DISCONNECT = 0x0, -+ BTC_MEDIA_CONNECT = 0x1, ++} BTC_NOTIFY_TYPE_ASSOCIATE, *PBTC_NOTIFY_TYPE_ASSOCIATE; ++ ++typedef enum _BTC_NOTIFY_TYPE_MEDIA_STATUS { ++ BTC_MEDIA_DISCONNECT = 0x0, ++ BTC_MEDIA_CONNECT = 0x1, + BTC_MEDIA_MAX -+}BTC_NOTIFY_TYPE_MEDIA_STATUS,*PBTC_NOTIFY_TYPE_MEDIA_STATUS; -+typedef enum _BTC_NOTIFY_TYPE_SPECIAL_PACKET{ ++} BTC_NOTIFY_TYPE_MEDIA_STATUS, *PBTC_NOTIFY_TYPE_MEDIA_STATUS; ++ ++typedef enum _BTC_NOTIFY_TYPE_SPECIAL_PACKET { + BTC_PACKET_UNKNOWN = 0x0, -+ BTC_PACKET_DHCP = 0x1, -+ BTC_PACKET_ARP = 0x2, -+ BTC_PACKET_EAPOL = 0x3, ++ BTC_PACKET_DHCP = 0x1, ++ BTC_PACKET_ARP = 0x2, ++ BTC_PACKET_EAPOL = 0x3, + BTC_PACKET_MAX -+}BTC_NOTIFY_TYPE_SPECIAL_PACKET,*PBTC_NOTIFY_TYPE_SPECIAL_PACKET; -+typedef enum _BTC_NOTIFY_TYPE_STACK_OPERATION{ ++} BTC_NOTIFY_TYPE_SPECIAL_PACKET, *PBTC_NOTIFY_TYPE_SPECIAL_PACKET; ++ ++typedef enum _BTC_NOTIFY_TYPE_STACK_OPERATION { + BTC_STACK_OP_NONE = 0x0, -+ BTC_STACK_OP_INQ_PAGE_PAIR_START = 0x1, ++ BTC_STACK_OP_INQ_PAGE_PAIR_START = 0x1, + BTC_STACK_OP_INQ_PAGE_PAIR_FINISH = 0x2, + BTC_STACK_OP_MAX -+}BTC_NOTIFY_TYPE_STACK_OPERATION,*PBTC_NOTIFY_TYPE_STACK_OPERATION; ++} BTC_NOTIFY_TYPE_STACK_OPERATION, *PBTC_NOTIFY_TYPE_STACK_OPERATION; + +/* Bryant Add */ -+typedef enum _BTC_ANTENNA_POS{ -+ BTC_ANTENNA_AT_MAIN_PORT = 0x1, -+ BTC_ANTENNA_AT_AUX_PORT = 0x2, -+}BTC_ANTENNA_POS,*PBTC_ANTENNA_POS; ++typedef enum _BTC_ANTENNA_POS { ++ BTC_ANTENNA_AT_MAIN_PORT = 0x1, ++ BTC_ANTENNA_AT_AUX_PORT = 0x2, ++} BTC_ANTENNA_POS, *PBTC_ANTENNA_POS; + -+typedef u8 -+(*BFP_BTC_R1)( -+void * pBtcContext, -+u32 RegAddr -+ ); -+typedef u16 -+(*BFP_BTC_R2)( -+void * pBtcContext, -+u32 RegAddr -+ ); -+typedef u32 -+(*BFP_BTC_R4)( -+void * pBtcContext, -+u32 RegAddr -+ ); -+typedef void -+(*BFP_BTC_W1)( -+void * pBtcContext, -+u32 RegAddr, -+u8 Data -+ ); -+typedef void -+(*BFP_BTC_W1_BIT_MASK)( -+void * pBtcContext, -+u32 regAddr, -+u8 bitMask, -+u8 data1b -+ ); -+typedef void -+(*BFP_BTC_W2)( -+void * pBtcContext, -+u32 RegAddr, -+u16 Data -+ ); -+typedef void -+(*BFP_BTC_W4)( -+void * pBtcContext, -+u32 RegAddr, -+u32 Data -+ ); -+typedef void -+(*BFP_BTC_LOCAL_REG_W1)( -+void * pBtcContext, -+u32 RegAddr, -+u8 Data -+ ); -+typedef void -+(*BFP_BTC_SET_BB_REG)( -+void * pBtcContext, -+u32 RegAddr, -+u32 BitMask, -+u32 Data -+ ); -+typedef u32 -+(*BFP_BTC_GET_BB_REG)( -+void * pBtcContext, -+u32 RegAddr, -+u32 BitMask -+ ); -+typedef void -+(*BFP_BTC_SET_RF_REG)( -+void * pBtcContext, -+u8 eRFPath, -+u32 RegAddr, -+u32 BitMask, -+u32 Data -+ ); -+typedef u32 -+(*BFP_BTC_GET_RF_REG)( -+void * pBtcContext, -+u8 eRFPath, -+u32 RegAddr, -+u32 BitMask -+ ); -+typedef void -+(*BFP_BTC_FILL_H2C)( -+void * pBtcContext, -+u8 elementId, -+u32 cmdLen, -+u8 * pCmdBuffer -+ ); ++typedef u8 (*BFP_BTC_R1)(void *pBtcContext, u32 RegAddr); ++typedef u16(*BFP_BTC_R2)(void *pBtcContext, u32 RegAddr); ++typedef u32 (*BFP_BTC_R4)(void *pBtcContext, u32 RegAddr); ++typedef void (*BFP_BTC_W1)(void *pBtcContext, u32 RegAddr, u8 Data); ++typedef void(*BFP_BTC_W1_BIT_MASK)( ++ void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b ++); ++typedef void (*BFP_BTC_W2)(void *pBtcContext, u32 RegAddr, u16 Data); ++typedef void (*BFP_BTC_W4)(void *pBtcContext, u32 RegAddr, u32 Data); ++typedef void (*BFP_BTC_LOCAL_REG_W1)(void *pBtcContext, u32 RegAddr, u8 Data); ++typedef void (*BFP_BTC_SET_BB_REG)( ++ void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data ++); ++typedef u32 (*BFP_BTC_GET_BB_REG)(void *pBtcContext, u32 RegAddr, u32 BitMask); ++typedef void (*BFP_BTC_SET_RF_REG)( ++ void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data ++); ++typedef u32 (*BFP_BTC_GET_RF_REG)( ++ void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask ++); ++typedef void (*BFP_BTC_FILL_H2C)( ++ void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer ++); + -+typedef u8 -+(*BFP_BTC_GET)( -+void * pBtCoexist, -+u8 getType, -+ void * pOutBuf -+ ); ++typedef u8 (*BFP_BTC_GET)(void *pBtCoexist, u8 getType, void *pOutBuf); + -+typedef u8 -+(*BFP_BTC_SET)( -+void * pBtCoexist, -+u8 setType, -+ void * pInBuf -+ ); -+typedef void -+(*BFP_BTC_SET_BT_REG)( -+void * pBtcContext, -+u8 regType, -+u32 offset, -+u32 value -+ ); -+typedef u32 -+(*BFP_BTC_GET_BT_REG)( -+void * pBtcContext, -+u8 regType, -+u32 offset -+ ); -+typedef void -+(*BFP_BTC_DISP_DBG_MSG)( -+void * pBtCoexist, -+u8 dispType -+ ); ++typedef u8 (*BFP_BTC_SET)(void *pBtCoexist, u8 setType, void *pInBuf); ++typedef void (*BFP_BTC_SET_BT_REG)( ++ void *pBtcContext, u8 regType, u32 offset, u32 value ++); ++typedef u32 (*BFP_BTC_GET_BT_REG)(void *pBtcContext, u8 regType, u32 offset); ++typedef void (*BFP_BTC_DISP_DBG_MSG)(void *pBtCoexist, u8 dispType); + -+typedef struct _BTC_BT_INFO{ -+ bool bBtDisabled; -+ u8 rssiAdjustForAgcTableOn; -+ u8 rssiAdjustFor1AntCoexType; -+ bool bPreBtCtrlAggBufSize; -+ bool bBtCtrlAggBufSize; -+ bool bRejectAggPkt; -+ bool bIncreaseScanDevNum; -+ bool bBtTxRxMask; -+ u8 preAggBufSize; -+ u8 aggBufSize; -+ bool bBtBusy; -+ bool bLimitedDig; -+ u16 btHciVer; -+ u16 btRealFwVer; -+ u8 btFwVer; -+ u32 getBtFwVerCnt; ++typedef struct _BTC_BT_INFO { ++ bool bBtDisabled; ++ u8 rssiAdjustForAgcTableOn; ++ u8 rssiAdjustFor1AntCoexType; ++ bool bPreBtCtrlAggBufSize; ++ bool bBtCtrlAggBufSize; ++ bool bRejectAggPkt; ++ bool bIncreaseScanDevNum; ++ bool bBtTxRxMask; ++ u8 preAggBufSize; ++ u8 aggBufSize; ++ bool bBtBusy; ++ bool bLimitedDig; ++ u16 btHciVer; ++ u16 btRealFwVer; ++ u8 btFwVer; ++ u32 getBtFwVerCnt; + -+ bool bBtDisableLowPwr; ++ bool bBtDisableLowPwr; + -+ bool bBtCtrlLps; -+ bool bBtLpsOn; -+ bool bForceToRoam; /* for 1Ant solution */ -+ u8 lpsVal; -+ u8 rpwmVal; -+ u32 raMask; ++ bool bBtCtrlLps; ++ bool bBtLpsOn; ++ bool bForceToRoam; /* for 1Ant solution */ ++ u8 lpsVal; ++ u8 rpwmVal; ++ u32 raMask; +} BTC_BT_INFO, *PBTC_BT_INFO; + -+typedef struct _BTC_STACK_INFO{ -+ bool bProfileNotified; -+ u16 hciVersion; /* stack hci version */ -+ u8 numOfLink; -+ bool bBtLinkExist; -+ bool bScoExist; -+ bool bAclExist; -+ bool bA2dpExist; -+ bool bHidExist; -+ u8 numOfHid; -+ bool bPanExist; -+ bool bUnknownAclExist; -+ s8 minBtRssi; ++typedef struct _BTC_STACK_INFO { ++ bool bProfileNotified; ++ u16 hciVersion; /* stack hci version */ ++ u8 numOfLink; ++ bool bBtLinkExist; ++ bool bScoExist; ++ bool bAclExist; ++ bool bA2dpExist; ++ bool bHidExist; ++ u8 numOfHid; ++ bool bPanExist; ++ bool bUnknownAclExist; ++ s8 minBtRssi; +} BTC_STACK_INFO, *PBTC_STACK_INFO; + -+typedef struct _BTC_BT_LINK_INFO{ -+ bool bBtLinkExist; -+ bool bScoExist; -+ bool bScoOnly; -+ bool bA2dpExist; -+ bool bA2dpOnly; -+ bool bHidExist; -+ bool bHidOnly; -+ bool bPanExist; -+ bool bPanOnly; -+ bool bSlaveRole; ++typedef struct _BTC_BT_LINK_INFO { ++ bool bBtLinkExist; ++ bool bScoExist; ++ bool bScoOnly; ++ bool bA2dpExist; ++ bool bA2dpOnly; ++ bool bHidExist; ++ bool bHidOnly; ++ bool bPanExist; ++ bool bPanOnly; ++ bool bSlaveRole; +} BTC_BT_LINK_INFO, *PBTC_BT_LINK_INFO; + -+typedef struct _BTC_STATISTICS{ -+ u32 cntBind; -+ u32 cntPowerOn; -+ u32 cntInitHwConfig; -+ u32 cntInitCoexDm; -+ u32 cntIpsNotify; -+ u32 cntLpsNotify; -+ u32 cntScanNotify; -+ u32 cntConnectNotify; -+ u32 cntMediaStatusNotify; -+ u32 cntSpecialPacketNotify; -+ u32 cntBtInfoNotify; -+ u32 cntRfStatusNotify; -+ u32 cntPeriodical; -+ u32 cntCoexDmSwitch; -+ u32 cntStackOperationNotify; -+ u32 cntDbgCtrl; ++typedef struct _BTC_STATISTICS { ++ u32 cntBind; ++ u32 cntPowerOn; ++ u32 cntInitHwConfig; ++ u32 cntInitCoexDm; ++ u32 cntIpsNotify; ++ u32 cntLpsNotify; ++ u32 cntScanNotify; ++ u32 cntConnectNotify; ++ u32 cntMediaStatusNotify; ++ u32 cntSpecialPacketNotify; ++ u32 cntBtInfoNotify; ++ u32 cntRfStatusNotify; ++ u32 cntPeriodical; ++ u32 cntCoexDmSwitch; ++ u32 cntStackOperationNotify; ++ u32 cntDbgCtrl; +} BTC_STATISTICS, *PBTC_STATISTICS; + -+typedef struct _BTC_COEXIST{ -+ bool bBinded; /* make sure only one adapter can bind the data context */ -+ void * Adapter; /* default adapter */ -+ BTC_BOARD_INFO boardInfo; -+ BTC_BT_INFO btInfo; /* some bt info referenced by non-bt module */ -+ BTC_STACK_INFO stackInfo; -+ BTC_BT_LINK_INFO btLinkInfo; -+ BTC_CHIP_INTERFACE chipInterface; ++typedef struct _BTC_COEXIST { ++ bool bBinded; /* make sure only one adapter can bind the data context */ ++ void *Adapter; /* default adapter */ ++ BTC_BOARD_INFO boardInfo; ++ BTC_BT_INFO btInfo; /* some bt info referenced by non-bt module */ ++ BTC_STACK_INFO stackInfo; ++ BTC_BT_LINK_INFO btLinkInfo; ++ BTC_CHIP_INTERFACE chipInterface; + -+ bool bInitilized; -+ bool bStopCoexDm; -+ bool bManualControl; -+ u8 * cliBuf; -+ BTC_STATISTICS statistics; -+ u8 pwrModeVal[10]; ++ bool bInitilized; ++ bool bStopCoexDm; ++ bool bManualControl; ++ u8 *cliBuf; ++ BTC_STATISTICS statistics; ++ u8 pwrModeVal[10]; + + /* function pointers */ + /* io related */ -+ BFP_BTC_R1 fBtcRead1Byte; -+ BFP_BTC_W1 fBtcWrite1Byte; -+ BFP_BTC_W1_BIT_MASK fBtcWrite1ByteBitMask; -+ BFP_BTC_R2 fBtcRead2Byte; -+ BFP_BTC_W2 fBtcWrite2Byte; -+ BFP_BTC_R4 fBtcRead4Byte; -+ BFP_BTC_W4 fBtcWrite4Byte; -+ BFP_BTC_LOCAL_REG_W1 fBtcWriteLocalReg1Byte; ++ BFP_BTC_R1 fBtcRead1Byte; ++ BFP_BTC_W1 fBtcWrite1Byte; ++ BFP_BTC_W1_BIT_MASK fBtcWrite1ByteBitMask; ++ BFP_BTC_R2 fBtcRead2Byte; ++ BFP_BTC_W2 fBtcWrite2Byte; ++ BFP_BTC_R4 fBtcRead4Byte; ++ BFP_BTC_W4 fBtcWrite4Byte; ++ BFP_BTC_LOCAL_REG_W1 fBtcWriteLocalReg1Byte; + /* read/write bb related */ -+ BFP_BTC_SET_BB_REG fBtcSetBbReg; -+ BFP_BTC_GET_BB_REG fBtcGetBbReg; ++ BFP_BTC_SET_BB_REG fBtcSetBbReg; ++ BFP_BTC_GET_BB_REG fBtcGetBbReg; + + /* read/write rf related */ -+ BFP_BTC_SET_RF_REG fBtcSetRfReg; -+ BFP_BTC_GET_RF_REG fBtcGetRfReg; ++ BFP_BTC_SET_RF_REG fBtcSetRfReg; ++ BFP_BTC_GET_RF_REG fBtcGetRfReg; + + /* fill h2c related */ -+ BFP_BTC_FILL_H2C fBtcFillH2c; ++ BFP_BTC_FILL_H2C fBtcFillH2c; + /* other */ -+ BFP_BTC_DISP_DBG_MSG fBtcDispDbgMsg; ++ BFP_BTC_DISP_DBG_MSG fBtcDispDbgMsg; + /* normal get/set related */ -+ BFP_BTC_GET fBtcGet; -+ BFP_BTC_SET fBtcSet; ++ BFP_BTC_GET fBtcGet; ++ BFP_BTC_SET fBtcSet; + -+ BFP_BTC_GET_BT_REG fBtcGetBtReg; -+ BFP_BTC_SET_BT_REG fBtcSetBtReg; ++ BFP_BTC_GET_BT_REG fBtcGetBtReg; ++ BFP_BTC_SET_BT_REG fBtcSetBtReg; +} BTC_COEXIST, *PBTC_COEXIST; + -+extern BTC_COEXIST GLBtCoexist; ++extern BTC_COEXIST GLBtCoexist; + -+u8 -+EXhalbtcoutsrc_InitlizeVariables( -+void * Adapter -+ ); -+void -+EXhalbtcoutsrc_PowerOnSetting( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtcoutsrc_InitHwConfig( -+PBTC_COEXIST pBtCoexist, -+u8 bWifiOnly -+ ); -+void -+EXhalbtcoutsrc_InitCoexDm( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtcoutsrc_IpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtcoutsrc_LpsNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtcoutsrc_ScanNotify( -+PBTC_COEXIST pBtCoexist, -+u8 type -+ ); -+void -+EXhalbtcoutsrc_ConnectNotify( -+PBTC_COEXIST pBtCoexist, -+u8 action -+ ); -+void -+EXhalbtcoutsrc_MediaStatusNotify( -+PBTC_COEXIST pBtCoexist, -+RT_MEDIA_STATUS mediaStatus -+ ); -+void -+EXhalbtcoutsrc_SpecialPacketNotify( -+PBTC_COEXIST pBtCoexist, -+u8 pktType -+ ); -+void -+EXhalbtcoutsrc_BtInfoNotify( -+PBTC_COEXIST pBtCoexist, -+u8 * tmpBuf, -+u8 length -+ ); -+void -+EXhalbtcoutsrc_HaltNotify( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtcoutsrc_PnpNotify( -+PBTC_COEXIST pBtCoexist, -+u8 pnpState -+ ); -+void -+EXhalbtcoutsrc_Periodical( -+PBTC_COEXIST pBtCoexist -+ ); -+void -+EXhalbtcoutsrc_SetChipType( -+u8 chipType -+ ); -+void -+EXhalbtcoutsrc_SetAntNum( -+u8 type, -+u8 antNum -+ ); -+void -+EXhalbtcoutsrc_SetSingleAntPath( -+u8 singleAntPath -+ ); -+void -+EXhalbtcoutsrc_DisplayBtCoexInfo( -+PBTC_COEXIST pBtCoexist -+ ); ++u8 EXhalbtcoutsrc_InitlizeVariables(void *Adapter); ++void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist); ++void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly); ++void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist); ++void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type); ++void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action); ++void EXhalbtcoutsrc_MediaStatusNotify( ++ PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus ++); ++void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType); ++void EXhalbtcoutsrc_BtInfoNotify( ++ PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length ++); ++void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist); ++void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState); ++void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist); ++void EXhalbtcoutsrc_SetChipType(u8 chipType); ++void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum); ++void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath); ++void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_com.c ---- linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_com.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1464 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/hal_com.c linux/3rdparty/rtl8723bs/hal/hal_com.c +--- linux.old/3rdparty/rtl8723bs/hal/hal_com.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/hal_com.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1753 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -45758,8 +43992,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + +u8 rtw_hal_data_init(struct adapter *padapter) +{ -+ if (is_primary_adapter(padapter)) /* if (padapter->isprimary) */ -+ { ++ if (is_primary_adapter(padapter)) { /* if (padapter->isprimary) */ + padapter->hal_data_sz = sizeof(struct hal_com_data); + padapter->HalData = vzalloc(padapter->hal_data_sz); + if (padapter->HalData == NULL) { @@ -45772,10 +44005,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + +void rtw_hal_data_deinit(struct adapter *padapter) +{ -+ if (is_primary_adapter(padapter)) /* if (padapter->isprimary) */ -+ { -+ if (padapter->HalData) -+ { ++ if (is_primary_adapter(padapter)) { /* if (padapter->isprimary) */ ++ if (padapter->HalData) { + #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE + phy_free_filebuf(padapter); + #endif @@ -45793,28 +44024,41 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + u8 buf[128]; + + cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8723B_"); -+ cnt += sprintf((buf+cnt), "%s_", IS_NORMAL_CHIP(ChipVersion)?"Normal_Chip":"Test_Chip"); ++ cnt += sprintf((buf+cnt), "%s_", IS_NORMAL_CHIP(ChipVersion) ? "Normal_Chip" : "Test_Chip"); + if (IS_CHIP_VENDOR_TSMC(ChipVersion)) -+ cnt += sprintf((buf+cnt), "%s_","TSMC"); ++ cnt += sprintf((buf+cnt), "%s_", "TSMC"); + else if (IS_CHIP_VENDOR_UMC(ChipVersion)) -+ cnt += sprintf((buf+cnt), "%s_","UMC"); ++ cnt += sprintf((buf+cnt), "%s_", "UMC"); + else if (IS_CHIP_VENDOR_SMIC(ChipVersion)) -+ cnt += sprintf((buf+cnt), "%s_","SMIC"); ++ cnt += sprintf((buf+cnt), "%s_", "SMIC"); + -+ if (IS_A_CUT(ChipVersion)) cnt += sprintf((buf+cnt), "A_CUT_"); -+ else if (IS_B_CUT(ChipVersion)) cnt += sprintf((buf+cnt), "B_CUT_"); -+ else if (IS_C_CUT(ChipVersion)) cnt += sprintf((buf+cnt), "C_CUT_"); -+ else if (IS_D_CUT(ChipVersion)) cnt += sprintf((buf+cnt), "D_CUT_"); -+ else if (IS_E_CUT(ChipVersion)) cnt += sprintf((buf+cnt), "E_CUT_"); -+ else if (IS_I_CUT(ChipVersion)) cnt += sprintf((buf+cnt), "I_CUT_"); -+ else if (IS_J_CUT(ChipVersion)) cnt += sprintf((buf+cnt), "J_CUT_"); -+ else if (IS_K_CUT(ChipVersion)) cnt += sprintf((buf+cnt), "K_CUT_"); -+ else cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", ChipVersion.CUTVersion); ++ if (IS_A_CUT(ChipVersion)) ++ cnt += sprintf((buf+cnt), "A_CUT_"); ++ else if (IS_B_CUT(ChipVersion)) ++ cnt += sprintf((buf+cnt), "B_CUT_"); ++ else if (IS_C_CUT(ChipVersion)) ++ cnt += sprintf((buf+cnt), "C_CUT_"); ++ else if (IS_D_CUT(ChipVersion)) ++ cnt += sprintf((buf+cnt), "D_CUT_"); ++ else if (IS_E_CUT(ChipVersion)) ++ cnt += sprintf((buf+cnt), "E_CUT_"); ++ else if (IS_I_CUT(ChipVersion)) ++ cnt += sprintf((buf+cnt), "I_CUT_"); ++ else if (IS_J_CUT(ChipVersion)) ++ cnt += sprintf((buf+cnt), "J_CUT_"); ++ else if (IS_K_CUT(ChipVersion)) ++ cnt += sprintf((buf+cnt), "K_CUT_"); ++ else ++ cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", ChipVersion.CUTVersion); + -+ if (IS_1T1R(ChipVersion)) cnt += sprintf((buf+cnt), "1T1R_"); -+ else if (IS_1T2R(ChipVersion)) cnt += sprintf((buf+cnt), "1T2R_"); -+ else if (IS_2T2R(ChipVersion)) cnt += sprintf((buf+cnt), "2T2R_"); -+ else cnt += sprintf((buf+cnt), "UNKNOWN_RFTYPE(%d)_", ChipVersion.RFType); ++ if (IS_1T1R(ChipVersion)) ++ cnt += sprintf((buf+cnt), "1T1R_"); ++ else if (IS_1T2R(ChipVersion)) ++ cnt += sprintf((buf+cnt), "1T2R_"); ++ else if (IS_2T2R(ChipVersion)) ++ cnt += sprintf((buf+cnt), "2T2R_"); ++ else ++ cnt += sprintf((buf+cnt), "UNKNOWN_RFTYPE(%d)_", ChipVersion.RFType); + + cnt += sprintf((buf+cnt), "RomVer(%d)\n", ChipVersion.ROMVer); + @@ -45842,14 +44086,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + *Final channel plan decision + * + */ -+u8 -+hal_com_config_channel_plan( -+struct adapter *padapter, -+u8 hw_channel_plan, -+u8 sw_channel_plan, -+u8 def_channel_plan, -+bool AutoLoadFail -+ ) ++u8 hal_com_config_channel_plan( ++ struct adapter *padapter, ++ u8 hw_channel_plan, ++ u8 sw_channel_plan, ++ u8 def_channel_plan, ++ bool AutoLoadFail ++) +{ + struct hal_com_data *pHalData; + u8 chnlPlan; @@ -45861,13 +44104,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + if (0xFF == hw_channel_plan) + AutoLoadFail = true; + -+ if (false == AutoLoadFail) -+ { ++ if (false == AutoLoadFail) { + u8 hw_chnlPlan; + + hw_chnlPlan = hw_channel_plan & (~EEPROM_CHANNEL_PLAN_BY_HW_MASK); -+ if (rtw_is_channel_plan_valid(hw_chnlPlan)) -+ { ++ if (rtw_is_channel_plan_valid(hw_chnlPlan)) { +#ifndef CONFIG_SW_CHANNEL_PLAN + if (hw_channel_plan & EEPROM_CHANNEL_PLAN_BY_HW_MASK) + pHalData->bDisableSWChannelPlan = true; @@ -45877,20 +44118,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + } + } + -+ if ((false == pHalData->bDisableSWChannelPlan) -+ && rtw_is_channel_plan_valid(sw_channel_plan)) -+ { ++ if ( ++ (false == pHalData->bDisableSWChannelPlan) && ++ rtw_is_channel_plan_valid(sw_channel_plan) ++ ) + chnlPlan = sw_channel_plan; -+ } + + return chnlPlan; +} + -+bool -+HAL_IsLegalChannel( -+struct adapter *Adapter, -+u32 Channel -+ ) ++bool HAL_IsLegalChannel(struct adapter *Adapter, u32 Channel) +{ + bool bLegalChannel = true; + @@ -45914,95 +44151,261 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +{ + u8 ret = DESC_RATE1M; + -+ switch (rate) -+ { -+ case MGN_1M: ret = DESC_RATE1M; break; -+ case MGN_2M: ret = DESC_RATE2M; break; -+ case MGN_5_5M: ret = DESC_RATE5_5M; break; -+ case MGN_11M: ret = DESC_RATE11M; break; -+ case MGN_6M: ret = DESC_RATE6M; break; -+ case MGN_9M: ret = DESC_RATE9M; break; -+ case MGN_12M: ret = DESC_RATE12M; break; -+ case MGN_18M: ret = DESC_RATE18M; break; -+ case MGN_24M: ret = DESC_RATE24M; break; -+ case MGN_36M: ret = DESC_RATE36M; break; -+ case MGN_48M: ret = DESC_RATE48M; break; -+ case MGN_54M: ret = DESC_RATE54M; break; -+ -+ case MGN_MCS0: ret = DESC_RATEMCS0; break; -+ case MGN_MCS1: ret = DESC_RATEMCS1; break; -+ case MGN_MCS2: ret = DESC_RATEMCS2; break; -+ case MGN_MCS3: ret = DESC_RATEMCS3; break; -+ case MGN_MCS4: ret = DESC_RATEMCS4; break; -+ case MGN_MCS5: ret = DESC_RATEMCS5; break; -+ case MGN_MCS6: ret = DESC_RATEMCS6; break; -+ case MGN_MCS7: ret = DESC_RATEMCS7; break; -+ case MGN_MCS8: ret = DESC_RATEMCS8; break; -+ case MGN_MCS9: ret = DESC_RATEMCS9; break; -+ case MGN_MCS10: ret = DESC_RATEMCS10; break; -+ case MGN_MCS11: ret = DESC_RATEMCS11; break; -+ case MGN_MCS12: ret = DESC_RATEMCS12; break; -+ case MGN_MCS13: ret = DESC_RATEMCS13; break; -+ case MGN_MCS14: ret = DESC_RATEMCS14; break; -+ case MGN_MCS15: ret = DESC_RATEMCS15; break; -+ case MGN_MCS16: ret = DESC_RATEMCS16; break; -+ case MGN_MCS17: ret = DESC_RATEMCS17; break; -+ case MGN_MCS18: ret = DESC_RATEMCS18; break; -+ case MGN_MCS19: ret = DESC_RATEMCS19; break; -+ case MGN_MCS20: ret = DESC_RATEMCS20; break; -+ case MGN_MCS21: ret = DESC_RATEMCS21; break; -+ case MGN_MCS22: ret = DESC_RATEMCS22; break; -+ case MGN_MCS23: ret = DESC_RATEMCS23; break; -+ case MGN_MCS24: ret = DESC_RATEMCS24; break; -+ case MGN_MCS25: ret = DESC_RATEMCS25; break; -+ case MGN_MCS26: ret = DESC_RATEMCS26; break; -+ case MGN_MCS27: ret = DESC_RATEMCS27; break; -+ case MGN_MCS28: ret = DESC_RATEMCS28; break; -+ case MGN_MCS29: ret = DESC_RATEMCS29; break; -+ case MGN_MCS30: ret = DESC_RATEMCS30; break; -+ case MGN_MCS31: ret = DESC_RATEMCS31; break; -+ -+ case MGN_VHT1SS_MCS0: ret = DESC_RATEVHTSS1MCS0; break; -+ case MGN_VHT1SS_MCS1: ret = DESC_RATEVHTSS1MCS1; break; -+ case MGN_VHT1SS_MCS2: ret = DESC_RATEVHTSS1MCS2; break; -+ case MGN_VHT1SS_MCS3: ret = DESC_RATEVHTSS1MCS3; break; -+ case MGN_VHT1SS_MCS4: ret = DESC_RATEVHTSS1MCS4; break; -+ case MGN_VHT1SS_MCS5: ret = DESC_RATEVHTSS1MCS5; break; -+ case MGN_VHT1SS_MCS6: ret = DESC_RATEVHTSS1MCS6; break; -+ case MGN_VHT1SS_MCS7: ret = DESC_RATEVHTSS1MCS7; break; -+ case MGN_VHT1SS_MCS8: ret = DESC_RATEVHTSS1MCS8; break; -+ case MGN_VHT1SS_MCS9: ret = DESC_RATEVHTSS1MCS9; break; -+ case MGN_VHT2SS_MCS0: ret = DESC_RATEVHTSS2MCS0; break; -+ case MGN_VHT2SS_MCS1: ret = DESC_RATEVHTSS2MCS1; break; -+ case MGN_VHT2SS_MCS2: ret = DESC_RATEVHTSS2MCS2; break; -+ case MGN_VHT2SS_MCS3: ret = DESC_RATEVHTSS2MCS3; break; -+ case MGN_VHT2SS_MCS4: ret = DESC_RATEVHTSS2MCS4; break; -+ case MGN_VHT2SS_MCS5: ret = DESC_RATEVHTSS2MCS5; break; -+ case MGN_VHT2SS_MCS6: ret = DESC_RATEVHTSS2MCS6; break; -+ case MGN_VHT2SS_MCS7: ret = DESC_RATEVHTSS2MCS7; break; -+ case MGN_VHT2SS_MCS8: ret = DESC_RATEVHTSS2MCS8; break; -+ case MGN_VHT2SS_MCS9: ret = DESC_RATEVHTSS2MCS9; break; -+ case MGN_VHT3SS_MCS0: ret = DESC_RATEVHTSS3MCS0; break; -+ case MGN_VHT3SS_MCS1: ret = DESC_RATEVHTSS3MCS1; break; -+ case MGN_VHT3SS_MCS2: ret = DESC_RATEVHTSS3MCS2; break; -+ case MGN_VHT3SS_MCS3: ret = DESC_RATEVHTSS3MCS3; break; -+ case MGN_VHT3SS_MCS4: ret = DESC_RATEVHTSS3MCS4; break; -+ case MGN_VHT3SS_MCS5: ret = DESC_RATEVHTSS3MCS5; break; -+ case MGN_VHT3SS_MCS6: ret = DESC_RATEVHTSS3MCS6; break; -+ case MGN_VHT3SS_MCS7: ret = DESC_RATEVHTSS3MCS7; break; -+ case MGN_VHT3SS_MCS8: ret = DESC_RATEVHTSS3MCS8; break; -+ case MGN_VHT3SS_MCS9: ret = DESC_RATEVHTSS3MCS9; break; -+ case MGN_VHT4SS_MCS0: ret = DESC_RATEVHTSS4MCS0; break; -+ case MGN_VHT4SS_MCS1: ret = DESC_RATEVHTSS4MCS1; break; -+ case MGN_VHT4SS_MCS2: ret = DESC_RATEVHTSS4MCS2; break; -+ case MGN_VHT4SS_MCS3: ret = DESC_RATEVHTSS4MCS3; break; -+ case MGN_VHT4SS_MCS4: ret = DESC_RATEVHTSS4MCS4; break; -+ case MGN_VHT4SS_MCS5: ret = DESC_RATEVHTSS4MCS5; break; -+ case MGN_VHT4SS_MCS6: ret = DESC_RATEVHTSS4MCS6; break; -+ case MGN_VHT4SS_MCS7: ret = DESC_RATEVHTSS4MCS7; break; -+ case MGN_VHT4SS_MCS8: ret = DESC_RATEVHTSS4MCS8; break; -+ case MGN_VHT4SS_MCS9: ret = DESC_RATEVHTSS4MCS9; break; -+ default: break; ++ switch (rate) { ++ case MGN_1M: ++ ret = DESC_RATE1M; ++ break; ++ case MGN_2M: ++ ret = DESC_RATE2M; ++ break; ++ case MGN_5_5M: ++ ret = DESC_RATE5_5M; ++ break; ++ case MGN_11M: ++ ret = DESC_RATE11M; ++ break; ++ case MGN_6M: ++ ret = DESC_RATE6M; ++ break; ++ case MGN_9M: ++ ret = DESC_RATE9M; ++ break; ++ case MGN_12M: ++ ret = DESC_RATE12M; ++ break; ++ case MGN_18M: ++ ret = DESC_RATE18M; ++ break; ++ case MGN_24M: ++ ret = DESC_RATE24M; ++ break; ++ case MGN_36M: ++ ret = DESC_RATE36M; ++ break; ++ case MGN_48M: ++ ret = DESC_RATE48M; ++ break; ++ case MGN_54M: ++ ret = DESC_RATE54M; ++ break; ++ case MGN_MCS0: ++ ret = DESC_RATEMCS0; ++ break; ++ case MGN_MCS1: ++ ret = DESC_RATEMCS1; ++ break; ++ case MGN_MCS2: ++ ret = DESC_RATEMCS2; ++ break; ++ case MGN_MCS3: ++ ret = DESC_RATEMCS3; ++ break; ++ case MGN_MCS4: ++ ret = DESC_RATEMCS4; ++ break; ++ case MGN_MCS5: ++ ret = DESC_RATEMCS5; ++ break; ++ case MGN_MCS6: ++ ret = DESC_RATEMCS6; ++ break; ++ case MGN_MCS7: ++ ret = DESC_RATEMCS7; ++ break; ++ case MGN_MCS8: ++ ret = DESC_RATEMCS8; ++ break; ++ case MGN_MCS9: ++ ret = DESC_RATEMCS9; ++ break; ++ case MGN_MCS10: ++ ret = DESC_RATEMCS10; ++ break; ++ case MGN_MCS11: ++ ret = DESC_RATEMCS11; ++ break; ++ case MGN_MCS12: ++ ret = DESC_RATEMCS12; ++ break; ++ case MGN_MCS13: ++ ret = DESC_RATEMCS13; ++ break; ++ case MGN_MCS14: ++ ret = DESC_RATEMCS14; ++ break; ++ case MGN_MCS15: ++ ret = DESC_RATEMCS15; ++ break; ++ case MGN_MCS16: ++ ret = DESC_RATEMCS16; ++ break; ++ case MGN_MCS17: ++ ret = DESC_RATEMCS17; ++ break; ++ case MGN_MCS18: ++ ret = DESC_RATEMCS18; ++ break; ++ case MGN_MCS19: ++ ret = DESC_RATEMCS19; ++ break; ++ case MGN_MCS20: ++ ret = DESC_RATEMCS20; ++ break; ++ case MGN_MCS21: ++ ret = DESC_RATEMCS21; ++ break; ++ case MGN_MCS22: ++ ret = DESC_RATEMCS22; ++ break; ++ case MGN_MCS23: ++ ret = DESC_RATEMCS23; ++ break; ++ case MGN_MCS24: ++ ret = DESC_RATEMCS24; ++ break; ++ case MGN_MCS25: ++ ret = DESC_RATEMCS25; ++ break; ++ case MGN_MCS26: ++ ret = DESC_RATEMCS26; ++ break; ++ case MGN_MCS27: ++ ret = DESC_RATEMCS27; ++ break; ++ case MGN_MCS28: ++ ret = DESC_RATEMCS28; ++ break; ++ case MGN_MCS29: ++ ret = DESC_RATEMCS29; ++ break; ++ case MGN_MCS30: ++ ret = DESC_RATEMCS30; ++ break; ++ case MGN_MCS31: ++ ret = DESC_RATEMCS31; ++ break; ++ case MGN_VHT1SS_MCS0: ++ ret = DESC_RATEVHTSS1MCS0; ++ break; ++ case MGN_VHT1SS_MCS1: ++ ret = DESC_RATEVHTSS1MCS1; ++ break; ++ case MGN_VHT1SS_MCS2: ++ ret = DESC_RATEVHTSS1MCS2; ++ break; ++ case MGN_VHT1SS_MCS3: ++ ret = DESC_RATEVHTSS1MCS3; ++ break; ++ case MGN_VHT1SS_MCS4: ++ ret = DESC_RATEVHTSS1MCS4; ++ break; ++ case MGN_VHT1SS_MCS5: ++ ret = DESC_RATEVHTSS1MCS5; ++ break; ++ case MGN_VHT1SS_MCS6: ++ ret = DESC_RATEVHTSS1MCS6; ++ break; ++ case MGN_VHT1SS_MCS7: ++ ret = DESC_RATEVHTSS1MCS7; ++ break; ++ case MGN_VHT1SS_MCS8: ++ ret = DESC_RATEVHTSS1MCS8; ++ break; ++ case MGN_VHT1SS_MCS9: ++ ret = DESC_RATEVHTSS1MCS9; ++ break; ++ case MGN_VHT2SS_MCS0: ++ ret = DESC_RATEVHTSS2MCS0; ++ break; ++ case MGN_VHT2SS_MCS1: ++ ret = DESC_RATEVHTSS2MCS1; ++ break; ++ case MGN_VHT2SS_MCS2: ++ ret = DESC_RATEVHTSS2MCS2; ++ break; ++ case MGN_VHT2SS_MCS3: ++ ret = DESC_RATEVHTSS2MCS3; ++ break; ++ case MGN_VHT2SS_MCS4: ++ ret = DESC_RATEVHTSS2MCS4; ++ break; ++ case MGN_VHT2SS_MCS5: ++ ret = DESC_RATEVHTSS2MCS5; ++ break; ++ case MGN_VHT2SS_MCS6: ++ ret = DESC_RATEVHTSS2MCS6; ++ break; ++ case MGN_VHT2SS_MCS7: ++ ret = DESC_RATEVHTSS2MCS7; ++ break; ++ case MGN_VHT2SS_MCS8: ++ ret = DESC_RATEVHTSS2MCS8; ++ break; ++ case MGN_VHT2SS_MCS9: ++ ret = DESC_RATEVHTSS2MCS9; ++ break; ++ case MGN_VHT3SS_MCS0: ++ ret = DESC_RATEVHTSS3MCS0; ++ break; ++ case MGN_VHT3SS_MCS1: ++ ret = DESC_RATEVHTSS3MCS1; ++ break; ++ case MGN_VHT3SS_MCS2: ++ ret = DESC_RATEVHTSS3MCS2; ++ break; ++ case MGN_VHT3SS_MCS3: ++ ret = DESC_RATEVHTSS3MCS3; ++ break; ++ case MGN_VHT3SS_MCS4: ++ ret = DESC_RATEVHTSS3MCS4; ++ break; ++ case MGN_VHT3SS_MCS5: ++ ret = DESC_RATEVHTSS3MCS5; ++ break; ++ case MGN_VHT3SS_MCS6: ++ ret = DESC_RATEVHTSS3MCS6; ++ break; ++ case MGN_VHT3SS_MCS7: ++ ret = DESC_RATEVHTSS3MCS7; ++ break; ++ case MGN_VHT3SS_MCS8: ++ ret = DESC_RATEVHTSS3MCS8; ++ break; ++ case MGN_VHT3SS_MCS9: ++ ret = DESC_RATEVHTSS3MCS9; ++ break; ++ case MGN_VHT4SS_MCS0: ++ ret = DESC_RATEVHTSS4MCS0; ++ break; ++ case MGN_VHT4SS_MCS1: ++ ret = DESC_RATEVHTSS4MCS1; ++ break; ++ case MGN_VHT4SS_MCS2: ++ ret = DESC_RATEVHTSS4MCS2; ++ break; ++ case MGN_VHT4SS_MCS3: ++ ret = DESC_RATEVHTSS4MCS3; ++ break; ++ case MGN_VHT4SS_MCS4: ++ ret = DESC_RATEVHTSS4MCS4; ++ break; ++ case MGN_VHT4SS_MCS5: ++ ret = DESC_RATEVHTSS4MCS5; ++ break; ++ case MGN_VHT4SS_MCS6: ++ ret = DESC_RATEVHTSS4MCS6; ++ break; ++ case MGN_VHT4SS_MCS7: ++ ret = DESC_RATEVHTSS4MCS7; ++ break; ++ case MGN_VHT4SS_MCS8: ++ ret = DESC_RATEVHTSS4MCS8; ++ break; ++ case MGN_VHT4SS_MCS9: ++ ret = DESC_RATEVHTSS4MCS9; ++ break; ++ default: ++ break; + } + + return ret; @@ -46012,97 +44415,263 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +{ + u8 ret_rate = MGN_1M; + -+ switch (rate) -+ { ++ switch (rate) { ++ case DESC_RATE1M: ++ ret_rate = MGN_1M; ++ break; ++ case DESC_RATE2M: ++ ret_rate = MGN_2M; ++ break; ++ case DESC_RATE5_5M: ++ ret_rate = MGN_5_5M; ++ break; ++ case DESC_RATE11M: ++ ret_rate = MGN_11M; ++ break; ++ case DESC_RATE6M: ++ ret_rate = MGN_6M; ++ break; ++ case DESC_RATE9M: ++ ret_rate = MGN_9M; ++ break; ++ case DESC_RATE12M: ++ ret_rate = MGN_12M; ++ break; ++ case DESC_RATE18M: ++ ret_rate = MGN_18M; ++ break; ++ case DESC_RATE24M: ++ ret_rate = MGN_24M; ++ break; ++ case DESC_RATE36M: ++ ret_rate = MGN_36M; ++ break; ++ case DESC_RATE48M: ++ ret_rate = MGN_48M; ++ break; ++ case DESC_RATE54M: ++ ret_rate = MGN_54M; ++ break; ++ case DESC_RATEMCS0: ++ ret_rate = MGN_MCS0; ++ break; ++ case DESC_RATEMCS1: ++ ret_rate = MGN_MCS1; ++ break; ++ case DESC_RATEMCS2: ++ ret_rate = MGN_MCS2; ++ break; ++ case DESC_RATEMCS3: ++ ret_rate = MGN_MCS3; ++ break; ++ case DESC_RATEMCS4: ++ ret_rate = MGN_MCS4; ++ break; ++ case DESC_RATEMCS5: ++ ret_rate = MGN_MCS5; ++ break; ++ case DESC_RATEMCS6: ++ ret_rate = MGN_MCS6; ++ break; ++ case DESC_RATEMCS7: ++ ret_rate = MGN_MCS7; ++ break; ++ case DESC_RATEMCS8: ++ ret_rate = MGN_MCS8; ++ break; ++ case DESC_RATEMCS9: ++ ret_rate = MGN_MCS9; ++ break; ++ case DESC_RATEMCS10: ++ ret_rate = MGN_MCS10; ++ break; ++ case DESC_RATEMCS11: ++ ret_rate = MGN_MCS11; ++ break; ++ case DESC_RATEMCS12: ++ ret_rate = MGN_MCS12; ++ break; ++ case DESC_RATEMCS13: ++ ret_rate = MGN_MCS13; ++ break; ++ case DESC_RATEMCS14: ++ ret_rate = MGN_MCS14; ++ break; ++ case DESC_RATEMCS15: ++ ret_rate = MGN_MCS15; ++ break; ++ case DESC_RATEMCS16: ++ ret_rate = MGN_MCS16; ++ break; ++ case DESC_RATEMCS17: ++ ret_rate = MGN_MCS17; ++ break; ++ case DESC_RATEMCS18: ++ ret_rate = MGN_MCS18; ++ break; ++ case DESC_RATEMCS19: ++ ret_rate = MGN_MCS19; ++ break; ++ case DESC_RATEMCS20: ++ ret_rate = MGN_MCS20; ++ break; ++ case DESC_RATEMCS21: ++ ret_rate = MGN_MCS21; ++ break; ++ case DESC_RATEMCS22: ++ ret_rate = MGN_MCS22; ++ break; ++ case DESC_RATEMCS23: ++ ret_rate = MGN_MCS23; ++ break; ++ case DESC_RATEMCS24: ++ ret_rate = MGN_MCS24; ++ break; ++ case DESC_RATEMCS25: ++ ret_rate = MGN_MCS25; ++ break; ++ case DESC_RATEMCS26: ++ ret_rate = MGN_MCS26; ++ break; ++ case DESC_RATEMCS27: ++ ret_rate = MGN_MCS27; ++ break; ++ case DESC_RATEMCS28: ++ ret_rate = MGN_MCS28; ++ break; ++ case DESC_RATEMCS29: ++ ret_rate = MGN_MCS29; ++ break; ++ case DESC_RATEMCS30: ++ ret_rate = MGN_MCS30; ++ break; ++ case DESC_RATEMCS31: ++ ret_rate = MGN_MCS31; ++ break; ++ case DESC_RATEVHTSS1MCS0: ++ ret_rate = MGN_VHT1SS_MCS0; ++ break; ++ case DESC_RATEVHTSS1MCS1: ++ ret_rate = MGN_VHT1SS_MCS1; ++ break; ++ case DESC_RATEVHTSS1MCS2: ++ ret_rate = MGN_VHT1SS_MCS2; ++ break; ++ case DESC_RATEVHTSS1MCS3: ++ ret_rate = MGN_VHT1SS_MCS3; ++ break; ++ case DESC_RATEVHTSS1MCS4: ++ ret_rate = MGN_VHT1SS_MCS4; ++ break; ++ case DESC_RATEVHTSS1MCS5: ++ ret_rate = MGN_VHT1SS_MCS5; ++ break; ++ case DESC_RATEVHTSS1MCS6: ++ ret_rate = MGN_VHT1SS_MCS6; ++ break; ++ case DESC_RATEVHTSS1MCS7: ++ ret_rate = MGN_VHT1SS_MCS7; ++ break; ++ case DESC_RATEVHTSS1MCS8: ++ ret_rate = MGN_VHT1SS_MCS8; ++ break; ++ case DESC_RATEVHTSS1MCS9: ++ ret_rate = MGN_VHT1SS_MCS9; ++ break; ++ case DESC_RATEVHTSS2MCS0: ++ ret_rate = MGN_VHT2SS_MCS0; ++ break; ++ case DESC_RATEVHTSS2MCS1: ++ ret_rate = MGN_VHT2SS_MCS1; ++ break; ++ case DESC_RATEVHTSS2MCS2: ++ ret_rate = MGN_VHT2SS_MCS2; ++ break; ++ case DESC_RATEVHTSS2MCS3: ++ ret_rate = MGN_VHT2SS_MCS3; ++ break; ++ case DESC_RATEVHTSS2MCS4: ++ ret_rate = MGN_VHT2SS_MCS4; ++ break; ++ case DESC_RATEVHTSS2MCS5: ++ ret_rate = MGN_VHT2SS_MCS5; ++ break; ++ case DESC_RATEVHTSS2MCS6: ++ ret_rate = MGN_VHT2SS_MCS6; ++ break; ++ case DESC_RATEVHTSS2MCS7: ++ ret_rate = MGN_VHT2SS_MCS7; ++ break; ++ case DESC_RATEVHTSS2MCS8: ++ ret_rate = MGN_VHT2SS_MCS8; ++ break; ++ case DESC_RATEVHTSS2MCS9: ++ ret_rate = MGN_VHT2SS_MCS9; ++ break; ++ case DESC_RATEVHTSS3MCS0: ++ ret_rate = MGN_VHT3SS_MCS0; ++ break; ++ case DESC_RATEVHTSS3MCS1: ++ ret_rate = MGN_VHT3SS_MCS1; ++ break; ++ case DESC_RATEVHTSS3MCS2: ++ ret_rate = MGN_VHT3SS_MCS2; ++ break; ++ case DESC_RATEVHTSS3MCS3: ++ ret_rate = MGN_VHT3SS_MCS3; ++ break; ++ case DESC_RATEVHTSS3MCS4: ++ ret_rate = MGN_VHT3SS_MCS4; ++ break; ++ case DESC_RATEVHTSS3MCS5: ++ ret_rate = MGN_VHT3SS_MCS5; ++ break; ++ case DESC_RATEVHTSS3MCS6: ++ ret_rate = MGN_VHT3SS_MCS6; ++ break; ++ case DESC_RATEVHTSS3MCS7: ++ ret_rate = MGN_VHT3SS_MCS7; ++ break; ++ case DESC_RATEVHTSS3MCS8: ++ ret_rate = MGN_VHT3SS_MCS8; ++ break; ++ case DESC_RATEVHTSS3MCS9: ++ ret_rate = MGN_VHT3SS_MCS9; ++ break; ++ case DESC_RATEVHTSS4MCS0: ++ ret_rate = MGN_VHT4SS_MCS0; ++ break; ++ case DESC_RATEVHTSS4MCS1: ++ ret_rate = MGN_VHT4SS_MCS1; ++ break; ++ case DESC_RATEVHTSS4MCS2: ++ ret_rate = MGN_VHT4SS_MCS2; ++ break; ++ case DESC_RATEVHTSS4MCS3: ++ ret_rate = MGN_VHT4SS_MCS3; ++ break; ++ case DESC_RATEVHTSS4MCS4: ++ ret_rate = MGN_VHT4SS_MCS4; ++ break; ++ case DESC_RATEVHTSS4MCS5: ++ ret_rate = MGN_VHT4SS_MCS5; ++ break; ++ case DESC_RATEVHTSS4MCS6: ++ ret_rate = MGN_VHT4SS_MCS6; ++ break; ++ case DESC_RATEVHTSS4MCS7: ++ ret_rate = MGN_VHT4SS_MCS7; ++ break; ++ case DESC_RATEVHTSS4MCS8: ++ ret_rate = MGN_VHT4SS_MCS8; ++ break; ++ case DESC_RATEVHTSS4MCS9: ++ ret_rate = MGN_VHT4SS_MCS9; ++ break; + -+ case DESC_RATE1M: ret_rate = MGN_1M; break; -+ case DESC_RATE2M: ret_rate = MGN_2M; break; -+ case DESC_RATE5_5M: ret_rate = MGN_5_5M; break; -+ case DESC_RATE11M: ret_rate = MGN_11M; break; -+ case DESC_RATE6M: ret_rate = MGN_6M; break; -+ case DESC_RATE9M: ret_rate = MGN_9M; break; -+ case DESC_RATE12M: ret_rate = MGN_12M; break; -+ case DESC_RATE18M: ret_rate = MGN_18M; break; -+ case DESC_RATE24M: ret_rate = MGN_24M; break; -+ case DESC_RATE36M: ret_rate = MGN_36M; break; -+ case DESC_RATE48M: ret_rate = MGN_48M; break; -+ case DESC_RATE54M: ret_rate = MGN_54M; break; -+ case DESC_RATEMCS0: ret_rate = MGN_MCS0; break; -+ case DESC_RATEMCS1: ret_rate = MGN_MCS1; break; -+ case DESC_RATEMCS2: ret_rate = MGN_MCS2; break; -+ case DESC_RATEMCS3: ret_rate = MGN_MCS3; break; -+ case DESC_RATEMCS4: ret_rate = MGN_MCS4; break; -+ case DESC_RATEMCS5: ret_rate = MGN_MCS5; break; -+ case DESC_RATEMCS6: ret_rate = MGN_MCS6; break; -+ case DESC_RATEMCS7: ret_rate = MGN_MCS7; break; -+ case DESC_RATEMCS8: ret_rate = MGN_MCS8; break; -+ case DESC_RATEMCS9: ret_rate = MGN_MCS9; break; -+ case DESC_RATEMCS10: ret_rate = MGN_MCS10; break; -+ case DESC_RATEMCS11: ret_rate = MGN_MCS11; break; -+ case DESC_RATEMCS12: ret_rate = MGN_MCS12; break; -+ case DESC_RATEMCS13: ret_rate = MGN_MCS13; break; -+ case DESC_RATEMCS14: ret_rate = MGN_MCS14; break; -+ case DESC_RATEMCS15: ret_rate = MGN_MCS15; break; -+ case DESC_RATEMCS16: ret_rate = MGN_MCS16; break; -+ case DESC_RATEMCS17: ret_rate = MGN_MCS17; break; -+ case DESC_RATEMCS18: ret_rate = MGN_MCS18; break; -+ case DESC_RATEMCS19: ret_rate = MGN_MCS19; break; -+ case DESC_RATEMCS20: ret_rate = MGN_MCS20; break; -+ case DESC_RATEMCS21: ret_rate = MGN_MCS21; break; -+ case DESC_RATEMCS22: ret_rate = MGN_MCS22; break; -+ case DESC_RATEMCS23: ret_rate = MGN_MCS23; break; -+ case DESC_RATEMCS24: ret_rate = MGN_MCS24; break; -+ case DESC_RATEMCS25: ret_rate = MGN_MCS25; break; -+ case DESC_RATEMCS26: ret_rate = MGN_MCS26; break; -+ case DESC_RATEMCS27: ret_rate = MGN_MCS27; break; -+ case DESC_RATEMCS28: ret_rate = MGN_MCS28; break; -+ case DESC_RATEMCS29: ret_rate = MGN_MCS29; break; -+ case DESC_RATEMCS30: ret_rate = MGN_MCS30; break; -+ case DESC_RATEMCS31: ret_rate = MGN_MCS31; break; -+ case DESC_RATEVHTSS1MCS0: ret_rate = MGN_VHT1SS_MCS0; break; -+ case DESC_RATEVHTSS1MCS1: ret_rate = MGN_VHT1SS_MCS1; break; -+ case DESC_RATEVHTSS1MCS2: ret_rate = MGN_VHT1SS_MCS2; break; -+ case DESC_RATEVHTSS1MCS3: ret_rate = MGN_VHT1SS_MCS3; break; -+ case DESC_RATEVHTSS1MCS4: ret_rate = MGN_VHT1SS_MCS4; break; -+ case DESC_RATEVHTSS1MCS5: ret_rate = MGN_VHT1SS_MCS5; break; -+ case DESC_RATEVHTSS1MCS6: ret_rate = MGN_VHT1SS_MCS6; break; -+ case DESC_RATEVHTSS1MCS7: ret_rate = MGN_VHT1SS_MCS7; break; -+ case DESC_RATEVHTSS1MCS8: ret_rate = MGN_VHT1SS_MCS8; break; -+ case DESC_RATEVHTSS1MCS9: ret_rate = MGN_VHT1SS_MCS9; break; -+ case DESC_RATEVHTSS2MCS0: ret_rate = MGN_VHT2SS_MCS0; break; -+ case DESC_RATEVHTSS2MCS1: ret_rate = MGN_VHT2SS_MCS1; break; -+ case DESC_RATEVHTSS2MCS2: ret_rate = MGN_VHT2SS_MCS2; break; -+ case DESC_RATEVHTSS2MCS3: ret_rate = MGN_VHT2SS_MCS3; break; -+ case DESC_RATEVHTSS2MCS4: ret_rate = MGN_VHT2SS_MCS4; break; -+ case DESC_RATEVHTSS2MCS5: ret_rate = MGN_VHT2SS_MCS5; break; -+ case DESC_RATEVHTSS2MCS6: ret_rate = MGN_VHT2SS_MCS6; break; -+ case DESC_RATEVHTSS2MCS7: ret_rate = MGN_VHT2SS_MCS7; break; -+ case DESC_RATEVHTSS2MCS8: ret_rate = MGN_VHT2SS_MCS8; break; -+ case DESC_RATEVHTSS2MCS9: ret_rate = MGN_VHT2SS_MCS9; break; -+ case DESC_RATEVHTSS3MCS0: ret_rate = MGN_VHT3SS_MCS0; break; -+ case DESC_RATEVHTSS3MCS1: ret_rate = MGN_VHT3SS_MCS1; break; -+ case DESC_RATEVHTSS3MCS2: ret_rate = MGN_VHT3SS_MCS2; break; -+ case DESC_RATEVHTSS3MCS3: ret_rate = MGN_VHT3SS_MCS3; break; -+ case DESC_RATEVHTSS3MCS4: ret_rate = MGN_VHT3SS_MCS4; break; -+ case DESC_RATEVHTSS3MCS5: ret_rate = MGN_VHT3SS_MCS5; break; -+ case DESC_RATEVHTSS3MCS6: ret_rate = MGN_VHT3SS_MCS6; break; -+ case DESC_RATEVHTSS3MCS7: ret_rate = MGN_VHT3SS_MCS7; break; -+ case DESC_RATEVHTSS3MCS8: ret_rate = MGN_VHT3SS_MCS8; break; -+ case DESC_RATEVHTSS3MCS9: ret_rate = MGN_VHT3SS_MCS9; break; -+ case DESC_RATEVHTSS4MCS0: ret_rate = MGN_VHT4SS_MCS0; break; -+ case DESC_RATEVHTSS4MCS1: ret_rate = MGN_VHT4SS_MCS1; break; -+ case DESC_RATEVHTSS4MCS2: ret_rate = MGN_VHT4SS_MCS2; break; -+ case DESC_RATEVHTSS4MCS3: ret_rate = MGN_VHT4SS_MCS3; break; -+ case DESC_RATEVHTSS4MCS4: ret_rate = MGN_VHT4SS_MCS4; break; -+ case DESC_RATEVHTSS4MCS5: ret_rate = MGN_VHT4SS_MCS5; break; -+ case DESC_RATEVHTSS4MCS6: ret_rate = MGN_VHT4SS_MCS6; break; -+ case DESC_RATEVHTSS4MCS7: ret_rate = MGN_VHT4SS_MCS7; break; -+ case DESC_RATEVHTSS4MCS8: ret_rate = MGN_VHT4SS_MCS8; break; -+ case DESC_RATEVHTSS4MCS9: ret_rate = MGN_VHT4SS_MCS9; break; -+ -+ default: -+ DBG_871X("HwRateToMRate(): Non supported Rate [%x]!!!\n", rate); -+ break; ++ default: ++ DBG_871X("HwRateToMRate(): Non supported Rate [%x]!!!\n", rate); ++ break; + } + + return ret_rate; @@ -46112,7 +44681,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +{ + u8 i, is_brate, brate; + -+ for (i = 0;i < NDIS_802_11_LENGTH_RATES_EX; i++) { ++ for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { ++ + is_brate = mBratesOS[i] & IEEE80211_BASIC_RATE_MASK; + brate = mBratesOS[i] & 0x7f; + @@ -46174,11 +44744,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ +} + -+static void -+_TwoOutPipeMapping( -+struct adapter *padapter, -+bool bWIFICfg -+ ) ++static void _TwoOutPipeMapping(struct adapter *padapter, bool bWIFICfg) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + @@ -46198,8 +44764,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + -+ } -+ else {/* typical setting */ ++ } else { /* typical setting */ + + + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ @@ -46220,14 +44785,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + +} + -+static void _ThreeOutPipeMapping( -+struct adapter *padapter, -+bool bWIFICfg -+ ) ++static void _ThreeOutPipeMapping(struct adapter *padapter, bool bWIFICfg) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + -+ if (bWIFICfg) {/* for WMM */ ++ if (bWIFICfg) { /* for WMM */ + + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 1, 2, 1, 0, 0, 0, 0, 0, 0 }; */ @@ -46243,8 +44805,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + -+ } -+ else {/* typical setting */ ++ } else { /* typical setting */ + + + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ @@ -46264,33 +44825,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + +} + -+bool -+Hal_MappingOutPipe( -+struct adapter *padapter, -+u8 NumOutPipe -+ ) ++bool Hal_MappingOutPipe(struct adapter *padapter, u8 NumOutPipe) +{ + struct registry_priv *pregistrypriv = &padapter->registrypriv; + -+ bool bWIFICfg = (pregistrypriv->wifi_spec) ?true:false; ++ bool bWIFICfg = (pregistrypriv->wifi_spec) ? true : false; + + bool result = true; + -+ switch (NumOutPipe) -+ { -+ case 2: -+ _TwoOutPipeMapping(padapter, bWIFICfg); -+ break; -+ case 3: -+ case 4: -+ _ThreeOutPipeMapping(padapter, bWIFICfg); -+ break; -+ case 1: -+ _OneOutPipeMapping(padapter); -+ break; -+ default: -+ result = false; -+ break; ++ switch (NumOutPipe) { ++ case 2: ++ _TwoOutPipeMapping(padapter, bWIFICfg); ++ break; ++ case 3: ++ case 4: ++ _ThreeOutPipeMapping(padapter, bWIFICfg); ++ break; ++ case 1: ++ _OneOutPipeMapping(padapter); ++ break; ++ default: ++ result = false; ++ break; + } + + return result; @@ -46302,7 +44858,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + rtw_hal_set_hwreg(adapter, HW_VAR_MAC_ADDR, adapter->eeprompriv.mac_addr); +} + -+void rtw_init_hal_com_default_value(struct adapter * Adapter) ++void rtw_init_hal_com_default_value(struct adapter *Adapter) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + @@ -46337,11 +44893,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + + trigger = rtw_read8(adapter, REG_C2HEVT_CLEAR); + -+ if (trigger == C2H_EVT_HOST_CLOSE) { ++ if (trigger == C2H_EVT_HOST_CLOSE) + goto exit; /* Not ready */ -+ } else if (trigger != C2H_EVT_FW_CLOSE) { ++ else if (trigger != C2H_EVT_FW_CLOSE) + goto clear_evt; /* Not a valid value */ -+ } + + c2h_evt = (struct c2h_evt_hdr_88xx *)buf; + @@ -46351,11 +44906,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + c2h_evt->seq = rtw_read8(adapter, REG_C2HEVT_CMD_SEQ_88XX); + c2h_evt->plen = rtw_read8(adapter, REG_C2HEVT_CMD_LEN_88XX); + -+ RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, "c2h_evt_read(): ", -+ &c2h_evt , sizeof(c2h_evt)); ++ RT_PRINT_DATA( ++ _module_hal_init_c_, ++ _drv_info_, ++ "c2h_evt_read(): ", ++ &c2h_evt, ++ sizeof(c2h_evt) ++ ); + -+ DBG_871X("%s id:%u, len:%u, seq:%u, trigger:0x%02x\n", __func__ -+ , c2h_evt->id, c2h_evt->plen, c2h_evt->seq, trigger); ++ DBG_871X( ++ "%s id:%u, len:%u, seq:%u, trigger:0x%02x\n", ++ __func__, ++ c2h_evt->id, ++ c2h_evt->plen, ++ c2h_evt->seq, ++ trigger ++ ); + + /* Read the content */ + for (i = 0; i < c2h_evt->plen; i++) @@ -46381,12 +44947,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +{ + return networktype_to_raid_ex(adapter, psta); +} ++ +u8 rtw_get_mgntframe_raid(struct adapter *adapter, unsigned char network_type) +{ + + u8 raid; -+ raid = (network_type & WIRELESS_11B) ?RATEID_IDX_B -+ :RATEID_IDX_G; ++ raid = (network_type & WIRELESS_11B) ? RATEID_IDX_B : RATEID_IDX_G; + return raid; +} + @@ -46396,29 +44962,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + u32 tx_ra_bitmap; + + if (psta == NULL) -+ { + return; -+ } + + tx_ra_bitmap = 0; + + /* b/g mode ra_bitmap */ -+ for (i = 0; ibssrateset); i++) -+ { ++ for (i = 0; i < sizeof(psta->bssrateset); i++) { + if (psta->bssrateset[i]) + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + } + + /* n mode ra_bitmap */ -+ if (psta->htpriv.ht_option) -+ { ++ if (psta->htpriv.ht_option) { + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if (rf_type == RF_2T2R) -+ limit = 16;/* 2R */ ++ limit = 16; /* 2R */ + else -+ limit =8;/* 1R */ ++ limit = 8; /* 1R */ + -+ for (i = 0; ihtpriv.ht_cap.supp_mcs_set[i/8] & BIT(i%8)) + tx_ra_bitmap |= BIT(i+12); + } @@ -46428,7 +44990,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + psta->init_rate = get_highest_rate_idx(tx_ra_bitmap)&0x3f; +} + -+void hw_var_port_switch (struct adapter *adapter) ++void hw_var_port_switch(struct adapter *adapter) +{ +} + @@ -46439,7 +45001,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + + switch (variable) { + case HW_VAR_PORT_SWITCH: -+ hw_var_port_switch (adapter); ++ hw_var_port_switch(adapter); + break; + case HW_VAR_INIT_RTS_RATE: + rtw_warn_on(1); @@ -46457,22 +45019,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + struct security_priv *sec = &adapter->securitypriv; + u8 reg_scr = rtw_read8(adapter, REG_SECCFG); + -+ if (val) /* Enable default key related setting */ -+ { ++ if (val) { /* Enable default key related setting */ + reg_scr |= SCR_TXBCUSEDK; + if (sec->dot11AuthAlgrthm != dot11AuthAlgrthm_8021X) + reg_scr |= (SCR_RxUseDK|SCR_TxUseDK); -+ } -+ else /* Disable default key related setting */ -+ { ++ } else /* Disable default key related setting */ + reg_scr &= ~(SCR_RXBCUSEDK|SCR_TXBCUSEDK|SCR_RxUseDK|SCR_TxUseDK); -+ } + + rtw_write8(adapter, REG_SECCFG, reg_scr); + } + break; + case HW_VAR_DM_FLAG: -+ odm->SupportAbility = *((u32*)val); ++ odm->SupportAbility = *((u32 *)val); + break; + case HW_VAR_DM_FUNC_OP: + if (*((u8 *)val) == true) { @@ -46484,7 +45042,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + } + break; + case HW_VAR_DM_FUNC_SET: -+ if (*((u32*)val) == DYNAMIC_ALL_FUNC_ENABLE) { ++ if (*((u32 *)val) == DYNAMIC_ALL_FUNC_ENABLE) { + struct dm_priv *dm = &hal_data->dmpriv; + dm->DMFlag = dm->InitDMFlag; + odm->SupportAbility = dm->InitODMFlag; @@ -46506,8 +45064,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + /* TODO - Is something needed here? */ + break; + default: -+ DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" variable(%d) not defined!\n", -+ FUNC_ADPT_ARG(adapter), variable); ++ DBG_871X_LEVEL( ++ _drv_always_, ++ FUNC_ADPT_FMT" variable(%d) not defined!\n", ++ FUNC_ADPT_ARG(adapter), ++ variable ++ ); + break; + } +} @@ -46519,17 +45081,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + + switch (variable) { + case HW_VAR_BASIC_RATE: -+ *((u16*)val) = hal_data->BasicRateSet; ++ *((u16 *)val) = hal_data->BasicRateSet; + break; + case HW_VAR_DM_FLAG: -+ *((u32*)val) = odm->SupportAbility; ++ *((u32 *)val) = odm->SupportAbility; + break; + case HW_VAR_RF_TYPE: + *((u8 *)val) = hal_data->rf_type; + break; + default: -+ DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" variable(%d) not defined!\n", -+ FUNC_ADPT_ARG(adapter), variable); ++ DBG_871X_LEVEL( ++ _drv_always_, ++ FUNC_ADPT_FMT" variable(%d) not defined!\n", ++ FUNC_ADPT_ARG(adapter), ++ variable ++ ); + break; + } +} @@ -46537,8 +45103,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + + + -+u8 -+SetHalDefVar(struct adapter *adapter, enum HAL_DEF_VARIABLE variable, void *value) ++u8 SetHalDefVar( ++ struct adapter *adapter, enum HAL_DEF_VARIABLE variable, void *value ++) +{ + struct hal_com_data *hal_data = GET_HAL_DATA(adapter); + DM_ODM_T *odm = &(hal_data->odmpriv); @@ -46548,9 +45115,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + case HW_DEF_FA_CNT_DUMP: + /* ODM_COMP_COMMON */ + if (*((u8 *)value)) -+ odm->DebugComponents |= (ODM_COMP_DIG |ODM_COMP_FA_CNT); ++ odm->DebugComponents |= (ODM_COMP_DIG | ODM_COMP_FA_CNT); + else -+ odm->DebugComponents &= ~(ODM_COMP_DIG |ODM_COMP_FA_CNT); ++ odm->DebugComponents &= ~(ODM_COMP_DIG | ODM_COMP_FA_CNT); + break; + case HAL_DEF_DBG_RX_INFO_DUMP: + DBG_871X("============ Rx Info dump ===================\n"); @@ -46567,10 +45134,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + } + break; + case HW_DEF_ODM_DBG_FLAG: -+ ODM_CmnInfoUpdate(odm, ODM_CMNINFO_DBG_COMP, *((u64*)value)); ++ ODM_CmnInfoUpdate(odm, ODM_CMNINFO_DBG_COMP, *((u64 *)value)); + break; + case HW_DEF_ODM_DBG_LEVEL: -+ ODM_CmnInfoUpdate(odm, ODM_CMNINFO_DBG_LEVEL, *((u32*)value)); ++ ODM_CmnInfoUpdate(odm, ODM_CMNINFO_DBG_LEVEL, *((u32 *)value)); + break; + case HAL_DEF_DBG_DM_FUNC: + { @@ -46580,25 +45147,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + if (dm_func == 0) { /* disable all dynamic func */ + odm->SupportAbility = DYNAMIC_FUNC_DISABLE; + DBG_8192C("==> Disable all dynamic function...\n"); -+ } -+ else if (dm_func == 1) {/* disable DIG */ ++ } else if (dm_func == 1) {/* disable DIG */ + odm->SupportAbility &= (~DYNAMIC_BB_DIG); + DBG_8192C("==> Disable DIG...\n"); -+ } -+ else if (dm_func == 2) {/* disable High power */ ++ } else if (dm_func == 2) {/* disable High power */ + odm->SupportAbility &= (~DYNAMIC_BB_DYNAMIC_TXPWR); -+ } -+ else if (dm_func == 3) {/* disable tx power tracking */ ++ } else if (dm_func == 3) {/* disable tx power tracking */ + odm->SupportAbility &= (~DYNAMIC_RF_CALIBRATION); + DBG_8192C("==> Disable tx power tracking...\n"); -+ } -+ else if (dm_func == 4) {/* disable BT coexistence */ ++ } else if (dm_func == 4) {/* disable BT coexistence */ + dm->DMFlag &= (~DYNAMIC_FUNC_BT); -+ } -+ else if (dm_func == 5) {/* disable antenna diversity */ ++ } else if (dm_func == 5) {/* disable antenna diversity */ + odm->SupportAbility &= (~DYNAMIC_BB_ANT_DIV); -+ } -+ else if (dm_func == 6) {/* turn on all dynamic func */ ++ } else if (dm_func == 6) {/* turn on all dynamic func */ + if (!(odm->SupportAbility & DYNAMIC_BB_DIG)) { + DIG_T *pDigTable = &odm->DM_DigTable; + pDigTable->CurIGValue = rtw_read8(adapter, 0xc50); @@ -46627,67 +45188,67 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + return bResult; +} + -+u8 -+GetHalDefVar(struct adapter *adapter, enum HAL_DEF_VARIABLE variable, void *value) ++u8 GetHalDefVar( ++ struct adapter *adapter, enum HAL_DEF_VARIABLE variable, void *value ++) +{ + struct hal_com_data *hal_data = GET_HAL_DATA(adapter); + DM_ODM_T *odm = &(hal_data->odmpriv); + u8 bResult = _SUCCESS; + + switch (variable) { -+ case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB: -+ { -+ struct mlme_priv *pmlmepriv; -+ struct sta_priv *pstapriv; -+ struct sta_info *psta; ++ case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB: ++ { ++ struct mlme_priv *pmlmepriv; ++ struct sta_priv *pstapriv; ++ struct sta_info *psta; + -+ pmlmepriv = &adapter->mlmepriv; -+ pstapriv = &adapter->stapriv; -+ psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.MacAddress); -+ if (psta) -+ { -+ *((int*)value) = psta->rssi_stat.UndecoratedSmoothedPWDB; -+ } -+ } -+ break; -+ case HW_DEF_ODM_DBG_FLAG: -+ *((u64*)value) = odm->DebugComponents; -+ break; -+ case HW_DEF_ODM_DBG_LEVEL: -+ *((u32*)value) = odm->DebugLevel; -+ break; -+ case HAL_DEF_DBG_DM_FUNC: -+ *((u32*)value) =hal_data->odmpriv.SupportAbility; -+ break; -+ case HAL_DEF_DBG_DUMP_RXPKT: -+ *((u8 *)value) = hal_data->bDumpRxPkt; -+ break; -+ case HAL_DEF_DBG_DUMP_TXPKT: -+ *((u8 *)value) = hal_data->bDumpTxPkt; -+ break; -+ case HAL_DEF_ANT_DETECT: -+ *((u8 *)value) = hal_data->AntDetection; -+ break; -+ case HAL_DEF_MACID_SLEEP: -+ *(u8 *)value = false; -+ break; -+ case HAL_DEF_TX_PAGE_SIZE: -+ *((u32*)value) = PAGE_SIZE_128; -+ break; -+ default: -+ DBG_871X_LEVEL(_drv_always_, "%s: [WARNING] HAL_DEF_VARIABLE(%d) not defined!\n", __func__, variable); -+ bResult = _FAIL; -+ break; ++ pmlmepriv = &adapter->mlmepriv; ++ pstapriv = &adapter->stapriv; ++ psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.MacAddress); ++ if (psta) ++ *((int *)value) = psta->rssi_stat.UndecoratedSmoothedPWDB; ++ } ++ break; ++ case HW_DEF_ODM_DBG_FLAG: ++ *((u64 *)value) = odm->DebugComponents; ++ break; ++ case HW_DEF_ODM_DBG_LEVEL: ++ *((u32 *)value) = odm->DebugLevel; ++ break; ++ case HAL_DEF_DBG_DM_FUNC: ++ *((u32 *)value) = hal_data->odmpriv.SupportAbility; ++ break; ++ case HAL_DEF_DBG_DUMP_RXPKT: ++ *((u8 *)value) = hal_data->bDumpRxPkt; ++ break; ++ case HAL_DEF_DBG_DUMP_TXPKT: ++ *((u8 *)value) = hal_data->bDumpTxPkt; ++ break; ++ case HAL_DEF_ANT_DETECT: ++ *((u8 *)value) = hal_data->AntDetection; ++ break; ++ case HAL_DEF_MACID_SLEEP: ++ *(u8 *)value = false; ++ break; ++ case HAL_DEF_TX_PAGE_SIZE: ++ *((u32 *)value) = PAGE_SIZE_128; ++ break; ++ default: ++ DBG_871X_LEVEL(_drv_always_, "%s: [WARNING] HAL_DEF_VARIABLE(%d) not defined!\n", __func__, variable); ++ bResult = _FAIL; ++ break; + } + + return bResult; +} + +void GetHalODMVar( -+ struct adapter * Adapter, -+ enum HAL_ODM_VARIABLE eVariable, ++ struct adapter *Adapter, ++ enum HAL_ODM_VARIABLE eVariable, + void *pValue1, -+ void *pValue2) ++ void *pValue2 ++) +{ + switch (eVariable) { +#if defined(CONFIG_SIGNAL_DISPLAY_DBM) && defined(CONFIG_BACKGROUND_NOISE_MONITOR) @@ -46710,10 +45271,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +} + +void SetHalODMVar( -+ struct adapter * Adapter, -+ enum HAL_ODM_VARIABLE eVariable, -+ void * pValue1, -+ bool bSet) ++ struct adapter *Adapter, ++ enum HAL_ODM_VARIABLE eVariable, ++ void *pValue1, ++ bool bSet ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + PDM_ODM_T podmpriv = &pHalData->odmpriv; @@ -46725,14 +45287,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + if (bSet) { + DBG_8192C("### Set STA_(%d) info ###\n", psta->mac_id); + ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta); -+ } -+ else { ++ } else { + DBG_8192C("### Clean STA_(%d) info ###\n", psta->mac_id); + /* spin_lock_bh(&pHalData->odm_stainfo_lock); */ + ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, NULL); + + /* spin_unlock_bh(&pHalData->odm_stainfo_lock); */ -+ } ++ } + } + break; + case HAL_ODM_P2P_STATE: @@ -46769,19 +45330,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +} + + -+bool -+eqNByte( -+ u8*str1, -+ u8*str2, -+ u32 num -+ ) ++bool eqNByte(u8 *str1, u8 *str2, u32 num) +{ + if (num == 0) + return false; -+ while (num>0) -+ { ++ while (num > 0) { + num--; -+ if (str1[num]!=str2[num]) ++ if (str1[num] != str2[num]) + return false; + } + return true; @@ -46793,21 +45348,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +/* false otherwise. */ +/* */ +/* */ -+bool -+IsHexDigit( -+ char chTmp -+) ++bool IsHexDigit(char chTmp) +{ -+ if ((chTmp >= '0' && chTmp <= '9') || ++ if ( ++ (chTmp >= '0' && chTmp <= '9') || + (chTmp >= 'a' && chTmp <= 'f') || -+ (chTmp >= 'A' && chTmp <= 'F')) -+ { ++ (chTmp >= 'A' && chTmp <= 'F') ++ ) + return true; -+ } + else -+ { + return false; -+ } +} + + @@ -46815,10 +45365,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +/* Description: */ +/* Translate a character to hex digit. */ +/* */ -+u32 -+MapCharToHexDigit( -+ char chTmp -+) ++u32 MapCharToHexDigit(char chTmp) +{ + if (chTmp >= '0' && chTmp <= '9') + return (chTmp - '0'); @@ -46836,11 +45383,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +/* Parse hex number from the string pucStr. */ +bool GetHexValueFromString(char *szStr, u32 *pu4bVal, u32 *pu4bMove) +{ -+ char* szScan = szStr; ++ char *szScan = szStr; + + /* Check input parameter. */ -+ if (szStr == NULL || pu4bVal == NULL || pu4bMove == NULL) -+ { ++ if (szStr == NULL || pu4bVal == NULL || pu4bMove == NULL) { + DBG_871X("GetHexValueFromString(): Invalid inpur argumetns! szStr: %p, pu4bVal: %p, pu4bMove: %p\n", szStr, pu4bVal, pu4bMove); + return false; + } @@ -46850,16 +45396,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + *pu4bVal = 0; + + /* Skip leading space. */ -+ while (*szScan != '\0' && -+ (*szScan == ' ' || *szScan == '\t')) -+ { ++ while (*szScan != '\0' && (*szScan == ' ' || *szScan == '\t')) { + szScan++; + (*pu4bMove)++; + } + + /* Skip leading '0x' or '0X'. */ -+ if (*szScan == '0' && (*(szScan+1) == 'x' || *(szScan+1) == 'X')) -+ { ++ if (*szScan == '0' && (*(szScan+1) == 'x' || *(szScan+1) == 'X')) { + szScan += 2; + (*pu4bMove) += 2; + } @@ -46867,13 +45410,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + /* Check if szScan is now pointer to a character for hex digit, */ + /* if not, it means this is not a valid hex number. */ + if (!IsHexDigit(*szScan)) -+ { + return false; -+ } + + /* Parse each digit. */ -+ do -+ { ++ do { + (*pu4bVal) <<= 4; + *pu4bVal += MapCharToHexDigit(*szScan); + @@ -46884,8 +45424,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + return true; +} + -+bool GetFractionValueFromString(char *szStr, u8 *pInteger, u8 *pFraction, -+ u32 *pu4bMove) ++bool GetFractionValueFromString( ++ char *szStr, u8 *pInteger, u8 *pFraction, u32 *pu4bMove ++) +{ + char *szScan = szStr; + @@ -46908,8 +45449,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + ++szScan; + ++(*pu4bMove); + -+ if (*szScan == '.') -+ { ++ if (*szScan == '.') { + ++szScan; + ++(*pu4bMove); + @@ -46931,41 +45471,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +/* Description: */ +/* Return true if szStr is comment out with leading "//". */ +/* */ -+bool -+IsCommentString( -+ char *szStr -+) ++bool IsCommentString(char *szStr) +{ + if (*szStr == '/' && *(szStr+1) == '/') -+ { + return true; -+ } + else -+ { + return false; -+ } +} + -+bool -+GetU1ByteIntegerFromStringInDecimal( -+ char*Str, -+ u8* pInt -+ ) ++bool GetU1ByteIntegerFromStringInDecimal(char *Str, u8 *pInt) +{ + u16 i = 0; + *pInt = 0; + -+ while (Str[i] != '\0') -+ { -+ if (Str[i] >= '0' && Str[i] <= '9') -+ { ++ while (Str[i] != '\0') { ++ if (Str[i] >= '0' && Str[i] <= '9') { + *pInt *= 10; + *pInt += (Str[i] - '0'); -+ } -+ else -+ { ++ } else + return false; -+ } ++ + ++i; + } + @@ -46977,8 +45502,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + * a string "Hello [Kordan]". + * If RightQualifier does not exist, it will hang in the while loop + */ -+bool ParseQualifiedString(char *In, u32 *Start, char *Out, char LeftQualifier, -+ char RightQualifier) ++bool ParseQualifiedString( ++ char *In, u32 *Start, char *Out, char LeftQualifier, char RightQualifier ++) +{ + u32 i = 0, j = 0; + char c = In[(*Start)++]; @@ -46990,21 +45516,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + while ((c = In[(*Start)++]) != RightQualifier) + ; /* find ']' */ + j = (*Start) - 2; -+ strncpy((char *)Out, (const char*)(In+i), j-i+1); ++ strncpy((char *)Out, (const char *)(In+i), j-i+1); + + return true; +} + -+bool -+isAllSpaceOrTab( -+ u8*data, -+ u8 size -+ ) ++bool isAllSpaceOrTab(u8 *data, u8 size) +{ + u8 cnt = 0, NumOfSpaceAndTab = 0; + -+ while (size > cnt) -+ { ++ while (size > cnt) { + if (data[cnt] == ' ' || data[cnt] == '\t' || data[cnt] == '\0') + ++NumOfSpaceAndTab; + @@ -47019,7 +45540,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +{ + struct dvobj_priv *psdpriv = adapter->dvobj; + struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; -+ int save_cnt =false; ++ int save_cnt = false; + + /* switch counter to RX fifo */ + /* printk("8723b or 8192e , MAC_667 set 0xf0\n"); */ @@ -47027,8 +45548,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + save_cnt = true; + /* todo: other chips */ + -+ if (save_cnt) -+ { ++ if (save_cnt) { + /* rtw_write8(adapter, REG_RXERR_RPT+3, rtw_read8(adapter, REG_RXERR_RPT+3)|0xa0); */ + pdbgpriv->dbg_rx_fifo_last_overflow = pdbgpriv->dbg_rx_fifo_curr_overflow; + pdbgpriv->dbg_rx_fifo_curr_overflow = rtw_read16(adapter, REG_RXERR_RPT); @@ -47043,7 +45563,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + if (padapter->bLinkInfoDump == benable) + return; + -+ DBG_871X("%s %s\n", __func__, (benable)?"enable":"disable"); ++ DBG_871X("%s %s\n", __func__, (benable) ? "enable" : "disable"); + + if (benable) { + pwrctrlpriv->org_power_mgnt = pwrctrlpriv->power_mgnt;/* keep org value */ @@ -47051,37 +45571,48 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + + pwrctrlpriv->ips_org_mode = pwrctrlpriv->ips_mode;/* keep org value */ + rtw_pm_set_ips(padapter, IPS_NONE); -+ } -+ else { ++ } else { + rtw_pm_set_ips(padapter, pwrctrlpriv->ips_org_mode); + + rtw_pm_set_lps(padapter, pwrctrlpriv->ips_org_mode); + } -+ padapter->bLinkInfoDump = benable ; ++ padapter->bLinkInfoDump = benable; +} + +#ifdef DBG_RX_SIGNAL_DISPLAY_RAW_DATA +void rtw_get_raw_rssi_info(void *sel, struct adapter *padapter) +{ + u8 isCCKrate, rf_path; -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + struct rx_raw_rssi *psample_pkt_rssi = &padapter->recvpriv.raw_rssi_info; + -+ DBG_871X_SEL_NL(sel,"RxRate = %s, PWDBALL = %d(%%), rx_pwr_all = %d(dBm)\n", -+ HDATA_RATE(psample_pkt_rssi->data_rate), psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all); -+ isCCKrate = (psample_pkt_rssi->data_rate <= DESC_RATE11M)?true :false; ++ DBG_871X_SEL_NL( ++ sel, ++ "RxRate = %s, PWDBALL = %d(%%), rx_pwr_all = %d(dBm)\n", ++ HDATA_RATE(psample_pkt_rssi->data_rate), ++ psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all ++ ); ++ ++ isCCKrate = (psample_pkt_rssi->data_rate <= DESC_RATE11M) ? true : false; + + if (isCCKrate) + psample_pkt_rssi->mimo_singal_strength[0] = psample_pkt_rssi->pwdball; + -+ for (rf_path = 0;rf_pathNumTotalRFPath;rf_path++) -+ { -+ DBG_871X_SEL_NL(sel,"RF_PATH_%d =>singal_strength:%d(%%), singal_quality:%d(%%)\n" -+ , rf_path, psample_pkt_rssi->mimo_singal_strength[rf_path], psample_pkt_rssi->mimo_singal_quality[rf_path]); ++ for (rf_path = 0; rf_path < pHalData->NumTotalRFPath; rf_path++) { ++ DBG_871X_SEL_NL( ++ sel, ++ "RF_PATH_%d =>singal_strength:%d(%%), singal_quality:%d(%%)\n", ++ rf_path, psample_pkt_rssi->mimo_singal_strength[rf_path], ++ psample_pkt_rssi->mimo_singal_quality[rf_path] ++ ); + + if (!isCCKrate) { -+ DBG_871X_SEL_NL(sel,"\trx_ofdm_pwr:%d(dBm), rx_ofdm_snr:%d(dB)\n", -+ psample_pkt_rssi->ofdm_pwr[rf_path], psample_pkt_rssi->ofdm_snr[rf_path]); ++ DBG_871X_SEL_NL( ++ sel, ++ "\trx_ofdm_pwr:%d(dBm), rx_ofdm_snr:%d(dB)\n", ++ psample_pkt_rssi->ofdm_pwr[rf_path], ++ psample_pkt_rssi->ofdm_snr[rf_path] ++ ); + } + } +} @@ -47095,13 +45626,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + DBG_871X("RxRate = %s, PWDBALL = %d(%%), rx_pwr_all = %d(dBm)\n", + HDATA_RATE(psample_pkt_rssi->data_rate), psample_pkt_rssi->pwdball, psample_pkt_rssi->pwr_all); + -+ isCCKrate = (psample_pkt_rssi->data_rate <= DESC_RATE11M)?true :false; ++ isCCKrate = (psample_pkt_rssi->data_rate <= DESC_RATE11M) ? true : false; + + if (isCCKrate) + psample_pkt_rssi->mimo_singal_strength[0] = psample_pkt_rssi->pwdball; + -+ for (rf_path = 0;rf_pathNumTotalRFPath;rf_path++) -+ { ++ for (rf_path = 0; rf_path < pHalData->NumTotalRFPath; rf_path++) { + DBG_871X("RF_PATH_%d =>singal_strength:%d(%%), singal_quality:%d(%%)" + , rf_path, psample_pkt_rssi->mimo_singal_strength[rf_path], psample_pkt_rssi->mimo_singal_quality[rf_path]); + @@ -47124,13 +45654,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + struct rx_raw_rssi *psample_pkt_rssi = &padapter->recvpriv.raw_rssi_info; + + psample_pkt_rssi->data_rate = pattrib->data_rate; -+ isCCKrate = (pattrib->data_rate <= DESC_RATE11M)?true :false; ++ isCCKrate = (pattrib->data_rate <= DESC_RATE11M) ? true : false; + + psample_pkt_rssi->pwdball = pPhyInfo->RxPWDBAll; + psample_pkt_rssi->pwr_all = pPhyInfo->RecvSignalPower; + -+ for (rf_path = 0;rf_pathNumTotalRFPath;rf_path++) -+ { ++ for (rf_path = 0; rf_path < pHalData->NumTotalRFPath; rf_path++) { + psample_pkt_rssi->mimo_singal_strength[rf_path] = pPhyInfo->RxMIMOSignalStrength[rf_path]; + psample_pkt_rssi->mimo_singal_quality[rf_path] = pPhyInfo->RxMIMOSignalQuality[rf_path]; + if (!isCCKrate) { @@ -47142,24 +45671,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar +#endif + +static u32 Array_kfreemap[] = { -+0xf8, 0xe, -+0xf6, 0xc, -+0xf4, 0xa, -+0xf2, 0x8, -+0xf0, 0x6, -+0xf3, 0x4, -+0xf5, 0x2, -+0xf7, 0x0, -+0xf9, 0x0, -+0xfc, 0x0, ++ 0xf8, 0xe, ++ 0xf6, 0xc, ++ 0xf4, 0xa, ++ 0xf2, 0x8, ++ 0xf0, 0x6, ++ 0xf3, 0x4, ++ 0xf5, 0x2, ++ 0xf7, 0x0, ++ 0xf9, 0x0, ++ 0xfc, 0x0, +}; + +void rtw_bb_rf_gain_offset(struct adapter *padapter) +{ + u8 value = padapter->eeprompriv.EEPROMRFGainOffset; + u32 res, i = 0; -+ u32 ArrayLen = sizeof(Array_kfreemap)/sizeof(u32); -+ u32 * Array = Array_kfreemap; ++ u32 ArrayLen = sizeof(Array_kfreemap)/sizeof(u32); ++ u32 *Array = Array_kfreemap; + u32 v1 = 0, v2 = 0, target = 0; + /* DBG_871X("+%s value: 0x%02x+\n", __func__, value); */ + @@ -47171,14 +45700,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + res &= 0xfff87fff; + DBG_871X("Offset RF Gain. before reg 0x7f = 0x%08x\n", res); + /* res &= 0xfff87fff; */ -+ for (i = 0; i < ArrayLen; i += 2) -+ { ++ for (i = 0; i < ArrayLen; i += 2) { + v1 = Array[i]; + v2 = Array[i+1]; -+ if (v1 == padapter->eeprompriv.EEPROMRFGainVal) -+ { ++ if (v1 == padapter->eeprompriv.EEPROMRFGainVal) { + DBG_871X("Offset RF Gain. got v1 = 0x%x , v2 = 0x%x\n", v1, v2); -+ target =v2; ++ target = v2; + break; + } + } @@ -47189,19 +45716,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com.c linux-4.3-rtl8723bs/3rdpar + /* rtw_hal_write_rfreg(padapter, RF_PATH_A, REG_RF_BB_GAIN_OFFSET, RF_GAIN_OFFSET_MASK, res); */ + res = rtw_hal_read_rfreg(padapter, RF_PATH_A, 0x7f, 0xffffffff); + DBG_871X("Offset RF Gain. After reg 0x7f = 0x%08x\n", res); -+ } -+ else -+ { ++ } else + DBG_871X("Offset RF Gain. padapter->eeprompriv.EEPROMRFGainVal = 0x%x != 0xff, didn't run Kfree\n", padapter->eeprompriv.EEPROMRFGainVal); -+ } -+ } else { ++ } else + DBG_871X("Using the default RF gain.\n"); -+ } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_com_phycfg.c ---- linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_com_phycfg.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,3582 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux/3rdparty/rtl8723bs/hal/hal_com_phycfg.c +--- linux.old/3rdparty/rtl8723bs/hal/hal_com_phycfg.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/hal_com_phycfg.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,3288 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -47226,195 +45749,181 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + u8 TxNum, enum RATE_SECTION RateSection) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ u8 value = 0; ++ u8 value = 0; + -+ if (RfPath > ODM_RF_PATH_D) -+ { ++ if (RfPath > ODM_RF_PATH_D) { + DBG_871X("Invalid Rf Path %d in PHY_GetTxPowerByRateBase()\n", RfPath); + return 0; + } + -+ if (Band == BAND_ON_2_4G) -+ { ++ if (Band == BAND_ON_2_4G) { + switch (RateSection) { -+ case CCK: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0]; -+ break; -+ case OFDM: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1]; -+ break; -+ case HT_MCS0_MCS7: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2]; -+ break; -+ case HT_MCS8_MCS15: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3]; -+ break; -+ case HT_MCS16_MCS23: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4]; -+ break; -+ case HT_MCS24_MCS31: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5]; -+ break; -+ case VHT_1SSMCS0_1SSMCS9: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][6]; -+ break; -+ case VHT_2SSMCS0_2SSMCS9: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][7]; -+ break; -+ case VHT_3SSMCS0_3SSMCS9: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][8]; -+ break; -+ case VHT_4SSMCS0_4SSMCS9: -+ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9]; -+ break; -+ default: -+ DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n", -+ RateSection, RfPath, TxNum); -+ break; ++ case CCK: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0]; ++ break; ++ case OFDM: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1]; ++ break; ++ case HT_MCS0_MCS7: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2]; ++ break; ++ case HT_MCS8_MCS15: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3]; ++ break; ++ case HT_MCS16_MCS23: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4]; ++ break; ++ case HT_MCS24_MCS31: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5]; ++ break; ++ case VHT_1SSMCS0_1SSMCS9: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][6]; ++ break; ++ case VHT_2SSMCS0_2SSMCS9: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][7]; ++ break; ++ case VHT_3SSMCS0_3SSMCS9: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][8]; ++ break; ++ case VHT_4SSMCS0_4SSMCS9: ++ value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9]; ++ break; ++ default: ++ DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n", ++ RateSection, RfPath, TxNum); ++ break; + + }; -+ } -+ else if (Band == BAND_ON_5G) -+ { ++ } else if (Band == BAND_ON_5G) { + switch (RateSection) { -+ case OFDM: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][0]; -+ break; -+ case HT_MCS0_MCS7: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][1]; -+ break; -+ case HT_MCS8_MCS15: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][2]; -+ break; -+ case HT_MCS16_MCS23: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][3]; -+ break; -+ case HT_MCS24_MCS31: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][4]; -+ break; -+ case VHT_1SSMCS0_1SSMCS9: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][5]; -+ break; -+ case VHT_2SSMCS0_2SSMCS9: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][6]; -+ break; -+ case VHT_3SSMCS0_3SSMCS9: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][7]; -+ break; -+ case VHT_4SSMCS0_4SSMCS9: -+ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][8]; -+ break; -+ default: -+ DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n", -+ RateSection, RfPath, TxNum); -+ break; ++ case OFDM: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][0]; ++ break; ++ case HT_MCS0_MCS7: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][1]; ++ break; ++ case HT_MCS8_MCS15: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][2]; ++ break; ++ case HT_MCS16_MCS23: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][3]; ++ break; ++ case HT_MCS24_MCS31: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][4]; ++ break; ++ case VHT_1SSMCS0_1SSMCS9: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][5]; ++ break; ++ case VHT_2SSMCS0_2SSMCS9: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][6]; ++ break; ++ case VHT_3SSMCS0_3SSMCS9: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][7]; ++ break; ++ case VHT_4SSMCS0_4SSMCS9: ++ value = pHalData->TxPwrByRateBase5G[RfPath][TxNum][8]; ++ break; ++ default: ++ DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in PHY_GetTxPowerByRateBase()\n", ++ RateSection, RfPath, TxNum); ++ break; + }; -+ } -+ else -+ { ++ } else + DBG_871X("Invalid Band %d in PHY_GetTxPowerByRateBase()\n", Band); -+ } + + return value; +} + +static void +phy_SetTxPowerByRateBase( -+struct adapter * Adapter, -+u8 Band, -+u8 RfPath, -+enum RATE_SECTION RateSection, -+u8 TxNum, -+u8 Value -+ ) ++ struct adapter *Adapter, ++ u8 Band, ++ u8 RfPath, ++ enum RATE_SECTION RateSection, ++ u8 TxNum, ++ u8 Value ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + -+ if (RfPath > ODM_RF_PATH_D) -+ { ++ if (RfPath > ODM_RF_PATH_D) { + DBG_871X("Invalid Rf Path %d in phy_SetTxPowerByRatBase()\n", RfPath); + return; + } + -+ if (Band == BAND_ON_2_4G) -+ { ++ if (Band == BAND_ON_2_4G) { + switch (RateSection) { -+ case CCK: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0] = Value; -+ break; -+ case OFDM: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1] = Value; -+ break; -+ case HT_MCS0_MCS7: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2] = Value; -+ break; -+ case HT_MCS8_MCS15: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3] = Value; -+ break; -+ case HT_MCS16_MCS23: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4] = Value; -+ break; -+ case HT_MCS24_MCS31: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5] = Value; -+ break; -+ case VHT_1SSMCS0_1SSMCS9: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][6] = Value; -+ break; -+ case VHT_2SSMCS0_2SSMCS9: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][7] = Value; -+ break; -+ case VHT_3SSMCS0_3SSMCS9: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][8] = Value; -+ break; -+ case VHT_4SSMCS0_4SSMCS9: -+ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9] = Value; -+ break; -+ default: -+ DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n", -+ RateSection, RfPath, TxNum); -+ break; ++ case CCK: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0] = Value; ++ break; ++ case OFDM: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1] = Value; ++ break; ++ case HT_MCS0_MCS7: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2] = Value; ++ break; ++ case HT_MCS8_MCS15: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3] = Value; ++ break; ++ case HT_MCS16_MCS23: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4] = Value; ++ break; ++ case HT_MCS24_MCS31: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5] = Value; ++ break; ++ case VHT_1SSMCS0_1SSMCS9: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][6] = Value; ++ break; ++ case VHT_2SSMCS0_2SSMCS9: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][7] = Value; ++ break; ++ case VHT_3SSMCS0_3SSMCS9: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][8] = Value; ++ break; ++ case VHT_4SSMCS0_4SSMCS9: ++ pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][9] = Value; ++ break; ++ default: ++ DBG_871X("Invalid RateSection %d in Band 2.4G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n", ++ RateSection, RfPath, TxNum); ++ break; + }; -+ } -+ else if (Band == BAND_ON_5G) -+ { ++ } else if (Band == BAND_ON_5G) { + switch (RateSection) { -+ case OFDM: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][0] = Value; -+ break; -+ case HT_MCS0_MCS7: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][1] = Value; -+ break; -+ case HT_MCS8_MCS15: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][2] = Value; -+ break; -+ case HT_MCS16_MCS23: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][3] = Value; -+ break; -+ case HT_MCS24_MCS31: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][4] = Value; -+ break; -+ case VHT_1SSMCS0_1SSMCS9: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][5] = Value; -+ break; -+ case VHT_2SSMCS0_2SSMCS9: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][6] = Value; -+ break; -+ case VHT_3SSMCS0_3SSMCS9: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][7] = Value; -+ break; -+ case VHT_4SSMCS0_4SSMCS9: -+ pHalData->TxPwrByRateBase5G[RfPath][TxNum][8] = Value; -+ break; -+ default: -+ DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n", -+ RateSection, RfPath, TxNum); -+ break; ++ case OFDM: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][0] = Value; ++ break; ++ case HT_MCS0_MCS7: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][1] = Value; ++ break; ++ case HT_MCS8_MCS15: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][2] = Value; ++ break; ++ case HT_MCS16_MCS23: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][3] = Value; ++ break; ++ case HT_MCS24_MCS31: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][4] = Value; ++ break; ++ case VHT_1SSMCS0_1SSMCS9: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][5] = Value; ++ break; ++ case VHT_2SSMCS0_2SSMCS9: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][6] = Value; ++ break; ++ case VHT_3SSMCS0_3SSMCS9: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][7] = Value; ++ break; ++ case VHT_4SSMCS0_4SSMCS9: ++ pHalData->TxPwrByRateBase5G[RfPath][TxNum][8] = Value; ++ break; ++ default: ++ DBG_871X("Invalid RateSection %d in Band 5G, Rf Path %d, %dTx in phy_SetTxPowerByRateBase()\n", ++ RateSection, RfPath, TxNum); ++ break; + }; -+ } -+ else -+ { ++ } else + DBG_871X("Invalid Band %d in phy_SetTxPowerByRateBase()\n", Band); -+ } +} + +static void @@ -47426,8 +45935,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + + /* DBG_871X("===>%s\n", __func__); */ + -+ for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; ++path) -+ { ++ for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; ++path) { + base = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, path, RF_1TX, MGN_11M); + phy_SetTxPowerByRateBase(padapter, BAND_ON_2_4G, path, CCK, RF_1TX, base); + /* DBG_871X("Power index base of 2.4G path %d 1Tx CCK = > 0x%x\n", path, base); */ @@ -47492,45 +46000,68 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + /* DBG_871X("<===%s\n", __func__); */ +} + -+u8 -+PHY_GetRateSectionIndexOfTxPowerByRate( -+struct adapter *padapter, -+u32 RegAddr, -+u32 BitMask -+ ) ++u8 PHY_GetRateSectionIndexOfTxPowerByRate( ++ struct adapter *padapter, u32 RegAddr, u32 BitMask ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; -+ u8 index = 0; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ u8 index = 0; + -+ if (pDM_Odm->PhyRegPgVersion == 0) -+ { -+ switch (RegAddr) -+ { -+ case rTxAGC_A_Rate18_06: index = 0; break; -+ case rTxAGC_A_Rate54_24: index = 1; break; -+ case rTxAGC_A_CCK1_Mcs32: index = 6; break; -+ case rTxAGC_B_CCK11_A_CCK2_11: -+ if (BitMask == bMaskH3Bytes) -+ index = 7; -+ else if (BitMask == 0x000000ff) -+ index = 15; -+ break; ++ if (pDM_Odm->PhyRegPgVersion == 0) { ++ switch (RegAddr) { ++ case rTxAGC_A_Rate18_06: ++ index = 0; ++ break; ++ case rTxAGC_A_Rate54_24: ++ index = 1; ++ break; ++ case rTxAGC_A_CCK1_Mcs32: ++ index = 6; ++ break; ++ case rTxAGC_B_CCK11_A_CCK2_11: ++ if (BitMask == bMaskH3Bytes) ++ index = 7; ++ else if (BitMask == 0x000000ff) ++ index = 15; ++ break; + -+ case rTxAGC_A_Mcs03_Mcs00: index = 2; break; -+ case rTxAGC_A_Mcs07_Mcs04: index = 3; break; -+ case rTxAGC_A_Mcs11_Mcs08: index = 4; break; -+ case rTxAGC_A_Mcs15_Mcs12: index = 5; break; -+ case rTxAGC_B_Rate18_06: index = 8; break; -+ case rTxAGC_B_Rate54_24: index = 9; break; -+ case rTxAGC_B_CCK1_55_Mcs32: index = 14; break; -+ case rTxAGC_B_Mcs03_Mcs00: index = 10; break; -+ case rTxAGC_B_Mcs07_Mcs04: index = 11; break; -+ case rTxAGC_B_Mcs11_Mcs08: index = 12; break; -+ case rTxAGC_B_Mcs15_Mcs12: index = 13; break; -+ default: -+ DBG_871X("Invalid RegAddr 0x3%x in PHY_GetRateSectionIndexOfTxPowerByRate()", RegAddr); -+ break; ++ case rTxAGC_A_Mcs03_Mcs00: ++ index = 2; ++ break; ++ case rTxAGC_A_Mcs07_Mcs04: ++ index = 3; ++ break; ++ case rTxAGC_A_Mcs11_Mcs08: ++ index = 4; ++ break; ++ case rTxAGC_A_Mcs15_Mcs12: ++ index = 5; ++ break; ++ case rTxAGC_B_Rate18_06: ++ index = 8; ++ break; ++ case rTxAGC_B_Rate54_24: ++ index = 9; ++ break; ++ case rTxAGC_B_CCK1_55_Mcs32: ++ index = 14; ++ break; ++ case rTxAGC_B_Mcs03_Mcs00: ++ index = 10; ++ break; ++ case rTxAGC_B_Mcs07_Mcs04: ++ index = 11; ++ break; ++ case rTxAGC_B_Mcs11_Mcs08: ++ index = 12; ++ break; ++ case rTxAGC_B_Mcs15_Mcs12: ++ index = 13; ++ break; ++ default: ++ DBG_871X("Invalid RegAddr 0x3%x in PHY_GetRateSectionIndexOfTxPowerByRate()", RegAddr); ++ break; + }; + } + @@ -47539,488 +46070,444 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + +void +PHY_GetRateValuesOfTxPowerByRate( -+struct adapter *padapter, -+u32 RegAddr, -+u32 BitMask, -+u32 Value, -+ u8 * RateIndex, -+ s8 * PwrByRateVal, -+ u8 * RateNum -+ ) ++ struct adapter *padapter, ++ u32 RegAddr, ++ u32 BitMask, ++ u32 Value, ++ u8 *RateIndex, ++ s8 *PwrByRateVal, ++ u8 *RateNum ++) +{ + u8 i = 0; + -+ switch (RegAddr) -+ { -+ case rTxAGC_A_Rate18_06: -+ case rTxAGC_B_Rate18_06: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_6M); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_9M); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_12M); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_18M); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ switch (RegAddr) { ++ case rTxAGC_A_Rate18_06: ++ case rTxAGC_B_Rate18_06: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_6M); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_9M); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_12M); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_18M); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case rTxAGC_A_Rate54_24: -+ case rTxAGC_B_Rate54_24: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_24M); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_36M); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_48M); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_54M); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case rTxAGC_A_Rate54_24: ++ case rTxAGC_B_Rate54_24: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_24M); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_36M); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_48M); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_54M); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case rTxAGC_A_CCK1_Mcs32: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M); -+ PwrByRateVal[0] = (s8) ((((Value >> (8 + 4)) & 0xF)) * 10 + -+ ((Value >> 8) & 0xF)); -+ *RateNum = 1; -+ break; ++ case rTxAGC_A_CCK1_Mcs32: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M); ++ PwrByRateVal[0] = (s8) ((((Value >> (8 + 4)) & 0xF)) * 10 + ++ ((Value >> 8) & 0xF)); ++ *RateNum = 1; ++ break; + -+ case rTxAGC_B_CCK11_A_CCK2_11: -+ if (BitMask == 0xffffff00) -+ { -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M); -+ for (i = 1; i < 4; ++ i) -+ { -+ PwrByRateVal[i - 1] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 3; -+ } -+ else if (BitMask == 0x000000ff) -+ { -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M); -+ PwrByRateVal[0] = (s8) ((((Value >> 4) & 0xF)) * 10 + -+ (Value & 0xF)); -+ *RateNum = 1; -+ } -+ break; -+ -+ case rTxAGC_A_Mcs03_Mcs00: -+ case rTxAGC_B_Mcs03_Mcs00: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS0); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS1); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS2); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS3); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; -+ -+ case rTxAGC_A_Mcs07_Mcs04: -+ case rTxAGC_B_Mcs07_Mcs04: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS4); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS5); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS6); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS7); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; -+ -+ case rTxAGC_A_Mcs11_Mcs08: -+ case rTxAGC_B_Mcs11_Mcs08: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS8); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS9); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS10); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS11); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; -+ -+ case rTxAGC_A_Mcs15_Mcs12: -+ case rTxAGC_B_Mcs15_Mcs12: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS12); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS13); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS14); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS15); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ -+ break; -+ -+ case rTxAGC_B_CCK1_55_Mcs32: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M); -+ for (i = 1; i < 4; ++ i) -+ { ++ case rTxAGC_B_CCK11_A_CCK2_11: ++ if (BitMask == 0xffffff00) { ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M); ++ for (i = 1; i < 4; ++i) { + PwrByRateVal[i - 1] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + + ((Value >> (i * 8)) & 0xF)); + } + *RateNum = 3; -+ break; ++ } else if (BitMask == 0x000000ff) { ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M); ++ PwrByRateVal[0] = (s8) ((((Value >> 4) & 0xF)) * 10 + (Value & 0xF)); ++ *RateNum = 1; ++ } ++ break; + -+ case 0xC20: -+ case 0xE20: -+ case 0x1820: -+ case 0x1a20: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case rTxAGC_A_Mcs03_Mcs00: ++ case rTxAGC_B_Mcs03_Mcs00: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS0); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS1); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS2); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS3); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xC24: -+ case 0xE24: -+ case 0x1824: -+ case 0x1a24: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_6M); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_9M); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_12M); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_18M); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case rTxAGC_A_Mcs07_Mcs04: ++ case rTxAGC_B_Mcs07_Mcs04: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS4); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS5); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS6); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS7); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xC28: -+ case 0xE28: -+ case 0x1828: -+ case 0x1a28: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_24M); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_36M); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_48M); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_54M); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case rTxAGC_A_Mcs11_Mcs08: ++ case rTxAGC_B_Mcs11_Mcs08: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS8); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS9); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS10); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS11); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xC2C: -+ case 0xE2C: -+ case 0x182C: -+ case 0x1a2C: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS0); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS1); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS2); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS3); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case rTxAGC_A_Mcs15_Mcs12: ++ case rTxAGC_B_Mcs15_Mcs12: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS12); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS13); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS14); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS15); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; + -+ case 0xC30: -+ case 0xE30: -+ case 0x1830: -+ case 0x1a30: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS4); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS5); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS6); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS7); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ break; + -+ case 0xC34: -+ case 0xE34: -+ case 0x1834: -+ case 0x1a34: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS8); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS9); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS10); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS11); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case rTxAGC_B_CCK1_55_Mcs32: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M); ++ for (i = 1; i < 4; ++i) { ++ PwrByRateVal[i - 1] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 3; ++ break; + -+ case 0xC38: -+ case 0xE38: -+ case 0x1838: -+ case 0x1a38: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS12); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS13); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS14); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS15); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC20: ++ case 0xE20: ++ case 0x1820: ++ case 0x1a20: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_5_5M); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_11M); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xC3C: -+ case 0xE3C: -+ case 0x183C: -+ case 0x1a3C: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS0); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS1); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS2); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS3); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC24: ++ case 0xE24: ++ case 0x1824: ++ case 0x1a24: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_6M); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_9M); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_12M); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_18M); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xC40: -+ case 0xE40: -+ case 0x1840: -+ case 0x1a40: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS4); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS5); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS6); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS7); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC28: ++ case 0xE28: ++ case 0x1828: ++ case 0x1a28: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_24M); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_36M); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_48M); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_54M); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xC44: -+ case 0xE44: -+ case 0x1844: -+ case 0x1a44: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS8); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS9); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS0); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS1); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC2C: ++ case 0xE2C: ++ case 0x182C: ++ case 0x1a2C: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS0); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS1); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS2); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS3); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xC48: -+ case 0xE48: -+ case 0x1848: -+ case 0x1a48: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS2); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS3); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS4); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS5); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC30: ++ case 0xE30: ++ case 0x1830: ++ case 0x1a30: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS4); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS5); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS6); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS7); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xC4C: -+ case 0xE4C: -+ case 0x184C: -+ case 0x1a4C: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS6); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS7); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS8); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS9); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC34: ++ case 0xE34: ++ case 0x1834: ++ case 0x1a34: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS8); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS9); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS10); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS11); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xCD8: -+ case 0xED8: -+ case 0x18D8: -+ case 0x1aD8: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS16); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS17); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS18); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS19); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC38: ++ case 0xE38: ++ case 0x1838: ++ case 0x1a38: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS12); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS13); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS14); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS15); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xCDC: -+ case 0xEDC: -+ case 0x18DC: -+ case 0x1aDC: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS20); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS21); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS22); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS23); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC3C: ++ case 0xE3C: ++ case 0x183C: ++ case 0x1a3C: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS0); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS1); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS2); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS3); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xCE0: -+ case 0xEE0: -+ case 0x18E0: -+ case 0x1aE0: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS0); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS1); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS2); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS3); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC40: ++ case 0xE40: ++ case 0x1840: ++ case 0x1a40: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS4); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS5); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS6); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS7); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xCE4: -+ case 0xEE4: -+ case 0x18E4: -+ case 0x1aE4: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS4); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS5); -+ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS6); -+ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS7); -+ for (i = 0; i < 4; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC44: ++ case 0xE44: ++ case 0x1844: ++ case 0x1a44: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS8); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT1SS_MCS9); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS0); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS1); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ case 0xCE8: -+ case 0xEE8: -+ case 0x18E8: -+ case 0x1aE8: -+ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS8); -+ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS9); -+ for (i = 0; i < 2; ++ i) -+ { -+ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + -+ ((Value >> (i * 8)) & 0xF)); -+ } -+ *RateNum = 4; -+ break; ++ case 0xC48: ++ case 0xE48: ++ case 0x1848: ++ case 0x1a48: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS2); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS3); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS4); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS5); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; + -+ default: -+ DBG_871X("Invalid RegAddr 0x%x in %s()\n", RegAddr, __func__); -+ break; ++ case 0xC4C: ++ case 0xE4C: ++ case 0x184C: ++ case 0x1a4C: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS6); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS7); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS8); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS9); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; ++ ++ case 0xCD8: ++ case 0xED8: ++ case 0x18D8: ++ case 0x1aD8: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS16); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS17); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS18); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS19); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; ++ ++ case 0xCDC: ++ case 0xEDC: ++ case 0x18DC: ++ case 0x1aDC: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS20); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS21); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS22); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS23); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; ++ ++ case 0xCE0: ++ case 0xEE0: ++ case 0x18E0: ++ case 0x1aE0: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS0); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS1); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS2); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS3); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; ++ ++ case 0xCE4: ++ case 0xEE4: ++ case 0x18E4: ++ case 0x1aE4: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS4); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS5); ++ RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS6); ++ RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS7); ++ for (i = 0; i < 4; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; ++ ++ case 0xCE8: ++ case 0xEE8: ++ case 0x18E8: ++ case 0x1aE8: ++ RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS8); ++ RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_VHT3SS_MCS9); ++ for (i = 0; i < 2; ++i) { ++ PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + ++ ((Value >> (i * 8)) & 0xF)); ++ } ++ *RateNum = 4; ++ break; ++ ++ default: ++ DBG_871X("Invalid RegAddr 0x%x in %s()\n", RegAddr, __func__); ++ break; + }; +} + -+static void -+PHY_StoreTxPowerByRateNew( -+struct adapter *padapter, -+u32 Band, -+u32 RfPath, -+u32 TxNum, -+u32 RegAddr, -+u32 BitMask, -+u32 Data -+ ) ++static void PHY_StoreTxPowerByRateNew( ++ struct adapter *padapter, ++ u32 Band, ++ u32 RfPath, ++ u32 TxNum, ++ u32 RegAddr, ++ u32 BitMask, ++ u32 Data ++) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + u8 i = 0, rateIndex[4] = {0}, rateNum = 0; + s8 PwrByRateVal[4] = {0}; + + PHY_GetRateValuesOfTxPowerByRate(padapter, RegAddr, BitMask, Data, rateIndex, PwrByRateVal, &rateNum); + -+ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) -+ { ++ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) { + DBG_871X("Invalid Band %d\n", Band); + return; + } + -+ if (RfPath > ODM_RF_PATH_D) -+ { ++ if (RfPath > ODM_RF_PATH_D) { + DBG_871X("Invalid RfPath %d\n", RfPath); + return; + } + -+ if (TxNum > ODM_RF_PATH_D) -+ { ++ if (TxNum > ODM_RF_PATH_D) { + DBG_871X("Invalid TxNum %d\n", TxNum); + return; + } + -+ for (i = 0; i < rateNum; ++i) -+ { ++ for (i = 0; i < rateNum; ++i) { + if (rateIndex[i] == PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS0) || + rateIndex[i] == PHY_GetRateIndexOfTxPowerByRate(MGN_VHT2SS_MCS1)) -+ { + TxNum = RF_2TX; -+ } + + pHalData->TxPwrByRateOffset[Band][RfPath][TxNum][rateIndex[i]] = PwrByRateVal[i]; + } +} + -+static void -+PHY_StoreTxPowerByRateOld( -+struct adapter * padapter, -+u32 RegAddr, -+u32 BitMask, -+u32 Data -+ ) ++static void PHY_StoreTxPowerByRateOld( ++ struct adapter *padapter, u32 RegAddr, u32 BitMask, u32 Data ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ u8 index = PHY_GetRateSectionIndexOfTxPowerByRate(padapter, RegAddr, BitMask); ++ u8 index = PHY_GetRateSectionIndexOfTxPowerByRate(padapter, RegAddr, BitMask); + + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][index] = Data; + /* DBG_871X("MCSTxPowerLevelOriginalOffset[%d][0] = 0x%x\n", pHalData->pwrGroupCnt, */ -+ /* pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0]); */ ++ /* pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0]); */ +} + -+void -+PHY_InitTxPowerByRate( -+struct adapter *padapter -+ ) ++void PHY_InitTxPowerByRate(struct adapter *padapter) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + u8 band, rfPath, TxNum, rate; @@ -48032,34 +46519,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + pHalData->TxPwrByRateOffset[band][rfPath][TxNum][rate] = 0; +} + -+void -+PHY_StoreTxPowerByRate( -+struct adapter *padapter, -+u32 Band, -+u32 RfPath, -+u32 TxNum, -+u32 RegAddr, -+u32 BitMask, -+u32 Data -+ ) ++void PHY_StoreTxPowerByRate( ++ struct adapter *padapter, ++ u32 Band, ++ u32 RfPath, ++ u32 TxNum, ++ u32 RegAddr, ++ u32 BitMask, ++ u32 Data ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + + if (pDM_Odm->PhyRegPgVersion > 0) -+ { + PHY_StoreTxPowerByRateNew(padapter, Band, RfPath, TxNum, RegAddr, BitMask, Data); -+ } -+ else if (pDM_Odm->PhyRegPgVersion == 0) -+ { ++ else if (pDM_Odm->PhyRegPgVersion == 0) { + PHY_StoreTxPowerByRateOld(padapter, RegAddr, BitMask, Data); + + if (RegAddr == rTxAGC_A_Mcs15_Mcs12 && pHalData->rf_type == RF_1T1R) + pHalData->pwrGroupCnt++; + else if (RegAddr == rTxAGC_B_Mcs15_Mcs12 && pHalData->rf_type != RF_1T1R) + pHalData->pwrGroupCnt++; -+ } -+ else ++ } else + DBG_871X("Invalid PHY_REG_PG.txt version %d\n", pDM_Odm->PhyRegPgVersion); + +} @@ -48069,88 +46551,92 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs +struct adapter *padapter + ) +{ -+ u8 base = 0, i = 0, value = 0, -+ band = 0, path = 0, txNum = 0; -+ u8 cckRates[4] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M}, -+ ofdmRates[8] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M}, -+ mcs0_7Rates[8] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7}, -+ mcs8_15Rates[8] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15}, -+ mcs16_23Rates[8] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23}, -+ vht1ssRates[10] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4, -+ MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9}, -+ vht2ssRates[10] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4, -+ MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9}, -+ vht3ssRates[10] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4, -+ MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9}; ++ u8 base = 0, i = 0, value = 0, band = 0, path = 0, txNum = 0; ++ u8 cckRates[4] = { ++ MGN_1M, MGN_2M, MGN_5_5M, MGN_11M ++ }; ++ u8 ofdmRates[8] = { ++ MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M ++ }; ++ u8 mcs0_7Rates[8] = { ++ MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7 ++ }; ++ u8 mcs8_15Rates[8] = { ++ MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15 ++ }; ++ u8 mcs16_23Rates[8] = { ++ MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23 ++ }; ++ u8 vht1ssRates[10] = { ++ MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4, ++ MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9 ++ }; ++ u8 vht2ssRates[10] = { ++ MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4, ++ MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9 ++ }; ++ u8 vht3ssRates[10] = { ++ MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4, ++ MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9 ++ }; + + /* DBG_871X("===>PHY_ConvertTxPowerByRateInDbmToRelativeValues()\n"); */ + -+ for (band = BAND_ON_2_4G; band <= BAND_ON_5G; ++band) -+ { -+ for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path) -+ { -+ for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) -+ { ++ for (band = BAND_ON_2_4G; band <= BAND_ON_5G; ++band) { ++ for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path) { ++ for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) { + /* CCK */ + base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_11M); -+ for (i = 0; i < sizeof(cckRates); ++i) -+ { ++ for (i = 0; i < sizeof(cckRates); ++i) { + value = PHY_GetTxPowerByRate(padapter, band, path, txNum, cckRates[i]); + PHY_SetTxPowerByRate(padapter, band, path, txNum, cckRates[i], value - base); + } + + /* OFDM */ + base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_54M); -+ for (i = 0; i < sizeof(ofdmRates); ++i) -+ { ++ for (i = 0; i < sizeof(ofdmRates); ++i) { + value = PHY_GetTxPowerByRate(padapter, band, path, txNum, ofdmRates[i]); + PHY_SetTxPowerByRate(padapter, band, path, txNum, ofdmRates[i], value - base); + } + + /* HT MCS0~7 */ + base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_MCS7); -+ for (i = 0; i < sizeof(mcs0_7Rates); ++i) -+ { ++ for (i = 0; i < sizeof(mcs0_7Rates); ++i) { + value = PHY_GetTxPowerByRate(padapter, band, path, txNum, mcs0_7Rates[i]); + PHY_SetTxPowerByRate(padapter, band, path, txNum, mcs0_7Rates[i], value - base); + } + + /* HT MCS8~15 */ + base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_MCS15); -+ for (i = 0; i < sizeof(mcs8_15Rates); ++i) -+ { ++ for (i = 0; i < sizeof(mcs8_15Rates); ++i) { + value = PHY_GetTxPowerByRate(padapter, band, path, txNum, mcs8_15Rates[i]); + PHY_SetTxPowerByRate(padapter, band, path, txNum, mcs8_15Rates[i], value - base); + } + + /* HT MCS16~23 */ + base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_MCS23); -+ for (i = 0; i < sizeof(mcs16_23Rates); ++i) -+ { ++ for (i = 0; i < sizeof(mcs16_23Rates); ++i) { + value = PHY_GetTxPowerByRate(padapter, band, path, txNum, mcs16_23Rates[i]); + PHY_SetTxPowerByRate(padapter, band, path, txNum, mcs16_23Rates[i], value - base); + } + + /* VHT 1SS */ + base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_VHT1SS_MCS7); -+ for (i = 0; i < sizeof(vht1ssRates); ++i) -+ { ++ for (i = 0; i < sizeof(vht1ssRates); ++i) { + value = PHY_GetTxPowerByRate(padapter, band, path, txNum, vht1ssRates[i]); + PHY_SetTxPowerByRate(padapter, band, path, txNum, vht1ssRates[i], value - base); + } + + /* VHT 2SS */ + base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_VHT2SS_MCS7); -+ for (i = 0; i < sizeof(vht2ssRates); ++i) -+ { ++ for (i = 0; i < sizeof(vht2ssRates); ++i) { + value = PHY_GetTxPowerByRate(padapter, band, path, txNum, vht2ssRates[i]); + PHY_SetTxPowerByRate(padapter, band, path, txNum, vht2ssRates[i], value - base); + } + + /* VHT 3SS */ + base = PHY_GetTxPowerByRate(padapter, band, path, txNum, MGN_VHT3SS_MCS7); -+ for (i = 0; i < sizeof(vht3ssRates); ++i) -+ { ++ for (i = 0; i < sizeof(vht3ssRates); ++i) { + value = PHY_GetTxPowerByRate(padapter, band, path, txNum, vht3ssRates[i]); + PHY_SetTxPowerByRate(padapter, band, path, txNum, vht3ssRates[i], value - base); + } @@ -48165,130 +46651,95 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + * This function must be called if the value in the PHY_REG_PG.txt(or header) + * is exact dBm values + */ -+void -+PHY_TxPowerByRateConfiguration( -+ struct adapter * padapter -+ ) ++void PHY_TxPowerByRateConfiguration(struct adapter *padapter) +{ + phy_StoreTxPowerByRateBase(padapter); + phy_ConvertTxPowerByRateInDbmToRelativeValues(padapter); +} + -+void -+PHY_SetTxPowerIndexByRateSection( -+struct adapter * padapter, -+u8 RFPath, -+u8 Channel, -+u8 RateSection -+ ) ++void PHY_SetTxPowerIndexByRateSection( ++ struct adapter *padapter, u8 RFPath, u8 Channel, u8 RateSection ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + -+ if (RateSection == CCK) -+ { ++ if (RateSection == CCK) { + u8 cckRates[] = {MGN_1M, MGN_2M, MGN_5_5M, MGN_11M}; + if (pHalData->CurrentBandType == BAND_ON_2_4G) + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + cckRates, sizeof(cckRates)/sizeof(u8)); + -+ } -+ else if (RateSection == OFDM) -+ { ++ } else if (RateSection == OFDM) { + u8 ofdmRates[] = {MGN_6M, MGN_9M, MGN_12M, MGN_18M, MGN_24M, MGN_36M, MGN_48M, MGN_54M}; + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + ofdmRates, sizeof(ofdmRates)/sizeof(u8)); + -+ } -+ else if (RateSection == HT_MCS0_MCS7) -+ { ++ } else if (RateSection == HT_MCS0_MCS7) { + u8 htRates1T[] = {MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7}; + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + htRates1T, sizeof(htRates1T)/sizeof(u8)); + -+ } -+ else if (RateSection == HT_MCS8_MCS15) -+ { ++ } else if (RateSection == HT_MCS8_MCS15) { + u8 htRates2T[] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15}; + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + htRates2T, sizeof(htRates2T)/sizeof(u8)); + -+ } -+ else if (RateSection == HT_MCS16_MCS23) -+ { ++ } else if (RateSection == HT_MCS16_MCS23) { + u8 htRates3T[] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23}; + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + htRates3T, sizeof(htRates3T)/sizeof(u8)); + -+ } -+ else if (RateSection == HT_MCS24_MCS31) -+ { ++ } else if (RateSection == HT_MCS24_MCS31) { + u8 htRates4T[] = {MGN_MCS24, MGN_MCS25, MGN_MCS26, MGN_MCS27, MGN_MCS28, MGN_MCS29, MGN_MCS30, MGN_MCS31}; + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + htRates4T, sizeof(htRates4T)/sizeof(u8)); + -+ } -+ else if (RateSection == VHT_1SSMCS0_1SSMCS9) -+ { ++ } else if (RateSection == VHT_1SSMCS0_1SSMCS9) { + u8 vhtRates1T[] = {MGN_VHT1SS_MCS0, MGN_VHT1SS_MCS1, MGN_VHT1SS_MCS2, MGN_VHT1SS_MCS3, MGN_VHT1SS_MCS4, + MGN_VHT1SS_MCS5, MGN_VHT1SS_MCS6, MGN_VHT1SS_MCS7, MGN_VHT1SS_MCS8, MGN_VHT1SS_MCS9}; + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + vhtRates1T, sizeof(vhtRates1T)/sizeof(u8)); + -+ } -+ else if (RateSection == VHT_2SSMCS0_2SSMCS9) -+ { ++ } else if (RateSection == VHT_2SSMCS0_2SSMCS9) { + u8 vhtRates2T[] = {MGN_VHT2SS_MCS0, MGN_VHT2SS_MCS1, MGN_VHT2SS_MCS2, MGN_VHT2SS_MCS3, MGN_VHT2SS_MCS4, + MGN_VHT2SS_MCS5, MGN_VHT2SS_MCS6, MGN_VHT2SS_MCS7, MGN_VHT2SS_MCS8, MGN_VHT2SS_MCS9}; + + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + vhtRates2T, sizeof(vhtRates2T)/sizeof(u8)); -+ } -+ else if (RateSection == VHT_3SSMCS0_3SSMCS9) -+ { ++ } else if (RateSection == VHT_3SSMCS0_3SSMCS9) { + u8 vhtRates3T[] = {MGN_VHT3SS_MCS0, MGN_VHT3SS_MCS1, MGN_VHT3SS_MCS2, MGN_VHT3SS_MCS3, MGN_VHT3SS_MCS4, + MGN_VHT3SS_MCS5, MGN_VHT3SS_MCS6, MGN_VHT3SS_MCS7, MGN_VHT3SS_MCS8, MGN_VHT3SS_MCS9}; + + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + vhtRates3T, sizeof(vhtRates3T)/sizeof(u8)); -+ } -+ else if (RateSection == VHT_4SSMCS0_4SSMCS9) -+ { ++ } else if (RateSection == VHT_4SSMCS0_4SSMCS9) { + u8 vhtRates4T[] = {MGN_VHT4SS_MCS0, MGN_VHT4SS_MCS1, MGN_VHT4SS_MCS2, MGN_VHT4SS_MCS3, MGN_VHT4SS_MCS4, + MGN_VHT4SS_MCS5, MGN_VHT4SS_MCS6, MGN_VHT4SS_MCS7, MGN_VHT4SS_MCS8, MGN_VHT4SS_MCS9}; + + PHY_SetTxPowerIndexByRateArray(padapter, RFPath, pHalData->CurrentChannelBW, Channel, + vhtRates4T, sizeof(vhtRates4T)/sizeof(u8)); -+ } -+ else -+ { ++ } else + DBG_871X("Invalid RateSection %d in %s", RateSection, __func__); -+ } +} + -+static bool -+phy_GetChnlIndex( -+u8 Channel, -+ u8 *ChannelIdx -+ ) ++static bool phy_GetChnlIndex(u8 Channel, u8 *ChannelIdx) +{ -+ u8 channel5G[CHANNEL_MAX_NUMBER_5G] = -+ {36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, -+ 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 149, 151, -+ 153, 155, 157, 159, 161, 163, 165, 167, 168, 169, 171, 173, 175, 177}; ++ u8 channel5G[CHANNEL_MAX_NUMBER_5G] = { ++ 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 100, 102, ++ 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, ++ 132, 134, 136, 138, 140, 142, 144, 149, 151, 153, 155, 157, 159, 161, ++ 163, 165, 167, 168, 169, 171, 173, 175, 177 ++ }; + u8 i = 0; -+ bool bIn24G =true; ++ bool bIn24G = true; + -+ if (Channel <= 14) -+ { -+ bIn24G =true; -+ *ChannelIdx = Channel -1; -+ } -+ else -+ { ++ if (Channel <= 14) { ++ bIn24G = true; ++ *ChannelIdx = Channel-1; ++ } else { + bIn24G = false; + -+ for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i) -+ { ++ for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i) { + if (channel5G[i] == Channel) { + *ChannelIdx = i; + return bIn24G; @@ -48299,23 +46750,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return bIn24G; +} + -+u8 -+PHY_GetTxPowerIndexBase( -+struct adapter * padapter, -+u8 RFPath, -+u8 Rate, -+enum CHANNEL_WIDTH BandWidth, -+u8 Channel, -+ bool *bIn24G -+ ) ++u8 PHY_GetTxPowerIndexBase( ++ struct adapter *padapter, ++ u8 RFPath, ++ u8 Rate, ++ enum CHANNEL_WIDTH BandWidth, ++ u8 Channel, ++ bool *bIn24G ++) +{ -+ struct hal_com_data * pHalData = GET_HAL_DATA(padapter); -+ u8 i = 0; /* default set to 1S */ -+ u8 txPower = 0; -+ u8 chnlIdx = (Channel-1); ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ u8 i = 0; /* default set to 1S */ ++ u8 txPower = 0; ++ u8 chnlIdx = (Channel-1); + -+ if (HAL_IsLegalChannel(padapter, Channel) == false) -+ { ++ if (HAL_IsLegalChannel(padapter, Channel) == false) { + chnlIdx = 0; + DBG_871X("Illegal channel!!\n"); + } @@ -48324,33 +46773,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + + /* DBG_871X("[%s] Channel Index: %d\n", (*bIn24G?"2.4G":"5G"), chnlIdx); */ + -+ if (*bIn24G) /* 3 ============================== 2.4 G ============================== */ -+ { ++ if (*bIn24G) { /* 3 ============================== 2.4 G ============================== */ + if (IS_CCK_RATE(Rate)) -+ { + txPower = pHalData->Index24G_CCK_Base[RFPath][chnlIdx]; -+ } + else if (MGN_6M <= Rate) -+ { + txPower = pHalData->Index24G_BW40_Base[RFPath][chnlIdx]; -+ } + else -+ { + DBG_871X("PHY_GetTxPowerIndexBase: INVALID Rate.\n"); -+ } + + /* DBG_871X("Base Tx power(RF-%c, Rate #%d, Channel Index %d) = 0x%X\n", */ -+ /* ((RFPath == 0)?'A':'B'), Rate, chnlIdx, txPower); */ ++ /* ((RFPath == 0)?'A':'B'), Rate, chnlIdx, txPower); */ + + /* OFDM-1T */ -+ if ((MGN_6M <= Rate && Rate <= MGN_54M) && ! IS_CCK_RATE(Rate)) -+ { ++ if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate)) { + txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S]; + /* DBG_871X("+PowerDiff 2.4G (RF-%c): (OFDM-1T) = (%d)\n", ((RFPath == 0)?'A':'B'), pHalData->OFDM_24G_Diff[RFPath][TX_1S]); */ + } -+ /* BW20-1S, BW20-2S */ -+ if (BandWidth == CHANNEL_WIDTH_20) -+ { ++ if (BandWidth == CHANNEL_WIDTH_20) { /* BW20-1S, BW20-2S */ + if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) + txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S]; + if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) @@ -48361,12 +46800,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + txPower += pHalData->BW20_24G_Diff[RFPath][TX_4S]; + + /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW20-1S, BW20-2S, BW20-3S, BW20-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */ -+ /* pHalData->BW20_24G_Diff[RFPath][TX_1S], pHalData->BW20_24G_Diff[RFPath][TX_2S], */ -+ /* pHalData->BW20_24G_Diff[RFPath][TX_3S], pHalData->BW20_24G_Diff[RFPath][TX_4S]); */ -+ } -+ /* BW40-1S, BW40-2S */ -+ else if (BandWidth == CHANNEL_WIDTH_40) -+ { ++ /* pHalData->BW20_24G_Diff[RFPath][TX_1S], pHalData->BW20_24G_Diff[RFPath][TX_2S], */ ++ /* pHalData->BW20_24G_Diff[RFPath][TX_3S], pHalData->BW20_24G_Diff[RFPath][TX_4S]); */ ++ } else if (BandWidth == CHANNEL_WIDTH_40) { /* BW40-1S, BW40-2S */ + if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) + txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S]; + if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) @@ -48377,12 +46813,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S]; + + /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW40-1S, BW40-2S, BW40-3S, BW40-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */ -+ /* pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S], */ -+ /* pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]); */ ++ /* pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S], */ ++ /* pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]); */ + } + /* Willis suggest adopt BW 40M power index while in BW 80 mode */ -+ else if (BandWidth == CHANNEL_WIDTH_80) -+ { ++ else if (BandWidth == CHANNEL_WIDTH_80) { + if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) + txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S]; + if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) @@ -48393,34 +46828,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S]; + + /* DBG_871X("+PowerDiff 2.4G (RF-%c): (BW40-1S, BW40-2S, BW40-3S, BW40-4T) = (%d, %d, %d, %d) P.S. Current is in BW 80MHz\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */ -+ /* pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S], */ -+ /* pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]); */ ++ /* pHalData->BW40_24G_Diff[RFPath][TX_1S], pHalData->BW40_24G_Diff[RFPath][TX_2S], */ ++ /* pHalData->BW40_24G_Diff[RFPath][TX_3S], pHalData->BW40_24G_Diff[RFPath][TX_4S]); */ + } -+ } -+ else /* 3 ============================== 5 G ============================== */ -+ { ++ } else {/* 3 ============================== 5 G ============================== */ + if (MGN_6M <= Rate) -+ { + txPower = pHalData->Index5G_BW40_Base[RFPath][chnlIdx]; -+ } + else -+ { + DBG_871X("===> mpt_ProQueryCalTxPower_Jaguar: INVALID Rate.\n"); -+ } + + /* DBG_871X("Base Tx power(RF-%c, Rate #%d, Channel Index %d) = 0x%X\n", */ -+ /* ((RFPath == 0)?'A':'B'), Rate, chnlIdx, txPower); */ ++ /* ((RFPath == 0)?'A':'B'), Rate, chnlIdx, txPower); */ + + /* OFDM-1T */ -+ if ((MGN_6M <= Rate && Rate <= MGN_54M) && ! IS_CCK_RATE(Rate)) -+ { ++ if ((MGN_6M <= Rate && Rate <= MGN_54M) && !IS_CCK_RATE(Rate)) { + txPower += pHalData->OFDM_5G_Diff[RFPath][TX_1S]; + /* DBG_871X("+PowerDiff 5G (RF-%c): (OFDM-1T) = (%d)\n", ((RFPath == 0)?'A':'B'), pHalData->OFDM_5G_Diff[RFPath][TX_1S]); */ + } + + /* BW20-1S, BW20-2S */ -+ if (BandWidth == CHANNEL_WIDTH_20) -+ { ++ if (BandWidth == CHANNEL_WIDTH_20) { + if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) + txPower += pHalData->BW20_5G_Diff[RFPath][TX_1S]; + if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) @@ -48431,12 +46858,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + txPower += pHalData->BW20_5G_Diff[RFPath][TX_4S]; + + /* DBG_871X("+PowerDiff 5G (RF-%c): (BW20-1S, BW20-2S, BW20-3S, BW20-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */ -+ /* pHalData->BW20_5G_Diff[RFPath][TX_1S], pHalData->BW20_5G_Diff[RFPath][TX_2S], */ -+ /* pHalData->BW20_5G_Diff[RFPath][TX_3S], pHalData->BW20_5G_Diff[RFPath][TX_4S]); */ -+ } -+ /* BW40-1S, BW40-2S */ -+ else if (BandWidth == CHANNEL_WIDTH_40) -+ { ++ /* pHalData->BW20_5G_Diff[RFPath][TX_1S], pHalData->BW20_5G_Diff[RFPath][TX_2S], */ ++ /* pHalData->BW20_5G_Diff[RFPath][TX_3S], pHalData->BW20_5G_Diff[RFPath][TX_4S]); */ ++ } else if (BandWidth == CHANNEL_WIDTH_40) { /* BW40-1S, BW40-2S */ + if ((MGN_MCS0 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT1SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) + txPower += pHalData->BW40_5G_Diff[RFPath][TX_1S]; + if ((MGN_MCS8 <= Rate && Rate <= MGN_MCS31) || (MGN_VHT2SS_MCS0 <= Rate && Rate <= MGN_VHT4SS_MCS9)) @@ -48447,12 +46871,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + txPower += pHalData->BW40_5G_Diff[RFPath][TX_4S]; + + /* DBG_871X("+PowerDiff 5G(RF-%c): (BW40-1S, BW40-2S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */ -+ /* pHalData->BW40_5G_Diff[RFPath][TX_1S], pHalData->BW40_5G_Diff[RFPath][TX_2S], */ -+ /* pHalData->BW40_5G_Diff[RFPath][TX_3S], pHalData->BW40_5G_Diff[RFPath][TX_4S]); */ -+ } -+ /* BW80-1S, BW80-2S */ -+ else if (BandWidth == CHANNEL_WIDTH_80) -+ { ++ /* pHalData->BW40_5G_Diff[RFPath][TX_1S], pHalData->BW40_5G_Diff[RFPath][TX_2S], */ ++ /* pHalData->BW40_5G_Diff[RFPath][TX_3S], pHalData->BW40_5G_Diff[RFPath][TX_4S]); */ ++ } else if (BandWidth == CHANNEL_WIDTH_80) { /* BW80-1S, BW80-2S */ + /* <20121220, Kordan> Get the index of array "Index5G_BW80_Base". */ + u8 channel5G_80M[CHANNEL_MAX_NUMBER_5G_80M] = {42, 58, 106, 122, 138, 155, 171}; + for (i = 0; i < sizeof(channel5G_80M)/sizeof(u8); ++i) @@ -48471,35 +46892,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + txPower += pHalData->BW80_5G_Diff[RFPath][TX_4S]; + + /* DBG_871X("+PowerDiff 5G(RF-%c): (BW80-1S, BW80-2S, BW80-3S, BW80-4S) = (%d, %d, %d, %d)\n", ((RFPath == 0)?'A':(RFPath == 1)?'B':(RFPath ==2)?'C':'D'), */ -+ /* pHalData->BW80_5G_Diff[RFPath][TX_1S], pHalData->BW80_5G_Diff[RFPath][TX_2S], */ -+ /* pHalData->BW80_5G_Diff[RFPath][TX_3S], pHalData->BW80_5G_Diff[RFPath][TX_4S]); */ ++ /* pHalData->BW80_5G_Diff[RFPath][TX_1S], pHalData->BW80_5G_Diff[RFPath][TX_2S], */ ++ /* pHalData->BW80_5G_Diff[RFPath][TX_3S], pHalData->BW80_5G_Diff[RFPath][TX_4S]); */ + } + } + + return txPower; +} + -+s8 -+PHY_GetTxPowerTrackingOffset( -+ struct adapter *padapter, -+ u8 RFPath, -+ u8 Rate -+ ) ++s8 PHY_GetTxPowerTrackingOffset(struct adapter *padapter, u8 RFPath, u8 Rate) +{ -+ struct hal_com_data * pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; -+ s8 offset = 0; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ s8 offset = 0; + + if (pDM_Odm->RFCalibrateInfo.TxPowerTrackControl == false) + return offset; + -+ if ((Rate == MGN_1M) ||(Rate == MGN_2M)||(Rate == MGN_5_5M)||(Rate == MGN_11M)) -+ { ++ if ((Rate == MGN_1M) || (Rate == MGN_2M) || (Rate == MGN_5_5M) || (Rate == MGN_11M)) { + offset = pDM_Odm->Remnant_CCKSwingIdx; + /* DBG_871X("+Remnant_CCKSwingIdx = 0x%x\n", RFPath, Rate, pDM_Odm->Remnant_CCKSwingIdx); */ -+ } -+ else -+ { ++ } else { + offset = pDM_Odm->Remnant_OFDMSwingIdx[RFPath]; + /* DBG_871X("+Remanant_OFDMSwingIdx[RFPath %u][Rate 0x%x] = 0x%x\n", RFPath, Rate, pDM_Odm->Remnant_OFDMSwingIdx[RFPath]); */ + @@ -48508,140 +46921,295 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return offset; +} + -+u8 -+PHY_GetRateIndexOfTxPowerByRate( -+u8 Rate -+ ) ++u8 PHY_GetRateIndexOfTxPowerByRate(u8 Rate) +{ + u8 index = 0; -+ switch (Rate) -+ { -+ case MGN_1M: index = 0; break; -+ case MGN_2M: index = 1; break; -+ case MGN_5_5M: index = 2; break; -+ case MGN_11M: index = 3; break; -+ case MGN_6M: index = 4; break; -+ case MGN_9M: index = 5; break; -+ case MGN_12M: index = 6; break; -+ case MGN_18M: index = 7; break; -+ case MGN_24M: index = 8; break; -+ case MGN_36M: index = 9; break; -+ case MGN_48M: index = 10; break; -+ case MGN_54M: index = 11; break; -+ case MGN_MCS0: index = 12; break; -+ case MGN_MCS1: index = 13; break; -+ case MGN_MCS2: index = 14; break; -+ case MGN_MCS3: index = 15; break; -+ case MGN_MCS4: index = 16; break; -+ case MGN_MCS5: index = 17; break; -+ case MGN_MCS6: index = 18; break; -+ case MGN_MCS7: index = 19; break; -+ case MGN_MCS8: index = 20; break; -+ case MGN_MCS9: index = 21; break; -+ case MGN_MCS10: index = 22; break; -+ case MGN_MCS11: index = 23; break; -+ case MGN_MCS12: index = 24; break; -+ case MGN_MCS13: index = 25; break; -+ case MGN_MCS14: index = 26; break; -+ case MGN_MCS15: index = 27; break; -+ case MGN_MCS16: index = 28; break; -+ case MGN_MCS17: index = 29; break; -+ case MGN_MCS18: index = 30; break; -+ case MGN_MCS19: index = 31; break; -+ case MGN_MCS20: index = 32; break; -+ case MGN_MCS21: index = 33; break; -+ case MGN_MCS22: index = 34; break; -+ case MGN_MCS23: index = 35; break; -+ case MGN_MCS24: index = 36; break; -+ case MGN_MCS25: index = 37; break; -+ case MGN_MCS26: index = 38; break; -+ case MGN_MCS27: index = 39; break; -+ case MGN_MCS28: index = 40; break; -+ case MGN_MCS29: index = 41; break; -+ case MGN_MCS30: index = 42; break; -+ case MGN_MCS31: index = 43; break; -+ case MGN_VHT1SS_MCS0: index = 44; break; -+ case MGN_VHT1SS_MCS1: index = 45; break; -+ case MGN_VHT1SS_MCS2: index = 46; break; -+ case MGN_VHT1SS_MCS3: index = 47; break; -+ case MGN_VHT1SS_MCS4: index = 48; break; -+ case MGN_VHT1SS_MCS5: index = 49; break; -+ case MGN_VHT1SS_MCS6: index = 50; break; -+ case MGN_VHT1SS_MCS7: index = 51; break; -+ case MGN_VHT1SS_MCS8: index = 52; break; -+ case MGN_VHT1SS_MCS9: index = 53; break; -+ case MGN_VHT2SS_MCS0: index = 54; break; -+ case MGN_VHT2SS_MCS1: index = 55; break; -+ case MGN_VHT2SS_MCS2: index = 56; break; -+ case MGN_VHT2SS_MCS3: index = 57; break; -+ case MGN_VHT2SS_MCS4: index = 58; break; -+ case MGN_VHT2SS_MCS5: index = 59; break; -+ case MGN_VHT2SS_MCS6: index = 60; break; -+ case MGN_VHT2SS_MCS7: index = 61; break; -+ case MGN_VHT2SS_MCS8: index = 62; break; -+ case MGN_VHT2SS_MCS9: index = 63; break; -+ case MGN_VHT3SS_MCS0: index = 64; break; -+ case MGN_VHT3SS_MCS1: index = 65; break; -+ case MGN_VHT3SS_MCS2: index = 66; break; -+ case MGN_VHT3SS_MCS3: index = 67; break; -+ case MGN_VHT3SS_MCS4: index = 68; break; -+ case MGN_VHT3SS_MCS5: index = 69; break; -+ case MGN_VHT3SS_MCS6: index = 70; break; -+ case MGN_VHT3SS_MCS7: index = 71; break; -+ case MGN_VHT3SS_MCS8: index = 72; break; -+ case MGN_VHT3SS_MCS9: index = 73; break; -+ case MGN_VHT4SS_MCS0: index = 74; break; -+ case MGN_VHT4SS_MCS1: index = 75; break; -+ case MGN_VHT4SS_MCS2: index = 76; break; -+ case MGN_VHT4SS_MCS3: index = 77; break; -+ case MGN_VHT4SS_MCS4: index = 78; break; -+ case MGN_VHT4SS_MCS5: index = 79; break; -+ case MGN_VHT4SS_MCS6: index = 80; break; -+ case MGN_VHT4SS_MCS7: index = 81; break; -+ case MGN_VHT4SS_MCS8: index = 82; break; -+ case MGN_VHT4SS_MCS9: index = 83; break; -+ default: -+ DBG_871X("Invalid rate 0x%x in %s\n", Rate, __func__); -+ break; ++ switch (Rate) { ++ case MGN_1M: ++ index = 0; ++ break; ++ case MGN_2M: ++ index = 1; ++ break; ++ case MGN_5_5M: ++ index = 2; ++ break; ++ case MGN_11M: ++ index = 3; ++ break; ++ case MGN_6M: ++ index = 4; ++ break; ++ case MGN_9M: ++ index = 5; ++ break; ++ case MGN_12M: ++ index = 6; ++ break; ++ case MGN_18M: ++ index = 7; ++ break; ++ case MGN_24M: ++ index = 8; ++ break; ++ case MGN_36M: ++ index = 9; ++ break; ++ case MGN_48M: ++ index = 10; ++ break; ++ case MGN_54M: ++ index = 11; ++ break; ++ case MGN_MCS0: ++ index = 12; ++ break; ++ case MGN_MCS1: ++ index = 13; ++ break; ++ case MGN_MCS2: ++ index = 14; ++ break; ++ case MGN_MCS3: ++ index = 15; ++ break; ++ case MGN_MCS4: ++ index = 16; ++ break; ++ case MGN_MCS5: ++ index = 17; ++ break; ++ case MGN_MCS6: ++ index = 18; ++ break; ++ case MGN_MCS7: ++ index = 19; ++ break; ++ case MGN_MCS8: ++ index = 20; ++ break; ++ case MGN_MCS9: ++ index = 21; ++ break; ++ case MGN_MCS10: ++ index = 22; ++ break; ++ case MGN_MCS11: ++ index = 23; ++ break; ++ case MGN_MCS12: ++ index = 24; ++ break; ++ case MGN_MCS13: ++ index = 25; ++ break; ++ case MGN_MCS14: ++ index = 26; ++ break; ++ case MGN_MCS15: ++ index = 27; ++ break; ++ case MGN_MCS16: ++ index = 28; ++ break; ++ case MGN_MCS17: ++ index = 29; ++ break; ++ case MGN_MCS18: ++ index = 30; ++ break; ++ case MGN_MCS19: ++ index = 31; ++ break; ++ case MGN_MCS20: ++ index = 32; ++ break; ++ case MGN_MCS21: ++ index = 33; ++ break; ++ case MGN_MCS22: ++ index = 34; ++ break; ++ case MGN_MCS23: ++ index = 35; ++ break; ++ case MGN_MCS24: ++ index = 36; ++ break; ++ case MGN_MCS25: ++ index = 37; ++ break; ++ case MGN_MCS26: ++ index = 38; ++ break; ++ case MGN_MCS27: ++ index = 39; ++ break; ++ case MGN_MCS28: ++ index = 40; ++ break; ++ case MGN_MCS29: ++ index = 41; ++ break; ++ case MGN_MCS30: ++ index = 42; ++ break; ++ case MGN_MCS31: ++ index = 43; ++ break; ++ case MGN_VHT1SS_MCS0: ++ index = 44; ++ break; ++ case MGN_VHT1SS_MCS1: ++ index = 45; ++ break; ++ case MGN_VHT1SS_MCS2: ++ index = 46; ++ break; ++ case MGN_VHT1SS_MCS3: ++ index = 47; ++ break; ++ case MGN_VHT1SS_MCS4: ++ index = 48; ++ break; ++ case MGN_VHT1SS_MCS5: ++ index = 49; ++ break; ++ case MGN_VHT1SS_MCS6: ++ index = 50; ++ break; ++ case MGN_VHT1SS_MCS7: ++ index = 51; ++ break; ++ case MGN_VHT1SS_MCS8: ++ index = 52; ++ break; ++ case MGN_VHT1SS_MCS9: ++ index = 53; ++ break; ++ case MGN_VHT2SS_MCS0: ++ index = 54; ++ break; ++ case MGN_VHT2SS_MCS1: ++ index = 55; ++ break; ++ case MGN_VHT2SS_MCS2: ++ index = 56; ++ break; ++ case MGN_VHT2SS_MCS3: ++ index = 57; ++ break; ++ case MGN_VHT2SS_MCS4: ++ index = 58; ++ break; ++ case MGN_VHT2SS_MCS5: ++ index = 59; ++ break; ++ case MGN_VHT2SS_MCS6: ++ index = 60; ++ break; ++ case MGN_VHT2SS_MCS7: ++ index = 61; ++ break; ++ case MGN_VHT2SS_MCS8: ++ index = 62; ++ break; ++ case MGN_VHT2SS_MCS9: ++ index = 63; ++ break; ++ case MGN_VHT3SS_MCS0: ++ index = 64; ++ break; ++ case MGN_VHT3SS_MCS1: ++ index = 65; ++ break; ++ case MGN_VHT3SS_MCS2: ++ index = 66; ++ break; ++ case MGN_VHT3SS_MCS3: ++ index = 67; ++ break; ++ case MGN_VHT3SS_MCS4: ++ index = 68; ++ break; ++ case MGN_VHT3SS_MCS5: ++ index = 69; ++ break; ++ case MGN_VHT3SS_MCS6: ++ index = 70; ++ break; ++ case MGN_VHT3SS_MCS7: ++ index = 71; ++ break; ++ case MGN_VHT3SS_MCS8: ++ index = 72; ++ break; ++ case MGN_VHT3SS_MCS9: ++ index = 73; ++ break; ++ case MGN_VHT4SS_MCS0: ++ index = 74; ++ break; ++ case MGN_VHT4SS_MCS1: ++ index = 75; ++ break; ++ case MGN_VHT4SS_MCS2: ++ index = 76; ++ break; ++ case MGN_VHT4SS_MCS3: ++ index = 77; ++ break; ++ case MGN_VHT4SS_MCS4: ++ index = 78; ++ break; ++ case MGN_VHT4SS_MCS5: ++ index = 79; ++ break; ++ case MGN_VHT4SS_MCS6: ++ index = 80; ++ break; ++ case MGN_VHT4SS_MCS7: ++ index = 81; ++ break; ++ case MGN_VHT4SS_MCS8: ++ index = 82; ++ break; ++ case MGN_VHT4SS_MCS9: ++ index = 83; ++ break; ++ default: ++ DBG_871X("Invalid rate 0x%x in %s\n", Rate, __func__); ++ break; + }; + + return index; +} + -+s8 -+PHY_GetTxPowerByRate( -+struct adapter *padapter, -+u8 Band, -+u8 RFPath, -+u8 TxNum, -+u8 Rate -+ ) ++s8 PHY_GetTxPowerByRate( ++ struct adapter *padapter, u8 Band, u8 RFPath, u8 TxNum, u8 Rate ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ s8 value = 0; -+ u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate(Rate); ++ s8 value = 0; ++ u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate(Rate); + + if ((padapter->registrypriv.RegEnableTxPowerByRate == 2 && pHalData->EEPROMRegulatory == 2) || + padapter->registrypriv.RegEnableTxPowerByRate == 0) + return 0; + -+ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) -+ { ++ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) { + DBG_871X("Invalid band %d in %s\n", Band, __func__); + return value; + } -+ if (RFPath > ODM_RF_PATH_D) -+ { ++ if (RFPath > ODM_RF_PATH_D) { + DBG_871X("Invalid RfPath %d in %s\n", RFPath, __func__); + return value; + } -+ if (TxNum >= RF_MAX_TX_NUM) -+ { ++ if (TxNum >= RF_MAX_TX_NUM) { + DBG_871X("Invalid TxNum %d in %s\n", TxNum, __func__); + return value; + } -+ if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE) -+ { ++ if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE) { + DBG_871X("Invalid RateIndex %d in %s\n", rateIndex, __func__); + return value; + } @@ -48652,36 +47220,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + +} + -+void -+PHY_SetTxPowerByRate( -+struct adapter *padapter, -+u8 Band, -+u8 RFPath, -+u8 TxNum, -+u8 Rate, -+s8 Value -+ ) ++void PHY_SetTxPowerByRate( ++ struct adapter *padapter, ++ u8 Band, ++ u8 RFPath, ++ u8 TxNum, ++ u8 Rate, ++ s8 Value ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate(Rate); + -+ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) -+ { ++ if (Band != BAND_ON_2_4G && Band != BAND_ON_5G) { + DBG_871X("Invalid band %d in %s\n", Band, __func__); + return; + } -+ if (RFPath > ODM_RF_PATH_D) -+ { ++ if (RFPath > ODM_RF_PATH_D) { + DBG_871X("Invalid RfPath %d in %s\n", RFPath, __func__); + return; + } -+ if (TxNum >= RF_MAX_TX_NUM) -+ { ++ if (TxNum >= RF_MAX_TX_NUM) { + DBG_871X("Invalid TxNum %d in %s\n", TxNum, __func__); + return; + } -+ if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE) -+ { ++ if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE) { + DBG_871X("Invalid RateIndex %d in %s\n", rateIndex, __func__); + return; + } @@ -48689,12 +47252,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + pHalData->TxPwrByRateOffset[Band][RFPath][TxNum][rateIndex] = Value; +} + -+void -+PHY_SetTxPowerLevelByPath( -+struct adapter *Adapter, -+u8 channel, -+u8 path -+ ) ++void PHY_SetTxPowerLevelByPath(struct adapter *Adapter, u8 channel, u8 path) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + bool bIsIn24G = (pHalData->CurrentBandType == BAND_ON_2_4G); @@ -48708,36 +47266,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, HT_MCS0_MCS7); + + if (pHalData->NumTotalRFPath >= 2) -+ { + PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, HT_MCS8_MCS15); -+ } ++ + } +} + -+void -+PHY_SetTxPowerIndexByRateArray( -+struct adapter * padapter, -+u8 RFPath, -+enum CHANNEL_WIDTH BandWidth, -+u8 Channel, -+u8 * Rates, -+u8 RateArraySize -+ ) ++void PHY_SetTxPowerIndexByRateArray( ++ struct adapter *padapter, ++ u8 RFPath, ++ enum CHANNEL_WIDTH BandWidth, ++ u8 Channel, ++ u8 *Rates, ++ u8 RateArraySize ++) +{ + u32 powerIndex = 0; + int i = 0; + -+ for (i = 0; i < RateArraySize; ++i) -+ { ++ for (i = 0; i < RateArraySize; ++i) { + powerIndex = PHY_GetTxPowerIndex(padapter, RFPath, Rates[i], BandWidth, Channel); + PHY_SetTxPowerIndex(padapter, powerIndex, RFPath, Rates[i]); + } +} + -+static s8 -+phy_GetWorldWideLimit( -+ s8 * LimitTable -+) ++static s8 phy_GetWorldWideLimit(s8 *LimitTable) +{ + s8 min = LimitTable[0]; + u8 i = 0; @@ -48750,34 +47302,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return min; +} + -+static s8 -+phy_GetChannelIndexOfTxPowerLimit( -+u8 Band, -+u8 Channel -+ ) ++static s8 phy_GetChannelIndexOfTxPowerLimit(u8 Band, u8 Channel) +{ + s8 channelIndex = -1; -+ u8 channel5G[CHANNEL_MAX_NUMBER_5G] = -+ {36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, -+ 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 149, 151, -+ 153, 155, 157, 159, 161, 163, 165, 167, 168, 169, 171, 173, 175, 177}; ++ u8 channel5G[CHANNEL_MAX_NUMBER_5G] = { ++ 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 100, 102, ++ 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, ++ 132, 134, 136, 138, 140, 142, 144, 149, 151, 153, 155, 157, 159, 161, ++ 163, 165, 167, 168, 169, 171, 173, 175, 177 ++ }; + u8 i = 0; + if (Band == BAND_ON_2_4G) -+ { + channelIndex = Channel - 1; -+ } -+ else if (Band == BAND_ON_5G) -+ { -+ for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i) -+ { ++ else if (Band == BAND_ON_5G) { ++ for (i = 0; i < sizeof(channel5G)/sizeof(u8); ++i) { + if (channel5G[i] == Channel) + channelIndex = i; + } -+ } -+ else -+ { ++ } else + DBG_871X("Invalid Band %d in %s", Band, __func__); -+ } + + if (channelIndex == -1) + DBG_871X("Invalid Channel %d of Band %d in %s", Channel, Band, __func__); @@ -48785,121 +47328,122 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return channelIndex; +} + -+s8 -+PHY_GetTxPowerLimit( -+struct adapter * Adapter, -+u32 RegPwrTblSel, -+enum BAND_TYPE Band, -+enum CHANNEL_WIDTH Bandwidth, -+u8 RfPath, -+u8 DataRate, -+u8 Channel -+ ) ++s8 PHY_GetTxPowerLimit( ++ struct adapter *Adapter, ++ u32 RegPwrTblSel, ++ enum BAND_TYPE Band, ++ enum CHANNEL_WIDTH Bandwidth, ++ u8 RfPath, ++ u8 DataRate, ++ u8 Channel ++) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ s16 band = -1, regulation = -1, bandwidth = -1, -+ rateSection = -1, channel = -1; -+ s8 powerLimit = MAX_POWER_INDEX; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ s16 band = -1, regulation = -1, bandwidth = -1, rateSection = -1, channel = -1; ++ s8 powerLimit = MAX_POWER_INDEX; + + if ((Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory != 1) || + Adapter->registrypriv.RegEnableTxPowerLimit == 0) + return MAX_POWER_INDEX; + -+ switch (Adapter->registrypriv.RegPwrTblSel) -+ { -+ case 1: -+ regulation = TXPWR_LMT_ETSI; -+ break; -+ case 2: -+ regulation = TXPWR_LMT_MKK; -+ break; -+ case 3: -+ regulation = TXPWR_LMT_FCC; -+ break; ++ switch (Adapter->registrypriv.RegPwrTblSel) { ++ case 1: ++ regulation = TXPWR_LMT_ETSI; ++ break; ++ case 2: ++ regulation = TXPWR_LMT_MKK; ++ break; ++ case 3: ++ regulation = TXPWR_LMT_FCC; ++ break; + -+ case 4: -+ regulation = TXPWR_LMT_WW; -+ break; ++ case 4: ++ regulation = TXPWR_LMT_WW; ++ break; + -+ default: -+ regulation = (Band == BAND_ON_2_4G) ? pHalData->Regulation2_4G -+ : pHalData->Regulation5G; -+ break; ++ default: ++ regulation = (Band == BAND_ON_2_4G) ? pHalData->Regulation2_4G : pHalData->Regulation5G; ++ break; + } + + /* DBG_871X("pMgntInfo->RegPwrTblSel %d, final regulation %d\n", Adapter->registrypriv.RegPwrTblSel, regulation); */ + + -+ if (Band == BAND_ON_2_4G) band = 0; -+ else if (Band == BAND_ON_5G) band = 1; ++ if (Band == BAND_ON_2_4G) ++ band = 0; ++ else if (Band == BAND_ON_5G) ++ band = 1; + -+ if (Bandwidth == CHANNEL_WIDTH_20) bandwidth = 0; -+ else if (Bandwidth == CHANNEL_WIDTH_40) bandwidth = 1; -+ else if (Bandwidth == CHANNEL_WIDTH_80) bandwidth = 2; -+ else if (Bandwidth == CHANNEL_WIDTH_160) bandwidth = 3; ++ if (Bandwidth == CHANNEL_WIDTH_20) ++ bandwidth = 0; ++ else if (Bandwidth == CHANNEL_WIDTH_40) ++ bandwidth = 1; ++ else if (Bandwidth == CHANNEL_WIDTH_80) ++ bandwidth = 2; ++ else if (Bandwidth == CHANNEL_WIDTH_160) ++ bandwidth = 3; + -+ switch (DataRate) -+ { -+ case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M: -+ rateSection = 0; -+ break; ++ switch (DataRate) { ++ case MGN_1M: case MGN_2M: case MGN_5_5M: case MGN_11M: ++ rateSection = 0; ++ break; + -+ case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M: -+ case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M: -+ rateSection = 1; -+ break; ++ case MGN_6M: case MGN_9M: case MGN_12M: case MGN_18M: ++ case MGN_24M: case MGN_36M: case MGN_48M: case MGN_54M: ++ rateSection = 1; ++ break; + -+ case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3: -+ case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7: -+ rateSection = 2; -+ break; ++ case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3: ++ case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7: ++ rateSection = 2; ++ break; + -+ case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11: -+ case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15: -+ rateSection = 3; -+ break; ++ case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11: ++ case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15: ++ rateSection = 3; ++ break; + -+ case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19: -+ case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23: -+ rateSection = 4; -+ break; ++ case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19: ++ case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23: ++ rateSection = 4; ++ break; + -+ case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27: -+ case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31: -+ rateSection = 5; -+ break; ++ case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27: ++ case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31: ++ rateSection = 5; ++ break; + -+ case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2: -+ case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5: -+ case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8: -+ case MGN_VHT1SS_MCS9: -+ rateSection = 6; -+ break; ++ case MGN_VHT1SS_MCS0: case MGN_VHT1SS_MCS1: case MGN_VHT1SS_MCS2: ++ case MGN_VHT1SS_MCS3: case MGN_VHT1SS_MCS4: case MGN_VHT1SS_MCS5: ++ case MGN_VHT1SS_MCS6: case MGN_VHT1SS_MCS7: case MGN_VHT1SS_MCS8: ++ case MGN_VHT1SS_MCS9: ++ rateSection = 6; ++ break; + -+ case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2: -+ case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5: -+ case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8: -+ case MGN_VHT2SS_MCS9: -+ rateSection = 7; -+ break; ++ case MGN_VHT2SS_MCS0: case MGN_VHT2SS_MCS1: case MGN_VHT2SS_MCS2: ++ case MGN_VHT2SS_MCS3: case MGN_VHT2SS_MCS4: case MGN_VHT2SS_MCS5: ++ case MGN_VHT2SS_MCS6: case MGN_VHT2SS_MCS7: case MGN_VHT2SS_MCS8: ++ case MGN_VHT2SS_MCS9: ++ rateSection = 7; ++ break; + -+ case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2: -+ case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5: -+ case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8: -+ case MGN_VHT3SS_MCS9: -+ rateSection = 8; -+ break; ++ case MGN_VHT3SS_MCS0: case MGN_VHT3SS_MCS1: case MGN_VHT3SS_MCS2: ++ case MGN_VHT3SS_MCS3: case MGN_VHT3SS_MCS4: case MGN_VHT3SS_MCS5: ++ case MGN_VHT3SS_MCS6: case MGN_VHT3SS_MCS7: case MGN_VHT3SS_MCS8: ++ case MGN_VHT3SS_MCS9: ++ rateSection = 8; ++ break; + -+ case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2: -+ case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5: -+ case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8: -+ case MGN_VHT4SS_MCS9: -+ rateSection = 9; -+ break; ++ case MGN_VHT4SS_MCS0: case MGN_VHT4SS_MCS1: case MGN_VHT4SS_MCS2: ++ case MGN_VHT4SS_MCS3: case MGN_VHT4SS_MCS4: case MGN_VHT4SS_MCS5: ++ case MGN_VHT4SS_MCS6: case MGN_VHT4SS_MCS7: case MGN_VHT4SS_MCS8: ++ case MGN_VHT4SS_MCS9: ++ rateSection = 9; ++ break; + -+ default: -+ DBG_871X("Wrong rate 0x%x\n", DataRate); -+ break; ++ default: ++ DBG_871X("Wrong rate 0x%x\n", DataRate); ++ break; + } + + if (Band == BAND_ON_5G && rateSection == 0) @@ -48925,16 +47469,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, Channel); + else if (Band == BAND_ON_5G) + channel = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, Channel); -+ else if (Band == BAND_ON_BOTH) -+ { ++ else if (Band == BAND_ON_BOTH) { + /* BAND_ON_BOTH don't care temporarily */ + } + + if (band == -1 || regulation == -1 || bandwidth == -1 || -+ rateSection == -1 || channel == -1) -+ { ++ rateSection == -1 || channel == -1) { + /* DBG_871X("Wrong index value to access power limit table [band %d][regulation %d][bandwidth %d][rf_path %d][rate_section %d][chnlGroup %d]\n", */ -+ /* band, regulation, bandwidth, RfPath, rateSection, channelGroup); */ ++ /* band, regulation, bandwidth, RfPath, rateSection, channelGroup); */ + + return MAX_POWER_INDEX; + } @@ -48945,7 +47487,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + limits[i] = pHalData->TxPwrLimit_2_4G[i][bandwidth][rateSection][channel][RfPath]; + + powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) : -+ pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channel][RfPath]; ++ pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channel][RfPath]; + + } else if (Band == BAND_ON_5G) { + s8 limits[10] = {0}; u8 i = 0; @@ -48953,7 +47495,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + limits[i] = pHalData->TxPwrLimit_5G[i][bandwidth][rateSection][channel][RfPath]; + + powerLimit = (regulation == TXPWR_LMT_WW) ? phy_GetWorldWideLimit(limits) : -+ pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channel][RfPath]; ++ pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channel][RfPath]; + } else + DBG_871X("No power limit table of the specified band\n"); + @@ -48980,72 +47522,49 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + } + */ + /* DBG_871X("TxPwrLmt[Regulation %d][Band %d][BW %d][RFPath %d][Rate 0x%x][Chnl %d] = %d\n", */ -+ /* regulation, pHalData->CurrentBandType, Bandwidth, RfPath, DataRate, Channel, powerLimit); */ ++ /* regulation, pHalData->CurrentBandType, Bandwidth, RfPath, DataRate, Channel, powerLimit); */ + return powerLimit; +} + -+static void -+phy_CrossReferenceHTAndVHTTxPowerLimit( -+struct adapter * padapter -+ ) ++static void phy_CrossReferenceHTAndVHTTxPowerLimit(struct adapter *padapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ u8 regulation, bw, channel, rateSection; -+ s8 tempPwrLmt = 0; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ u8 regulation, bw, channel, rateSection; ++ s8 tempPwrLmt = 0; + -+ for (regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation) -+ { -+ for (bw = 0; bw < MAX_5G_BANDWITH_NUM; ++bw) -+ { -+ for (channel = 0; channel < CHANNEL_MAX_NUMBER_5G; ++channel) -+ { -+ for (rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection) -+ { ++ for (regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation) { ++ for (bw = 0; bw < MAX_5G_BANDWITH_NUM; ++bw) { ++ for (channel = 0; channel < CHANNEL_MAX_NUMBER_5G; ++channel) { ++ for (rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection) { + tempPwrLmt = pHalData->TxPwrLimit_5G[regulation][bw][rateSection][channel][ODM_RF_PATH_A]; -+ if (tempPwrLmt == MAX_POWER_INDEX) -+ { ++ if (tempPwrLmt == MAX_POWER_INDEX) { + u8 baseSection = 2, refSection = 6; + if (bw == 0 || bw == 1) { /* 5G 20M 40M VHT and HT can cross reference */ + /* DBG_871X("No power limit table of the specified band %d, bandwidth %d, ratesection %d, channel %d, rf path %d\n", */ -+ /* 1, bw, rateSection, channel, ODM_RF_PATH_A); */ ++ /* 1, bw, rateSection, channel, ODM_RF_PATH_A); */ + if (rateSection >= 2 && rateSection <= 9) { -+ if (rateSection == 2) -+ { ++ if (rateSection == 2) { + baseSection = 2; + refSection = 6; -+ } -+ else if (rateSection == 3) -+ { ++ } else if (rateSection == 3) { + baseSection = 3; + refSection = 7; -+ } -+ else if (rateSection == 4) -+ { ++ } else if (rateSection == 4) { + baseSection = 4; + refSection = 8; -+ } -+ else if (rateSection == 5) -+ { ++ } else if (rateSection == 5) { + baseSection = 5; + refSection = 9; -+ } -+ else if (rateSection == 6) -+ { ++ } else if (rateSection == 6) { + baseSection = 6; + refSection = 2; -+ } -+ else if (rateSection == 7) -+ { ++ } else if (rateSection == 7) { + baseSection = 7; + refSection = 3; -+ } -+ else if (rateSection == 8) -+ { ++ } else if (rateSection == 8) { + baseSection = 8; + refSection = 4; -+ } -+ else if (rateSection == 9) -+ { ++ } else if (rateSection == 9) { + baseSection = 9; + refSection = 5; + } @@ -49062,35 +47581,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + } +} + -+void -+PHY_ConvertTxPowerLimitToPowerIndex( -+struct adapter * Adapter -+ ) ++void PHY_ConvertTxPowerLimitToPowerIndex(struct adapter *Adapter) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ u8 BW40PwrBasedBm2_4G = 0x2E; -+ u8 regulation, bw, channel, rateSection; -+ s8 tempValue = 0, tempPwrLmt = 0; -+ u8 rfPath = 0; ++ u8 BW40PwrBasedBm2_4G = 0x2E; ++ u8 regulation, bw, channel, rateSection; ++ s8 tempValue = 0, tempPwrLmt = 0; ++ u8 rfPath = 0; + + /* DBG_871X("=====> PHY_ConvertTxPowerLimitToPowerIndex()\n"); */ + + phy_CrossReferenceHTAndVHTTxPowerLimit(Adapter); + -+ for (regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation) -+ { -+ for (bw = 0; bw < MAX_2_4G_BANDWITH_NUM; ++bw) -+ { -+ for (channel = 0; channel < CHANNEL_MAX_NUMBER_2G; ++channel) -+ { -+ for (rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection) -+ { ++ for (regulation = 0; regulation < MAX_REGULATION_NUM; ++regulation) { ++ for (bw = 0; bw < MAX_2_4G_BANDWITH_NUM; ++bw) { ++ for (channel = 0; channel < CHANNEL_MAX_NUMBER_2G; ++channel) { ++ for (rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection) { + tempPwrLmt = pHalData->TxPwrLimit_2_4G[regulation][bw][rateSection][channel][ODM_RF_PATH_A]; + -+ for (rfPath = ODM_RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath) -+ { -+ if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) -+ { ++ for (rfPath = ODM_RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath) { ++ if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) { + if (rateSection == 5) /* HT 4T */ + BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_4TX, HT_MCS24_MCS31); + else if (rateSection == 4) /* HT 3T */ @@ -49103,8 +47613,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_1TX, OFDM); + else if (rateSection == 0) /* CCK */ + BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, BAND_ON_2_4G, rfPath, RF_1TX, CCK); -+ } -+ else ++ } else + BW40PwrBasedBm2_4G = Adapter->registrypriv.RegPowerBase * 2; + + if (tempPwrLmt != MAX_POWER_INDEX) { @@ -49120,18 +47629,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + /* DBG_871X("<===== PHY_ConvertTxPowerLimitToPowerIndex()\n"); */ +} + -+void -+PHY_InitTxPowerLimit( -+struct adapter * Adapter -+ ) ++void PHY_InitTxPowerLimit(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ u8 i, j, k, l, m; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ u8 i, j, k, l, m; + + /* DBG_871X("=====> PHY_InitTxPowerLimit()!\n"); */ + -+ for (i = 0; i < MAX_REGULATION_NUM; ++i) -+ { ++ for (i = 0; i < MAX_REGULATION_NUM; ++i) { + for (j = 0; j < MAX_2_4G_BANDWITH_NUM; ++j) + for (k = 0; k < MAX_RATE_SECTION_NUM; ++k) + for (m = 0; m < CHANNEL_MAX_NUMBER_2G; ++m) @@ -49139,8 +47644,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + pHalData->TxPwrLimit_2_4G[i][j][k][m][l] = MAX_POWER_INDEX; + } + -+ for (i = 0; i < MAX_REGULATION_NUM; ++i) -+ { ++ for (i = 0; i < MAX_REGULATION_NUM; ++i) { + for (j = 0; j < MAX_5G_BANDWITH_NUM; ++j) + for (k = 0; k < MAX_RATE_SECTION_NUM; ++k) + for (m = 0; m < CHANNEL_MAX_NUMBER_5G; ++m) @@ -49151,38 +47655,38 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + /* DBG_871X("<===== PHY_InitTxPowerLimit()!\n"); */ +} + -+void -+PHY_SetTxPowerLimit( -+struct adapter * Adapter, -+u8 *Regulation, -+u8 *Band, -+u8 *Bandwidth, -+u8 *RateSection, -+u8 *RfPath, -+u8 *Channel, -+u8 *PowerLimit -+ ) ++void PHY_SetTxPowerLimit( ++ struct adapter *Adapter, ++ u8 *Regulation, ++ u8 *Band, ++ u8 *Bandwidth, ++ u8 *RateSection, ++ u8 *RfPath, ++ u8 *Channel, ++ u8 *PowerLimit ++) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ u8 regulation = 0, bandwidth = 0, rateSection = 0, -+ channel; -+ s8 powerLimit = 0, prevPowerLimit, channelIndex; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ u8 regulation = 0, bandwidth = 0, rateSection = 0, channel; ++ s8 powerLimit = 0, prevPowerLimit, channelIndex; + + /* DBG_871X("Index of power limit table [band %s][regulation %s][bw %s][rate section %s][rf path %s][chnl %s][val %s]\n", */ -+ /* Band, Regulation, Bandwidth, RateSection, RfPath, Channel, PowerLimit); */ ++ /* Band, Regulation, Bandwidth, RateSection, RfPath, Channel, PowerLimit); */ + + if (!GetU1ByteIntegerFromStringInDecimal((s8 *)Channel, &channel) || + !GetU1ByteIntegerFromStringInDecimal((s8 *)PowerLimit, &powerLimit)) -+ { + DBG_871X("Illegal index of power limit table [chnl %s][val %s]\n", Channel, PowerLimit); -+ } + + powerLimit = powerLimit > MAX_POWER_INDEX ? MAX_POWER_INDEX : powerLimit; + -+ if (eqNByte(Regulation, (u8 *)("FCC"), 3)) regulation = 0; -+ else if (eqNByte(Regulation, (u8 *)("MKK"), 3)) regulation = 1; -+ else if (eqNByte(Regulation, (u8 *)("ETSI"), 4)) regulation = 2; -+ else if (eqNByte(Regulation, (u8 *)("WW13"), 4)) regulation = 3; ++ if (eqNByte(Regulation, (u8 *)("FCC"), 3)) ++ regulation = 0; ++ else if (eqNByte(Regulation, (u8 *)("MKK"), 3)) ++ regulation = 1; ++ else if (eqNByte(Regulation, (u8 *)("ETSI"), 4)) ++ regulation = 2; ++ else if (eqNByte(Regulation, (u8 *)("WW13"), 4)) ++ regulation = 3; + + if (eqNByte(RateSection, (u8 *)("CCK"), 3) && eqNByte(RfPath, (u8 *)("1T"), 2)) + rateSection = 0; @@ -49204,20 +47708,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + rateSection = 8; + else if (eqNByte(RateSection, (u8 *)("VHT"), 3) && eqNByte(RfPath, (u8 *)("4T"), 2)) + rateSection = 9; -+ else -+ { ++ else { + DBG_871X("Wrong rate section!\n"); + return; + } + + -+ if (eqNByte(Bandwidth, (u8 *)("20M"), 3)) bandwidth = 0; -+ else if (eqNByte(Bandwidth, (u8 *)("40M"), 3)) bandwidth = 1; -+ else if (eqNByte(Bandwidth, (u8 *)("80M"), 3)) bandwidth = 2; -+ else if (eqNByte(Bandwidth, (u8 *)("160M"), 4)) bandwidth = 3; ++ if (eqNByte(Bandwidth, (u8 *)("20M"), 3)) ++ bandwidth = 0; ++ else if (eqNByte(Bandwidth, (u8 *)("40M"), 3)) ++ bandwidth = 1; ++ else if (eqNByte(Bandwidth, (u8 *)("80M"), 3)) ++ bandwidth = 2; ++ else if (eqNByte(Bandwidth, (u8 *)("160M"), 4)) ++ bandwidth = 3; + -+ if (eqNByte(Band, (u8 *)("2.4G"), 4)) -+ { ++ if (eqNByte(Band, (u8 *)("2.4G"), 4)) { + channelIndex = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_2_4G, channel); + + if (channelIndex == -1) @@ -49229,10 +47735,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit; + + /* DBG_871X("2.4G Band value : [regulation %d][bw %d][rate_section %d][chnl %d][val %d]\n", */ -+ /* regulation, bandwidth, rateSection, channelIndex, pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]); */ -+ } -+ else if (eqNByte(Band, (u8 *)("5G"), 2)) -+ { ++ /* regulation, bandwidth, rateSection, channelIndex, pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]); */ ++ } else if (eqNByte(Band, (u8 *)("5G"), 2)) { + channelIndex = phy_GetChannelIndexOfTxPowerLimit(BAND_ON_5G, channel); + + if (channelIndex == -1) @@ -49244,203 +47748,191 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit; + + /* DBG_871X("5G Band value : [regulation %d][bw %d][rate_section %d][chnl %d][val %d]\n", */ -+ /* regulation, bandwidth, rateSection, channel, pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]); */ -+ } -+ else -+ { ++ /* regulation, bandwidth, rateSection, channel, pHalData->TxPwrLimit_5G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]); */ ++ } else { + DBG_871X("Cannot recognize the band info in %s\n", Band); + return; + } +} + -+u8 -+PHY_GetTxPowerIndex( -+struct adapter * padapter, -+u8 RFPath, -+u8 Rate, -+enum CHANNEL_WIDTH BandWidth, -+u8 Channel -+ ) ++u8 PHY_GetTxPowerIndex( ++ struct adapter *padapter, ++ u8 RFPath, ++ u8 Rate, ++ enum CHANNEL_WIDTH BandWidth, ++ u8 Channel ++) +{ + return PHY_GetTxPowerIndex_8723B(padapter, RFPath, Rate, BandWidth, Channel); +} + -+void -+PHY_SetTxPowerIndex( -+struct adapter * padapter, -+u32 PowerIndex, -+u8 RFPath, -+u8 Rate -+ ) ++void PHY_SetTxPowerIndex( ++ struct adapter *padapter, u32 PowerIndex, u8 RFPath, u8 Rate ++) +{ + PHY_SetTxPowerIndex_8723B(padapter, PowerIndex, RFPath, Rate); +} + -+void -+Hal_ChannelPlanToRegulation( -+struct adapter * Adapter, -+u16 ChannelPlan -+ ) ++void Hal_ChannelPlanToRegulation(struct adapter *Adapter, u16 ChannelPlan) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + pHalData->Regulation2_4G = TXPWR_LMT_WW; + pHalData->Regulation5G = TXPWR_LMT_WW; + -+ switch (ChannelPlan) -+ { -+ case RT_CHANNEL_DOMAIN_WORLD_NULL: -+ pHalData->Regulation2_4G = TXPWR_LMT_WW; -+ break; -+ case RT_CHANNEL_DOMAIN_ETSI1_NULL: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_NULL: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_MKK1_NULL: -+ pHalData->Regulation2_4G = TXPWR_LMT_MKK; -+ break; -+ case RT_CHANNEL_DOMAIN_ETSI2_NULL: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_FCC1: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI1: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_MKK1_MKK1: -+ pHalData->Regulation2_4G = TXPWR_LMT_MKK; -+ pHalData->Regulation5G = TXPWR_LMT_MKK; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_KCC1: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_MKK; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_FCC2: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_FCC3: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_FCC4: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_FCC5: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_FCC6: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_FCC7: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI2: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI3: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_MKK1_MKK2: -+ pHalData->Regulation2_4G = TXPWR_LMT_MKK; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_MKK1_MKK3: -+ pHalData->Regulation2_4G = TXPWR_LMT_MKK; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_NCC1: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_NCC2: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_GLOBAL_NULL: -+ pHalData->Regulation2_4G = TXPWR_LMT_WW; -+ pHalData->Regulation5G = TXPWR_LMT_WW; -+ break; -+ case RT_CHANNEL_DOMAIN_ETSI1_ETSI4: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_FCC2: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_NCC3: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI5: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_FCC8: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI6: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI7: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI8: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI9: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI10: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI11: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_NCC4: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI12: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_FCC9: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_WORLD_ETSI13: -+ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; -+ pHalData->Regulation5G = TXPWR_LMT_ETSI; -+ break; -+ case RT_CHANNEL_DOMAIN_FCC1_FCC10: -+ pHalData->Regulation2_4G = TXPWR_LMT_FCC; -+ pHalData->Regulation5G = TXPWR_LMT_FCC; -+ break; -+ case RT_CHANNEL_DOMAIN_REALTEK_DEFINE: /* Realtek Reserve */ -+ pHalData->Regulation2_4G = TXPWR_LMT_WW; -+ pHalData->Regulation5G = TXPWR_LMT_WW; -+ break; -+ default: -+ break; ++ switch (ChannelPlan) { ++ case RT_CHANNEL_DOMAIN_WORLD_NULL: ++ pHalData->Regulation2_4G = TXPWR_LMT_WW; ++ break; ++ case RT_CHANNEL_DOMAIN_ETSI1_NULL: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_NULL: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_MKK1_NULL: ++ pHalData->Regulation2_4G = TXPWR_LMT_MKK; ++ break; ++ case RT_CHANNEL_DOMAIN_ETSI2_NULL: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_FCC1: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI1: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_MKK1_MKK1: ++ pHalData->Regulation2_4G = TXPWR_LMT_MKK; ++ pHalData->Regulation5G = TXPWR_LMT_MKK; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_KCC1: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_MKK; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_FCC2: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_FCC3: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_FCC4: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_FCC5: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_FCC6: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_FCC7: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI2: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI3: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_MKK1_MKK2: ++ pHalData->Regulation2_4G = TXPWR_LMT_MKK; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_MKK1_MKK3: ++ pHalData->Regulation2_4G = TXPWR_LMT_MKK; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_NCC1: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_NCC2: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_GLOBAL_NULL: ++ pHalData->Regulation2_4G = TXPWR_LMT_WW; ++ pHalData->Regulation5G = TXPWR_LMT_WW; ++ break; ++ case RT_CHANNEL_DOMAIN_ETSI1_ETSI4: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_FCC2: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_NCC3: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI5: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_FCC8: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI6: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI7: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI8: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI9: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI10: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI11: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_NCC4: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI12: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_FCC9: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_WORLD_ETSI13: ++ pHalData->Regulation2_4G = TXPWR_LMT_ETSI; ++ pHalData->Regulation5G = TXPWR_LMT_ETSI; ++ break; ++ case RT_CHANNEL_DOMAIN_FCC1_FCC10: ++ pHalData->Regulation2_4G = TXPWR_LMT_FCC; ++ pHalData->Regulation5G = TXPWR_LMT_FCC; ++ break; ++ case RT_CHANNEL_DOMAIN_REALTEK_DEFINE: /* Realtek Reserve */ ++ pHalData->Regulation2_4G = TXPWR_LMT_WW; ++ pHalData->Regulation5G = TXPWR_LMT_WW; ++ break; ++ default: ++ break; + } +} + @@ -49450,11 +47942,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + +#define GetLineFromBuffer(buffer) strsep(&buffer, "\n") + -+int -+phy_ConfigMACWithParaFile( -+struct adapter *Adapter, -+char* pFileName -+) ++int phy_ConfigMACWithParaFile(struct adapter *Adapter, char *pFileName) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + int rlen = 0, rtStatus = _FAIL; @@ -49466,76 +47954,53 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + + memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); + -+ if ((pHalData->mac_reg_len == 0) && (pHalData->mac_reg == NULL)) -+ { ++ if ((pHalData->mac_reg_len == 0) && (pHalData->mac_reg == NULL)) { + rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); + -+ if (rtw_is_file_readable(file_path_bs) == true) -+ { ++ if (rtw_is_file_readable(file_path_bs) == true) { + rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); -+ if (rlen > 0) -+ { ++ if (rlen > 0) { + rtStatus = _SUCCESS; + pHalData->mac_reg = vzalloc(rlen); + if (pHalData->mac_reg) { + memcpy(pHalData->mac_reg, pHalData->para_file_buf, rlen); + pHalData->mac_reg_len = rlen; -+ } -+ else { ++ } else + DBG_871X("%s mac_reg alloc fail !\n", __func__); -+ } + } + } -+ } -+ else -+ { ++ } else { + if ((pHalData->mac_reg_len != 0) && (pHalData->mac_reg != NULL)) { + memcpy(pHalData->para_file_buf, pHalData->mac_reg, pHalData->mac_reg_len); + rtStatus = _SUCCESS; -+ } -+ else { ++ } else + DBG_871X("%s(): Critical Error !!!\n", __func__); -+ } + } + -+ if (rtStatus == _SUCCESS) -+ { ++ if (rtStatus == _SUCCESS) { + ptmp = pHalData->para_file_buf; -+ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) -+ { -+ if (!IsCommentString(szLine)) -+ { ++ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { ++ if (!IsCommentString(szLine)) { + /* Get 1st hex value as register offset */ -+ if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) -+ { -+ if (u4bRegOffset == 0xffff) -+ { /* Ending. */ ++ if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) { ++ if (u4bRegOffset == 0xffff) /* Ending. */ + break; -+ } + + /* Get 2nd hex value as register value. */ + szLine += u4bMove; + if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) -+ { + rtw_write8(Adapter, u4bRegOffset, (u8)u4bRegValue); -+ } + } + } + } -+ } -+ else -+ { ++ } else + DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); -+ } + + return rtStatus; +} + -+int -+phy_ConfigBBWithParaFile( -+struct adapter *Adapter, -+char* pFileName, -+u32 ConfigType ++int phy_ConfigBBWithParaFile( ++ struct adapter *Adapter, char *pFileName, u32 ConfigType +) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); @@ -49548,108 +48013,78 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + if (!(Adapter->registrypriv.load_phy_file & LOAD_BB_PARA_FILE)) + return rtStatus; + -+ switch (ConfigType) -+ { -+ case CONFIG_BB_PHY_REG: -+ pBuf = pHalData->bb_phy_reg; -+ pBufLen = &pHalData->bb_phy_reg_len; -+ break; -+ case CONFIG_BB_AGC_TAB: -+ pBuf = pHalData->bb_agc_tab; -+ pBufLen = &pHalData->bb_agc_tab_len; -+ break; -+ default: -+ DBG_871X("Unknown ConfigType!! %d\r\n", ConfigType); -+ break; ++ switch (ConfigType) { ++ case CONFIG_BB_PHY_REG: ++ pBuf = pHalData->bb_phy_reg; ++ pBufLen = &pHalData->bb_phy_reg_len; ++ break; ++ case CONFIG_BB_AGC_TAB: ++ pBuf = pHalData->bb_agc_tab; ++ pBufLen = &pHalData->bb_agc_tab_len; ++ break; ++ default: ++ DBG_871X("Unknown ConfigType!! %d\r\n", ConfigType); ++ break; + } + + memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); + -+ if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) -+ { ++ if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) { + rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); + -+ if (rtw_is_file_readable(file_path_bs) == true) -+ { ++ if (rtw_is_file_readable(file_path_bs) == true) { + rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); -+ if (rlen > 0) -+ { ++ if (rlen > 0) { + rtStatus = _SUCCESS; + pBuf = vzalloc(rlen); + if (pBuf) { + memcpy(pBuf, pHalData->para_file_buf, rlen); + *pBufLen = rlen; + -+ switch (ConfigType) -+ { -+ case CONFIG_BB_PHY_REG: -+ pHalData->bb_phy_reg = pBuf; -+ break; -+ case CONFIG_BB_AGC_TAB: -+ pHalData->bb_agc_tab = pBuf; -+ break; ++ switch (ConfigType) { ++ case CONFIG_BB_PHY_REG: ++ pHalData->bb_phy_reg = pBuf; ++ break; ++ case CONFIG_BB_AGC_TAB: ++ pHalData->bb_agc_tab = pBuf; ++ break; + } -+ } -+ else { ++ } else + DBG_871X("%s(): ConfigType %d alloc fail !\n", __func__, ConfigType); -+ } + } + } -+ } -+ else -+ { ++ } else { + if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) { + memcpy(pHalData->para_file_buf, pBuf, *pBufLen); + rtStatus = _SUCCESS; -+ } -+ else { ++ } else + DBG_871X("%s(): Critical Error !!!\n", __func__); -+ } + } + -+ if (rtStatus == _SUCCESS) -+ { ++ if (rtStatus == _SUCCESS) { + ptmp = pHalData->para_file_buf; -+ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) -+ { -+ if (!IsCommentString(szLine)) -+ { ++ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { ++ if (!IsCommentString(szLine)) { + /* Get 1st hex value as register offset. */ -+ if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) -+ { -+ if (u4bRegOffset == 0xffff) -+ { /* Ending. */ ++ if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) { ++ if (u4bRegOffset == 0xffff) /* Ending. */ + break; -+ } + else if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe) -+ { + msleep(50); -+ } + else if (u4bRegOffset == 0xfd) -+ { + mdelay(5); -+ } + else if (u4bRegOffset == 0xfc) -+ { + mdelay(1); -+ } + else if (u4bRegOffset == 0xfb) -+ { + udelay(50); -+ } + else if (u4bRegOffset == 0xfa) -+ { + udelay(5); -+ } + else if (u4bRegOffset == 0xf9) -+ { + udelay(1); -+ } + + /* Get 2nd hex value as register value. */ + szLine += u4bMove; -+ if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) -+ { ++ if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) { + /* DBG_871X("[BB-ADDR]%03lX =%08lX\n", u4bRegOffset, u4bRegValue); */ + PHY_SetBBReg(Adapter, u4bRegOffset, bMaskDWord, u4bRegValue); + @@ -49662,20 +48097,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + } + } + } -+ } -+ else -+ { ++ } else + DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); -+ } + + return rtStatus; +} + -+static void -+phy_DecryptBBPgParaFile( -+ struct adapter * Adapter, -+ char* buffer -+ ) ++static void phy_DecryptBBPgParaFile(struct adapter *Adapter, char *buffer) +{ + u32 i = 0, j = 0; + u8 map[95] = {0}; @@ -49689,12 +48117,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + + ptmp = buffer; + i = 0; -+ for (BufOfLines = GetLineFromBuffer(ptmp); BufOfLines != NULL; BufOfLines = GetLineFromBuffer(ptmp)) -+ { ++ for (BufOfLines = GetLineFromBuffer(ptmp); BufOfLines != NULL; BufOfLines = GetLineFromBuffer(ptmp)) { + /* DBG_871X("Encrypted Line: %s\n", BufOfLines); */ + -+ for (j = 0; j < strlen(BufOfLines); ++j) -+ { ++ for (j = 0; j < strlen(BufOfLines); ++j) { + currentChar = BufOfLines[j]; + + if (currentChar == '\0') @@ -49711,11 +48137,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + } +} + -+static int -+phy_ParseBBPgParaFile( -+ struct adapter * Adapter, -+ char* buffer -+ ) ++static int phy_ParseBBPgParaFile(struct adapter *Adapter, char *buffer) +{ + int rtStatus = _SUCCESS; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); @@ -49732,64 +48154,47 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + phy_DecryptBBPgParaFile(Adapter, buffer); + + ptmp = buffer; -+ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) -+ { -+ if (!IsCommentString(szLine)) -+ { ++ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { ++ if (!IsCommentString(szLine)) { + if (isAllSpaceOrTab(szLine, sizeof(*szLine))) + continue; + + /* Get header info (relative value or exact value) */ -+ if (firstLine) -+ { -+ if (eqNByte(szLine, (u8 *)("#[v1]"), 5)) -+ { ++ if (firstLine) { ++ if (eqNByte(szLine, (u8 *)("#[v1]"), 5)) { + + pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0'; + /* DBG_871X("This is a new format PHY_REG_PG.txt\n"); */ -+ } -+ else if (eqNByte(szLine, (u8 *)("#[v0]"), 5)) -+ { ++ } else if (eqNByte(szLine, (u8 *)("#[v0]"), 5)) { + pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0'; + /* DBG_871X("This is a old format PHY_REG_PG.txt ok\n"); */ -+ } -+ else -+ { ++ } else { + DBG_871X("The format in PHY_REG_PG are invalid %s\n", szLine); + return _FAIL; + } + -+ if (eqNByte(szLine + 5, (u8 *)("[Exact]#"), 8)) -+ { ++ if (eqNByte(szLine + 5, (u8 *)("[Exact]#"), 8)) { + pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE; + /* DBG_871X("The values in PHY_REG_PG are exact values ok\n"); */ + firstLine = false; + continue; -+ } -+ else if (eqNByte(szLine + 5, (u8 *)("[Relative]#"), 11)) -+ { ++ } else if (eqNByte(szLine + 5, (u8 *)("[Relative]#"), 11)) { + pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_RELATIVE_VALUE; + /* DBG_871X("The values in PHY_REG_PG are relative values ok\n"); */ + firstLine = false; + continue; -+ } -+ else -+ { ++ } else { + DBG_871X("The values in PHY_REG_PG are invalid %s\n", szLine); + return _FAIL; + } + } + -+ if (pHalData->odmpriv.PhyRegPgVersion == 0) -+ { ++ if (pHalData->odmpriv.PhyRegPgVersion == 0) { + /* Get 1st hex value as register offset. */ -+ if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) -+ { ++ if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) { + szLine += u4bMove; -+ if (u4bRegOffset == 0xffff) -+ { /* Ending. */ ++ if (u4bRegOffset == 0xffff) /* Ending. */ + break; -+ } + + /* Get 2nd hex value as register mask. */ + if (GetHexValueFromString(szLine, &u4bRegMask, &u4bMove)) @@ -49797,21 +48202,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + else + return _FAIL; + -+ if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE) -+ { ++ if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE) { + /* Get 3rd hex value as register value. */ -+ if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) -+ { ++ if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) { + PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, u4bRegValue); + /* DBG_871X("[ADDR] %03X =%08X Mask =%08x\n", u4bRegOffset, u4bRegValue, u4bRegMask); */ -+ } -+ else -+ { ++ } else + return _FAIL; -+ } -+ } -+ else if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) -+ { ++ } else if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) { + u32 combineValue = 0; + u8 integer = 0, fraction = 0; + @@ -49821,7 +48219,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + integer *= 2; -+ if (fraction == 5) integer += 1; ++ if (fraction == 5) ++ integer += 1; + combineValue |= (((integer / 10) << 4) + (integer % 10)); + /* DBG_871X(" %d", integer); */ + @@ -49831,7 +48230,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + integer *= 2; -+ if (fraction == 5) integer += 1; ++ if (fraction == 5) ++ integer += 1; + combineValue <<= 8; + combineValue |= (((integer / 10) << 4) + (integer % 10)); + /* DBG_871X(" %d", integer); */ @@ -49842,7 +48242,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + integer *= 2; -+ if (fraction == 5) integer += 1; ++ if (fraction == 5) ++ integer += 1; + combineValue <<= 8; + combineValue |= (((integer / 10) << 4) + (integer % 10)); + /* DBG_871X(" %d", integer); */ @@ -49853,7 +48254,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + integer *= 2; -+ if (fraction == 5) integer += 1; ++ if (fraction == 5) ++ integer += 1; + combineValue <<= 8; + combineValue |= (((integer / 10) << 4) + (integer % 10)); + /* DBG_871X(" %d", integer); */ @@ -49862,41 +48264,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + /* DBG_871X("[ADDR] 0x%3x = 0x%4x\n", u4bRegOffset, combineValue); */ + } + } -+ } -+ else if (pHalData->odmpriv.PhyRegPgVersion > 0) -+ { ++ } else if (pHalData->odmpriv.PhyRegPgVersion > 0) { + u32 index = 0; + + if (eqNByte(szLine, "0xffff", 6)) + break; + -+ if (!eqNByte("#[END]#", szLine, 7)) -+ { ++ if (!eqNByte("#[END]#", szLine, 7)) { + /* load the table label info */ -+ if (szLine[0] == '#') -+ { ++ if (szLine[0] == '#') { + index = 0; -+ if (eqNByte(szLine, "#[2.4G]" , 7)) -+ { ++ if (eqNByte(szLine, "#[2.4G]", 7)) { + band = BAND_ON_2_4G; + index += 8; -+ } -+ else if (eqNByte(szLine, "#[5G]", 5)) -+ { ++ } else if (eqNByte(szLine, "#[5G]", 5)) { + band = BAND_ON_5G; + index += 6; -+ } -+ else -+ { ++ } else { + DBG_871X("Invalid band %s in PHY_REG_PG.txt\n", szLine); + return _FAIL; + } + + rf_path = szLine[index] - 'A'; + /* DBG_871X(" Table label Band %d, RfPath %d\n", band, rf_path); */ -+ } -+ else /* load rows of tables */ -+ { ++ } else { /* load rows of tables */ + if (szLine[1] == '1') + tx_num = RF_1TX; + else if (szLine[1] == '2') @@ -49905,8 +48296,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + tx_num = RF_3TX; + else if (szLine[1] == '4') + tx_num = RF_4TX; -+ else -+ { ++ else { + DBG_871X("Invalid row in PHY_REG_PG.txt %c\n", szLine[1]); + return _FAIL; + } @@ -49928,21 +48318,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + else + return _FAIL; + -+ if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE) -+ { ++ if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE) { + /* Get 3rd hex value as register value. */ -+ if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) -+ { ++ if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) { + PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, u4bRegValue); + /* DBG_871X("[ADDR] %03X (tx_num %d) =%08X Mask =%08x\n", u4bRegOffset, tx_num, u4bRegValue, u4bRegMask); */ -+ } -+ else -+ { ++ } else + return _FAIL; -+ } -+ } -+ else if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) -+ { ++ } else if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) { + u32 combineValue = 0; + u8 integer = 0, fraction = 0; + @@ -49952,7 +48335,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + integer *= 2; -+ if (fraction == 5) integer += 1; ++ if (fraction == 5) ++ integer += 1; + combineValue |= (((integer / 10) << 4) + (integer % 10)); + /* DBG_871X(" %d", integer); */ + @@ -49962,7 +48346,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + integer *= 2; -+ if (fraction == 5) integer += 1; ++ if (fraction == 5) ++ integer += 1; + combineValue <<= 8; + combineValue |= (((integer / 10) << 4) + (integer % 10)); + /* DBG_871X(" %d", integer); */ @@ -49973,7 +48358,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + integer *= 2; -+ if (fraction == 5) integer += 1; ++ if (fraction == 5) ++ integer += 1; + combineValue <<= 8; + combineValue |= (((integer / 10) << 4) + (integer % 10)); + /* DBG_871X(" %d", integer); */ @@ -49984,7 +48370,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + integer *= 2; -+ if (fraction == 5) integer += 1; ++ if (fraction == 5) ++ integer += 1; + combineValue <<= 8; + combineValue |= (((integer / 10) << 4) + (integer % 10)); + /* DBG_871X(" %d", integer); */ @@ -50001,10 +48388,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return rtStatus; +} + -+int -+phy_ConfigBBWithPgParaFile( -+struct adapter *Adapter, -+char* pFileName) ++int phy_ConfigBBWithPgParaFile(struct adapter *Adapter, char *pFileName) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + int rlen = 0, rtStatus = _FAIL; @@ -50014,56 +48398,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + + memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); + -+ if ((pHalData->bb_phy_reg_pg_len == 0) && (pHalData->bb_phy_reg_pg == NULL)) -+ { ++ if ((pHalData->bb_phy_reg_pg_len == 0) && (pHalData->bb_phy_reg_pg == NULL)) { + rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); + -+ if (rtw_is_file_readable(file_path_bs) == true) -+ { ++ if (rtw_is_file_readable(file_path_bs) == true) { + rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); -+ if (rlen > 0) -+ { ++ if (rlen > 0) { + rtStatus = _SUCCESS; + pHalData->bb_phy_reg_pg = vzalloc(rlen); + if (pHalData->bb_phy_reg_pg) { + memcpy(pHalData->bb_phy_reg_pg, pHalData->para_file_buf, rlen); + pHalData->bb_phy_reg_pg_len = rlen; -+ } -+ else { ++ } else + DBG_871X("%s bb_phy_reg_pg alloc fail !\n", __func__); -+ } + } + } -+ } -+ else -+ { ++ } else { + if ((pHalData->bb_phy_reg_pg_len != 0) && (pHalData->bb_phy_reg_pg != NULL)) { + memcpy(pHalData->para_file_buf, pHalData->bb_phy_reg_pg, pHalData->bb_phy_reg_pg_len); + rtStatus = _SUCCESS; -+ } -+ else { ++ } else + DBG_871X("%s(): Critical Error !!!\n", __func__); -+ } + } + -+ if (rtStatus == _SUCCESS) -+ { ++ if (rtStatus == _SUCCESS) { + /* DBG_871X("phy_ConfigBBWithPgParaFile(): read %s ok\n", pFileName); */ + phy_ParseBBPgParaFile(Adapter, pHalData->para_file_buf); -+ } -+ else -+ { ++ } else + DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); -+ } + + return rtStatus; +} + -+int -+PHY_ConfigRFWithParaFile( -+struct adapter *Adapter, -+char* pFileName, -+u8 eRFPath ++int PHY_ConfigRFWithParaFile( ++ struct adapter *Adapter, char *pFileName, u8 eRFPath +) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); @@ -50077,114 +48445,84 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + if (!(Adapter->registrypriv.load_phy_file & LOAD_RF_PARA_FILE)) + return rtStatus; + -+ switch (eRFPath) -+ { -+ case ODM_RF_PATH_A: -+ pBuf = pHalData->rf_radio_a; -+ pBufLen = &pHalData->rf_radio_a_len; -+ break; -+ case ODM_RF_PATH_B: -+ pBuf = pHalData->rf_radio_b; -+ pBufLen = &pHalData->rf_radio_b_len; -+ break; -+ default: -+ DBG_871X("Unknown RF path!! %d\r\n", eRFPath); -+ break; ++ switch (eRFPath) { ++ case ODM_RF_PATH_A: ++ pBuf = pHalData->rf_radio_a; ++ pBufLen = &pHalData->rf_radio_a_len; ++ break; ++ case ODM_RF_PATH_B: ++ pBuf = pHalData->rf_radio_b; ++ pBufLen = &pHalData->rf_radio_b_len; ++ break; ++ default: ++ DBG_871X("Unknown RF path!! %d\r\n", eRFPath); ++ break; + } + + memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); + -+ if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) -+ { ++ if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) { + rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); + -+ if (rtw_is_file_readable(file_path_bs) == true) -+ { ++ if (rtw_is_file_readable(file_path_bs) == true) { + rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); -+ if (rlen > 0) -+ { ++ if (rlen > 0) { + rtStatus = _SUCCESS; + pBuf = vzalloc(rlen); + if (pBuf) { + memcpy(pBuf, pHalData->para_file_buf, rlen); + *pBufLen = rlen; + -+ switch (eRFPath) -+ { -+ case ODM_RF_PATH_A: -+ pHalData->rf_radio_a = pBuf; -+ break; -+ case ODM_RF_PATH_B: -+ pHalData->rf_radio_b = pBuf; -+ break; ++ switch (eRFPath) { ++ case ODM_RF_PATH_A: ++ pHalData->rf_radio_a = pBuf; ++ break; ++ case ODM_RF_PATH_B: ++ pHalData->rf_radio_b = pBuf; ++ break; + } -+ } -+ else { ++ } else + DBG_871X("%s(): eRFPath =%d alloc fail !\n", __func__, eRFPath); -+ } + } + } -+ } -+ else -+ { ++ } else { + if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) { + memcpy(pHalData->para_file_buf, pBuf, *pBufLen); + rtStatus = _SUCCESS; -+ } -+ else { ++ } else + DBG_871X("%s(): Critical Error !!!\n", __func__); -+ } + } + -+ if (rtStatus == _SUCCESS) -+ { ++ if (rtStatus == _SUCCESS) { + /* DBG_871X("%s(): read %s successfully\n", __func__, pFileName); */ + + ptmp = pHalData->para_file_buf; -+ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) -+ { -+ if (!IsCommentString(szLine)) -+ { ++ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { ++ if (!IsCommentString(szLine)) { + /* Get 1st hex value as register offset. */ -+ if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) -+ { -+ if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe) -+ { /* Deay specific ms. Only RF configuration require delay. */ ++ if (GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) { ++ if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe) /* Deay specific ms. Only RF configuration require delay. */ + msleep(50); -+ } -+ else if (u4bRegOffset == 0xfd) -+ { ++ else if (u4bRegOffset == 0xfd) { + /* mdelay(5); */ -+ for (i = 0;i<100;i++) ++ for (i = 0; i < 100; i++) + udelay(MAX_STALL_TIME); -+ } -+ else if (u4bRegOffset == 0xfc) -+ { ++ } else if (u4bRegOffset == 0xfc) { + /* mdelay(1); */ -+ for (i = 0;i<20;i++) ++ for (i = 0; i < 20; i++) + udelay(MAX_STALL_TIME); -+ } -+ else if (u4bRegOffset == 0xfb) -+ { ++ } else if (u4bRegOffset == 0xfb) + udelay(50); -+ } + else if (u4bRegOffset == 0xfa) -+ { + udelay(5); -+ } + else if (u4bRegOffset == 0xf9) -+ { + udelay(1); -+ } + else if (u4bRegOffset == 0xffff) -+ { + break; -+ } + + /* Get 2nd hex value as register value. */ + szLine += u4bMove; -+ if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) -+ { ++ if (GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) { + PHY_SetRFReg(Adapter, eRFPath, u4bRegOffset, bRFRegOffsetMask, u4bRegValue); + + /* Temp add, for frequency lock, if no delay, that may cause */ @@ -50200,24 +48538,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + } + } + } -+ } -+ else -+ { ++ } else + DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); -+ } + + return rtStatus; +} + -+static void -+initDeltaSwingIndexTables( ++static void initDeltaSwingIndexTables( + struct adapter *Adapter, -+ char* Band, -+ char* Path, -+ char* Sign, -+ char* Channel, -+ char* Rate, -+ char* Data ++ char *Band, ++ char *Path, ++ char *Sign, ++ char *Channel, ++ char *Rate, ++ char *Data +) +{ + #define STR_EQUAL_5G(_band, _path, _sign, _rate, _chnl) \ @@ -50230,132 +48564,77 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + ) + + #define STORE_SWING_TABLE(_array, _iteratedIdx) \ -+ for (token = strsep(&Data, delim); token != NULL; token = strsep(&Data, delim))\ -+ {\ ++ for (token = strsep(&Data, delim); token != NULL; token = strsep(&Data, delim)) {\ + sscanf(token, "%d", &idx);\ + _array[_iteratedIdx++] = (u8)idx;\ -+ }\ ++ } \ + + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; -+ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); + u32 j = 0; + char *token; + char delim[] = ","; + u32 idx = 0; + + /* DBG_871X("===>initDeltaSwingIndexTables(): Band: %s;\nPath: %s;\nSign: %s;\nChannel: %s;\nRate: %s;\n, Data: %s;\n", */ -+ /* Band, Path, Sign, Channel, Rate, Data); */ ++ /* Band, Path, Sign, Channel, Rate, Data); */ + -+ if (STR_EQUAL_2G("2G", "A", "+", "CCK")) -+ { ++ if (STR_EQUAL_2G("2G", "A", "+", "CCK")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, j); -+ } -+ else if (STR_EQUAL_2G("2G", "A", "-", "CCK")) -+ { ++ } else if (STR_EQUAL_2G("2G", "A", "-", "CCK")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, j); -+ } -+ else if (STR_EQUAL_2G("2G", "B", "+", "CCK")) -+ { ++ } else if (STR_EQUAL_2G("2G", "B", "+", "CCK")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, j); -+ } -+ else if (STR_EQUAL_2G("2G", "B", "-", "CCK")) -+ { ++ } else if (STR_EQUAL_2G("2G", "B", "-", "CCK")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, j); -+ } -+ else if (STR_EQUAL_2G("2G", "A", "+", "ALL")) -+ { ++ } else if (STR_EQUAL_2G("2G", "A", "+", "ALL")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, j); -+ } -+ else if (STR_EQUAL_2G("2G", "A", "-", "ALL")) -+ { ++ } else if (STR_EQUAL_2G("2G", "A", "-", "ALL")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, j); -+ } -+ else if (STR_EQUAL_2G("2G", "B", "+", "ALL")) -+ { ++ } else if (STR_EQUAL_2G("2G", "B", "+", "ALL")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, j); -+ } -+ else if (STR_EQUAL_2G("2G", "B", "-", "ALL")) -+ { ++ } else if (STR_EQUAL_2G("2G", "B", "-", "ALL")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, j); -+ } -+ else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "0")) -+ { ++ } else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "0")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[0], j); -+ } -+ else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "0")) -+ { ++ } else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "0")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[0], j); -+ } -+ else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "0")) -+ { ++ } else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "0")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[0], j); -+ } -+ else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "0")) -+ { ++ } else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "0")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[0], j); -+ } -+ else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "1")) -+ { ++ } else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "1")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[1], j); -+ } -+ else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "1")) -+ { ++ } else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "1")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[1], j); -+ } -+ else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "1")) -+ { ++ } else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "1")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[1], j); -+ } -+ else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "1")) -+ { ++ } else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "1")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[1], j); -+ } -+ else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "2")) -+ { ++ } else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "2")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[2], j); -+ } -+ else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "2")) -+ { ++ } else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "2")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[2], j); -+ } -+ else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "2")) -+ { ++ } else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "2")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[2], j); -+ } -+ else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "2")) -+ { ++ } else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "2")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[2], j); -+ } -+ else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "3")) -+ { ++ } else if (STR_EQUAL_5G("5G", "A", "+", "ALL", "3")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[3], j); -+ } -+ else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "3")) -+ { ++ } else if (STR_EQUAL_5G("5G", "A", "-", "ALL", "3")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[3], j); -+ } -+ else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "3")) -+ { ++ } else if (STR_EQUAL_5G("5G", "B", "+", "ALL", "3")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[3], j); -+ } -+ else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "3")) -+ { ++ } else if (STR_EQUAL_5G("5G", "B", "-", "ALL", "3")) { + STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[3], j); -+ } -+ else -+ { ++ } else + DBG_871X("===>initDeltaSwingIndexTables(): The input is invalid!!\n"); -+ } +} + -+int -+PHY_ConfigRFWithTxPwrTrackParaFile( -+struct adapter * Adapter, -+char* pFileName -+) ++int PHY_ConfigRFWithTxPwrTrackParaFile(struct adapter *Adapter, char *pFileName) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + int rlen = 0, rtStatus = _FAIL; + char *szLine, *ptmp; + u32 i = 0; @@ -50365,50 +48644,38 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + + memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); + -+ if ((pHalData->rf_tx_pwr_track_len == 0) && (pHalData->rf_tx_pwr_track == NULL)) -+ { ++ if ((pHalData->rf_tx_pwr_track_len == 0) && (pHalData->rf_tx_pwr_track == NULL)) { + rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); + -+ if (rtw_is_file_readable(file_path_bs) == true) -+ { ++ if (rtw_is_file_readable(file_path_bs) == true) { + rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); -+ if (rlen > 0) -+ { ++ if (rlen > 0) { + rtStatus = _SUCCESS; + pHalData->rf_tx_pwr_track = vzalloc(rlen); + if (pHalData->rf_tx_pwr_track) { + memcpy(pHalData->rf_tx_pwr_track, pHalData->para_file_buf, rlen); + pHalData->rf_tx_pwr_track_len = rlen; -+ } -+ else { ++ } else + DBG_871X("%s rf_tx_pwr_track alloc fail !\n", __func__); -+ } + } + } -+ } -+ else -+ { ++ } else { + if ((pHalData->rf_tx_pwr_track_len != 0) && (pHalData->rf_tx_pwr_track != NULL)) { + memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_track, pHalData->rf_tx_pwr_track_len); + rtStatus = _SUCCESS; -+ } -+ else { ++ } else + DBG_871X("%s(): Critical Error !!!\n", __func__); -+ } + } + -+ if (rtStatus == _SUCCESS) -+ { ++ if (rtStatus == _SUCCESS) { + /* DBG_871X("%s(): read %s successfully\n", __func__, pFileName); */ + + ptmp = pHalData->para_file_buf; -+ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) -+ { -+ if (! IsCommentString(szLine)) -+ { -+ char band[5]="", path[5]="", sign[5] = ""; -+ char chnl[5]="", rate[10]=""; -+ char data[300]=""; /* 100 is too small */ ++ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { ++ if (!IsCommentString(szLine)) { ++ char band[5] = "", path[5] = "", sign[5] = ""; ++ char chnl[5] = "", rate[10] = ""; ++ char data[300] = ""; /* 100 is too small */ + + if (strlen(szLine) < 10 || szLine[0] != '[') + continue; @@ -50418,35 +48685,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + strncpy(sign, szLine+8, 1); + + i = 10; /* szLine+10 */ -+ if (! ParseQualifiedString(szLine, &i, rate, '[', ']')) { ++ if (!ParseQualifiedString(szLine, &i, rate, '[', ']')) { + /* DBG_871X("Fail to parse rate!\n"); */ + } -+ if (! ParseQualifiedString(szLine, &i, chnl, '[', ']')) { ++ if (!ParseQualifiedString(szLine, &i, chnl, '[', ']')) { + /* DBG_871X("Fail to parse channel group!\n"); */ + } + while (szLine[i] != '{' && i < strlen(szLine)) + i++; -+ if (! ParseQualifiedString(szLine, &i, data, '{', '}')) { ++ if (!ParseQualifiedString(szLine, &i, data, '{', '}')) { + /* DBG_871X("Fail to parse data!\n"); */ + } + + initDeltaSwingIndexTables(Adapter, band, path, sign, chnl, rate, data); + } + } -+ } -+ else -+ { ++ } else + DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); -+ } + + return rtStatus; +} + -+static int -+phy_ParsePowerLimitTableFile( -+ struct adapter * Adapter, -+ char* buffer -+) ++static int phy_ParsePowerLimitTableFile(struct adapter *Adapter, char *buffer) +{ + u32 i = 0, forCnt = 0; + u8 loadingStage = 0, limitValue = 0, fraction = 0; @@ -50462,8 +48722,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + phy_DecryptBBPgParaFile(Adapter, buffer); + + ptmp = buffer; -+ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) -+ { ++ for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { + /* skip comment */ + if (IsCommentString(szLine)) { + continue; @@ -50472,6 +48731,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + if (loadingStage == 0) { + for (forCnt = 0; forCnt < TXPWR_LMT_MAX_REGULATION_NUM; ++forCnt) + memset((void *) regulation[forCnt], 0, 10); ++ + memset((void *) band, 0, 10); + memset((void *) bandwidth, 0, 10); + memset((void *) rateSection, 0, 10); @@ -50489,27 +48749,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + szLine[--i] = ' '; /* return the space in front of the regulation info */ + + /* Parse the label of the table */ -+ if (! ParseQualifiedString(szLine, &i, band, ' ', ',')) { ++ if (!ParseQualifiedString(szLine, &i, band, ' ', ',')) { + DBG_871X("Fail to parse band!\n"); + return _FAIL; + } -+ if (! ParseQualifiedString(szLine, &i, bandwidth, ' ', ',')) { ++ if (!ParseQualifiedString(szLine, &i, bandwidth, ' ', ',')) { + DBG_871X("Fail to parse bandwidth!\n"); + return _FAIL; + } -+ if (! ParseQualifiedString(szLine, &i, rfPath, ' ', ',')) { ++ if (!ParseQualifiedString(szLine, &i, rfPath, ' ', ',')) { + DBG_871X("Fail to parse rf path!\n"); + return _FAIL; + } -+ if (! ParseQualifiedString(szLine, &i, rateSection, ' ', ',')) { ++ if (!ParseQualifiedString(szLine, &i, rateSection, ' ', ',')) { + DBG_871X("Fail to parse rate!\n"); + return _FAIL; + } + + loadingStage = 1; -+ } -+ else if (loadingStage == 1) -+ { ++ } else if (loadingStage == 1) { + if (szLine[0] != '#' || szLine[1] != '#') + continue; + @@ -50524,9 +48782,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + } + + loadingStage = 2; -+ } -+ else if (loadingStage == 2) -+ { ++ } else if (loadingStage == 2) { + if (szLine[0] != '#' || szLine[1] != '#') + continue; + @@ -50535,7 +48791,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + while (szLine[i] == ' ' || szLine[i] == '\t') + ++i; + -+ if (! ParseQualifiedString(szLine, &i, colNumBuf, '#', '#')) { ++ if (!ParseQualifiedString(szLine, &i, colNumBuf, '#', '#')) { + DBG_871X("Fail to parse column number!\n"); + return _FAIL; + } @@ -50544,13 +48800,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return _FAIL; + + if (colNum > TXPWR_LMT_MAX_REGULATION_NUM) { -+ DBG_871X("unvalid col number %d (greater than max %d)\n", -+ colNum, TXPWR_LMT_MAX_REGULATION_NUM); ++ DBG_871X( ++ "unvalid col number %d (greater than max %d)\n", ++ colNum, TXPWR_LMT_MAX_REGULATION_NUM ++ ); + return _FAIL; + } + -+ for (forCnt = 0; forCnt < colNum; ++forCnt) -+ { ++ for (forCnt = 0; forCnt < colNum; ++forCnt) { + u8 regulation_name_cnt = 0; + + /* skip the space */ @@ -50568,9 +48825,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + } + + loadingStage = 3; -+ } -+ else if (loadingStage == 3) -+ { ++ } else if (loadingStage == 3) { + char channel[10] = {0}, powerLimit[10] = {0}; + u8 cnt = 0; + @@ -50583,8 +48838,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + if (eqNByte((u8 *)(szLine + i), (u8 *)("END"), 3)) { + loadingStage = 0; + continue; -+ } -+ else { ++ } else { + DBG_871X("Wrong format\n"); + DBG_871X("<===== phy_ParsePowerLimitTableFile()\n"); + return _FAIL; @@ -50607,8 +48861,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + } + /* DBG_871X("chnl %s!\n", channel); */ + -+ for (forCnt = 0; forCnt < colNum; ++forCnt) -+ { ++ for (forCnt = 0; forCnt < colNum; ++forCnt) { + /* skip the space between channel number and the power limit value */ + while (szLine[i] == ' ' || szLine[i] == '\t') + ++i; @@ -50617,14 +48870,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + cnt = 0; + fraction = 0; + memset((void *) powerLimit, 0, 10); -+ while ((szLine[i] >= '0' && szLine[i] <= '9') || szLine[i] == '.') -+ { ++ while ((szLine[i] >= '0' && szLine[i] <= '9') || szLine[i] == '.') { + if (szLine[i] == '.') { + if ((szLine[i+1] >= '0' && szLine[i+1] <= '9')) { + fraction = szLine[i+1]; + i += 2; -+ } -+ else { ++ } else { + DBG_871X("Wrong fraction in TXPWR_LMT.txt\n"); + return _FAIL; + } @@ -50641,8 +48892,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + powerLimit[0] = '6'; + powerLimit[1] = '3'; + i += 2; -+ } -+ else { ++ } else { + if (!GetU1ByteIntegerFromStringInDecimal(powerLimit, &limitValue)) + return _FAIL; + @@ -50659,15 +48909,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + if (limitValue >= 10) { + powerLimit[cnt++] = limitValue/10 + '0'; + limitValue %= 10; -+ } -+ else { ++ } else + powerLimit[cnt++] = '0'; -+ } + + powerLimit[cnt++] = limitValue + '0'; -+ } -+ /* the value is greater or equal to 10 */ -+ else if (limitValue >= 10) { ++ } else if (limitValue >= 10) { /* the value is greater or equal to 10 */ + powerLimit[cnt++] = limitValue/10 + '0'; + limitValue %= 10; + powerLimit[cnt++] = limitValue + '0'; @@ -50686,9 +48932,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + (u8 *)bandwidth, (u8 *)rateSection, (u8 *)rfPath, (u8 *)channel, (u8 *)powerLimit); + + } -+ } -+ else -+ { ++ } else { + DBG_871X("Abnormal loading stage in phy_ParsePowerLimitTableFile()!\n"); + rtStatus = _FAIL; + break; @@ -50699,13 +48943,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + return rtStatus; +} + -+int -+PHY_ConfigRFWithPowerLimitTableParaFile( -+struct adapter *Adapter, -+char* pFileName ++int PHY_ConfigRFWithPowerLimitTableParaFile( ++ struct adapter *Adapter, char *pFileName +) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + int rlen = 0, rtStatus = _FAIL; + + if (!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_LMT_PARA_FILE)) @@ -50713,47 +48955,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs + + memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); + -+ if ((pHalData->rf_tx_pwr_lmt_len == 0) && (pHalData->rf_tx_pwr_lmt == NULL)) -+ { ++ if ((pHalData->rf_tx_pwr_lmt_len == 0) && (pHalData->rf_tx_pwr_lmt == NULL)) { + rtw_merge_string(file_path_bs, PATH_MAX, rtw_phy_file_path, pFileName); + -+ if (rtw_is_file_readable(file_path_bs) == true) -+ { ++ if (rtw_is_file_readable(file_path_bs) == true) { + rlen = rtw_retrive_from_file(file_path_bs, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); -+ if (rlen > 0) -+ { ++ if (rlen > 0) { + rtStatus = _SUCCESS; + pHalData->rf_tx_pwr_lmt = vzalloc(rlen); + if (pHalData->rf_tx_pwr_lmt) { + memcpy(pHalData->rf_tx_pwr_lmt, pHalData->para_file_buf, rlen); + pHalData->rf_tx_pwr_lmt_len = rlen; -+ } -+ else { ++ } else + DBG_871X("%s rf_tx_pwr_lmt alloc fail !\n", __func__); -+ } + } + } -+ } -+ else -+ { ++ } else { + if ((pHalData->rf_tx_pwr_lmt_len != 0) && (pHalData->rf_tx_pwr_lmt != NULL)) { + memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_lmt, pHalData->rf_tx_pwr_lmt_len); + rtStatus = _SUCCESS; -+ } -+ else { ++ } else + DBG_871X("%s(): Critical Error !!!\n", __func__); -+ } + } + -+ if (rtStatus == _SUCCESS) -+ { ++ if (rtStatus == _SUCCESS) { + /* DBG_871X("%s(): read %s ok\n", __func__, pFileName); */ + rtStatus = phy_ParsePowerLimitTableFile(Adapter, pHalData->para_file_buf); -+ } -+ else -+ { ++ } else + DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __func__, pFileName); -+ } + + return rtStatus; +} @@ -50784,10 +49013,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_com_phycfg.c linux-4.3-rtl8723bs +} + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c ---- linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,612 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c +--- linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,643 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -50806,40 +49035,71 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c linux-4.3-rtl8723 + +#include "odm_precomp.h" + -+static bool -+CheckPositive( -+ PDM_ODM_T pDM_Odm, -+ const u32 Condition1, -+ const u32 Condition2 -+ ) ++static bool CheckPositive( ++ PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2 ++) +{ -+ u8 _BoardType = ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /* _GLNA */ -+ ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /* _GPA */ -+ ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /* _ALNA */ -+ ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /* _APA */ -+ ((pDM_Odm->BoardType & BIT2) >> 2) << 4; /* _BT */ ++ u8 _BoardType = ++ ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /* _GLNA */ ++ ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /* _GPA */ ++ ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /* _ALNA */ ++ ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /* _APA */ ++ ((pDM_Odm->BoardType & BIT2) >> 2) << 4; /* _BT */ + -+ u32 cond1 = Condition1, cond2 = Condition2; -+ u32 driver1 = pDM_Odm->CutVersion << 24 | -+ pDM_Odm->SupportPlatform << 16 | -+ pDM_Odm->PackageType << 12 | -+ pDM_Odm->SupportInterface << 8 | -+ _BoardType; ++ u32 cond1 = Condition1, cond2 = Condition2; ++ u32 driver1 = ++ pDM_Odm->CutVersion << 24 | ++ pDM_Odm->SupportPlatform << 16 | ++ pDM_Odm->PackageType << 12 | ++ pDM_Odm->SupportInterface << 8 | ++ _BoardType; + -+ u32 driver2 = pDM_Odm->TypeGLNA << 0 | -+ pDM_Odm->TypeGPA << 8 | -+ pDM_Odm->TypeALNA << 16 | -+ pDM_Odm->TypeAPA << 24; ++ u32 driver2 = ++ pDM_Odm->TypeGLNA << 0 | ++ pDM_Odm->TypeGPA << 8 | ++ pDM_Odm->TypeALNA << 16 | ++ pDM_Odm->TypeAPA << 24; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ ("===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n", cond1, cond2)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ ("===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n", driver1, driver2)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n", ++ cond1, ++ cond2 ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n", ++ driver1, ++ driver2 ++ ) ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ (" (Platform, Interface) = (0x%X, 0x%X)\n", pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ (" (Board, Package) = (0x%X, 0x%X)\n", pDM_Odm->BoardType, pDM_Odm->PackageType)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ (" (Platform, Interface) = (0x%X, 0x%X)\n", ++ pDM_Odm->SupportPlatform, ++ pDM_Odm->SupportInterface ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ " (Board, Package) = (0x%X, 0x%X)\n", ++ pDM_Odm->BoardType, ++ pDM_Odm->PackageType ++ ) ++ ); + + + /* Value Defined Check =============== */ @@ -50851,13 +49111,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c linux-4.3-rtl8723 + return false; + + /* Bit Defined Check ================ */ -+ /* We don't care [31:28] and [23:20] */ -+ /* */ ++ /* We don't care [31:28] and [23:20] */ ++ /* */ + cond1 &= 0x000F0FFF; + driver1 &= 0x000F0FFF; + + if ((cond1 & driver1) == cond1) { + u32 bitMask = 0; ++ + if ((cond1 & 0x0F) == 0) /* BoardType is DONTCARE */ + return true; + @@ -50870,19 +49131,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c linux-4.3-rtl8723 + if ((cond1 & BIT3) != 0) /* APA */ + bitMask |= 0xFF000000; + -+ if ((cond2 & bitMask) == (driver2 & bitMask)) /* BoardType of each RF path is matched */ ++ /* BoardType of each RF path is matched */ ++ if ((cond2 & bitMask) == (driver2 & bitMask)) + return true; + } + return false; +} -+static bool -+CheckNegative( -+ PDM_ODM_T pDM_Odm, -+ const u32 Condition1, -+ const u32 Condition2 -+ ) ++ ++static bool CheckNegative( ++ PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2 ++) +{ -+ return true; ++ return true; +} + +/****************************************************************************** @@ -51024,72 +49284,72 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c linux-4.3-rtl8723 + +}; + -+void -+ODM_ReadAndConfig_MP_8723B_AGC_TAB( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm) +{ -+ u32 i = 0; -+ u32 ArrayLen = sizeof(Array_MP_8723B_AGC_TAB)/sizeof(u32); -+ u32 * Array = Array_MP_8723B_AGC_TAB; ++ u32 i = 0; ++ u32 ArrayLen = sizeof(Array_MP_8723B_AGC_TAB)/sizeof(u32); ++ u32 *Array = Array_MP_8723B_AGC_TAB; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_8723B_AGC_TAB\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ("===> ODM_ReadAndConfig_MP_8723B_AGC_TAB\n") ++ ); + -+ for (i = 0; i < ArrayLen; i += 2) -+ { -+ u32 v1 = Array[i]; -+ u32 v2 = Array[i+1]; ++ for (i = 0; i < ArrayLen; i += 2) { ++ u32 v1 = Array[i]; ++ u32 v2 = Array[i+1]; + -+ /* This (offset, data) pair doesn't care the condition. */ -+ if (v1 < 0x40000000) -+ { -+ odm_ConfigBB_AGC_8723B(pDM_Odm, v1, bMaskDWord, v2); -+ continue; -+ } -+ else -+ { /* This line is the beginning of branch. */ -+ bool bMatched = true; -+ u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ /* This (offset, data) pair doesn't care the condition. */ ++ if (v1 < 0x40000000) { ++ odm_ConfigBB_AGC_8723B(pDM_Odm, v1, bMaskDWord, v2); ++ continue; ++ } else { ++ /* This line is the beginning of branch. */ ++ bool bMatched = true; ++ u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); + -+ if (cCond == COND_ELSE) { /* ELSE, ENDIF */ -+ bMatched = true; -+ READ_NEXT_PAIR(v1, v2, i); -+ } else if (! CheckPositive(pDM_Odm, v1, v2)) { -+ bMatched = false; -+ READ_NEXT_PAIR(v1, v2, i); -+ READ_NEXT_PAIR(v1, v2, i); -+ } else { -+ READ_NEXT_PAIR(v1, v2, i); -+ if (! CheckNegative(pDM_Odm, v1, v2)) -+ bMatched = false; -+ else -+ bMatched = true; -+ READ_NEXT_PAIR(v1, v2, i); -+ } ++ if (cCond == COND_ELSE) { /* ELSE, ENDIF */ ++ bMatched = true; ++ READ_NEXT_PAIR(v1, v2, i); ++ } else if (!CheckPositive(pDM_Odm, v1, v2)) { ++ bMatched = false; ++ READ_NEXT_PAIR(v1, v2, i); ++ READ_NEXT_PAIR(v1, v2, i); ++ } else { ++ READ_NEXT_PAIR(v1, v2, i); ++ if (!CheckNegative(pDM_Odm, v1, v2)) ++ bMatched = false; ++ else ++ bMatched = true; ++ READ_NEXT_PAIR(v1, v2, i); ++ } + -+ if (bMatched == false) -+ { /* Condition isn't matched. Discard the following (offset, data) pairs. */ -+ while (v1 < 0x40000000 && i < ArrayLen -2) -+ READ_NEXT_PAIR(v1, v2, i); ++ if (bMatched == false) { ++ /* Condition isn't matched. ++ * Discard the following (offset, data) pairs. ++ */ ++ while (v1 < 0x40000000 && i < ArrayLen-2) ++ READ_NEXT_PAIR(v1, v2, i); + -+ i -= 2; /* prevent from for-loop += 2 */ -+ } -+ else /* Configure matched pairs and skip to end of if-else. */ -+ { -+ while (v1 < 0x40000000 && i < ArrayLen-2) { -+ odm_ConfigBB_AGC_8723B(pDM_Odm, v1, bMaskDWord, v2); -+ READ_NEXT_PAIR(v1, v2, i); -+ } ++ i -= 2; /* prevent from for-loop += 2 */ ++ } else { ++ /* Configure matched pairs and skip to end of if-else. */ ++ while (v1 < 0x40000000 && i < ArrayLen-2) { ++ odm_ConfigBB_AGC_8723B(pDM_Odm, v1, bMaskDWord, v2); ++ READ_NEXT_PAIR(v1, v2, i); ++ } + -+ /* Keeps reading until ENDIF. */ -+ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); -+ while (cCond != COND_ENDIF && i < ArrayLen-2) { -+ READ_NEXT_PAIR(v1, v2, i); -+ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); -+ } -+ } -+ } -+ } ++ /* Keeps reading until ENDIF. */ ++ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ while (cCond != COND_ENDIF && i < ArrayLen-2) { ++ READ_NEXT_PAIR(v1, v2, i); ++ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ } ++ } ++ } ++ } +} + +/****************************************************************************** @@ -51293,72 +49553,71 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c linux-4.3-rtl8723 + +}; + -+void -+ODM_ReadAndConfig_MP_8723B_PHY_REG( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm) +{ -+ u32 i = 0; -+ u32 ArrayLen = sizeof(Array_MP_8723B_PHY_REG)/sizeof(u32); -+ u32 * Array = Array_MP_8723B_PHY_REG; ++ u32 i = 0; ++ u32 ArrayLen = sizeof(Array_MP_8723B_PHY_REG)/sizeof(u32); ++ u32 *Array = Array_MP_8723B_PHY_REG; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_8723B_PHY_REG\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ("===> ODM_ReadAndConfig_MP_8723B_PHY_REG\n") ++ ); + -+ for (i = 0; i < ArrayLen; i += 2) -+ { -+ u32 v1 = Array[i]; -+ u32 v2 = Array[i+1]; ++ for (i = 0; i < ArrayLen; i += 2) { ++ u32 v1 = Array[i]; ++ u32 v2 = Array[i+1]; + -+ /* This (offset, data) pair doesn't care the condition. */ -+ if (v1 < 0x40000000) -+ { -+ odm_ConfigBB_PHY_8723B(pDM_Odm, v1, bMaskDWord, v2); -+ continue; -+ } -+ else -+ { /* This line is the beginning of branch. */ -+ bool bMatched = true; -+ u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ /* This (offset, data) pair doesn't care the condition. */ ++ if (v1 < 0x40000000) { ++ odm_ConfigBB_PHY_8723B(pDM_Odm, v1, bMaskDWord, v2); ++ continue; ++ } else { ++ /* This line is the beginning of branch. */ ++ bool bMatched = true; ++ u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); + -+ if (cCond == COND_ELSE) { /* ELSE, ENDIF */ -+ bMatched = true; -+ READ_NEXT_PAIR(v1, v2, i); -+ } else if (! CheckPositive(pDM_Odm, v1, v2)) { -+ bMatched = false; -+ READ_NEXT_PAIR(v1, v2, i); -+ READ_NEXT_PAIR(v1, v2, i); -+ } else { -+ READ_NEXT_PAIR(v1, v2, i); -+ if (! CheckNegative(pDM_Odm, v1, v2)) -+ bMatched = false; -+ else -+ bMatched = true; -+ READ_NEXT_PAIR(v1, v2, i); -+ } ++ if (cCond == COND_ELSE) { /* ELSE, ENDIF */ ++ bMatched = true; ++ READ_NEXT_PAIR(v1, v2, i); ++ } else if (!CheckPositive(pDM_Odm, v1, v2)) { ++ bMatched = false; ++ READ_NEXT_PAIR(v1, v2, i); ++ READ_NEXT_PAIR(v1, v2, i); ++ } else { ++ READ_NEXT_PAIR(v1, v2, i); ++ if (!CheckNegative(pDM_Odm, v1, v2)) ++ bMatched = false; ++ else ++ bMatched = true; ++ READ_NEXT_PAIR(v1, v2, i); ++ } + -+ if (bMatched == false) -+ { /* Condition isn't matched. Discard the following (offset, data) pairs. */ -+ while (v1 < 0x40000000 && i < ArrayLen -2) -+ READ_NEXT_PAIR(v1, v2, i); ++ if (bMatched == false) { ++ /* Condition isn't matched. ++ * Discard the following (offset, data) pairs. ++ */ ++ while (v1 < 0x40000000 && i < ArrayLen-2) ++ READ_NEXT_PAIR(v1, v2, i); + -+ i -= 2; /* prevent from for-loop += 2 */ -+ } -+ else /* Configure matched pairs and skip to end of if-else. */ -+ { -+ while (v1 < 0x40000000 && i < ArrayLen-2) { -+ odm_ConfigBB_PHY_8723B(pDM_Odm, v1, bMaskDWord, v2); -+ READ_NEXT_PAIR(v1, v2, i); -+ } ++ i -= 2; /* prevent from for-loop += 2 */ ++ } else { /* Configure matched pairs and skip to end of if-else. */ ++ while (v1 < 0x40000000 && i < ArrayLen-2) { ++ odm_ConfigBB_PHY_8723B(pDM_Odm, v1, bMaskDWord, v2); ++ READ_NEXT_PAIR(v1, v2, i); ++ } + -+ /* Keeps reading until ENDIF. */ -+ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); -+ while (cCond != COND_ENDIF && i < ArrayLen-2) { -+ READ_NEXT_PAIR(v1, v2, i); -+ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); -+ } -+ } -+ } -+ } ++ /* Keeps reading until ENDIF. */ ++ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ while (cCond != COND_ENDIF && i < ArrayLen-2) { ++ READ_NEXT_PAIR(v1, v2, i); ++ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ } ++ } ++ } ++ } +} + +/****************************************************************************** @@ -51374,35 +49633,36 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.c linux-4.3-rtl8723 + 0, 0, 0, 0x00000e14, 0xffffffff, 0x26303436 +}; + -+void -+ODM_ReadAndConfig_MP_8723B_PHY_REG_PG( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm) +{ -+ u32 i = 0; -+ u32 ArrayLen = sizeof(Array_MP_8723B_PHY_REG_PG)/sizeof(u32); -+ u32 * Array = Array_MP_8723B_PHY_REG_PG; ++ u32 i = 0; ++ u32 ArrayLen = sizeof(Array_MP_8723B_PHY_REG_PG)/sizeof(u32); ++ u32 *Array = Array_MP_8723B_PHY_REG_PG; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_8723B_PHY_REG_PG\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ("===> ODM_ReadAndConfig_MP_8723B_PHY_REG_PG\n") ++ ); + + pDM_Odm->PhyRegPgVersion = 1; + pDM_Odm->PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE; + -+ for (i = 0; i < ArrayLen; i += 6) -+ { -+ u32 v1 = Array[i]; -+ u32 v2 = Array[i+1]; -+ u32 v3 = Array[i+2]; -+ u32 v4 = Array[i+3]; -+ u32 v5 = Array[i+4]; -+ u32 v6 = Array[i+5]; ++ for (i = 0; i < ArrayLen; i += 6) { ++ u32 v1 = Array[i]; ++ u32 v2 = Array[i+1]; ++ u32 v3 = Array[i+2]; ++ u32 v4 = Array[i+3]; ++ u32 v5 = Array[i+4]; ++ u32 v6 = Array[i+5]; + -+ odm_ConfigBB_PHY_REG_PG_8723B(pDM_Odm, v1, v2, v3, v4, v5, v6); ++ odm_ConfigBB_PHY_REG_PG_8723B(pDM_Odm, v1, v2, v3, v4, v5, v6); + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h ---- linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h +--- linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,48 @@ +/****************************************************************************** +* @@ -51452,10 +49712,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_BB.h linux-4.3-rtl8723 +u32 ODM_GetVersion_MP_8723B_PHY_REG_PG(void); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c ---- linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,275 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c +--- linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,302 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -51474,40 +49734,72 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c linux-4.3-rtl872 + +#include "odm_precomp.h" + -+static bool -+CheckPositive( -+ PDM_ODM_T pDM_Odm, -+ const u32 Condition1, -+ const u32 Condition2 -+ ) ++static bool CheckPositive( ++ PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2 ++) +{ -+ u8 _BoardType = ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /* _GLNA */ -+ ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /* _GPA */ -+ ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /* _ALNA */ -+ ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /* _APA */ -+ ((pDM_Odm->BoardType & BIT2) >> 2) << 4; /* _BT */ ++ u8 _BoardType = ++ ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /* _GLNA */ ++ ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /* _GPA */ ++ ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /* _ALNA */ ++ ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /* _APA */ ++ ((pDM_Odm->BoardType & BIT2) >> 2) << 4; /* _BT */ + + u32 cond1 = Condition1, cond2 = Condition2; -+ u32 driver1 = pDM_Odm->CutVersion << 24 | -+ pDM_Odm->SupportPlatform << 16 | -+ pDM_Odm->PackageType << 12 | -+ pDM_Odm->SupportInterface << 8 | -+ _BoardType; ++ u32 driver1 = ++ pDM_Odm->CutVersion << 24 | ++ pDM_Odm->SupportPlatform << 16 | ++ pDM_Odm->PackageType << 12 | ++ pDM_Odm->SupportInterface << 8 | ++ _BoardType; + -+ u32 driver2 = pDM_Odm->TypeGLNA << 0 | -+ pDM_Odm->TypeGPA << 8 | -+ pDM_Odm->TypeALNA << 16 | -+ pDM_Odm->TypeAPA << 24; ++ u32 driver2 = ++ pDM_Odm->TypeGLNA << 0 | ++ pDM_Odm->TypeGPA << 8 | ++ pDM_Odm->TypeALNA << 16 | ++ pDM_Odm->TypeAPA << 24; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ ("===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n", cond1, cond2)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ ("===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n", driver1, driver2)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n", ++ cond1, ++ cond2 ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n", ++ driver1, ++ driver2 ++ ) ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ (" (Platform, Interface) = (0x%X, 0x%X)\n", pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ (" (Board, Package) = (0x%X, 0x%X)\n", pDM_Odm->BoardType, pDM_Odm->PackageType)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ " (Platform, Interface) = (0x%X, 0x%X)\n", ++ pDM_Odm->SupportPlatform, ++ pDM_Odm->SupportInterface ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ " (Board, Package) = (0x%X, 0x%X)\n", ++ pDM_Odm->BoardType, ++ pDM_Odm->PackageType ++ ) ++ ); + + + /* Value Defined Check =============== */ @@ -51519,8 +49811,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c linux-4.3-rtl872 + return false; + + /* Bit Defined Check ================ */ -+ /* We don't care [31:28] and [23:20] */ -+ /* */ ++ /* We don't care [31:28] and [23:20] */ ++ /* */ + cond1 &= 0x000F0FFF; + driver1 &= 0x000F0FFF; + @@ -51543,14 +49835,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c linux-4.3-rtl872 + } + return false; +} -+static bool -+CheckNegative( -+ PDM_ODM_T pDM_Odm, -+ const u32 Condition1, -+ const u32 Condition2 -+ ) ++ ++static bool CheckNegative( ++ PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2 ++) +{ -+ return true; ++ return true; +} + +/****************************************************************************** @@ -51664,76 +49954,73 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.c linux-4.3-rtl872 + +}; + -+void -+ODM_ReadAndConfig_MP_8723B_MAC_REG( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm) +{ -+ u32 i = 0; -+ u32 ArrayLen = sizeof(Array_MP_8723B_MAC_REG)/sizeof(u32); -+ u32 * Array = Array_MP_8723B_MAC_REG; ++ u32 i = 0; ++ u32 ArrayLen = sizeof(Array_MP_8723B_MAC_REG)/sizeof(u32); ++ u32 *Array = Array_MP_8723B_MAC_REG; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_8723B_MAC_REG\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ("===> ODM_ReadAndConfig_MP_8723B_MAC_REG\n") ++ ); + -+ for (i = 0; i < ArrayLen; i += 2) -+ { -+ u32 v1 = Array[i]; -+ u32 v2 = Array[i+1]; ++ for (i = 0; i < ArrayLen; i += 2) { ++ u32 v1 = Array[i]; ++ u32 v2 = Array[i+1]; + -+ /* This (offset, data) pair doesn't care the condition. */ -+ if (v1 < 0x40000000) -+ { -+ odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2); -+ continue; -+ } -+ else -+ { /* This line is the beginning of branch. */ -+ bool bMatched = true; -+ u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ /* This (offset, data) pair doesn't care the condition. */ ++ if (v1 < 0x40000000) { ++ odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2); ++ continue; ++ } else { ++ /* This line is the beginning of branch. */ ++ bool bMatched = true; ++ u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); + -+ if (cCond == COND_ELSE) { /* ELSE, ENDIF */ -+ bMatched = true; -+ READ_NEXT_PAIR(v1, v2, i); -+ } else if (! CheckPositive(pDM_Odm, v1, v2)) { -+ bMatched = false; -+ READ_NEXT_PAIR(v1, v2, i); -+ READ_NEXT_PAIR(v1, v2, i); -+ } else { -+ READ_NEXT_PAIR(v1, v2, i); -+ if (! CheckNegative(pDM_Odm, v1, v2)) -+ bMatched = false; -+ else -+ bMatched = true; -+ READ_NEXT_PAIR(v1, v2, i); -+ } ++ if (cCond == COND_ELSE) { /* ELSE, ENDIF */ ++ bMatched = true; ++ READ_NEXT_PAIR(v1, v2, i); ++ } else if (!CheckPositive(pDM_Odm, v1, v2)) { ++ bMatched = false; ++ READ_NEXT_PAIR(v1, v2, i); ++ READ_NEXT_PAIR(v1, v2, i); ++ } else { ++ READ_NEXT_PAIR(v1, v2, i); ++ if (!CheckNegative(pDM_Odm, v1, v2)) ++ bMatched = false; ++ else ++ bMatched = true; ++ READ_NEXT_PAIR(v1, v2, i); ++ } + -+ if (bMatched == false) -+ { /* Condition isn't matched. Discard the following (offset, data) pairs. */ -+ while (v1 < 0x40000000 && i < ArrayLen -2) -+ READ_NEXT_PAIR(v1, v2, i); ++ if (bMatched == false) { ++ /* Condition isn't matched. Discard the following (offset, data) pairs. */ ++ while (v1 < 0x40000000 && i < ArrayLen-2) ++ READ_NEXT_PAIR(v1, v2, i); + -+ i -= 2; /* prevent from for-loop += 2 */ -+ } -+ else /* Configure matched pairs and skip to end of if-else. */ -+ { -+ while (v1 < 0x40000000 && i < ArrayLen-2) { -+ odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2); -+ READ_NEXT_PAIR(v1, v2, i); -+ } ++ i -= 2; /* prevent from for-loop += 2 */ ++ } else { /* Configure matched pairs and skip to end of if-else. */ ++ while (v1 < 0x40000000 && i < ArrayLen-2) { ++ odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2); ++ READ_NEXT_PAIR(v1, v2, i); ++ } + -+ /* Keeps reading until ENDIF. */ -+ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); -+ while (cCond != COND_ENDIF && i < ArrayLen-2) { -+ READ_NEXT_PAIR(v1, v2, i); -+ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); -+ } -+ } -+ } -+ } ++ /* Keeps reading until ENDIF. */ ++ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ while (cCond != COND_ENDIF && i < ArrayLen-2) { ++ READ_NEXT_PAIR(v1, v2, i); ++ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ } ++ } ++ } ++ } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h ---- linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h +--- linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,28 @@ +/****************************************************************************** +* @@ -51763,10 +50050,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_MAC.h linux-4.3-rtl872 + PDM_ODM_T pDM_Odm +); +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c ---- linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,638 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c +--- linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,799 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -51785,47 +50072,86 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c linux-4.3-rtl8723 + +#include "odm_precomp.h" + -+static bool -+CheckPositive( -+ PDM_ODM_T pDM_Odm, -+ const u32 Condition1, -+ const u32 Condition2 -+ ) ++static bool CheckPositive( ++ PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2 ++) +{ -+ u8 _BoardType = ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /* _GLNA */ -+ ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /* _GPA */ -+ ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /* _ALNA */ -+ ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /* _APA */ -+ ((pDM_Odm->BoardType & BIT2) >> 2) << 4; /* _BT */ ++ u8 _BoardType = ++ ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /* _GLNA */ ++ ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /* _GPA */ ++ ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /* _ALNA */ ++ ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /* _APA */ ++ ((pDM_Odm->BoardType & BIT2) >> 2) << 4; /* _BT */ + -+ u32 cond1 = Condition1, cond2 = Condition2; -+ u32 driver1 = pDM_Odm->CutVersion << 24 | -+ pDM_Odm->SupportPlatform << 16 | -+ pDM_Odm->PackageType << 12 | -+ pDM_Odm->SupportInterface << 8 | -+ _BoardType; ++ u32 cond1 = Condition1, cond2 = Condition2; ++ u32 driver1 = ++ pDM_Odm->CutVersion << 24 | ++ pDM_Odm->SupportPlatform << 16 | ++ pDM_Odm->PackageType << 12 | ++ pDM_Odm->SupportInterface << 8 | ++ _BoardType; + -+ u32 driver2 = pDM_Odm->TypeGLNA << 0 | -+ pDM_Odm->TypeGPA << 8 | -+ pDM_Odm->TypeALNA << 16 | -+ pDM_Odm->TypeAPA << 24; ++ u32 driver2 = ++ pDM_Odm->TypeGLNA << 0 | ++ pDM_Odm->TypeGPA << 8 | ++ pDM_Odm->TypeALNA << 16 | ++ pDM_Odm->TypeAPA << 24; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ ("===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n", cond1, cond2)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ ("===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n", driver1, driver2)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n", ++ cond1, ++ cond2 ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n", ++ driver1, ++ driver2 ++ ) ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ (" (Platform, Interface) = (0x%X, 0x%X)\n", pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, -+ (" (Board, Package) = (0x%X, 0x%X)\n", pDM_Odm->BoardType, pDM_Odm->PackageType)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ " (Platform, Interface) = (0x%X, 0x%X)\n", ++ pDM_Odm->SupportPlatform, ++ pDM_Odm->SupportInterface ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ " (Board, Package) = (0x%X, 0x%X)\n", ++ pDM_Odm->BoardType, ++ pDM_Odm->PackageType ++ ) ++ ); + + /* Value Defined Check =============== */ + /* QFN Type [15:12] and Cut Version [27:24] need to do value check */ + -+ if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000))) ++ if ( ++ ((cond1 & 0x0000F000) != 0) && ++ ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)) ++ ) + return false; -+ if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000))) ++ ++ if ( ++ ((cond1 & 0x0F000000) != 0) && ++ ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)) ++ ) + return false; + + /* Bit Defined Check ================ */ @@ -51835,6 +50161,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c linux-4.3-rtl8723 + + if ((cond1 & driver1) == cond1) { + u32 bitMask = 0; ++ + if ((cond1 & 0x0F) == 0) /* BoardType is DONTCARE */ + return true; + @@ -51847,21 +50174,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c linux-4.3-rtl8723 + if ((cond1 & BIT3) != 0) /* APA */ + bitMask |= 0xFF000000; + -+ if ((cond2 & bitMask) == (driver2 & bitMask)) /* BoardType of each RF path is matched */ ++ /* BoardType of each RF path is matched */ ++ if ((cond2 & bitMask) == (driver2 & bitMask)) + return true; ++ + return false; + } -+ return false; ++ ++ return false; +} + -+static bool -+CheckNegative( -+ PDM_ODM_T pDM_Odm, -+ const u32 Condition1, -+ const u32 Condition2 -+ ) ++static bool CheckNegative( ++ PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2 ++) +{ -+ return true; ++ return true; +} + +/****************************************************************************** @@ -51996,72 +50323,72 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c linux-4.3-rtl8723 + +}; + -+void -+ODM_ReadAndConfig_MP_8723B_RadioA( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_ReadAndConfig_MP_8723B_RadioA(PDM_ODM_T pDM_Odm) +{ -+ u32 i = 0; -+ u32 ArrayLen = sizeof(Array_MP_8723B_RadioA)/sizeof(u32); -+ u32 * Array = Array_MP_8723B_RadioA; ++ u32 i = 0; ++ u32 ArrayLen = sizeof(Array_MP_8723B_RadioA)/sizeof(u32); ++ u32 *Array = Array_MP_8723B_RadioA; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_8723B_RadioA\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ("===> ODM_ReadAndConfig_MP_8723B_RadioA\n") ++ ); + -+ for (i = 0; i < ArrayLen; i += 2) -+ { -+ u32 v1 = Array[i]; -+ u32 v2 = Array[i+1]; ++ for (i = 0; i < ArrayLen; i += 2) { ++ u32 v1 = Array[i]; ++ u32 v2 = Array[i+1]; + -+ /* This (offset, data) pair doesn't care the condition. */ -+ if (v1 < 0x40000000) -+ { -+ odm_ConfigRF_RadioA_8723B(pDM_Odm, v1, v2); -+ continue; -+ } -+ else -+ { /* This line is the beginning of branch. */ -+ bool bMatched = true; -+ u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ /* This (offset, data) pair doesn't care the condition. */ ++ if (v1 < 0x40000000) { ++ odm_ConfigRF_RadioA_8723B(pDM_Odm, v1, v2); ++ continue; ++ } else { ++ /* This line is the beginning of branch. */ ++ bool bMatched = true; ++ u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); + -+ if (cCond == COND_ELSE) { /* ELSE, ENDIF */ -+ bMatched = true; -+ READ_NEXT_PAIR(v1, v2, i); -+ } else if (! CheckPositive(pDM_Odm, v1, v2)) { -+ bMatched = false; -+ READ_NEXT_PAIR(v1, v2, i); -+ READ_NEXT_PAIR(v1, v2, i); -+ } else { -+ READ_NEXT_PAIR(v1, v2, i); -+ if (! CheckNegative(pDM_Odm, v1, v2)) -+ bMatched = false; -+ else -+ bMatched = true; -+ READ_NEXT_PAIR(v1, v2, i); -+ } ++ if (cCond == COND_ELSE) { /* ELSE, ENDIF */ ++ bMatched = true; ++ READ_NEXT_PAIR(v1, v2, i); ++ } else if (!CheckPositive(pDM_Odm, v1, v2)) { ++ bMatched = false; ++ READ_NEXT_PAIR(v1, v2, i); ++ READ_NEXT_PAIR(v1, v2, i); ++ } else { ++ READ_NEXT_PAIR(v1, v2, i); ++ if (!CheckNegative(pDM_Odm, v1, v2)) ++ bMatched = false; ++ else ++ bMatched = true; ++ READ_NEXT_PAIR(v1, v2, i); ++ } + -+ if (bMatched == false) -+ { /* Condition isn't matched. Discard the following (offset, data) pairs. */ -+ while (v1 < 0x40000000 && i < ArrayLen -2) -+ READ_NEXT_PAIR(v1, v2, i); ++ if (bMatched == false) { ++ /* Condition isn't matched. ++ * Discard the following (offset, data) pairs. ++ */ ++ while (v1 < 0x40000000 && i < ArrayLen-2) ++ READ_NEXT_PAIR(v1, v2, i); + -+ i -= 2; /* prevent from for-loop += 2 */ -+ } -+ else /* Configure matched pairs and skip to end of if-else. */ -+ { -+ while (v1 < 0x40000000 && i < ArrayLen-2) { -+ odm_ConfigRF_RadioA_8723B(pDM_Odm, v1, v2); -+ READ_NEXT_PAIR(v1, v2, i); -+ } ++ i -= 2; /* prevent from for-loop += 2 */ ++ } else { ++ /* Configure matched pairs and skip to end of if-else. */ ++ while (v1 < 0x40000000 && i < ArrayLen-2) { ++ odm_ConfigRF_RadioA_8723B(pDM_Odm, v1, v2); ++ READ_NEXT_PAIR(v1, v2, i); ++ } + -+ /* Keeps reading until ENDIF. */ -+ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); -+ while (cCond != COND_ENDIF && i < ArrayLen-2) { -+ READ_NEXT_PAIR(v1, v2, i); -+ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); -+ } -+ } -+ } -+ } ++ /* Keeps reading until ENDIF. */ ++ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ while (cCond != COND_ENDIF && i < ArrayLen-2) { ++ READ_NEXT_PAIR(v1, v2, i); ++ cCond = (u8)((v1 & (BIT29|BIT28)) >> 28); ++ } ++ } ++ } ++ } +} + +/****************************************************************************** @@ -52069,65 +50396,175 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c linux-4.3-rtl8723 +******************************************************************************/ + +static u8 gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_SDIO_8723B[][DELTA_SWINGIDX_SIZE] = { -+ {0, 1, 1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14}, -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14}, -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14}, ++ { ++ 0, 1, 1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, ++ 9, 10, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14 ++ }, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, ++ 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14 ++ }, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, ++ 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14 ++ }, +}; +static u8 gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_SDIO_8723B[][DELTA_SWINGIDX_SIZE] = { -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 16, 17, 17, 18, 19, 20, 20, 20}, -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 19, 20, 20, 20}, -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 21, 21}, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, ++ 12, 13, 14, 15, 15, 16, 16, 17, 17, 18, 19, 20, 20, 20 ++ }, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, ++ 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 19, 20, 20, 20 ++ }, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, ++ 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 21, 21 ++ }, +}; +static u8 gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_SDIO_8723B[][DELTA_SWINGIDX_SIZE] = { -+ {0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14}, -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 6, 7, 7, 8, 8, 9, 10, 11, 11, 12, 13, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16}, -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 16, 16, 16, 16, 16}, ++ { ++ 0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 9, 10, ++ 10, 11, 11, 12, 12, 13, 13, 14, 14, 14, 14, 14, 14, 14 ++ }, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 6, 7, 7, 8, 8, 9, 10, ++ 11, 11, 12, 13, 13, 14, 15, 16, 16, 16, 16, 16, 16, 16 ++ }, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10, 11, ++ 11, 12, 13, 14, 14, 15, 15, 16, 16, 16, 16, 16, 16, 16 ++ }, +}; +static u8 gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_SDIO_8723B[][DELTA_SWINGIDX_SIZE] = { -+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 21, 21}, -+ {0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 21, 21}, ++ { ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ++ }, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, ++ 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 21, 21 ++ }, ++ { ++ 0, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, ++ 12, 13, 14, 15, 15, 16, 17, 18, 18, 19, 20, 21, 21, 21 ++ }, ++}; ++static u8 gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_SDIO_8723B[] = { ++ 0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 6, 6, ++ 7, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15 ++}; ++static u8 gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_SDIO_8723B[] = { ++ 0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, ++ 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15 ++}; ++static u8 gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_SDIO_8723B[] = { ++ 0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 6, 6, ++ 7, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15 ++}; ++static u8 gDeltaSwingTableIdx_MP_2GA_P_TxPowerTrack_SDIO_8723B[] = { ++ 0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, ++ 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15 ++}; ++static u8 gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_SDIO_8723B[] = { ++ 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 7, 8, ++ 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15 ++}; ++static u8 gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_SDIO_8723B[] = { ++ 0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 7, 7, ++ 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15 ++}; ++static u8 gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_SDIO_8723B[] = { ++ 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 7, 8, ++ 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15 ++}; ++static u8 gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_SDIO_8723B[] = { ++ 0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 7, 7, ++ 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15 +}; -+static u8 gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_SDIO_8723B[] = {0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15}; -+static u8 gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_SDIO_8723B[] = {0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15}; -+static u8 gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_SDIO_8723B[] = {0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 10, 10, 11, 12, 13, 14, 15}; -+static u8 gDeltaSwingTableIdx_MP_2GA_P_TxPowerTrack_SDIO_8723B[] = {0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15}; -+static u8 gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_SDIO_8723B[] = {0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15}; -+static u8 gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_SDIO_8723B[] = {0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15}; -+static u8 gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_SDIO_8723B[] = {0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15}; -+static u8 gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_SDIO_8723B[] = {0, 0, 1, 2, 2, 2, 3, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, 12, 12, 13, 14, 15}; + -+void -+ODM_ReadAndConfig_MP_8723B_TxPowerTrack_SDIO( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_ReadAndConfig_MP_8723B_TxPowerTrack_SDIO(PDM_ODM_T pDM_Odm) +{ -+ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); ++ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_MP_8723B\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ("===> ODM_ReadAndConfig_MP_MP_8723B\n") ++ ); + + -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, gDeltaSwingTableIdx_MP_2GA_P_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, ++ gDeltaSwingTableIdx_MP_2GA_P_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, ++ gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, ++ gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, ++ gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE ++ ); + -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, ++ gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, ++ gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, ++ gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, ++ gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE ++ ); + -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P, gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE*3); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N, gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE*3); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P, gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE*3); -+ memcpy(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N, gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_SDIO_8723B, DELTA_SWINGIDX_SIZE*3); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P, ++ gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE*3 ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N, ++ gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE*3 ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P, ++ gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE*3 ++ ); ++ memcpy( ++ pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N, ++ gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_SDIO_8723B, ++ DELTA_SWINGIDX_SIZE*3 ++ ); +} + +/****************************************************************************** +* TXPWR_LMT.TXT +******************************************************************************/ + -+static u8 * Array_MP_8723B_TXPWR_LMT[] = { ++static u8 *Array_MP_8723B_TXPWR_LMT[] = { + "FCC", "2.4G", "20M", "CCK", "1T", "01", "32", + "ETSI", "2.4G", "20M", "CCK", "1T", "01", "32", + "MKK", "2.4G", "20M", "CCK", "1T", "01", "32", @@ -52382,32 +50819,43 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.c linux-4.3-rtl8723 + "MKK", "2.4G", "40M", "HT", "2T", "14", "63" +}; + -+void -+ODM_ReadAndConfig_MP_8723B_TXPWR_LMT( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(PDM_ODM_T pDM_Odm) +{ -+ u32 i = 0; -+ u32 ArrayLen = sizeof(Array_MP_8723B_TXPWR_LMT)/sizeof(u8 *); -+ u8 * *Array = Array_MP_8723B_TXPWR_LMT; ++ u32 i = 0; ++ u32 ArrayLen = sizeof(Array_MP_8723B_TXPWR_LMT)/sizeof(u8 *); ++ u8 **Array = Array_MP_8723B_TXPWR_LMT; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_8723B_TXPWR_LMT\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ("===> ODM_ReadAndConfig_MP_8723B_TXPWR_LMT\n") ++ ); + + for (i = 0; i < ArrayLen; i += 7) { -+ u8 * regulation = Array[i]; -+ u8 * band = Array[i+1]; -+ u8 * bandwidth = Array[i+2]; -+ u8 * rate = Array[i+3]; -+ u8 * rfPath = Array[i+4]; -+ u8 * chnl = Array[i+5]; -+ u8 * val = Array[i+6]; ++ u8 *regulation = Array[i]; ++ u8 *band = Array[i+1]; ++ u8 *bandwidth = Array[i+2]; ++ u8 *rate = Array[i+3]; ++ u8 *rfPath = Array[i+4]; ++ u8 *chnl = Array[i+5]; ++ u8 *val = Array[i+6]; + -+ odm_ConfigBB_TXPWR_LMT_8723B(pDM_Odm, regulation, band, bandwidth, rate, rfPath, chnl, val); ++ odm_ConfigBB_TXPWR_LMT_8723B( ++ pDM_Odm, ++ regulation, ++ band, ++ bandwidth, ++ rate, ++ rfPath, ++ chnl, ++ val ++ ); + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h ---- linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h +--- linux.old/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,49 @@ +/****************************************************************************** +* @@ -52458,10 +50906,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalHWImg8723B_RF.h linux-4.3-rtl8723 +u32 ODM_GetVersion_MP_8723B_TXPWR_LMT(void); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_intf.c ---- linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_intf.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,478 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/hal_intf.c linux/3rdparty/rtl8723bs/hal/hal_intf.c +--- linux.old/3rdparty/rtl8723bs/hal/hal_intf.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/hal_intf.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,474 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -52507,6 +50955,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + if (padapter->HalFunc.init_default_value) + padapter->HalFunc.init_default_value(padapter); +} ++ +void rtw_hal_free_data(struct adapter *padapter) +{ + /* free HAL Data */ @@ -52516,12 +50965,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + if (padapter->HalFunc.free_hal_data) + padapter->HalFunc.free_hal_data(padapter); +} ++ +void rtw_hal_dm_init(struct adapter *padapter) +{ + if (is_primary_adapter(padapter)) + if (padapter->HalFunc.dm_init) + padapter->HalFunc.dm_init(padapter); +} ++ +void rtw_hal_dm_deinit(struct adapter *padapter) +{ + /* cancel dm timer */ @@ -52550,9 +51001,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + rtw_setopmode_cmd(padapter, networkType, false); +} + -+uint rtw_hal_init(struct adapter *padapter) ++uint rtw_hal_init(struct adapter *padapter) +{ -+ uint status; ++ uint status; + struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); + + status = padapter->HalFunc.hal_init(padapter); @@ -52623,6 +51074,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + return padapter->HalFunc.SetHalDefVarHandler(padapter, eVariable, pValue); + return _FAIL; +} ++ +u8 rtw_hal_get_def_var(struct adapter *padapter, enum HAL_DEF_VARIABLE eVariable, void *pValue) +{ + if (padapter->HalFunc.GetHalDefVarHandler) @@ -52635,6 +51087,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + if (padapter->HalFunc.SetHalODMVarHandler) + padapter->HalFunc.SetHalODMVarHandler(padapter, eVariable, pValue1, bSet); +} ++ +void rtw_hal_get_odm_var(struct adapter *padapter, enum HAL_ODM_VARIABLE eVariable, void *pValue1, void *pValue2) +{ + if (padapter->HalFunc.GetHalODMVarHandler) @@ -52649,6 +51102,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + DBG_871X("%s: HalFunc.enable_interrupt is NULL!\n", __func__); + +} ++ +void rtw_hal_disable_interrupt(struct adapter *padapter) +{ + if (padapter->HalFunc.disable_interrupt) @@ -52696,15 +51150,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + /* pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; */ + /* memcpy(pmgntframe->attrib.ra, pwlanhdr->addr1, ETH_ALEN); */ + -+ if (padapter->securitypriv.binstallBIPkey == true) -+ { -+ if (IS_MCAST(pmgntframe->attrib.ra)) -+ { ++ if (padapter->securitypriv.binstallBIPkey == true) { ++ if (IS_MCAST(pmgntframe->attrib.ra)) { + pmgntframe->attrib.encrypt = _BIP_; + /* pmgntframe->attrib.bswenc = true; */ -+ } -+ else -+ { ++ } else { + pmgntframe->attrib.encrypt = _AES_; + pmgntframe->attrib.bswenc = true; + } @@ -52722,6 +51172,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + return padapter->HalFunc.init_xmit_priv(padapter); + return _FAIL; +} ++ +void rtw_hal_free_xmit_priv(struct adapter *padapter) +{ + if (padapter->HalFunc.free_xmit_priv != NULL) @@ -52735,6 +51186,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + + return _FAIL; +} ++ +void rtw_hal_free_recv_priv(struct adapter *padapter) +{ + @@ -52755,11 +51207,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + pmlmepriv = &(padapter->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) -+ { + add_RATid(padapter, psta, rssi_level); -+ } -+ else -+ { ++ else { + if (padapter->HalFunc.UpdateRAMaskHandler) + padapter->HalFunc.UpdateRAMaskHandler(padapter, psta->mac_id, rssi_level); + } @@ -52834,12 +51283,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + +void rtw_hal_dm_watchdog_in_lps(struct adapter *padapter) +{ -+ if (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode ==true) -+ { ++ if (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode == true) { + if (padapter->HalFunc.hal_dm_watchdog_in_lps) -+ { -+ padapter->HalFunc.hal_dm_watchdog_in_lps(padapter);/* this fuction caller is in interrupt context */ -+ } ++ padapter->HalFunc.hal_dm_watchdog_in_lps(padapter); /* this fuction caller is in interrupt context */ + } +} + @@ -52863,7 +51309,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + adapter->HalFunc.hal_notch_filter(adapter, enable); +} + -+void rtw_hal_reset_security_engine(struct adapter * adapter) ++void rtw_hal_reset_security_engine(struct adapter *adapter) +{ + if (adapter->HalFunc.hal_reset_security_engine) + adapter->HalFunc.hal_reset_security_engine(adapter); @@ -52871,7 +51317,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + +bool rtw_hal_c2h_valid(struct adapter *adapter, u8 *buf) +{ -+ return c2h_evt_valid((struct c2h_evt_hdr_88xx*)buf); ++ return c2h_evt_valid((struct c2h_evt_hdr_88xx *)buf); +} + +s32 rtw_hal_c2h_evt_read(struct adapter *adapter, u8 *buf) @@ -52934,16 +51380,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_intf.c linux-4.3-rtl8723bs/3rdpa + if (padapter->HalFunc.fill_h2c_cmd) + ret = padapter->HalFunc.fill_h2c_cmd(padapter, ElementID, CmdLen, pCmdBuffer); + else -+ { + DBG_871X("%s: func[fill_h2c_cmd] not defined!\n", __func__); -+ } + + return ret; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_phy.c ---- linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_phy.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,272 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/hal_phy.c linux/3rdparty/rtl8723bs/hal/hal_phy.c +--- linux.old/3rdparty/rtl8723bs/hal/hal_phy.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/hal_phy.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,224 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -52973,20 +51417,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar +* Output: none +* Return: u32 Return the shift bit bit position of the mask +*/ -+u32 -+PHY_CalculateBitShift( -+ u32 BitMask -+ ) ++u32 PHY_CalculateBitShift(u32 BitMask) +{ + u32 i; + -+ for(i=0; i<=31; i++) -+ { -+ if (((BitMask>>i) & 0x1 ) == 1) ++ for (i = 0; i <= 31; i++) { ++ if (((BitMask>>i) & 0x1) == 1) + break; + } + -+ return (i); ++ return i; +} + + @@ -53018,23 +51458,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar + * 11/20/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ -+u32 -+PHY_RFShadowRead( -+ IN PADAPTER Adapter, -+ IN u8 eRFPath, -+ IN u32 Offset) ++u32 PHY_RFShadowRead(IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset) +{ + return RF_Shadow[eRFPath][Offset].Value; + +} /* PHY_RFShadowRead */ + + -+void -+PHY_RFShadowWrite( -+ IN PADAPTER Adapter, -+ IN u8 eRFPath, -+ IN u32 Offset, -+ IN u32 Data) ++void PHY_RFShadowWrite( ++ IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset, IN u32 Data ++) +{ + RF_Shadow[eRFPath][Offset].Value = (Data & bRFRegOffsetMask); + RF_Shadow[eRFPath][Offset].Driver_Write = true; @@ -53042,44 +51475,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar +} /* PHY_RFShadowWrite */ + + -+bool -+PHY_RFShadowCompare( -+ IN PADAPTER Adapter, -+ IN u8 eRFPath, -+ IN u32 Offset) ++bool PHY_RFShadowCompare(IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset) +{ + u32 reg; + /* Check if we need to check the register */ -+ if (RF_Shadow[eRFPath][Offset].Compare == true) -+ { ++ if (RF_Shadow[eRFPath][Offset].Compare == true) { + reg = rtw_hal_read_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask); + /* Compare shadow and real rf register for 20bits!! */ -+ if (RF_Shadow[eRFPath][Offset].Value != reg) -+ { ++ if (RF_Shadow[eRFPath][Offset].Value != reg) { + /* Locate error position. */ + RF_Shadow[eRFPath][Offset].ErrorOrNot = true; + /* RT_TRACE(COMP_INIT, DBG_LOUD, */ + /* PHY_RFShadowCompare RF-%d Addr%02lx Err = %05lx\n", */ + /* eRFPath, Offset, reg)); */ + } -+ return RF_Shadow[eRFPath][Offset].ErrorOrNot ; ++ return RF_Shadow[eRFPath][Offset].ErrorOrNot; + } + return false; +} /* PHY_RFShadowCompare */ + + -+void -+PHY_RFShadowRecorver( -+ IN PADAPTER Adapter, -+ IN u8 eRFPath, -+ IN u32 Offset) ++void PHY_RFShadowRecorver(IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset) +{ + /* Check if the address is error */ -+ if (RF_Shadow[eRFPath][Offset].ErrorOrNot == true) -+ { ++ if (RF_Shadow[eRFPath][Offset].ErrorOrNot == true) { + /* Check if we need to recorver the register. */ -+ if (RF_Shadow[eRFPath][Offset].Recorver == true) -+ { ++ if (RF_Shadow[eRFPath][Offset].Recorver == true) { + rtw_hal_write_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask, + RF_Shadow[eRFPath][Offset].Value); + /* RT_TRACE(COMP_INIT, DBG_LOUD, */ @@ -53091,17 +51512,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar +} /* PHY_RFShadowRecorver */ + + -+void -+PHY_RFShadowCompareAll( -+ IN PADAPTER Adapter) ++void PHY_RFShadowCompareAll(IN PADAPTER Adapter) +{ -+ u8 eRFPath = 0 ; -+ u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter); ++ u8 eRFPath = 0; ++ u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter); + -+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) -+ { -+ for (Offset = 0; Offset < maxReg; Offset++) -+ { ++ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) { ++ for (Offset = 0; Offset < maxReg; Offset++) { + PHY_RFShadowCompare(Adapter, eRFPath, Offset); + } + } @@ -53109,17 +51526,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar +} /* PHY_RFShadowCompareAll */ + + -+void -+PHY_RFShadowRecorverAll( -+ IN PADAPTER Adapter) ++void PHY_RFShadowRecorverAll(IN PADAPTER Adapter) +{ -+ u8 eRFPath =0; -+ u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter); ++ u8 eRFPath = 0; ++ u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter); + -+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) -+ { -+ for (Offset = 0; Offset < maxReg; Offset++) -+ { ++ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) { ++ for (Offset = 0; Offset < maxReg; Offset++) { + PHY_RFShadowRecorver(Adapter, eRFPath, Offset); + } + } @@ -53129,10 +51542,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar + +void +PHY_RFShadowCompareFlagSet( -+ IN PADAPTER Adapter, -+ IN u8 eRFPath, -+ IN u32 Offset, -+ IN u8 Type) ++ IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset, IN u8 Type ++) +{ + /* Set True or False!!! */ + RF_Shadow[eRFPath][Offset].Compare = Type; @@ -53140,30 +51551,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar +} /* PHY_RFShadowCompareFlagSet */ + + -+void -+PHY_RFShadowRecorverFlagSet( -+ IN PADAPTER Adapter, -+ IN u8 eRFPath, -+ IN u32 Offset, -+ IN u8 Type) ++void PHY_RFShadowRecorverFlagSet( ++ IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset, IN u8 Type ++) +{ + /* Set True or False!!! */ -+ RF_Shadow[eRFPath][Offset].Recorver= Type; ++ RF_Shadow[eRFPath][Offset].Recorver = Type; + +} /* PHY_RFShadowRecorverFlagSet */ + + -+void -+PHY_RFShadowCompareFlagSetAll( -+ IN PADAPTER Adapter) ++void PHY_RFShadowCompareFlagSetAll(IN PADAPTER Adapter) +{ + u8 eRFPath = 0; -+ u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter); ++ u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter); + -+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) -+ { -+ for (Offset = 0; Offset < maxReg; Offset++) -+ { ++ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) { ++ for (Offset = 0; Offset < maxReg; Offset++) { + /* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */ + if (Offset != 0x26 && Offset != 0x27) + PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, false); @@ -53175,17 +51579,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar +} /* PHY_RFShadowCompareFlagSetAll */ + + -+void -+PHY_RFShadowRecorverFlagSetAll( -+ IN PADAPTER Adapter) ++void PHY_RFShadowRecorverFlagSetAll(IN PADAPTER Adapter) +{ + u8 eRFPath = 0; -+ u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter); ++ u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter); + -+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) -+ { -+ for (Offset = 0; Offset < maxReg; Offset++) -+ { ++ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) { ++ for (Offset = 0; Offset < maxReg; Offset++) { + /* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */ + if (Offset != 0x26 && Offset != 0x27) + PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, false); @@ -53196,17 +51596,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar + +} /* PHY_RFShadowCompareFlagSetAll */ + -+void -+PHY_RFShadowRefresh( -+ IN PADAPTER Adapter) ++void PHY_RFShadowRefresh(IN PADAPTER Adapter) +{ + u8 eRFPath = 0; -+ u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter); ++ u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter); + -+ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) -+ { -+ for (Offset = 0; Offset < maxReg; Offset++) -+ { ++ for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) { ++ for (Offset = 0; Offset < maxReg; Offset++) { + RF_Shadow[eRFPath][Offset].Value = 0; + RF_Shadow[eRFPath][Offset].Compare = false; + RF_Shadow[eRFPath][Offset].Recorver = false; @@ -53216,10 +51612,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_phy.c linux-4.3-rtl8723bs/3rdpar + } + +} /* PHY_RFShadowRead */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c ---- linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,2171 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c +--- linux.old/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,2091 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -53270,11 +51666,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + * 88E as the default table. + */ +static u8 DeltaSwingTableIdx_2GA_N_8188E[] = { -+ 0, 0, 0, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 8, 8, -+ 9, 9, 10, 10, 10, 11, 11, 11, 11}; ++ 0, 0, 0, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, ++ 7, 7, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 11, 11 ++}; +static u8 DeltaSwingTableIdx_2GA_P_8188E[] = { -+ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 7, -+ 7, 8, 8, 8, 9, 9, 9, 9, 9}; ++ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, ++ 4, 4, 4, 5, 5, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9 ++}; + +/* 3 ============================================================ */ +/* 3 Tx Power Tracking */ @@ -53282,14 +51680,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + +static void setIqkMatrix_8723B( -+ PDM_ODM_T pDM_Odm, ++ PDM_ODM_T pDM_Odm, + u8 OFDM_index, + u8 RFPath, -+ s32 IqkResult_X, -+ s32 IqkResult_Y -+ ) ++ s32 IqkResult_X, ++ s32 IqkResult_Y ++) +{ -+ s32 ele_A = 0, ele_D, ele_C = 0, value32; ++ s32 ele_A = 0, ele_D, ele_C = 0, value32; + + if (OFDM_index >= OFDM_TABLE_SIZE) + OFDM_index = OFDM_TABLE_SIZE-1; @@ -53297,8 +51695,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ele_D = (OFDMSwingTable_New[OFDM_index] & 0xFFC00000)>>22; + + /* new element A = element D x X */ -+ if ((IqkResult_X != 0) && (*(pDM_Odm->pBandType) == ODM_BAND_2_4G)) -+ { ++ if ((IqkResult_X != 0) && (*(pDM_Odm->pBandType) == ODM_BAND_2_4G)) { + if ((IqkResult_X & 0x00000200) != 0) /* consider minus */ + IqkResult_X = IqkResult_X | 0xFFFFFC00; + ele_A = ((IqkResult_X * ele_D)>>8)&0x000003FF; @@ -53309,8 +51706,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ele_C = ((IqkResult_Y * ele_D)>>8)&0x000003FF; + + /* if (RFPath == ODM_RF_PATH_A) */ -+ switch (RFPath) -+ { ++ switch (RFPath) { + case ODM_RF_PATH_A: + /* wirte new elements A, C, D to regC80 and regC94, element B is always 0 */ + value32 = (ele_D<<22)|((ele_C&0x3F)<<16)|ele_A; @@ -53324,7 +51720,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + break; + case ODM_RF_PATH_B: + /* wirte new elements A, C, D to regC88 and regC9C, element B is always 0 */ -+ value32 =(ele_D<<22)|((ele_C&0x3F)<<16) |ele_A; ++ value32 = (ele_D<<22)|((ele_C&0x3F)<<16)|ele_A; + PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XBTxIQImbalance, bMaskDWord, value32); + + value32 = (ele_C&0x000003C0)>>6; @@ -53337,11 +51733,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + default: + break; + } -+ } -+ else -+ { -+ switch (RFPath) -+ { ++ } else { ++ switch (RFPath) { + case ODM_RF_PATH_A: + PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable_New[OFDM_index]); + PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XCTxAFE, bMaskH4Bits, 0x00); @@ -53364,14 +51757,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +} + + -+static void -+setCCKFilterCoefficient( -+ PDM_ODM_T pDM_Odm, -+ u8 CCKSwingIndex -+) ++static void setCCKFilterCoefficient(PDM_ODM_T pDM_Odm, u8 CCKSwingIndex) +{ -+ if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) -+ { ++ if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + rtw_write8(pDM_Odm->Adapter, 0xa22, CCKSwingTable_Ch1_Ch13_New[CCKSwingIndex][0]); + rtw_write8(pDM_Odm->Adapter, 0xa23, CCKSwingTable_Ch1_Ch13_New[CCKSwingIndex][1]); + rtw_write8(pDM_Odm->Adapter, 0xa24, CCKSwingTable_Ch1_Ch13_New[CCKSwingIndex][2]); @@ -53380,9 +51768,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + rtw_write8(pDM_Odm->Adapter, 0xa27, CCKSwingTable_Ch1_Ch13_New[CCKSwingIndex][5]); + rtw_write8(pDM_Odm->Adapter, 0xa28, CCKSwingTable_Ch1_Ch13_New[CCKSwingIndex][6]); + rtw_write8(pDM_Odm->Adapter, 0xa29, CCKSwingTable_Ch1_Ch13_New[CCKSwingIndex][7]); -+ } -+ else -+ { ++ } else { + rtw_write8(pDM_Odm->Adapter, 0xa22, CCKSwingTable_Ch14_New[CCKSwingIndex][0]); + rtw_write8(pDM_Odm->Adapter, 0xa23, CCKSwingTable_Ch14_New[CCKSwingIndex][1]); + rtw_write8(pDM_Odm->Adapter, 0xa24, CCKSwingTable_Ch14_New[CCKSwingIndex][2]); @@ -53395,11 +51781,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +} + +void DoIQK_8723B( -+ PDM_ODM_T pDM_Odm, ++ PDM_ODM_T pDM_Odm, + u8 DeltaThermalIndex, + u8 ThermalValue, + u8 Threshold -+ ) ++) +{ +} + @@ -53420,40 +51806,35 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + *04/23/2012 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ -+void -+ODM_TxPwrTrackSetPwr_8723B( -+ PDM_ODM_T pDM_Odm, -+ PWRTRACK_METHOD Method, -+ u8 RFPath, -+ u8 ChannelMappedIndex -+ ) ++void ODM_TxPwrTrackSetPwr_8723B( ++ PDM_ODM_T pDM_Odm, ++ PWRTRACK_METHOD Method, ++ u8 RFPath, ++ u8 ChannelMappedIndex ++) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + u8 PwrTrackingLimit_OFDM = 34; /* 0dB */ -+ u8 PwrTrackingLimit_CCK = 28; /* 2dB */ ++ u8 PwrTrackingLimit_CCK = 28; /* 2dB */ + u8 TxRate = 0xFF; + u8 Final_OFDM_Swing_Index = 0; + u8 Final_CCK_Swing_Index = 0; + + { -+ u16 rate = *(pDM_Odm->pForcedDataRate); ++ u16 rate = *(pDM_Odm->pForcedDataRate); + -+ if (!rate) /* auto rate */ -+ { ++ if (!rate) { /* auto rate */ + if (pDM_Odm->TxRate != 0xFF) + TxRate = HwRateToMRate(pDM_Odm->TxRate); -+ } -+ else /* force rate */ -+ { ++ } else /* force rate */ + TxRate = (u8)rate; -+ } ++ + } + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("===>ODM_TxPwrTrackSetPwr8723B\n")); + -+ if (TxRate != 0xFF) -+ { ++ if (TxRate != 0xFF) { + /* 2 CCK */ + if ((TxRate >= MGN_1M) && (TxRate <= MGN_11M)) + PwrTrackingLimit_CCK = 28; /* 2dB */ @@ -53477,18 +51858,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("TxRate = 0x%x, PwrTrackingLimit =%d\n", TxRate, PwrTrackingLimit_OFDM)); + + if (Method == TXAGC) { -+ struct adapter * Adapter = pDM_Odm->Adapter; ++ struct adapter *Adapter = pDM_Odm->Adapter; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("odm_TxPwrTrackSetPwr8723B CH =%d\n", *(pDM_Odm->pChannel))); + + pDM_Odm->Remnant_OFDMSwingIdx[RFPath] = pDM_Odm->Absolute_OFDMSwingIdx[RFPath]; + -+ pDM_Odm->Modify_TxAGC_Flag_PathA = true; -+ pDM_Odm->Modify_TxAGC_Flag_PathA_CCK = true; ++ pDM_Odm->Modify_TxAGC_Flag_PathA = true; ++ pDM_Odm->Modify_TxAGC_Flag_PathA_CCK = true; + -+ PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, CCK); -+ PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, OFDM); -+ PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, HT_MCS0_MCS7); ++ PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, CCK); ++ PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, OFDM); ++ PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, HT_MCS0_MCS7); + } else if (Method == BBSWING) { + Final_OFDM_Swing_Index = pDM_Odm->DefaultOfdmIndex + pDM_Odm->Absolute_OFDMSwingIdx[RFPath]; + Final_CCK_Swing_Index = pDM_Odm->DefaultCckIndex + pDM_Odm->Absolute_OFDMSwingIdx[RFPath]; @@ -53510,9 +51891,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + setCCKFilterCoefficient(pDM_Odm, Final_CCK_Swing_Index); + -+ } -+ else if (Method == MIX_MODE) -+ { ++ } else if (Method == MIX_MODE) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("pDM_Odm->DefaultOfdmIndex =%d, pDM_Odm->DefaultCCKIndex =%d, pDM_Odm->Absolute_OFDMSwingIdx[RFPath]=%d, RF_Path = %d\n", + pDM_Odm->DefaultOfdmIndex, pDM_Odm->DefaultCckIndex, pDM_Odm->Absolute_OFDMSwingIdx[RFPath], RFPath)); @@ -53520,8 +51899,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + Final_OFDM_Swing_Index = pDM_Odm->DefaultOfdmIndex + pDM_Odm->Absolute_OFDMSwingIdx[RFPath]; + Final_CCK_Swing_Index = pDM_Odm->DefaultCckIndex + pDM_Odm->Absolute_OFDMSwingIdx[RFPath]; + -+ if (Final_OFDM_Swing_Index > PwrTrackingLimit_OFDM) /* BBSwing higher then Limit */ -+ { ++ if (Final_OFDM_Swing_Index > PwrTrackingLimit_OFDM) { /* BBSwing higher then Limit */ + pDM_Odm->Remnant_OFDMSwingIdx[RFPath] = Final_OFDM_Swing_Index - PwrTrackingLimit_OFDM; + + setIqkMatrix_8723B(pDM_Odm, PwrTrackingLimit_OFDM, RFPath, @@ -53535,9 +51913,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("******Path_A Over BBSwing Limit , PwrTrackingLimit = %d , Remnant TxAGC Value = %d\n", + PwrTrackingLimit_OFDM, pDM_Odm->Remnant_OFDMSwingIdx[RFPath])); -+ } -+ else if (Final_OFDM_Swing_Index <= 0) -+ { ++ } else if (Final_OFDM_Swing_Index <= 0) { + pDM_Odm->Remnant_OFDMSwingIdx[RFPath] = Final_OFDM_Swing_Index; + + setIqkMatrix_8723B(pDM_Odm, 0, RFPath, @@ -53551,9 +51927,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("******Path_A Lower then BBSwing lower bound 0 , Remnant TxAGC Value = %d\n", + pDM_Odm->Remnant_OFDMSwingIdx[RFPath])); -+ } -+ else -+ { ++ } else { + setIqkMatrix_8723B(pDM_Odm, Final_OFDM_Swing_Index, RFPath, + pDM_Odm->RFCalibrateInfo.IQKMatrixRegSetting[ChannelMappedIndex].Value[0][0], + pDM_Odm->RFCalibrateInfo.IQKMatrixRegSetting[ChannelMappedIndex].Value[0][1]); @@ -53561,8 +51935,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("******Path_A Compensate with BBSwing , Final_OFDM_Swing_Index = %d\n", Final_OFDM_Swing_Index)); + -+ if (pDM_Odm->Modify_TxAGC_Flag_PathA) /* If TxAGC has changed, reset TxAGC again */ -+ { ++ if (pDM_Odm->Modify_TxAGC_Flag_PathA) { /* If TxAGC has changed, reset TxAGC again */ + pDM_Odm->Remnant_OFDMSwingIdx[RFPath] = 0; + PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, OFDM); + PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, HT_MCS0_MCS7); @@ -53573,8 +51946,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + } + } + -+ if (Final_CCK_Swing_Index > PwrTrackingLimit_CCK) -+ { ++ if (Final_CCK_Swing_Index > PwrTrackingLimit_CCK) { + pDM_Odm->Remnant_CCKSwingIdx = Final_CCK_Swing_Index - PwrTrackingLimit_CCK; + setCCKFilterCoefficient(pDM_Odm, PwrTrackingLimit_CCK); + pDM_Odm->Modify_TxAGC_Flag_PathA_CCK = true; @@ -53582,9 +51954,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("******Path_A CCK Over Limit , PwrTrackingLimit_CCK = %d , pDM_Odm->Remnant_CCKSwingIdx = %d\n", PwrTrackingLimit_CCK, pDM_Odm->Remnant_CCKSwingIdx)); -+ } -+ else if (Final_CCK_Swing_Index <= 0) /* Lowest CCK Index = 0 */ -+ { ++ } else if (Final_CCK_Swing_Index <= 0) { /* Lowest CCK Index = 0 */ + pDM_Odm->Remnant_CCKSwingIdx = Final_CCK_Swing_Index; + setCCKFilterCoefficient(pDM_Odm, 0); + pDM_Odm->Modify_TxAGC_Flag_PathA_CCK = true; @@ -53592,16 +51962,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("******Path_A CCK Under Limit , PwrTrackingLimit_CCK = %d , pDM_Odm->Remnant_CCKSwingIdx = %d\n", 0, pDM_Odm->Remnant_CCKSwingIdx)); -+ } -+ else -+ { ++ } else { + setCCKFilterCoefficient(pDM_Odm, Final_CCK_Swing_Index); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("******Path_A CCK Compensate with BBSwing , Final_CCK_Swing_Index = %d\n", Final_CCK_Swing_Index)); + -+ if (pDM_Odm->Modify_TxAGC_Flag_PathA_CCK) /* If TxAGC has changed, reset TxAGC again */ -+ { ++ if (pDM_Odm->Modify_TxAGC_Flag_PathA_CCK) { /* If TxAGC has changed, reset TxAGC again */ + pDM_Odm->Remnant_CCKSwingIdx = 0; + PHY_SetTxPowerIndexByRateSection(Adapter, RFPath, pHalData->CurrentChannel, CCK); + pDM_Odm->Modify_TxAGC_Flag_PathA_CCK = false; @@ -53610,27 +51977,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ("******Path_A pDM_Odm->Modify_TxAGC_Flag_CCK = false\n")); + } + } -+ } -+ else -+ { ++ } else + return; /* This method is not supported. */ -+ } +} + -+static void -+GetDeltaSwingTable_8723B( -+PDM_ODM_T pDM_Odm, -+ u8 * *TemperatureUP_A, -+ u8 * *TemperatureDOWN_A, -+ u8 * *TemperatureUP_B, -+ u8 * *TemperatureDOWN_B -+ ) ++static void GetDeltaSwingTable_8723B( ++ PDM_ODM_T pDM_Odm, ++ u8 **TemperatureUP_A, ++ u8 **TemperatureDOWN_A, ++ u8 **TemperatureUP_B, ++ u8 **TemperatureDOWN_B ++) +{ -+ struct adapter * Adapter = pDM_Odm->Adapter; -+ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ u16 rate = *(pDM_Odm->pForcedDataRate); -+ u8 channel = pHalData->CurrentChannel; ++ struct adapter *Adapter = pDM_Odm->Adapter; ++ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ u16 rate = *(pDM_Odm->pForcedDataRate); ++ u8 channel = pHalData->CurrentChannel; + + if (1 <= channel && channel <= 14) { + if (IS_CCK_RATE(rate)) { @@ -53644,7 +52007,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + *TemperatureUP_B = pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P; + *TemperatureDOWN_B = pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N; + } -+ }/*else if (36 <= channel && channel <= 64) { ++ } /*else if (36 <= channel && channel <= 64) { + *TemperatureUP_A = pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[0]; + *TemperatureDOWN_A = pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[0]; + *TemperatureUP_B = pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[0]; @@ -53670,9 +52033,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +} + + -+void ConfigureTxpowerTrack_8723B( -+ PTXPWRTRACK_CFG pConfig -+ ) ++void ConfigureTxpowerTrack_8723B(PTXPWRTRACK_CFG pConfig) +{ + pConfig->SwingTableSize_CCK = CCK_TABLE_SIZE; + pConfig->SwingTableSize_OFDM = OFDM_TABLE_SIZE; @@ -53687,16 +52048,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + pConfig->GetDeltaSwingTable = GetDeltaSwingTable_8723B; +} + -+/* 1 7. IQK */ ++/* 1 7. IQK */ +#define MAX_TOLERANCE 5 +#define IQK_DELAY_TIME 1 /* ms */ + -+static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -+phy_PathA_IQK_8723B( -+struct adapter *padapter, -+bool configPathB, -+u8 RF_Path -+ ) ++/* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ ++static u8 phy_PathA_IQK_8723B( ++ struct adapter *padapter, bool configPathB, u8 RF_Path ++) +{ + u32 regEAC, regE94, regE9C, tmp, Path_SEL_BB /*, regEA4*/; + u8 result = 0x00; @@ -53786,16 +52145,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + + /* Allen 20131125 */ -+ tmp =(regE9C & 0x03FF0000)>>16; -+ if ((tmp & 0x200)> 0) ++ tmp = (regE9C & 0x03FF0000)>>16; ++ if ((tmp & 0x200) > 0) + tmp = 0x400 - tmp; + -+ if (!(regEAC & BIT28) && -+ (((regE94 & 0x03FF0000)>>16) != 0x142) && -+ (((regE9C & 0x03FF0000)>>16) != 0x42) && -+ (((regE94 & 0x03FF0000)>>16) <0x110) && -+ (((regE94 & 0x03FF0000)>>16) >0xf0) && -+ (tmp <0xf)) ++ if ( ++ !(regEAC & BIT28) && ++ (((regE94 & 0x03FF0000)>>16) != 0x142) && ++ (((regE9C & 0x03FF0000)>>16) != 0x42) && ++ (((regE94 & 0x03FF0000)>>16) < 0x110) && ++ (((regE94 & 0x03FF0000)>>16) > 0xf0) && ++ (tmp < 0xf) ++ ) + result |= 0x01; + else /* if Tx not OK, ignore Rx */ + return result; @@ -53803,17 +52164,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + return result; +} + -+static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -+phy_PathA_RxIQK8723B( -+struct adapter *padapter, -+bool configPathB, -+u8 RF_Path -+ ) ++/* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ ++static u8 phy_PathA_RxIQK8723B( ++ struct adapter *padapter, bool configPathB, u8 RF_Path ++) +{ + u32 regEAC, regE94, regE9C, regEA4, u4tmp, tmp, Path_SEL_BB; + u8 result = 0x00; -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + +/* ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK!\n")); */ + @@ -53895,24 +52254,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x, 0xe9c = 0x%x\n", regE94, regE9C)); + /* monitor image power before & after IQK */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe90(before IQK) = 0x%x, 0xe98(afer IQK) = 0x%x\n", -+ PHY_QueryBBReg(pDM_Odm->Adapter, 0xe90, bMaskDWord), PHY_QueryBBReg(pDM_Odm->Adapter, 0xe98, bMaskDWord))); ++ PHY_QueryBBReg(pDM_Odm->Adapter, 0xe90, bMaskDWord), PHY_QueryBBReg(pDM_Odm->Adapter, 0xe98, bMaskDWord))); + + /* Allen 20131125 */ -+ tmp =(regE9C & 0x03FF0000)>>16; -+ if ((tmp & 0x200)> 0) ++ tmp = (regE9C & 0x03FF0000)>>16; ++ if ((tmp & 0x200) > 0) + tmp = 0x400 - tmp; + -+ if (!(regEAC & BIT28) && -+ (((regE94 & 0x03FF0000)>>16) != 0x142) && -+ (((regE9C & 0x03FF0000)>>16) != 0x42) && -+ (((regE94 & 0x03FF0000)>>16) <0x110) && -+ (((regE94 & 0x03FF0000)>>16) >0xf0) && -+ (tmp <0xf)) ++ if ( ++ !(regEAC & BIT28) && ++ (((regE94 & 0x03FF0000)>>16) != 0x142) && ++ (((regE9C & 0x03FF0000)>>16) != 0x42) && ++ (((regE94 & 0x03FF0000)>>16) < 0x110) && ++ (((regE94 & 0x03FF0000)>>16) > 0xf0) && ++ (tmp < 0xf) ++ ) + result |= 0x01; + else /* if Tx not OK, ignore Rx */ + return result; + -+ u4tmp = 0x80007C00 | (regE94&0x3FF0000) | ((regE9C&0x3FF0000) >> 16); ++ u4tmp = 0x80007C00 | (regE94&0x3FF0000) | ((regE9C&0x3FF0000) >> 16); + PHY_SetBBReg(pDM_Odm->Adapter, rTx_IQK, bMaskDWord, u4tmp); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe40 = 0x%x u4tmp = 0x%x\n", PHY_QueryBBReg(pDM_Odm->Adapter, rTx_IQK, bMaskDWord), u4tmp)); + @@ -54001,31 +52362,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x780); + + /* Allen 20131125 */ -+ tmp =(regEAC & 0x03FF0000)>>16; -+ if ((tmp & 0x200)> 0) ++ tmp = (regEAC & 0x03FF0000)>>16; ++ if ((tmp & 0x200) > 0) + tmp = 0x400 - tmp; + -+ if (!(regEAC & BIT27) && /* if Tx is OK, check whether Rx is OK */ -+ (((regEA4 & 0x03FF0000)>>16) != 0x132) && -+ (((regEAC & 0x03FF0000)>>16) != 0x36) && -+ (((regEA4 & 0x03FF0000)>>16) < 0x110) && -+ (((regEA4 & 0x03FF0000)>>16) > 0xf0) && -+ (tmp <0xf)) ++ if ( ++ !(regEAC & BIT27) && /* if Tx is OK, check whether Rx is OK */ ++ (((regEA4 & 0x03FF0000)>>16) != 0x132) && ++ (((regEAC & 0x03FF0000)>>16) != 0x36) && ++ (((regEA4 & 0x03FF0000)>>16) < 0x110) && ++ (((regEA4 & 0x03FF0000)>>16) > 0xf0) && ++ (tmp < 0xf) ++ ) + result |= 0x02; + else /* if Tx not OK, ignore Rx */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK fail!!\n")); + return result; +} + -+static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -+phy_PathB_IQK_8723B( -+struct adapter *padapter -+ ) ++/* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ ++static u8 phy_PathB_IQK_8723B(struct adapter *padapter) +{ + u32 regEAC, regE94, regE9C, tmp, Path_SEL_BB/*, regEC4, regECC, Path_SEL_BB*/; + u8 result = 0x00; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK!\n")); + @@ -54106,34 +52467,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x, 0xe9c = 0x%x\n", regE94, regE9C)); + /* monitor image power before & after IQK */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe90(before IQK) = 0x%x, 0xe98(afer IQK) = 0x%x\n", -+ PHY_QueryBBReg(pDM_Odm->Adapter, 0xe90, bMaskDWord), PHY_QueryBBReg(pDM_Odm->Adapter, 0xe98, bMaskDWord))); ++ PHY_QueryBBReg(pDM_Odm->Adapter, 0xe90, bMaskDWord), PHY_QueryBBReg(pDM_Odm->Adapter, 0xe98, bMaskDWord))); + + /* Allen 20131125 */ -+ tmp =(regE9C & 0x03FF0000)>>16; -+ if ((tmp & 0x200)> 0) ++ tmp = (regE9C & 0x03FF0000)>>16; ++ if ((tmp & 0x200) > 0) + tmp = 0x400 - tmp; + -+ if (!(regEAC & BIT28) && -+ (((regE94 & 0x03FF0000)>>16) != 0x142) && -+ (((regE9C & 0x03FF0000)>>16) != 0x42) && -+ (((regE94 & 0x03FF0000)>>16) <0x110) && -+ (((regE94 & 0x03FF0000)>>16) >0xf0) && -+ (tmp <0xf)) ++ if ( ++ !(regEAC & BIT28) && ++ (((regE94 & 0x03FF0000)>>16) != 0x142) && ++ (((regE9C & 0x03FF0000)>>16) != 0x42) && ++ (((regE94 & 0x03FF0000)>>16) < 0x110) && ++ (((regE94 & 0x03FF0000)>>16) > 0xf0) && ++ (tmp < 0xf) ++ ) + result |= 0x01; + + return result; +} + -+static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ -+phy_PathB_RxIQK8723B( -+struct adapter *padapter, -+bool configPathB -+ ) ++/* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ ++static u8 phy_PathB_RxIQK8723B(struct adapter *padapter, bool configPathB) +{ + u32 regE94, regE9C, regEA4, regEAC, u4tmp, tmp, Path_SEL_BB; + u8 result = 0x00; -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + +/* ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Rx IQK!\n")); */ + @@ -54219,18 +52579,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + PHY_QueryBBReg(pDM_Odm->Adapter, 0xe90, bMaskDWord), PHY_QueryBBReg(pDM_Odm->Adapter, 0xe98, bMaskDWord))); + + /* Allen 20131125 */ -+ tmp =(regE9C & 0x03FF0000)>>16; ++ tmp = (regE9C & 0x03FF0000)>>16; +/* ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("tmp1 = 0x%x\n", tmp)); */ -+ if ((tmp & 0x200)> 0) ++ if ((tmp & 0x200) > 0) + tmp = 0x400 - tmp; +/* ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("tmp2 = 0x%x\n", tmp)); */ + -+ if (!(regEAC & BIT28) && -+ (((regE94 & 0x03FF0000)>>16) != 0x142) && -+ (((regE9C & 0x03FF0000)>>16) != 0x42) && -+ (((regE94 & 0x03FF0000)>>16) <0x110) && -+ (((regE94 & 0x03FF0000)>>16) >0xf0) && -+ (tmp <0xf)) ++ if ( ++ !(regEAC & BIT28) && ++ (((regE94 & 0x03FF0000)>>16) != 0x142) && ++ (((regE9C & 0x03FF0000)>>16) != 0x42) && ++ (((regE94 & 0x03FF0000)>>16) < 0x110) && ++ (((regE94 & 0x03FF0000)>>16) > 0xf0) && ++ (tmp < 0xf) ++ ) + result |= 0x01; + else /* if Tx not OK, ignore Rx */ + return result; @@ -54324,16 +52686,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + + /* Allen 20131125 */ -+ tmp =(regEAC & 0x03FF0000)>>16; -+ if ((tmp & 0x200)> 0) ++ tmp = (regEAC & 0x03FF0000)>>16; ++ if ((tmp & 0x200) > 0) + tmp = 0x400 - tmp; + -+ if (!(regEAC & BIT27) && /* if Tx is OK, check whether Rx is OK */ -+ (((regEA4 & 0x03FF0000)>>16) != 0x132) && -+ (((regEAC & 0x03FF0000)>>16) != 0x36) && -+ (((regEA4 & 0x03FF0000)>>16) <0x110) && -+ (((regEA4 & 0x03FF0000)>>16) >0xf0) && -+ (tmp <0xf)) ++ if ( ++ !(regEAC & BIT27) && /* if Tx is OK, check whether Rx is OK */ ++ (((regEA4 & 0x03FF0000)>>16) != 0x132) && ++ (((regEAC & 0x03FF0000)>>16) != 0x36) && ++ (((regEA4 & 0x03FF0000)>>16) < 0x110) && ++ (((regEA4 & 0x03FF0000)>>16) > 0xf0) && ++ (tmp < 0xf) ++ ) + result |= 0x02; + else + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Rx IQK fail!!\n")); @@ -54341,29 +52705,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + return result; +} + -+static void -+_PHY_PathAFillIQKMatrix8723B( -+struct adapter *padapter, -+bool bIQKOK, -+s32 result[][8], -+u8 final_candidate, -+bool bTxOnly -+ ) ++static void _PHY_PathAFillIQKMatrix8723B( ++ struct adapter *padapter, ++ bool bIQKOK, ++ s32 result[][8], ++ u8 final_candidate, ++ bool bTxOnly ++) +{ + u32 Oldval_0, X, TX0_A, reg; -+ s32 Y, TX0_C; ++ s32 Y, TX0_C; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + -+ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); ++ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQ Calibration %s !\n", (bIQKOK)?"Success":"Failed")); + + if (final_candidate == 0xFF) + return; + -+ else if (bIQKOK) -+ { ++ else if (bIQKOK) { + Oldval_0 = (PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF; + + X = result[final_candidate][0]; @@ -54373,7 +52735,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("X = 0x%x, TX0_A = 0x%x, Oldval_0 0x%x\n", X, TX0_A, Oldval_0)); + PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A); + -+ PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT(31), ((X* Oldval_0>>7) & 0x1)); ++ PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT(31), ((X*Oldval_0>>7) & 0x1)); + + Y = result[final_candidate][1]; + if ((Y & 0x00000200) != 0) @@ -54390,12 +52752,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + pRFCalibrateInfo->TxIQC_8723B[PATH_S1][IDX_0xC80][KEY] = rOFDM0_XATxIQImbalance; + pRFCalibrateInfo->TxIQC_8723B[PATH_S1][IDX_0xC80][VAL] = PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_XATxIQImbalance, bMaskDWord); + -+ PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT(29), ((Y* Oldval_0>>7) & 0x1)); ++ PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT(29), ((Y*Oldval_0>>7) & 0x1)); + pRFCalibrateInfo->TxIQC_8723B[PATH_S1][IDX_0xC4C][KEY] = rOFDM0_ECCAThreshold; + pRFCalibrateInfo->TxIQC_8723B[PATH_S1][IDX_0xC4C][VAL] = PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, bMaskDWord); + -+ if (bTxOnly) -+ { ++ if (bTxOnly) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("_PHY_PathAFillIQKMatrix8723B only Tx OK\n")); + + /* <20130226, Kordan> Saving RxIQC, otherwise not initialized. */ @@ -54424,29 +52785,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + } +} + -+static void -+_PHY_PathBFillIQKMatrix8723B( -+struct adapter *padapter, -+bool bIQKOK, -+s32 result[][8], -+u8 final_candidate, -+bool bTxOnly /* do Tx only */ -+ ) ++static void _PHY_PathBFillIQKMatrix8723B( ++ struct adapter *padapter, ++ bool bIQKOK, ++ s32 result[][8], ++ u8 final_candidate, ++ bool bTxOnly /* do Tx only */ ++) +{ + u32 Oldval_1, X, TX1_A, reg; + s32 Y, TX1_C; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + -+ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); ++ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQ Calibration %s !\n", (bIQKOK)?"Success":"Failed")); + + if (final_candidate == 0xFF) + return; + -+ else if (bIQKOK) -+ { ++ else if (bIQKOK) { + Oldval_1 = (PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_XBTxIQImbalance, bMaskDWord) >> 22) & 0x3FF; + + X = result[final_candidate][4]; @@ -54457,7 +52816,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XBTxIQImbalance, 0x3FF, TX1_A); + -+ PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT(27), ((X* Oldval_1>>7) & 0x1)); ++ PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT(27), ((X*Oldval_1>>7) & 0x1)); + + Y = result[final_candidate][5]; + if ((Y & 0x00000200) != 0) @@ -54477,7 +52836,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC80][KEY] = rOFDM0_XATxIQImbalance; + pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC80][VAL] = PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_XBTxIQImbalance, bMaskDWord); + -+ PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT(25), ((Y* Oldval_1>>7) & 0x1)); ++ PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT(25), ((Y*Oldval_1>>7) & 0x1)); + pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC4C][KEY] = rOFDM0_ECCAThreshold; + pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC4C][VAL] = PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, bMaskDWord); + @@ -54503,7 +52862,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + reg = (result[final_candidate][7] >> 6) & 0xF; +/* PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_AGCRSSITable, 0x0000F000, reg); */ + pRFCalibrateInfo->RxIQC_8723B[PATH_S0][IDX_0xCA0][KEY] = rOFDM0_RxIQExtAnta; -+ pRFCalibrateInfo->RxIQC_8723B[PATH_S0][IDX_0xCA0][VAL] = (reg << 28)|(PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_RxIQExtAnta, bMaskDWord)& 0x0fffffff); ++ pRFCalibrateInfo->RxIQC_8723B[PATH_S0][IDX_0xCA0][VAL] = (reg << 28)|(PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_RxIQExtAnta, bMaskDWord)&0x0fffffff); + } +} + @@ -54512,18 +52871,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +/* */ +/* MP Already declare in odm.c */ + -+void -+ODM_SetIQCbyRFpath(PDM_ODM_T pDM_Odm, u32 RFpath) ++void ODM_SetIQCbyRFpath(PDM_ODM_T pDM_Odm, u32 RFpath) +{ + -+ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); ++ PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); + -+ if ((pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC80][VAL] != 0x0) && -+ (pRFCalibrateInfo->RxIQC_8723B[PATH_S0][IDX_0xC14][VAL] != 0x0) && -+ (pRFCalibrateInfo->TxIQC_8723B[PATH_S1][IDX_0xC80][VAL] != 0x0) && -+ (pRFCalibrateInfo->RxIQC_8723B[PATH_S1][IDX_0xC14][VAL] != 0x0)) { -+ if (RFpath) /* S1: RFpath = 0, S0:RFpath = 1 */ -+ { ++ if ( ++ (pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC80][VAL] != 0x0) && ++ (pRFCalibrateInfo->RxIQC_8723B[PATH_S0][IDX_0xC14][VAL] != 0x0) && ++ (pRFCalibrateInfo->TxIQC_8723B[PATH_S1][IDX_0xC80][VAL] != 0x0) && ++ (pRFCalibrateInfo->RxIQC_8723B[PATH_S1][IDX_0xC14][VAL] != 0x0) ++ ) { ++ if (RFpath) { /* S1: RFpath = 0, S0:RFpath = 1 */ + /* S0 TX IQC */ + PHY_SetBBReg(pDM_Odm->Adapter, pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC94][KEY], bMaskDWord, pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC94][VAL]); + PHY_SetBBReg(pDM_Odm->Adapter, pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC80][KEY], bMaskDWord, pRFCalibrateInfo->TxIQC_8723B[PATH_S0][IDX_0xC80][VAL]); @@ -54543,24 +52902,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + } +} + -+static bool -+ODM_CheckPowerStatus( -+ struct adapter * Adapter) ++static bool ODM_CheckPowerStatus(struct adapter *Adapter) +{ -+ return true; ++ return true; +} + -+static void -+_PHY_SaveADDARegisters8723B( -+struct adapter *padapter, -+u32 * ADDAReg, -+u32 * ADDABackup, -+u32 RegisterNum -+ ) ++static void _PHY_SaveADDARegisters8723B( ++ struct adapter *padapter, ++ u32 *ADDAReg, ++ u32 *ADDABackup, ++ u32 RegisterNum ++) +{ + u32 i; -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + + if (ODM_CheckPowerStatus(padapter) == false) + return; @@ -54572,12 +52928,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +} + + -+static void -+_PHY_SaveMACRegisters8723B( -+struct adapter *padapter, -+u32 * MACReg, -+u32 * MACBackup -+ ) ++static void _PHY_SaveMACRegisters8723B( ++ struct adapter *padapter, u32 *MACReg, u32 *MACBackup ++) +{ + u32 i; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); @@ -54592,31 +52945,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +} + + -+static void -+_PHY_ReloadADDARegisters8723B( -+struct adapter *padapter, -+u32 * ADDAReg, -+u32 * ADDABackup, -+u32 RegiesterNum -+ ) ++static void _PHY_ReloadADDARegisters8723B( ++ struct adapter *padapter, ++ u32 *ADDAReg, ++ u32 *ADDABackup, ++ u32 RegiesterNum ++) +{ + u32 i; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload ADDA power saving parameters !\n")); -+ for (i = 0 ; i < RegiesterNum; i++) -+ { ++ for (i = 0 ; i < RegiesterNum; i++) { + PHY_SetBBReg(pDM_Odm->Adapter, ADDAReg[i], bMaskDWord, ADDABackup[i]); + } +} + -+static void -+_PHY_ReloadMACRegisters8723B( -+struct adapter *padapter, -+u32 * MACReg, -+u32 * MACBackup -+ ) ++static void _PHY_ReloadMACRegisters8723B( ++ struct adapter *padapter, u32 *MACReg, u32 *MACBackup ++) +{ + u32 i; + @@ -54627,18 +52975,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +} + + -+static void -+_PHY_PathADDAOn8723B( -+struct adapter *padapter, -+u32 * ADDAReg, -+bool isPathAOn, -+bool is2T -+ ) ++static void _PHY_PathADDAOn8723B( ++ struct adapter *padapter, ++ u32 *ADDAReg, ++ bool isPathAOn, ++ bool is2T ++) +{ + u32 pathOn; + u32 i; -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n")); + @@ -54646,8 +52993,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + if (false == is2T) { + pathOn = 0x01c00014; + PHY_SetBBReg(pDM_Odm->Adapter, ADDAReg[0], bMaskDWord, 0x01c00014); -+ } -+ else { ++ } else { + PHY_SetBBReg(pDM_Odm->Adapter, ADDAReg[0], bMaskDWord, pathOn); + } + @@ -54657,16 +53003,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + +} + -+static void -+_PHY_MACSettingCalibration8723B( -+struct adapter *padapter, -+u32 * MACReg, -+u32 * MACBackup -+ ) ++static void _PHY_MACSettingCalibration8723B( ++ struct adapter *padapter, u32 *MACReg, u32 *MACBackup ++) +{ + u32 i = 0; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("MAC settings for Calibration.\n")); + @@ -54679,18 +53022,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + +} + -+static bool -+phy_SimularityCompare_8723B( -+struct adapter *padapter, -+s32 result[][8], -+u8 c1, -+u8 c2 -+ ) ++static bool phy_SimularityCompare_8723B( ++ struct adapter *padapter, ++ s32 result[][8], ++ u8 c1, ++ u8 c2 ++) +{ -+ u32 i, j, diff, SimularityBitMap, bound = 0; -+ u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ -+ bool bResult = true; -+ bool is2T = true; ++ u32 i, j, diff, SimularityBitMap, bound = 0; ++ u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ ++ bool bResult = true; ++ bool is2T = true; + s32 tmp1 = 0, tmp2 = 0; + + if (is2T) @@ -54700,81 +53042,65 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + SimularityBitMap = 0; + -+ for (i = 0; i < bound; i++) -+ { ++ for (i = 0; i < bound; i++) { + -+ if ((i == 1) || (i ==3) || (i ==5) || (i ==7)) -+ { -+ if ((result[c1][i]& 0x00000200) != 0) ++ if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) { ++ if ((result[c1][i] & 0x00000200) != 0) + tmp1 = result[c1][i] | 0xFFFFFC00; + else + tmp1 = result[c1][i]; + -+ if ((result[c2][i]& 0x00000200) != 0) ++ if ((result[c2][i] & 0x00000200) != 0) + tmp2 = result[c2][i] | 0xFFFFFC00; + else + tmp2 = result[c2][i]; -+ } -+ else -+ { ++ } else { + tmp1 = result[c1][i]; + tmp2 = result[c2][i]; + } + + diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); + -+ if (diff > MAX_TOLERANCE) -+ { -+ if ((i == 2 || i == 6) && !SimularityBitMap) -+ { ++ if (diff > MAX_TOLERANCE) { ++ if ((i == 2 || i == 6) && !SimularityBitMap) { + if (result[c1][i]+result[c1][i+1] == 0) + final_candidate[(i/4)] = c2; + else if (result[c2][i]+result[c2][i+1] == 0) + final_candidate[(i/4)] = c1; + else + SimularityBitMap = SimularityBitMap|(1<odmpriv; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + -+ u32 i; -+ u8 PathAOK, PathBOK; -+ u8 tmp0xc50 = (u8)PHY_QueryBBReg(pDM_Odm->Adapter, 0xC50, bMaskByte0); -+ u8 tmp0xc58 = (u8)PHY_QueryBBReg(pDM_Odm->Adapter, 0xC58, bMaskByte0); -+ u32 ADDA_REG[IQK_ADDA_REG_NUM] = { -+ rFPGA0_XCD_SwitchControl, rBlue_Tooth, -+ rRx_Wait_CCA, rTx_CCK_RFON, -+ rTx_CCK_BBON, rTx_OFDM_RFON, -+ rTx_OFDM_BBON, rTx_To_Rx, -+ rTx_To_Tx, rRx_CCK, -+ rRx_OFDM, rRx_Wait_RIFS, -+ rRx_TO_Rx, rStandby, -+ rSleep, rPMPD_ANAEN }; -+ u32 IQK_MAC_REG[IQK_MAC_REG_NUM] = { -+ REG_TXPAUSE, REG_BCN_CTRL, -+ REG_BCN_CTRL_1, REG_GPIO_MUXCFG}; ++ u32 i; ++ u8 PathAOK, PathBOK; ++ u8 tmp0xc50 = (u8)PHY_QueryBBReg(pDM_Odm->Adapter, 0xC50, bMaskByte0); ++ u8 tmp0xc58 = (u8)PHY_QueryBBReg(pDM_Odm->Adapter, 0xC58, bMaskByte0); ++ u32 ADDA_REG[IQK_ADDA_REG_NUM] = { ++ rFPGA0_XCD_SwitchControl, ++ rBlue_Tooth, ++ rRx_Wait_CCA, ++ rTx_CCK_RFON, ++ rTx_CCK_BBON, ++ rTx_OFDM_RFON, ++ rTx_OFDM_BBON, ++ rTx_To_Rx, ++ rTx_To_Tx, ++ rRx_CCK, ++ rRx_OFDM, ++ rRx_Wait_RIFS, ++ rRx_TO_Rx, ++ rStandby, ++ rSleep, ++ rPMPD_ANAEN ++ }; ++ u32 IQK_MAC_REG[IQK_MAC_REG_NUM] = { ++ REG_TXPAUSE, ++ REG_BCN_CTRL, ++ REG_BCN_CTRL_1, ++ REG_GPIO_MUXCFG ++ }; + + /* since 92C & 92D have the different define in IQK_BB_REG */ + u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { -+ rOFDM0_TRxPathEnable, rOFDM0_TRMuxPar, -+ rFPGA0_XCD_RFInterfaceSW, rConfig_AntA, rConfig_AntB, -+ rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE, -+ rFPGA0_XB_RFInterfaceOE, rCCK0_AFESetting -+ }; ++ rOFDM0_TRxPathEnable, ++ rOFDM0_TRMuxPar, ++ rFPGA0_XCD_RFInterfaceSW, ++ rConfig_AntA, ++ rConfig_AntB, ++ rFPGA0_XAB_RFInterfaceSW, ++ rFPGA0_XA_RFInterfaceOE, ++ rFPGA0_XB_RFInterfaceOE, ++ rCCK0_AFESetting ++ }; + const u32 retryCount = 2; + + /* Note: IQ calibration must be performed after loading */ @@ -54827,8 +53169,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + /* u32 bbvalue; */ + -+ if (t == 0) -+ { ++ if (t == 0) { +/* bbvalue = PHY_QueryBBReg(pDM_Odm->Adapter, rFPGA0_RFMOD, bMaskDWord); */ +/* RT_DISP(FINIT, INIT_IQK, ("phy_IQCalibrate_8188E() ==>0x%08x\n", bbvalue)); */ + @@ -54902,9 +53243,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + result[t][2] = (PHY_QueryBBReg(pDM_Odm->Adapter, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + result[t][3] = (PHY_QueryBBReg(pDM_Odm->Adapter, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + break; -+ } -+ else -+ { ++ } else { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Fail!!\n")); + } + } @@ -54988,11 +53327,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +} + + -+static void -+phy_LCCalibrate_8723B( -+ PDM_ODM_T pDM_Odm, -+ bool is2T -+ ) ++static void phy_LCCalibrate_8723B(PDM_ODM_T pDM_Odm, bool is2T) +{ + u8 tmpReg; + u32 RF_Amode = 0, RF_Bmode = 0, LC_Cal; @@ -55006,8 +53341,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + else /* Deal with Packet TX case */ + rtw_write8(pDM_Odm->Adapter, REG_TXPAUSE, 0xFF); /* block all queues */ + -+ if ((tmpReg&0x70) != 0) -+ { ++ if ((tmpReg&0x70) != 0) { + /* 1. Read original RF mode */ + /* Path-A */ + RF_Amode = PHY_QueryRFReg(padapter, ODM_RF_PATH_A, RF_AC, bMask12Bits); @@ -55037,14 +53371,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xB0, bRFRegOffsetMask, 0xDFFE0); /* LDO OFF */ + + /* Channel 10 LC calibration issue for 8723bs with 26M xtal */ -+ if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO && pDM_Odm->PackageType >= 0x2) -+ { ++ if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO && pDM_Odm->PackageType >= 0x2) { + PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal); + } + + /* Restore original situation */ -+ if ((tmpReg&0x70) != 0) /* Deal with contisuous TX case */ -+ { ++ if ((tmpReg&0x70) != 0) { /* Deal with contisuous TX case */ + /* Path-A */ + rtw_write8(pDM_Odm->Adapter, 0xd03, tmpReg); + PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); @@ -55052,11 +53384,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + /* Path-B */ + if (is2T) + PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); -+ } -+ else /* Deal with Packet TX case */ -+ { ++ } else /* Deal with Packet TX case */ + rtw_write8(pDM_Odm->Adapter, REG_TXPAUSE, 0x00); -+ } +} + +/* Analog Pre-distortion calibration */ @@ -55075,31 +53404,35 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + +/* IQK version:V2.5 20140123 */ +/* IQK is controlled by Is2ant, RF path */ -+void -+PHY_IQCalibrate_8723B( ++void PHY_IQCalibrate_8723B( + struct adapter *padapter, -+ bool bReCovery, -+ bool bRestore, -+ bool Is2ant, /* false:1ant, true:2-ant */ ++ bool bReCovery, ++ bool bRestore, ++ bool Is2ant, /* false:1ant, true:2-ant */ + u8 RF_Path /* 0:S1, 1:S0 */ -+ ) ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + -+ s32 result[4][8]; /* last is final result */ -+ u8 i, final_candidate, Indexforchannel; -+ bool bPathAOK, bPathBOK; -+ s32 RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC, RegTmp = 0; -+ bool is12simular, is13simular, is23simular; -+ bool bSingleTone = false, bCarrierSuppression = false; -+ u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { -+ rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, -+ rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable, -+ rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance, -+ rOFDM0_XCTxAFE, rOFDM0_XDTxAFE, -+ rOFDM0_RxIQExtAnta}; ++ s32 result[4][8]; /* last is final result */ ++ u8 i, final_candidate, Indexforchannel; ++ bool bPathAOK, bPathBOK; ++ s32 RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC, RegTmp = 0; ++ bool is12simular, is13simular, is23simular; ++ bool bSingleTone = false, bCarrierSuppression = false; ++ u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { ++ rOFDM0_XARxIQImbalance, ++ rOFDM0_XBRxIQImbalance, ++ rOFDM0_ECCAThreshold, ++ rOFDM0_AGCRSSITable, ++ rOFDM0_XATxIQImbalance, ++ rOFDM0_XBTxIQImbalance, ++ rOFDM0_XCTxAFE, ++ rOFDM0_XDTxAFE, ++ rOFDM0_RxIQExtAnta ++ }; +/* u32 Path_SEL_BB = 0; */ + u32 GNT_BT_default; + u32 StartTime; @@ -55109,9 +53442,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + return; + + if (!(pDM_Odm->SupportAbility & ODM_RF_CALIBRATION)) -+ { + return; -+ } + + /* 20120213 Turn on when continuous Tx to pass lab testing. (required by Edlu) */ + if (bSingleTone || bCarrierSuppression) @@ -55138,7 +53469,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + offset = pRFCalibrateInfo->TxIQC_8723B[path][i][0]; + data = pRFCalibrateInfo->TxIQC_8723B[path][i][1]; + if ((offset == 0) || (data == 0)) { -+ DBG_871X("%s =>path:%s Restore TX IQK result failed\n", __func__, (path ==ODM_RF_PATH_A)?"A":"B"); ++ DBG_871X( ++ "%s =>path:%s Restore TX IQK result failed\n", ++ __func__, ++ (path == ODM_RF_PATH_A)?"A":"B" ++ ); + bResult = FAIL; + break; + } @@ -55151,7 +53486,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + offset = pRFCalibrateInfo->RxIQC_8723B[path][i][0]; + data = pRFCalibrateInfo->RxIQC_8723B[path][i][1]; + if ((offset == 0) || (data == 0)) { -+ DBG_871X("%s =>path:%s Restore RX IQK result failed\n", __func__, (path ==ODM_RF_PATH_A)?"A":"B"); ++ DBG_871X( ++ "%s =>path:%s Restore RX IQK result failed\n", ++ __func__, ++ (path == ODM_RF_PATH_A)?"A":"B" ++ ); + bResult = FAIL; + break; + } @@ -55171,8 +53510,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + return; + } + -+ if (bReCovery) -+ { ++ if (bReCovery) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("PHY_IQCalibrate_8723B: Return due to bReCovery!\n")); + _PHY_ReloadADDARegisters8723B(padapter, IQK_BB_REG_92C, pDM_Odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); + return; @@ -55191,13 +53529,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +/* PHY_SetBBReg(pDM_Odm->Adapter, 0x764, BIT11, 0x1); */ + + -+ for (i = 0; i < 8; i++) -+ { ++ for (i = 0; i < 8; i++) { + result[0][i] = 0; + result[1][i] = 0; + result[2][i] = 0; + result[3][i] = 0; + } ++ + final_candidate = 0xff; + bPathAOK = false; + bPathBOK = false; @@ -55206,39 +53544,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + is13simular = false; + + -+ for (i = 0; i<3; i++) -+ { ++ for (i = 0; i < 3; i++) { + phy_IQCalibrate_8723B(padapter, result, i, Is2ant, RF_Path); + -+ if (i == 1) -+ { ++ if (i == 1) { + is12simular = phy_SimularityCompare_8723B(padapter, result, 0, 1); -+ if (is12simular) -+ { ++ if (is12simular) { + final_candidate = 0; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is12simular final_candidate is %x\n", final_candidate)); + break; + } + } + -+ if (i == 2) -+ { ++ if (i == 2) { + is13simular = phy_SimularityCompare_8723B(padapter, result, 0, 2); -+ if (is13simular) -+ { ++ if (is13simular) { + final_candidate = 0; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is13simular final_candidate is %x\n", final_candidate)); + + break; + } ++ + is23simular = phy_SimularityCompare_8723B(padapter, result, 1, 2); -+ if (is23simular) -+ { ++ if (is23simular) { + final_candidate = 1; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is23simular final_candidate is %x\n", final_candidate)); -+ } -+ else -+ { ++ } else { + for (i = 0; i < 8; i++) + RegTmp += result[3][i]; + @@ -55251,8 +53582,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + } +/* RT_TRACE(COMP_INIT, DBG_LOUD, ("Release Mutex in IQCalibrate\n")); */ + -+ for (i = 0; i<4; i++) -+ { ++ for (i = 0; i < 4; i++) { + RegE94 = result[i][0]; + RegE9C = result[i][1]; + RegEA4 = result[i][2]; @@ -55264,8 +53594,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: RegE94 =%x RegE9C =%x RegEA4 =%x RegEAC =%x RegEB4 =%x RegEBC =%x RegEC4 =%x RegECC =%x\n ", RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); + } + -+ if (final_candidate != 0xff) -+ { ++ if (final_candidate != 0xff) { + pDM_Odm->RFCalibrateInfo.RegE94 = RegE94 = result[final_candidate][0]; + pDM_Odm->RFCalibrateInfo.RegE9C = RegE9C = result[final_candidate][1]; + RegEA4 = result[final_candidate][2]; @@ -55277,9 +53606,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: final_candidate is %x\n", final_candidate)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: RegE94 =%x RegE9C =%x RegEA4 =%x RegEAC =%x RegEB4 =%x RegEBC =%x RegEC4 =%x RegECC =%x\n ", RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); + bPathAOK = bPathBOK = true; -+ } -+ else -+ { ++ } else { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: FAIL use default value\n")); + + pDM_Odm->RFCalibrateInfo.RegE94 = pDM_Odm->RFCalibrateInfo.RegEB4 = 0x100; /* X default value */ @@ -55288,23 +53615,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + + { + if (RegE94 != 0) -+ { + _PHY_PathAFillIQKMatrix8723B(padapter, bPathAOK, result, final_candidate, (RegEA4 == 0)); -+ } + } + { + if (RegEB4 != 0) -+ { + _PHY_PathBFillIQKMatrix8723B(padapter, bPathBOK, result, final_candidate, (RegEC4 == 0)); -+ } + } + + Indexforchannel = ODM_GetRightChnlPlaceforIQK(pHalData->CurrentChannel); + +/* To Fix BSOD when final_candidate is 0xff */ +/* by sherry 20120321 */ -+ if (final_candidate < 4) -+ { ++ if (final_candidate < 4) { + for (i = 0; i < IQK_Matrix_REG_NUM; i++) + pDM_Odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][i] = result[final_candidate][i]; + pDM_Odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].bIQKDone = true; @@ -55349,10 +53671,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +} + + -+void -+PHY_LCCalibrate_8723B( -+ PDM_ODM_T pDM_Odm -+ ) ++void PHY_LCCalibrate_8723B(PDM_ODM_T pDM_Odm) +{ + bool bSingleTone = false, bCarrierSuppression = false; + u32 timeout = 2000, timecount = 0; @@ -55364,17 +53683,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs +#endif + + if (!(pDM_Odm->SupportAbility & ODM_RF_CALIBRATION)) -+ { + return; -+ } + + /* 20120213 Turn on when continuous Tx to pass lab testing. (required by Edlu) */ + if (bSingleTone || bCarrierSuppression) + return; + + StartTime = jiffies; -+ while (*(pDM_Odm->pbScanInProcess) && timecount < timeout) -+ { ++ while (*(pDM_Odm->pbScanInProcess) && timecount < timeout) { + mdelay(50); + timecount += 50; + } @@ -55391,10 +53707,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.c linux-4.3-rtl8723bs + ProgressingTime = jiffies_to_msecs(jiffies - StartTime); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LCK ProgressingTime = %d\n", ProgressingTime)); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h ---- linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,100 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h linux/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h +--- linux.old/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,83 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -55421,84 +53737,67 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf_8723B.h linux-4.3-rtl8723bs +#define RF_T_METER_8723B 0x42 /* */ + + -+void ConfigureTxpowerTrack_8723B( -+ PTXPWRTRACK_CFG pConfig -+ ); ++void ConfigureTxpowerTrack_8723B(PTXPWRTRACK_CFG pConfig); + +void DoIQK_8723B( -+ PDM_ODM_T pDM_Odm, ++ PDM_ODM_T pDM_Odm, + u8 DeltaThermalIndex, + u8 ThermalValue, + u8 Threshold -+ ); ++); + -+void -+ODM_TxPwrTrackSetPwr_8723B( -+ PDM_ODM_T pDM_Odm, -+ PWRTRACK_METHOD Method, -+ u8 RFPath, -+ u8 ChannelMappedIndex -+ ); ++void ODM_TxPwrTrackSetPwr_8723B( ++ PDM_ODM_T pDM_Odm, ++ PWRTRACK_METHOD Method, ++ u8 RFPath, ++ u8 ChannelMappedIndex ++); + -+/* 1 7. IQK */ -+ -+void -+PHY_IQCalibrate_8723B( ++/* 1 7. IQK */ ++void PHY_IQCalibrate_8723B( + struct adapter *Adapter, -+ bool bReCovery, -+ bool bRestore, -+ bool Is2ant, -+ u8 RF_Path); ++ bool bReCovery, ++ bool bRestore, ++ bool Is2ant, ++ u8 RF_Path ++); + -+void -+ODM_SetIQCbyRFpath( -+ PDM_ODM_T pDM_Odm, -+ u32 RFpath -+ ); ++void ODM_SetIQCbyRFpath(PDM_ODM_T pDM_Odm, u32 RFpath); + +/* */ +/* LC calibrate */ +/* */ -+void -+PHY_LCCalibrate_8723B( -+ PDM_ODM_T pDM_Odm -+); ++void PHY_LCCalibrate_8723B(PDM_ODM_T pDM_Odm); + +/* */ +/* AP calibrate */ +/* */ -+void -+PHY_DigitalPredistortion_8723B(struct adapter *padapter); ++void PHY_DigitalPredistortion_8723B(struct adapter *padapter); + + -+void -+_PHY_SaveADDARegisters_8723B( ++void _PHY_SaveADDARegisters_8723B( + struct adapter *padapter, -+ u32 * ADDAReg, -+ u32 * ADDABackup, -+ u32 RegisterNum -+ ); ++ u32 *ADDAReg, ++ u32 *ADDABackup, ++ u32 RegisterNum ++); + -+void -+_PHY_PathADDAOn_8723B( ++void _PHY_PathADDAOn_8723B( + struct adapter *padapter, -+ u32 * ADDAReg, -+ bool isPathAOn, -+ bool is2T -+ ); ++ u32 *ADDAReg, ++ bool isPathAOn, ++ bool is2T ++); + -+void -+_PHY_MACSettingCalibration_8723B( -+ struct adapter *padapter, -+ u32 * MACReg, -+ u32 * MACBackup -+ ); ++void _PHY_MACSettingCalibration_8723B( ++ struct adapter *padapter, u32 *MACReg, u32 *MACBackup ++); + -+#endif /* #ifndef __HAL_PHY_RF_8188E_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPhyRf.c ---- linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPhyRf.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,394 @@ ++#endif /* #ifndef __HAL_PHY_RF_8188E_H__ */ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalPhyRf.c linux/3rdparty/rtl8723bs/hal/HalPhyRf.c +--- linux.old/3rdparty/rtl8723bs/hal/HalPhyRf.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalPhyRf.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,662 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -55518,26 +53817,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.c linux-4.3-rtl8723bs/3rdpa +#include "odm_precomp.h" + + -+#define CALCULATE_SWINGTALBE_OFFSET(_offset, _direction, _size, _deltaThermal) \ -+ do {\ -+ for (_offset = 0; _offset < _size; _offset++)\ -+ {\ -+ if (_deltaThermal < thermalThreshold[_direction][_offset])\ -+ {\ -+ if (_offset != 0)\ -+ _offset--;\ -+ break;\ -+ }\ -+ } \ -+ if (_offset >= _size)\ -+ _offset = _size-1;\ -+ } while (0) ++#define CALCULATE_SWINGTALBE_OFFSET(_offset, _direction, _size, _deltaThermal) \ ++ do {\ ++ for (_offset = 0; _offset < _size; _offset++) {\ ++ if (_deltaThermal < thermalThreshold[_direction][_offset]) {\ ++ if (_offset != 0)\ ++ _offset--;\ ++ break;\ ++ } \ ++ } \ ++ if (_offset >= _size)\ ++ _offset = _size-1;\ ++ } while (0) + + -+void ConfigureTxpowerTrack( -+PDM_ODM_T pDM_Odm, -+ PTXPWRTRACK_CFG pConfig -+ ) ++void ConfigureTxpowerTrack(PDM_ODM_T pDM_Odm, PTXPWRTRACK_CFG pConfig) +{ + ConfigureTxpowerTrack_8723B(pConfig); +} @@ -55550,20 +53844,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.c linux-4.3-rtl8723bs/3rdpa +/* NOTE: If Tx BB swing or Tx scaling is varified during run-time, still */ +/* need to call this function. */ +/* */ -+void -+ODM_ClearTxPowerTrackingState( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_ClearTxPowerTrackingState(PDM_ODM_T pDM_Odm) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(pDM_Odm->Adapter); -+ u8 p = 0; ++ u8 p = 0; + + pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex; + pDM_Odm->BbSwingIdxCck = pDM_Odm->DefaultCckIndex; + pDM_Odm->RFCalibrateInfo.CCK_index = 0; + -+ for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) -+ { ++ for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) { + pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex; + pDM_Odm->BbSwingIdxOfdm[p] = pDM_Odm->DefaultOfdmIndex; + pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex; @@ -55573,67 +53863,87 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.c linux-4.3-rtl8723bs/3rdpa + pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] = 0; + pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0; + -+ pDM_Odm->Absolute_OFDMSwingIdx[p] = 0; /* Initial Mix mode power tracking */ ++ /* Initial Mix mode power tracking */ ++ pDM_Odm->Absolute_OFDMSwingIdx[p] = 0; + pDM_Odm->Remnant_OFDMSwingIdx[p] = 0; + } + -+ pDM_Odm->Modify_TxAGC_Flag_PathA = false; /* Initial at Modify Tx Scaling Mode */ -+ pDM_Odm->Modify_TxAGC_Flag_PathB = false; /* Initial at Modify Tx Scaling Mode */ ++ /* Initial at Modify Tx Scaling Mode */ ++ pDM_Odm->Modify_TxAGC_Flag_PathA = false; ++ /* Initial at Modify Tx Scaling Mode */ ++ pDM_Odm->Modify_TxAGC_Flag_PathB = false; + pDM_Odm->Remnant_CCKSwingIdx = 0; + pDM_Odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter; + pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = pHalData->EEPROMThermalMeter; + pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = pHalData->EEPROMThermalMeter; +} + -+void -+ODM_TXPowerTrackingCallback_ThermalMeter( -+ struct adapter *Adapter -+ ) ++void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter) +{ + -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + -+ u8 ThermalValue = 0, delta, delta_LCK, delta_IQK, p = 0, i = 0; -+ u8 ThermalValue_AVG_count = 0; -+ u32 ThermalValue_AVG = 0; ++ u8 ThermalValue = 0, delta, delta_LCK, delta_IQK, p = 0, i = 0; ++ u8 ThermalValue_AVG_count = 0; ++ u32 ThermalValue_AVG = 0; + -+ u8 OFDM_min_index = 0; /* OFDM BB Swing should be less than +3.0dB, which is required by Arthur */ -+ u8 Indexforchannel = 0; /* GetRightChnlPlaceforIQK(pHalData->CurrentChannel) */ ++ u8 OFDM_min_index = 0; /* OFDM BB Swing should be less than +3.0dB, which is required by Arthur */ ++ u8 Indexforchannel = 0; /* GetRightChnlPlaceforIQK(pHalData->CurrentChannel) */ + -+ TXPWRTRACK_CFG c; ++ TXPWRTRACK_CFG c; + + + /* 4 1. The following TWO tables decide the final index of OFDM/CCK swing table. */ -+ u8 * deltaSwingTableIdx_TUP_A; -+ u8 * deltaSwingTableIdx_TDOWN_A; -+ u8 * deltaSwingTableIdx_TUP_B; -+ u8 * deltaSwingTableIdx_TDOWN_B; ++ u8 *deltaSwingTableIdx_TUP_A; ++ u8 *deltaSwingTableIdx_TDOWN_A; ++ u8 *deltaSwingTableIdx_TUP_B; ++ u8 *deltaSwingTableIdx_TDOWN_B; + + /* 4 2. Initilization (7 steps in total) */ + + ConfigureTxpowerTrack(pDM_Odm, &c); + -+ (*c.GetDeltaSwingTable)(pDM_Odm, (u8 **)&deltaSwingTableIdx_TUP_A, (u8 **)&deltaSwingTableIdx_TDOWN_A, -+ (u8 **)&deltaSwingTableIdx_TUP_B, (u8 **)&deltaSwingTableIdx_TDOWN_B); ++ (*c.GetDeltaSwingTable)( ++ pDM_Odm, ++ (u8 **)&deltaSwingTableIdx_TUP_A, ++ (u8 **)&deltaSwingTableIdx_TDOWN_A, ++ (u8 **)&deltaSwingTableIdx_TUP_B, ++ (u8 **)&deltaSwingTableIdx_TDOWN_B ++ ); + -+ pDM_Odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; /* cosa add for debug */ ++ /* cosa add for debug */ ++ pDM_Odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; + pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = true; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("===>ODM_TXPowerTrackingCallback_ThermalMeter, \ -+ \n pDM_Odm->BbSwingIdxCckBase: %d, pDM_Odm->BbSwingIdxOfdmBase[A]: %d, pDM_Odm->DefaultOfdmIndex: %d\n", -+ pDM_Odm->BbSwingIdxCckBase, pDM_Odm->BbSwingIdxOfdmBase[ODM_RF_PATH_A], pDM_Odm->DefaultOfdmIndex)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "===>ODM_TXPowerTrackingCallback_ThermalMeter,\npDM_Odm->BbSwingIdxCckBase: %d, pDM_Odm->BbSwingIdxOfdmBase[A]: %d, pDM_Odm->DefaultOfdmIndex: %d\n", ++ pDM_Odm->BbSwingIdxCckBase, ++ pDM_Odm->BbSwingIdxOfdmBase[ODM_RF_PATH_A], ++ pDM_Odm->DefaultOfdmIndex ++ ) ++ ); + + ThermalValue = (u8)PHY_QueryRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, c.ThermalRegAddr, 0xfc00); /* 0x42: RF Reg[15:10] 88E */ -+ if (! pDM_Odm->RFCalibrateInfo.TxPowerTrackControl || pHalData->EEPROMThermalMeter == 0 || -+ pHalData->EEPROMThermalMeter == 0xFF) ++ if ( ++ !pDM_Odm->RFCalibrateInfo.TxPowerTrackControl || ++ pHalData->EEPROMThermalMeter == 0 || ++ pHalData->EEPROMThermalMeter == 0xFF ++ ) + return; + + /* 4 3. Initialize ThermalValues of RFCalibrateInfo */ + + if (pDM_Odm->RFCalibrateInfo.bReloadtxpowerindex) -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("reload ofdm index for band switch\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ++ ("reload ofdm index for band switch\n") ++ ); + + /* 4 4. Calculate average thermal meter */ + @@ -55649,156 +53959,337 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.c linux-4.3-rtl8723bs/3rdpa + } + } + -+ if (ThermalValue_AVG_count) /* Calculate Average ThermalValue after average enough times */ -+ { ++ /* Calculate Average ThermalValue after average enough times */ ++ if (ThermalValue_AVG_count) { + ThermalValue = (u8)(ThermalValue_AVG / ThermalValue_AVG_count); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("AVG Thermal Meter = 0x%X, EFUSE Thermal Base = 0x%X\n", ThermalValue, pHalData->EEPROMThermalMeter)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "AVG Thermal Meter = 0x%X, EFUSE Thermal Base = 0x%X\n", ++ ThermalValue, ++ pHalData->EEPROMThermalMeter ++ ) ++ ); + } + + /* 4 5. Calculate delta, delta_LCK, delta_IQK. */ -+ + /* delta" here is used to determine whether thermal value changes or not. */ -+ delta = (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue)?(ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue):(pDM_Odm->RFCalibrateInfo.ThermalValue - ThermalValue); -+ delta_LCK = (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue_LCK)?(ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue_LCK):(pDM_Odm->RFCalibrateInfo.ThermalValue_LCK - ThermalValue); -+ delta_IQK = (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue_IQK)?(ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue_IQK):(pDM_Odm->RFCalibrateInfo.ThermalValue_IQK - ThermalValue); ++ delta = ++ (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue) ? ++ (ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue) : ++ (pDM_Odm->RFCalibrateInfo.ThermalValue - ThermalValue); ++ delta_LCK = ++ (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue_LCK) ? ++ (ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue_LCK) : ++ (pDM_Odm->RFCalibrateInfo.ThermalValue_LCK - ThermalValue); ++ delta_IQK = ++ (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue_IQK) ? ++ (ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue_IQK) : ++ (pDM_Odm->RFCalibrateInfo.ThermalValue_IQK - ThermalValue); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("(delta, delta_LCK, delta_IQK) = (%d, %d, %d)\n", delta, delta_LCK, delta_IQK)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "(delta, delta_LCK, delta_IQK) = (%d, %d, %d)\n", ++ delta, ++ delta_LCK, ++ delta_IQK ++ ) ++ ); + + /* 4 6. If necessary, do LCK. */ -+ -+ if ((delta_LCK >= c.Threshold_IQK)) /* Delta temperature is equal to or larger than 20 centigrade. */ -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("delta_LCK(%d) >= Threshold_IQK(%d)\n", delta_LCK, c.Threshold_IQK)); ++ /* Delta temperature is equal to or larger than 20 centigrade. */ ++ if (delta_LCK >= c.Threshold_IQK) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "delta_LCK(%d) >= Threshold_IQK(%d)\n", ++ delta_LCK, ++ c.Threshold_IQK ++ ) ++ ); + pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; + if (c.PHY_LCCalibrate) + (*c.PHY_LCCalibrate)(pDM_Odm); + } + + /* 3 7. If necessary, move the index of swing table to adjust Tx power. */ -+ + if (delta > 0 && pDM_Odm->RFCalibrateInfo.TxPowerTrackControl) { + /* delta" here is used to record the absolute value of differrence. */ -+ delta = ThermalValue > pHalData->EEPROMThermalMeter?(ThermalValue - pHalData->EEPROMThermalMeter):(pHalData->EEPROMThermalMeter - ThermalValue); ++ delta = ++ ThermalValue > pHalData->EEPROMThermalMeter ? ++ (ThermalValue - pHalData->EEPROMThermalMeter) : ++ (pHalData->EEPROMThermalMeter - ThermalValue); ++ + if (delta >= TXPWR_TRACK_TABLE_SIZE) + delta = TXPWR_TRACK_TABLE_SIZE - 1; + + /* 4 7.1 The Final Power Index = BaseIndex + PowerIndexOffset */ -+ + if (ThermalValue > pHalData->EEPROMThermalMeter) { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("deltaSwingTableIdx_TUP_A[%d] = %d\n", delta, deltaSwingTableIdx_TUP_A[delta])); -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_A] = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A]; -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A] = deltaSwingTableIdx_TUP_A[delta]; ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "deltaSwingTableIdx_TUP_A[%d] = %d\n", ++ delta, ++ deltaSwingTableIdx_TUP_A[delta] ++ ) ++ ); ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_A] = ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A]; ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A] = ++ deltaSwingTableIdx_TUP_A[delta]; + -+ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = deltaSwingTableIdx_TUP_A[delta]; /* Record delta swing for mix mode power tracking */ ++ /* Record delta swing for mix mode power tracking */ ++ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = ++ deltaSwingTableIdx_TUP_A[delta]; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("******Temp is higher and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = %d\n", pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A])); -+ -+ if (c.RfPathCount > 1) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("deltaSwingTableIdx_TUP_B[%d] = %d\n", delta, deltaSwingTableIdx_TUP_B[delta])); -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_B] = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B]; -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B] = deltaSwingTableIdx_TUP_B[delta]; -+ -+ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = deltaSwingTableIdx_TUP_B[delta]; /* Record delta swing for mix mode power tracking */ -+ -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("******Temp is higher and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = %d\n", pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B])); -+ } -+ -+ } else { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("deltaSwingTableIdx_TDOWN_A[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_A[delta])); -+ -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_A] = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A]; -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A] = -1 * deltaSwingTableIdx_TDOWN_A[delta]; -+ -+ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = -1 * deltaSwingTableIdx_TDOWN_A[delta]; /* Record delta swing for mix mode power tracking */ -+ -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("******Temp is lower and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = %d\n", pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A])); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "******Temp is higher and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = %d\n", ++ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] ++ ) ++ ); + + if (c.RfPathCount > 1) { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("deltaSwingTableIdx_TDOWN_B[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_B[delta])); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "deltaSwingTableIdx_TUP_B[%d] = %d\n", ++ delta, ++ deltaSwingTableIdx_TUP_B[delta] ++ ) ++ ); ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_B] = ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B]; ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B] = ++ deltaSwingTableIdx_TUP_B[delta]; + -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_B] = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B]; -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B] = -1 * deltaSwingTableIdx_TDOWN_B[delta]; ++ /* Record delta swing for mix mode power tracking */ ++ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = ++ deltaSwingTableIdx_TUP_B[delta]; ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "******Temp is higher and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = %d\n", ++ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] ++ ) ++ ); ++ } + -+ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = -1 * deltaSwingTableIdx_TDOWN_B[delta]; /* Record delta swing for mix mode power tracking */ ++ } else { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "deltaSwingTableIdx_TDOWN_A[%d] = %d\n", ++ delta, ++ deltaSwingTableIdx_TDOWN_A[delta] ++ ) ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("******Temp is lower and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = %d\n", pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B])); -+ } -+ } ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_A] = ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A]; ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A] = ++ -1 * deltaSwingTableIdx_TDOWN_A[delta]; ++ ++ /* Record delta swing for mix mode power tracking */ ++ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = ++ -1 * deltaSwingTableIdx_TDOWN_A[delta]; ++ ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "******Temp is lower and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = %d\n", ++ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] ++ ) ++ ); ++ ++ if (c.RfPathCount > 1) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "deltaSwingTableIdx_TDOWN_B[%d] = %d\n", ++ delta, ++ deltaSwingTableIdx_TDOWN_B[delta] ++ ) ++ ); ++ ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_B] = ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B]; ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B] = ++ -1 * deltaSwingTableIdx_TDOWN_B[delta]; ++ ++ /* Record delta swing for mix mode power tracking */ ++ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = ++ -1 * deltaSwingTableIdx_TDOWN_B[delta]; ++ ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "******Temp is lower and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = %d\n", ++ pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] ++ ) ++ ); ++ } ++ } + + for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("\n\n ================================ [Path-%c] Calculating PowerIndexOffset ================================\n", (p == ODM_RF_PATH_A ? 'A' : 'B'))); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "\n\n ================================ [Path-%c] Calculating PowerIndexOffset ================================\n", ++ (p == ODM_RF_PATH_A ? 'A' : 'B') ++ ) ++ ); + -+ if (pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] == pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p]) /* If Thermal value changes but lookup table value still the same */ ++ if ( ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] == ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] ++ ) /* If Thermal value changes but lookup table value still the same */ + pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0; + else + pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p]; /* Power Index Diff between 2 times Power Tracking */ + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("[Path-%c] PowerIndexOffset(%d) = DeltaPowerIndex(%d) - DeltaPowerIndexLast(%d)\n", -+ (p == ODM_RF_PATH_A ? 'A' : 'B'), pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p], pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p], -+ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p])); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "[Path-%c] PowerIndexOffset(%d) = DeltaPowerIndex(%d) - DeltaPowerIndexLast(%d)\n", ++ ( ++ p == ODM_RF_PATH_A ? 'A' : 'B'), ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p], ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p], ++ pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] ++ ) ++ ); + -+ pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->BbSwingIdxOfdmBase[p] + pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p]; -+ pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->BbSwingIdxCckBase + pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p]; ++ pDM_Odm->RFCalibrateInfo.OFDM_index[p] = ++ pDM_Odm->BbSwingIdxOfdmBase[p] + ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p]; + -+ pDM_Odm->BbSwingIdxCck = pDM_Odm->RFCalibrateInfo.CCK_index; -+ pDM_Odm->BbSwingIdxOfdm[p] = pDM_Odm->RFCalibrateInfo.OFDM_index[p]; ++ pDM_Odm->RFCalibrateInfo.CCK_index = ++ pDM_Odm->BbSwingIdxCckBase + ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p]; ++ ++ pDM_Odm->BbSwingIdxCck = ++ pDM_Odm->RFCalibrateInfo.CCK_index; ++ ++ pDM_Odm->BbSwingIdxOfdm[p] = ++ pDM_Odm->RFCalibrateInfo.OFDM_index[p]; + + /* *************Print BB Swing Base and Index Offset************* */ ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "The 'CCK' final index(%d) = BaseIndex(%d) + PowerIndexOffset(%d)\n", ++ pDM_Odm->BbSwingIdxCck, ++ pDM_Odm->BbSwingIdxCckBase, ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "The 'OFDM' final index(%d) = BaseIndex[%c](%d) + PowerIndexOffset(%d)\n", ++ pDM_Odm->BbSwingIdxOfdm[p], ++ (p == ODM_RF_PATH_A ? 'A' : 'B'), ++ pDM_Odm->BbSwingIdxOfdmBase[p], ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] ++ ) ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("The 'CCK' final index(%d) = BaseIndex(%d) + PowerIndexOffset(%d)\n", -+ pDM_Odm->BbSwingIdxCck, pDM_Odm->BbSwingIdxCckBase, pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p])); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("The 'OFDM' final index(%d) = BaseIndex[%c](%d) + PowerIndexOffset(%d)\n", -+ pDM_Odm->BbSwingIdxOfdm[p], (p == ODM_RF_PATH_A ? 'A' : 'B'), pDM_Odm->BbSwingIdxOfdmBase[p], pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p])); -+ -+ /* 4 7.1 Handle boundary conditions of index. */ -+ -+ ++ /* 4 7.1 Handle boundary conditions of index. */ + if (pDM_Odm->RFCalibrateInfo.OFDM_index[p] > c.SwingTableSize_OFDM-1) -+ { + pDM_Odm->RFCalibrateInfo.OFDM_index[p] = c.SwingTableSize_OFDM-1; -+ } + else if (pDM_Odm->RFCalibrateInfo.OFDM_index[p] < OFDM_min_index) -+ { + pDM_Odm->RFCalibrateInfo.OFDM_index[p] = OFDM_min_index; -+ } + } -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("\n\n ========================================================================================================\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ("\n\n ========================================================================================================\n") ++ ); + if (pDM_Odm->RFCalibrateInfo.CCK_index > c.SwingTableSize_CCK-1) + pDM_Odm->RFCalibrateInfo.CCK_index = c.SwingTableSize_CCK-1; + /* else if (pDM_Odm->RFCalibrateInfo.CCK_index < 0) */ + /* pDM_Odm->RFCalibrateInfo.CCK_index = 0; */ -+ } -+ else -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("The thermal meter is unchanged or TxPowerTracking OFF(%d): ThermalValue: %d , pDM_Odm->RFCalibrateInfo.ThermalValue: %d\n", -+ pDM_Odm->RFCalibrateInfo.TxPowerTrackControl, ThermalValue, pDM_Odm->RFCalibrateInfo.ThermalValue)); ++ } else { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "The thermal meter is unchanged or TxPowerTracking OFF(%d): ThermalValue: %d , pDM_Odm->RFCalibrateInfo.ThermalValue: %d\n", ++ pDM_Odm->RFCalibrateInfo.TxPowerTrackControl, ++ ThermalValue, ++ pDM_Odm->RFCalibrateInfo.ThermalValue ++ ) ++ ); + -+ for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) -+ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0; ++ for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0; + } -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("TxPowerTracking: [CCK] Swing Current Index: %d, Swing Base Index: %d\n", -+ pDM_Odm->RFCalibrateInfo.CCK_index, pDM_Odm->BbSwingIdxCckBase)); /* Print Swing base & current */ -+ for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("TxPowerTracking: [OFDM] Swing Current Index: %d, Swing Base Index[%c]: %d\n", -+ pDM_Odm->RFCalibrateInfo.OFDM_index[p], (p == ODM_RF_PATH_A ? 'A' : 'B'), pDM_Odm->BbSwingIdxOfdmBase[p])); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "TxPowerTracking: [CCK] Swing Current Index: %d, Swing Base Index: %d\n", ++ pDM_Odm->RFCalibrateInfo.CCK_index, ++ pDM_Odm->BbSwingIdxCckBase ++ ) ++ ); ++ ++ /* Print Swing base & current */ ++ for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "TxPowerTracking: [OFDM] Swing Current Index: %d, Swing Base Index[%c]: %d\n", ++ pDM_Odm->RFCalibrateInfo.OFDM_index[p], ++ (p == ODM_RF_PATH_A ? 'A' : 'B'), ++ pDM_Odm->BbSwingIdxOfdmBase[p] ++ ) ++ ); + } + -+ if ((pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_A] != 0 || ++ if ( ++ (pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_A] != 0 || + pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_B] != 0) && -+ pDM_Odm->RFCalibrateInfo.TxPowerTrackControl) -+ { ++ pDM_Odm->RFCalibrateInfo.TxPowerTrackControl ++ ) { + /* 4 7.2 Configure the Swing Table to adjust Tx Power. */ + + pDM_Odm->RFCalibrateInfo.bTxPowerChanged = true; /* Always true after Tx Power is adjusted by power tracking. */ @@ -55807,61 +54298,135 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.c linux-4.3-rtl8723bs/3rdpa + /* to increase TX power. Otherwise, EVM will be bad. */ + /* */ + /* 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. */ -+ if (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("Temperature Increasing(A): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", -+ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_A], delta, ThermalValue, pHalData->EEPROMThermalMeter, pDM_Odm->RFCalibrateInfo.ThermalValue)); ++ if (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "Temperature Increasing(A): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_A], ++ delta, ++ ThermalValue, ++ pHalData->EEPROMThermalMeter, ++ pDM_Odm->RFCalibrateInfo.ThermalValue ++ ) ++ ); + + if (c.RfPathCount > 1) -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("Temperature Increasing(B): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", -+ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_B], delta, ThermalValue, pHalData->EEPROMThermalMeter, pDM_Odm->RFCalibrateInfo.ThermalValue)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "Temperature Increasing(B): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_B], ++ delta, ++ ThermalValue, ++ pHalData->EEPROMThermalMeter, ++ pDM_Odm->RFCalibrateInfo.ThermalValue ++ ) ++ ); + -+ } -+ else if (ThermalValue < pDM_Odm->RFCalibrateInfo.ThermalValue)/* Low temperature */ -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("Temperature Decreasing(A): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", -+ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_A], delta, ThermalValue, pHalData->EEPROMThermalMeter, pDM_Odm->RFCalibrateInfo.ThermalValue)); ++ } else if (ThermalValue < pDM_Odm->RFCalibrateInfo.ThermalValue) { /* Low temperature */ ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "Temperature Decreasing(A): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_A], ++ delta, ++ ThermalValue, ++ pHalData->EEPROMThermalMeter, ++ pDM_Odm->RFCalibrateInfo.ThermalValue ++ ) ++ ); + + if (c.RfPathCount > 1) -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("Temperature Decreasing(B): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", -+ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_B], delta, ThermalValue, pHalData->EEPROMThermalMeter, pDM_Odm->RFCalibrateInfo.ThermalValue)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "Temperature Decreasing(B): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", ++ pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_B], ++ delta, ++ ThermalValue, ++ pHalData->EEPROMThermalMeter, ++ pDM_Odm->RFCalibrateInfo.ThermalValue ++ ) ++ ); + + } -+ if (ThermalValue > pHalData->EEPROMThermalMeter) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("Temperature(%d) higher than PG value(%d)\n", ThermalValue, pHalData->EEPROMThermalMeter)); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("**********Enter POWER Tracking MIX_MODE**********\n")); ++ if (ThermalValue > pHalData->EEPROMThermalMeter) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "Temperature(%d) higher than PG value(%d)\n", ++ ThermalValue, ++ pHalData->EEPROMThermalMeter ++ ) ++ ); ++ ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ("**********Enter POWER Tracking MIX_MODE**********\n") ++ ); + for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) + (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, 0); -+ } -+ else -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("Temperature(%d) lower than PG value(%d)\n", ThermalValue, pHalData->EEPROMThermalMeter)); ++ } else { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ( ++ "Temperature(%d) lower than PG value(%d)\n", ++ ThermalValue, ++ pHalData->EEPROMThermalMeter ++ ) ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("**********Enter POWER Tracking MIX_MODE**********\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ("**********Enter POWER Tracking MIX_MODE**********\n") ++ ); + for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) + (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, Indexforchannel); + } + -+ pDM_Odm->BbSwingIdxCckBase = pDM_Odm->BbSwingIdxCck; /* Record last time Power Tracking result as base. */ ++ /* Record last time Power Tracking result as base. */ ++ pDM_Odm->BbSwingIdxCckBase = pDM_Odm->BbSwingIdxCck; + for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) -+ pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->BbSwingIdxOfdm[p]; ++ pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->BbSwingIdxOfdm[p]; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, -+ ("pDM_Odm->RFCalibrateInfo.ThermalValue = %d ThermalValue = %d\n", pDM_Odm->RFCalibrateInfo.ThermalValue, ThermalValue)); -+ -+ pDM_Odm->RFCalibrateInfo.ThermalValue = ThermalValue; /* Record last Power Tracking Thermal Value */ ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ++ ( ++ "pDM_Odm->RFCalibrateInfo.ThermalValue = %d ThermalValue = %d\n", ++ pDM_Odm->RFCalibrateInfo.ThermalValue, ++ ThermalValue ++ ) ++ ); + ++ /* Record last Power Tracking Thermal Value */ ++ pDM_Odm->RFCalibrateInfo.ThermalValue = ThermalValue; + } + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("<===ODM_TXPowerTrackingCallback_ThermalMeter\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_TX_PWR_TRACK, ++ ODM_DBG_LOUD, ++ ("<===ODM_TXPowerTrackingCallback_ThermalMeter\n") ++ ); + + pDM_Odm->RFCalibrateInfo.TXPowercount = 0; +} @@ -55875,28 +54440,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.c linux-4.3-rtl8723bs/3rdpa + +u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) +{ -+ u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = -+ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153, 155, 157, 159, 161, 163, 165}; ++ u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { ++ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ++ 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, ++ 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, ++ 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, ++ 134, 136, 138, 140, 149, 151, 153, 155, 157, 159, ++ 161, 163, 165 ++ }; + u8 place = chnl; + + -+ if (chnl > 14) -+ { -+ for (place = 14; place 14) { ++ for (place = 14; place < sizeof(channel_all); place++) { + if (channel_all[place] == chnl) -+ { + return place-13; -+ } + } + } + return 0; + +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPhyRf.h ---- linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPhyRf.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,75 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalPhyRf.h linux/3rdparty/rtl8723bs/hal/HalPhyRf.h +--- linux.old/3rdparty/rtl8723bs/hal/HalPhyRf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalPhyRf.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,63 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -55937,45 +54504,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPhyRf.h linux-4.3-rtl8723bs/3rdpa + u8 Threshold_IQK; + u8 AverageThermalNum; + u8 RfPathCount; -+ u32 ThermalRegAddr; -+ FuncSetPwr ODM_TxPwrTrackSetPwr; -+ FuncIQK DoIQK; -+ FuncLCK PHY_LCCalibrate; -+ FuncSwing GetDeltaSwingTable; ++ u32 ThermalRegAddr; ++ FuncSetPwr ODM_TxPwrTrackSetPwr; ++ FuncIQK DoIQK; ++ FuncLCK PHY_LCCalibrate; ++ FuncSwing GetDeltaSwingTable; +} TXPWRTRACK_CFG, *PTXPWRTRACK_CFG; + -+void ConfigureTxpowerTrack( -+ PDM_ODM_T pDM_Odm, -+ PTXPWRTRACK_CFG pConfig -+ ); ++void ConfigureTxpowerTrack(PDM_ODM_T pDM_Odm, PTXPWRTRACK_CFG pConfig); + + -+void -+ODM_ClearTxPowerTrackingState( -+ PDM_ODM_T pDM_Odm -+ ); ++void ODM_ClearTxPowerTrackingState(PDM_ODM_T pDM_Odm); + -+void -+ODM_TXPowerTrackingCallback_ThermalMeter( -+ struct adapter *Adapter -+ ); ++void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter); + + + -+#define ODM_TARGET_CHNL_NUM_2G_5G 59 ++#define ODM_TARGET_CHNL_NUM_2G_5G 59 + + -+u8 -+ODM_GetRightChnlPlaceforIQK( -+ u8 chnl -+); ++u8 ODM_GetRightChnlPlaceforIQK(u8 chnl); + + +#endif /* #ifndef __HAL_PHY_RF_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c ---- linux-4.3/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,166 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c linux/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c +--- linux.old/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,205 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -56012,140 +54567,179 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/HalPwrSeqCmd.c linux-4.3-rtl8723bs/3 + + +/* */ -+/* Description: */ -+/* This routine deal with the Power Configuration CMDs parsing for RTL8723/RTL8188E Series IC. */ ++/* Description: */ ++/* This routine deal with the Power Configuration CMDs parsing for RTL8723/RTL8188E Series IC. */ +/* */ -+/* Assumption: */ -+/* We should follow specific format which was released from HW SD. */ ++/* Assumption: */ ++/* We should follow specific format which was released from HW SD. */ +/* */ -+/* 2011.07.07, added by Roger. */ ++/* 2011.07.07, added by Roger. */ +/* */ +u8 HalPwrSeqCmdParsing( -+ struct adapter * padapter, -+ u8 CutVersion, -+ u8 FabVersion, -+ u8 InterfaceType, -+ WLAN_PWR_CFG PwrSeqCmd[]) ++ struct adapter *padapter, ++ u8 CutVersion, ++ u8 FabVersion, ++ u8 InterfaceType, ++ WLAN_PWR_CFG PwrSeqCmd[] ++) +{ -+ WLAN_PWR_CFG PwrCfgCmd = {0}; -+ u8 bPollingBit = false; -+ u32 AryIdx = 0; -+ u8 value = 0; -+ u32 offset = 0; -+ u32 pollingCount = 0; /* polling autoload done. */ -+ u32 maxPollingCnt = 5000; ++ WLAN_PWR_CFG PwrCfgCmd = {0}; ++ u8 bPollingBit = false; ++ u32 AryIdx = 0; ++ u8 value = 0; ++ u32 offset = 0; ++ u32 pollingCount = 0; /* polling autoload done. */ ++ u32 maxPollingCnt = 5000; + + do { + PwrCfgCmd = PwrSeqCmd[AryIdx]; + -+ RT_TRACE(_module_hal_init_c_ , _drv_info_, -+ ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", -+ GET_PWR_CFG_OFFSET(PwrCfgCmd), -+ GET_PWR_CFG_CUT_MASK(PwrCfgCmd), -+ GET_PWR_CFG_FAB_MASK(PwrCfgCmd), -+ GET_PWR_CFG_INTF_MASK(PwrCfgCmd), -+ GET_PWR_CFG_BASE(PwrCfgCmd), -+ GET_PWR_CFG_CMD(PwrCfgCmd), -+ GET_PWR_CFG_MASK(PwrCfgCmd), -+ GET_PWR_CFG_VALUE(PwrCfgCmd))); ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_info_, ++ ( ++ "HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", ++ GET_PWR_CFG_OFFSET(PwrCfgCmd), ++ GET_PWR_CFG_CUT_MASK(PwrCfgCmd), ++ GET_PWR_CFG_FAB_MASK(PwrCfgCmd), ++ GET_PWR_CFG_INTF_MASK(PwrCfgCmd), ++ GET_PWR_CFG_BASE(PwrCfgCmd), ++ GET_PWR_CFG_CMD(PwrCfgCmd), ++ GET_PWR_CFG_MASK(PwrCfgCmd), ++ GET_PWR_CFG_VALUE(PwrCfgCmd) ++ ) ++ ); + + /* 2 Only Handle the command whose FAB, CUT, and Interface are matched */ -+ if ((GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) && ++ if ( ++ (GET_PWR_CFG_FAB_MASK(PwrCfgCmd) & FabVersion) && + (GET_PWR_CFG_CUT_MASK(PwrCfgCmd) & CutVersion) && -+ (GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType)) -+ { -+ switch (GET_PWR_CFG_CMD(PwrCfgCmd)) -+ { -+ case PWR_CMD_READ: -+ RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); -+ break; ++ (GET_PWR_CFG_INTF_MASK(PwrCfgCmd) & InterfaceType) ++ ) { ++ switch (GET_PWR_CFG_CMD(PwrCfgCmd)) { ++ case PWR_CMD_READ: ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_info_, ++ ("HalPwrSeqCmdParsing: PWR_CMD_READ\n") ++ ); ++ break; + -+ case PWR_CMD_WRITE: -+ RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); -+ offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); ++ case PWR_CMD_WRITE: ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_info_, ++ ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n") ++ ); ++ offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); + -+ /* */ -+ /* We should deal with interface specific address mapping for some interfaces, e.g., SDIO interface */ -+ /* 2011.07.07. */ -+ /* */ ++ /* */ ++ /* We should deal with interface specific address mapping for some interfaces, e.g., SDIO interface */ ++ /* 2011.07.07. */ ++ /* */ ++ if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) { ++ /* Read Back SDIO Local value */ ++ value = SdioLocalCmd52Read1Byte(padapter, offset); ++ ++ value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd)); ++ value |= ( ++ GET_PWR_CFG_VALUE(PwrCfgCmd) & ++ GET_PWR_CFG_MASK(PwrCfgCmd) ++ ); ++ ++ /* Write Back SDIO Local value */ ++ SdioLocalCmd52Write1Byte(padapter, offset, value); ++ } else { ++ /* Read the value from system register */ ++ value = rtw_read8(padapter, offset); ++ ++ value &= (~(GET_PWR_CFG_MASK(PwrCfgCmd))); ++ value |= ( ++ GET_PWR_CFG_VALUE(PwrCfgCmd) ++ &GET_PWR_CFG_MASK(PwrCfgCmd) ++ ); ++ ++ /* Write the value back to sytem register */ ++ rtw_write8(padapter, offset, value); ++ } ++ break; ++ ++ case PWR_CMD_POLLING: ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_info_, ++ ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n") ++ ); ++ ++ bPollingBit = false; ++ offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); ++ do { + if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) -+ { -+ /* Read Back SDIO Local value */ + value = SdioLocalCmd52Read1Byte(padapter, offset); -+ -+ value &= ~(GET_PWR_CFG_MASK(PwrCfgCmd)); -+ value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd)); -+ -+ /* Write Back SDIO Local value */ -+ SdioLocalCmd52Write1Byte(padapter, offset, value); -+ } + else -+ { -+ /* Read the value from system register */ + value = rtw_read8(padapter, offset); + -+ value =value&(~(GET_PWR_CFG_MASK(PwrCfgCmd))); -+ value =value|(GET_PWR_CFG_VALUE(PwrCfgCmd)&GET_PWR_CFG_MASK(PwrCfgCmd)); -+ -+ /* Write the value back to sytem register */ -+ rtw_write8(padapter, offset, value); -+ } -+ break; -+ -+ case PWR_CMD_POLLING: -+ RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); -+ -+ bPollingBit = false; -+ offset = GET_PWR_CFG_OFFSET(PwrCfgCmd); -+ do { -+ if (GET_PWR_CFG_BASE(PwrCfgCmd) == PWR_BASEADDR_SDIO) -+ value = SdioLocalCmd52Read1Byte(padapter, offset); -+ else -+ value = rtw_read8(padapter, offset); -+ -+ value =value&GET_PWR_CFG_MASK(PwrCfgCmd); -+ if (value == (GET_PWR_CFG_VALUE(PwrCfgCmd) & GET_PWR_CFG_MASK(PwrCfgCmd))) -+ bPollingBit = true; -+ else -+ udelay(10); -+ -+ if (pollingCount++ > maxPollingCnt) { -+ DBG_871X("Fail to polling Offset[%#x]=%02x\n", offset, value); -+ return false; -+ } -+ } while (!bPollingBit); -+ -+ break; -+ -+ case PWR_CMD_DELAY: -+ RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); -+ if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US) -+ udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd)); ++ value = value&GET_PWR_CFG_MASK(PwrCfgCmd); ++ if ( ++ value == (GET_PWR_CFG_VALUE(PwrCfgCmd) & ++ GET_PWR_CFG_MASK(PwrCfgCmd)) ++ ) ++ bPollingBit = true; + else -+ udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd)*1000); -+ break; ++ udelay(10); + -+ case PWR_CMD_END: -+ /* When this command is parsed, end the process */ -+ RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); -+ return true; -+ break; ++ if (pollingCount++ > maxPollingCnt) { ++ DBG_871X( ++ "Fail to polling Offset[%#x]=%02x\n", ++ offset, ++ value ++ ); ++ return false; ++ } ++ } while (!bPollingBit); + -+ default: -+ RT_TRACE(_module_hal_init_c_ , _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); -+ break; ++ break; ++ ++ case PWR_CMD_DELAY: ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_info_, ++ ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n") ++ ); ++ if (GET_PWR_CFG_VALUE(PwrCfgCmd) == PWRSEQ_DELAY_US) ++ udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd)); ++ else ++ udelay(GET_PWR_CFG_OFFSET(PwrCfgCmd)*1000); ++ break; ++ ++ case PWR_CMD_END: ++ /* When this command is parsed, end the process */ ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_info_, ++ ("HalPwrSeqCmdParsing: PWR_CMD_END\n") ++ ); ++ return true; ++ ++ default: ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_err_, ++ ("HalPwrSeqCmdParsing: Unknown CMD!!\n") ++ ); ++ break; + } + } + + AryIdx++;/* Add Array Index */ -+ }while (1); ++ } while (1); + + return true; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_sdio.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_sdio.c ---- linux-4.3/3rdparty/rtl8723bs/hal/hal_sdio.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/hal_sdio.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,106 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/hal_sdio.c linux/3rdparty/rtl8723bs/hal/hal_sdio.c +--- linux.old/3rdparty/rtl8723bs/hal/hal_sdio.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/hal_sdio.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,115 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -56176,7 +54770,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_sdio.c linux-4.3-rtl8723bs/3rdpa + return pHalData->SdioTxOQTMaxFreeSpace; +} + -+u8 rtw_hal_sdio_query_tx_freepage(struct adapter *padapter, u8 PageIdx, u8 RequiredPageNum) ++u8 rtw_hal_sdio_query_tx_freepage( ++ struct adapter *padapter, u8 PageIdx, u8 RequiredPageNum ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + @@ -56186,7 +54782,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_sdio.c linux-4.3-rtl8723bs/3rdpa + return false; +} + -+void rtw_hal_sdio_update_tx_freepage(struct adapter *padapter, u8 PageIdx, u8 RequiredPageNum) ++void rtw_hal_sdio_update_tx_freepage( ++ struct adapter *padapter, u8 PageIdx, u8 RequiredPageNum ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + u8 DedicatedPgNum = 0; @@ -56207,21 +54805,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_sdio.c linux-4.3-rtl8723bs/3rdpa + /* spin_unlock_bh(&pHalData->SdioTxFIFOFreePageLock); */ +} + -+void rtw_hal_set_sdio_tx_max_length(struct adapter *padapter, u8 numHQ, u8 numNQ, u8 numLQ, u8 numPubQ) ++void rtw_hal_set_sdio_tx_max_length( ++ struct adapter *padapter, u8 numHQ, u8 numNQ, u8 numLQ, u8 numPubQ ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + u32 page_size; + u32 lenHQ, lenNQ, lenLQ; + -+ rtw_hal_get_def_var(padapter, HAL_DEF_TX_PAGE_SIZE,&page_size); ++ rtw_hal_get_def_var(padapter, HAL_DEF_TX_PAGE_SIZE, &page_size); + + lenHQ = ((numHQ + numPubQ) >> 1) * page_size; + lenNQ = ((numNQ + numPubQ) >> 1) * page_size; + lenLQ = ((numLQ + numPubQ) >> 1) * page_size; + -+ pHalData->sdio_tx_max_len[HI_QUEUE_IDX] = (lenHQ > MAX_XMITBUF_SZ)? MAX_XMITBUF_SZ:lenHQ; -+ pHalData->sdio_tx_max_len[MID_QUEUE_IDX] = (lenNQ > MAX_XMITBUF_SZ)? MAX_XMITBUF_SZ:lenNQ; -+ pHalData->sdio_tx_max_len[LOW_QUEUE_IDX] = (lenLQ > MAX_XMITBUF_SZ)? MAX_XMITBUF_SZ:lenLQ; ++ pHalData->sdio_tx_max_len[HI_QUEUE_IDX] = ++ (lenHQ > MAX_XMITBUF_SZ) ? MAX_XMITBUF_SZ : lenHQ; ++ pHalData->sdio_tx_max_len[MID_QUEUE_IDX] = ++ (lenNQ > MAX_XMITBUF_SZ) ? MAX_XMITBUF_SZ : lenNQ; ++ pHalData->sdio_tx_max_len[LOW_QUEUE_IDX] = ++ (lenLQ > MAX_XMITBUF_SZ) ? MAX_XMITBUF_SZ : lenLQ; +} + +u32 rtw_hal_get_sdio_tx_max_length(struct adapter *padapter, u8 queue_idx) @@ -56233,28 +54836,28 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/hal_sdio.c linux-4.3-rtl8723bs/3rdpa + + deviceId = ffaddr2deviceId(pdvobjpriv, queue_idx); + switch (deviceId) { -+ case WLAN_TX_HIQ_DEVICE_ID: -+ max_len = pHalData->sdio_tx_max_len[HI_QUEUE_IDX]; -+ break; ++ case WLAN_TX_HIQ_DEVICE_ID: ++ max_len = pHalData->sdio_tx_max_len[HI_QUEUE_IDX]; ++ break; + -+ case WLAN_TX_MIQ_DEVICE_ID: -+ max_len = pHalData->sdio_tx_max_len[MID_QUEUE_IDX]; -+ break; ++ case WLAN_TX_MIQ_DEVICE_ID: ++ max_len = pHalData->sdio_tx_max_len[MID_QUEUE_IDX]; ++ break; + -+ case WLAN_TX_LOQ_DEVICE_ID: -+ max_len = pHalData->sdio_tx_max_len[LOW_QUEUE_IDX]; -+ break; ++ case WLAN_TX_LOQ_DEVICE_ID: ++ max_len = pHalData->sdio_tx_max_len[LOW_QUEUE_IDX]; ++ break; + -+ default: -+ max_len = pHalData->sdio_tx_max_len[MID_QUEUE_IDX]; -+ break; ++ default: ++ max_len = pHalData->sdio_tx_max_len[MID_QUEUE_IDX]; ++ break; + } + + return max_len; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/Mp_Precomp.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/Mp_Precomp.h ---- linux-4.3/3rdparty/rtl8723bs/hal/Mp_Precomp.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/Mp_Precomp.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/Mp_Precomp.h linux/3rdparty/rtl8723bs/hal/Mp_Precomp.h +--- linux.old/3rdparty/rtl8723bs/hal/Mp_Precomp.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/Mp_Precomp.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,33 @@ +/****************************************************************************** + * @@ -56289,10 +54892,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/Mp_Precomp.h linux-4.3-rtl8723bs/3rd +#include "HalBtc8723b2Ant.h" + +#endif /* __MP_PRECOMP_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_AntDiv.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_AntDiv.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_AntDiv.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_AntDiv.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,74 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_AntDiv.c linux/3rdparty/rtl8723bs/hal/odm_AntDiv.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_AntDiv.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_AntDiv.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,70 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -56315,61 +54918,57 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_AntDiv.c linux-4.3-rtl8723bs/3rd +#include "odm_precomp.h" + +//====================================================== -+// when antenna test utility is on or some testing need to disable antenna diversity -+// call this function to disable all ODM related mechanisms which will switch antenna. ++// when antenna test utility is on or some testing ++// need to disable antenna diversity ++// call this function to disable all ODM related mechanisms ++// which will switch antenna. +//====================================================== -+void -+ODM_StopAntennaSwitchDm( -+PDM_ODM_T pDM_Odm -+ ) ++void ODM_StopAntennaSwitchDm(PDM_ODM_T pDM_Odm) +{ + // disable ODM antenna diversity + pDM_Odm->SupportAbility &= ~ODM_BB_ANT_DIV; -+ ODM_RT_TRACE(pDM_Odm,ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("STOP Antenna Diversity\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_ANT_DIV, ++ ODM_DBG_LOUD, ++ ("STOP Antenna Diversity\n") ++ ); +} + -+void -+ODM_SetAntConfig( -+PDM_ODM_T pDM_Odm, -+u8 antSetting // 0=A, 1=B, 2=C, .... -+ ) ++void ODM_SetAntConfig(PDM_ODM_T pDM_Odm, u8 antSetting)// 0=A, 1=B, 2=C, .... +{ -+ if(antSetting == 0) // ant A ++ if (antSetting == 0) // ant A + PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, 0x00000000); -+ else if(antSetting == 1) ++ else if (antSetting == 1) + PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, 0x00000280); +} + +//====================================================== + + -+void -+ODM_SwAntDivRestAfterLink( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_SwAntDivRestAfterLink(PDM_ODM_T pDM_Odm) +{ -+ pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; -+ pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable; -+ u32 i; ++ pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; ++ pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable; ++ u32 i; + + pDM_Odm->RSSI_test = false; + pDM_SWAT_Table->try_flag = 0xff; + pDM_SWAT_Table->RSSI_Trying = 0; -+ pDM_SWAT_Table->Double_chk_flag= 0; ++ pDM_SWAT_Table->Double_chk_flag = 0; + -+ pDM_FatTable->RxIdleAnt=MAIN_ANT; ++ pDM_FatTable->RxIdleAnt = MAIN_ANT; + -+ for (i=0; iMainAnt_Sum[i] = 0; + pDM_FatTable->AuxAnt_Sum[i] = 0; + pDM_FatTable->MainAnt_Cnt[i] = 0; + pDM_FatTable->AuxAnt_Cnt[i] = 0; + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_AntDiv.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_AntDiv.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_AntDiv.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_AntDiv.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_AntDiv.h linux/3rdparty/rtl8723bs/hal/odm_AntDiv.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_AntDiv.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_AntDiv.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,38 @@ +/****************************************************************************** + * @@ -56409,10 +55008,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_AntDiv.h linux-4.3-rtl8723bs/3rd +#define RELEASE_ANTDIV_TIMMER 2 + +#endif /* ifndef __ODMANTDIV_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1630 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm.c linux/3rdparty/rtl8723bs/hal/odm.c +--- linux.old/3rdparty/rtl8723bs/hal/odm.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1446 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -56440,7 +55039,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + {4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125, + 15849}, + {17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119, -+ 56234, 65535}}; ++ 56234, 65535} ++ }; + +/* Global var */ + @@ -56638,7 +55238,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04} /* 32, +0dB */ +}; + -+u8 CCKSwingTable_Ch14_New[CCK_TABLE_SIZE][8]= { ++u8 CCKSwingTable_Ch14_New[CCK_TABLE_SIZE][8] = { + {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}, /* 0, -16.0dB */ + {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 1, -15.5dB */ + {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 2, -15.0dB */ @@ -56674,8 +55274,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00} /* 32, +0dB */ +}; + -+u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] = -+{ ++u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] = { + 0x081, /* 0, -12.0dB */ + 0x088, /* 1, -11.5dB */ + 0x090, /* 2, -11.0dB */ @@ -56718,26 +55317,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* Local Function predefine. */ + +/* START------------COMMON INFO RELATED--------------- */ -+void -+odm_CommonInfoSelfInit( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm); + -+void -+odm_CommonInfoSelfUpdate( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm); + -+void -+odm_CmnInfoInit_Debug( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm); + -+void -+odm_BasicDbgMessage -+( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm); + +/* END------------COMMON INFO RELATED--------------- */ + @@ -56751,107 +55337,59 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* Remove BB power Saving by YuChen */ +/* END---------BB POWER SAVE----------------------- */ + -+void -+odm_RefreshRateAdaptiveMaskCE( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm); + +/* Remove by YuChen */ + -+void -+odm_RSSIMonitorInit( -+PDM_ODM_T pDM_Odm -+ ); ++void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm); + -+void -+odm_RSSIMonitorCheckCE( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm); + -+void -+odm_RSSIMonitorCheck( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm); + -+void -+odm_SwAntDetectInit( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm); + +void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext); + + + -+void -+odm_GlobalAdapterCheck( -+ void -+ ); ++void odm_GlobalAdapterCheck(void); + -+void -+odm_RefreshRateAdaptiveMask( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm); + -+void -+ODM_TXPowerTrackingCheck( -+ PDM_ODM_T pDM_Odm -+ ); ++void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm); + -+void -+odm_RateAdaptiveMaskInit( -+PDM_ODM_T pDM_Odm -+ ); ++void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm); + -+void -+odm_TXPowerTrackingThermalMeterInit( -+PDM_ODM_T pDM_Odm -+ ); ++void odm_TXPowerTrackingThermalMeterInit(PDM_ODM_T pDM_Odm); + + -+void -+odm_TXPowerTrackingInit( -+PDM_ODM_T pDM_Odm -+ ); ++void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm); + -+void -+odm_TXPowerTrackingCheckCE( -+PDM_ODM_T pDM_Odm -+ ); ++void odm_TXPowerTrackingCheckCE(PDM_ODM_T pDM_Odm); + +/* Remove Edca by Yu Chen */ + + -+#define RxDefaultAnt1 0x65a9 -+#define RxDefaultAnt2 0x569a ++#define RxDefaultAnt1 0x65a9 ++#define RxDefaultAnt2 0x569a + -+void -+odm_InitHybridAntDiv( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_InitHybridAntDiv(PDM_ODM_T pDM_Odm); + -+bool -+odm_StaDefAntSel( -+ PDM_ODM_T pDM_Odm, -+ u32 OFDM_Ant1_Cnt, -+ u32 OFDM_Ant2_Cnt, -+ u32 CCK_Ant1_Cnt, -+ u32 CCK_Ant2_Cnt, ++bool odm_StaDefAntSel( ++ PDM_ODM_T pDM_Odm, ++ u32 OFDM_Ant1_Cnt, ++ u32 OFDM_Ant2_Cnt, ++ u32 CCK_Ant1_Cnt, ++ u32 CCK_Ant2_Cnt, + u8 *pDefAnt -+ ); -+ -+void -+odm_SetRxIdleAnt( -+PDM_ODM_T pDM_Odm, -+u8 Ant, -+ bool bDualPath +); + ++void odm_SetRxIdleAnt(PDM_ODM_T pDM_Odm, u8 Ant, bool bDualPath); + + -+void -+odm_HwAntDiv( -+PDM_ODM_T pDM_Odm -+); ++ ++void odm_HwAntDiv(PDM_ODM_T pDM_Odm); + + +/* */ @@ -56861,10 +55399,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* */ +/* 2011/09/21 MH Add to describe different team necessary resource allocate?? */ +/* */ -+void -+ODM_DMInit( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_DMInit(PDM_ODM_T pDM_Odm) +{ + + odm_CommonInfoSelfInit(pDM_Odm); @@ -56894,10 +55429,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* You can not add any dummy function here, be care, you can only use DM structure */ +/* to perform any new ODM_DM. */ +/* */ -+void -+ODM_DMWatchdog( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_DMWatchdog(PDM_ODM_T pDM_Odm) +{ + odm_CommonInfoSelfUpdate(pDM_Odm); + odm_BasicDbgMessage(pDM_Odm); @@ -56913,27 +55445,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + /* Fix Leave LPS issue */ + if ((adapter_to_pwrctl(pDM_Odm->Adapter)->pwr_mode != PS_MODE_ACTIVE) /* in LPS mode */ + /* */ -+ /* (pDM_Odm->SupportICType & (ODM_RTL8723A))|| */ -+ /* (pDM_Odm->SupportICType & (ODM_RTL8188E) &&(&&(((pDM_Odm->SupportInterface == ODM_ITRF_SDIO))) */ ++ /* (pDM_Odm->SupportICType & (ODM_RTL8723A))|| */ ++ /* (pDM_Odm->SupportICType & (ODM_RTL8188E) &&(&&(((pDM_Odm->SupportInterface == ODM_ITRF_SDIO))) */ + /* */ -+ ) -+ { ++ ) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n")); + odm_DIGbyRSSI_LPS(pDM_Odm); -+ } -+ else -+ { ++ } else + odm_DIG(pDM_Odm); -+ } + + { -+ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ + odm_Adaptivity(pDM_Odm, pDM_DigTable->CurIGValue); + } + odm_CCKPacketDetectionThresh(pDM_Odm); + -+ if (*(pDM_Odm->pbPowerSaving) ==true) ++ if (*(pDM_Odm->pbPowerSaving) == true) + return; + + @@ -56955,283 +55484,267 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* */ +/* Init /.. Fixed HW value. Only init time. */ +/* */ -+void -+ODM_CmnInfoInit( -+ PDM_ODM_T pDM_Odm, -+ ODM_CMNINFO_E CmnInfo, -+ u32 Value -+ ) ++void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value) +{ + /* */ + /* This section is used for init value */ + /* */ -+ switch (CmnInfo) -+ { -+ /* */ -+ /* Fixed ODM value. */ -+ /* */ -+ case ODM_CMNINFO_ABILITY: -+ pDM_Odm->SupportAbility = (u32)Value; -+ break; ++ switch (CmnInfo) { ++ /* */ ++ /* Fixed ODM value. */ ++ /* */ ++ case ODM_CMNINFO_ABILITY: ++ pDM_Odm->SupportAbility = (u32)Value; ++ break; + -+ case ODM_CMNINFO_RF_TYPE: -+ pDM_Odm->RFType = (u8)Value; -+ break; ++ case ODM_CMNINFO_RF_TYPE: ++ pDM_Odm->RFType = (u8)Value; ++ break; + -+ case ODM_CMNINFO_PLATFORM: -+ pDM_Odm->SupportPlatform = (u8)Value; -+ break; ++ case ODM_CMNINFO_PLATFORM: ++ pDM_Odm->SupportPlatform = (u8)Value; ++ break; + -+ case ODM_CMNINFO_INTERFACE: -+ pDM_Odm->SupportInterface = (u8)Value; -+ break; ++ case ODM_CMNINFO_INTERFACE: ++ pDM_Odm->SupportInterface = (u8)Value; ++ break; + -+ case ODM_CMNINFO_MP_TEST_CHIP: -+ pDM_Odm->bIsMPChip = (u8)Value; -+ break; ++ case ODM_CMNINFO_MP_TEST_CHIP: ++ pDM_Odm->bIsMPChip = (u8)Value; ++ break; + -+ case ODM_CMNINFO_IC_TYPE: -+ pDM_Odm->SupportICType = Value; -+ break; ++ case ODM_CMNINFO_IC_TYPE: ++ pDM_Odm->SupportICType = Value; ++ break; + -+ case ODM_CMNINFO_CUT_VER: -+ pDM_Odm->CutVersion = (u8)Value; -+ break; ++ case ODM_CMNINFO_CUT_VER: ++ pDM_Odm->CutVersion = (u8)Value; ++ break; + -+ case ODM_CMNINFO_FAB_VER: -+ pDM_Odm->FabVersion = (u8)Value; -+ break; ++ case ODM_CMNINFO_FAB_VER: ++ pDM_Odm->FabVersion = (u8)Value; ++ break; + -+ case ODM_CMNINFO_RFE_TYPE: -+ pDM_Odm->RFEType = (u8)Value; -+ break; ++ case ODM_CMNINFO_RFE_TYPE: ++ pDM_Odm->RFEType = (u8)Value; ++ break; + -+ case ODM_CMNINFO_RF_ANTENNA_TYPE: -+ pDM_Odm->AntDivType = (u8)Value; -+ break; ++ case ODM_CMNINFO_RF_ANTENNA_TYPE: ++ pDM_Odm->AntDivType = (u8)Value; ++ break; + -+ case ODM_CMNINFO_BOARD_TYPE: -+ pDM_Odm->BoardType = (u8)Value; -+ break; ++ case ODM_CMNINFO_BOARD_TYPE: ++ pDM_Odm->BoardType = (u8)Value; ++ break; + -+ case ODM_CMNINFO_PACKAGE_TYPE: -+ pDM_Odm->PackageType = (u8)Value; -+ break; ++ case ODM_CMNINFO_PACKAGE_TYPE: ++ pDM_Odm->PackageType = (u8)Value; ++ break; + -+ case ODM_CMNINFO_EXT_LNA: -+ pDM_Odm->ExtLNA = (u8)Value; -+ break; ++ case ODM_CMNINFO_EXT_LNA: ++ pDM_Odm->ExtLNA = (u8)Value; ++ break; + -+ case ODM_CMNINFO_5G_EXT_LNA: -+ pDM_Odm->ExtLNA5G = (u8)Value; -+ break; ++ case ODM_CMNINFO_5G_EXT_LNA: ++ pDM_Odm->ExtLNA5G = (u8)Value; ++ break; + -+ case ODM_CMNINFO_EXT_PA: -+ pDM_Odm->ExtPA = (u8)Value; -+ break; ++ case ODM_CMNINFO_EXT_PA: ++ pDM_Odm->ExtPA = (u8)Value; ++ break; + -+ case ODM_CMNINFO_5G_EXT_PA: -+ pDM_Odm->ExtPA5G = (u8)Value; -+ break; ++ case ODM_CMNINFO_5G_EXT_PA: ++ pDM_Odm->ExtPA5G = (u8)Value; ++ break; + -+ case ODM_CMNINFO_GPA: -+ pDM_Odm->TypeGPA = (ODM_TYPE_GPA_E)Value; -+ break; -+ case ODM_CMNINFO_APA: -+ pDM_Odm->TypeAPA = (ODM_TYPE_APA_E)Value; -+ break; -+ case ODM_CMNINFO_GLNA: -+ pDM_Odm->TypeGLNA = (ODM_TYPE_GLNA_E)Value; -+ break; -+ case ODM_CMNINFO_ALNA: -+ pDM_Odm->TypeALNA = (ODM_TYPE_ALNA_E)Value; -+ break; ++ case ODM_CMNINFO_GPA: ++ pDM_Odm->TypeGPA = (ODM_TYPE_GPA_E)Value; ++ break; ++ case ODM_CMNINFO_APA: ++ pDM_Odm->TypeAPA = (ODM_TYPE_APA_E)Value; ++ break; ++ case ODM_CMNINFO_GLNA: ++ pDM_Odm->TypeGLNA = (ODM_TYPE_GLNA_E)Value; ++ break; ++ case ODM_CMNINFO_ALNA: ++ pDM_Odm->TypeALNA = (ODM_TYPE_ALNA_E)Value; ++ break; + -+ case ODM_CMNINFO_EXT_TRSW: -+ pDM_Odm->ExtTRSW = (u8)Value; -+ break; -+ case ODM_CMNINFO_PATCH_ID: -+ pDM_Odm->PatchID = (u8)Value; -+ break; -+ case ODM_CMNINFO_BINHCT_TEST: -+ pDM_Odm->bInHctTest = (bool)Value; -+ break; -+ case ODM_CMNINFO_BWIFI_TEST: -+ pDM_Odm->bWIFITest = (bool)Value; -+ break; ++ case ODM_CMNINFO_EXT_TRSW: ++ pDM_Odm->ExtTRSW = (u8)Value; ++ break; ++ case ODM_CMNINFO_PATCH_ID: ++ pDM_Odm->PatchID = (u8)Value; ++ break; ++ case ODM_CMNINFO_BINHCT_TEST: ++ pDM_Odm->bInHctTest = (bool)Value; ++ break; ++ case ODM_CMNINFO_BWIFI_TEST: ++ pDM_Odm->bWIFITest = (bool)Value; ++ break; + -+ case ODM_CMNINFO_SMART_CONCURRENT: -+ pDM_Odm->bDualMacSmartConcurrent = (bool)Value; -+ break; -+ -+ /* To remove the compiler warning, must add an empty default statement to handle the other values. */ -+ default: -+ /* do nothing */ -+ break; ++ case ODM_CMNINFO_SMART_CONCURRENT: ++ pDM_Odm->bDualMacSmartConcurrent = (bool)Value; ++ break; + ++ /* To remove the compiler warning, must add an empty default statement to handle the other values. */ ++ default: ++ /* do nothing */ ++ break; + } + +} + + -+void -+ODM_CmnInfoHook( -+ PDM_ODM_T pDM_Odm, -+ ODM_CMNINFO_E CmnInfo, -+ void * pValue -+ ) ++void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue) +{ + /* */ + /* Hook call by reference pointer. */ + /* */ -+ switch (CmnInfo) -+ { -+ /* */ -+ /* Dynamic call by reference pointer. */ -+ /* */ -+ case ODM_CMNINFO_MAC_PHY_MODE: -+ pDM_Odm->pMacPhyMode = (u8 *)pValue; -+ break; ++ switch (CmnInfo) { ++ /* */ ++ /* Dynamic call by reference pointer. */ ++ /* */ ++ case ODM_CMNINFO_MAC_PHY_MODE: ++ pDM_Odm->pMacPhyMode = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_TX_UNI: -+ pDM_Odm->pNumTxBytesUnicast = (u64 *)pValue; -+ break; ++ case ODM_CMNINFO_TX_UNI: ++ pDM_Odm->pNumTxBytesUnicast = (u64 *)pValue; ++ break; + -+ case ODM_CMNINFO_RX_UNI: -+ pDM_Odm->pNumRxBytesUnicast = (u64 *)pValue; -+ break; ++ case ODM_CMNINFO_RX_UNI: ++ pDM_Odm->pNumRxBytesUnicast = (u64 *)pValue; ++ break; + -+ case ODM_CMNINFO_WM_MODE: -+ pDM_Odm->pwirelessmode = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_WM_MODE: ++ pDM_Odm->pwirelessmode = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_BAND: -+ pDM_Odm->pBandType = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_BAND: ++ pDM_Odm->pBandType = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_SEC_CHNL_OFFSET: -+ pDM_Odm->pSecChOffset = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_SEC_CHNL_OFFSET: ++ pDM_Odm->pSecChOffset = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_SEC_MODE: -+ pDM_Odm->pSecurity = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_SEC_MODE: ++ pDM_Odm->pSecurity = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_BW: -+ pDM_Odm->pBandWidth = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_BW: ++ pDM_Odm->pBandWidth = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_CHNL: -+ pDM_Odm->pChannel = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_CHNL: ++ pDM_Odm->pChannel = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_DMSP_GET_VALUE: -+ pDM_Odm->pbGetValueFromOtherMac = (bool *)pValue; -+ break; ++ case ODM_CMNINFO_DMSP_GET_VALUE: ++ pDM_Odm->pbGetValueFromOtherMac = (bool *)pValue; ++ break; + -+ case ODM_CMNINFO_BUDDY_ADAPTOR: -+ pDM_Odm->pBuddyAdapter = (struct adapter * *)pValue; -+ break; ++ case ODM_CMNINFO_BUDDY_ADAPTOR: ++ pDM_Odm->pBuddyAdapter = (struct adapter **)pValue; ++ break; + -+ case ODM_CMNINFO_DMSP_IS_MASTER: -+ pDM_Odm->pbMasterOfDMSP = (bool *)pValue; -+ break; ++ case ODM_CMNINFO_DMSP_IS_MASTER: ++ pDM_Odm->pbMasterOfDMSP = (bool *)pValue; ++ break; + -+ case ODM_CMNINFO_SCAN: -+ pDM_Odm->pbScanInProcess = (bool *)pValue; -+ break; ++ case ODM_CMNINFO_SCAN: ++ pDM_Odm->pbScanInProcess = (bool *)pValue; ++ break; + -+ case ODM_CMNINFO_POWER_SAVING: -+ pDM_Odm->pbPowerSaving = (bool *)pValue; -+ break; ++ case ODM_CMNINFO_POWER_SAVING: ++ pDM_Odm->pbPowerSaving = (bool *)pValue; ++ break; + -+ case ODM_CMNINFO_ONE_PATH_CCA: -+ pDM_Odm->pOnePathCCA = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_ONE_PATH_CCA: ++ pDM_Odm->pOnePathCCA = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_DRV_STOP: -+ pDM_Odm->pbDriverStopped = (bool *)pValue; -+ break; ++ case ODM_CMNINFO_DRV_STOP: ++ pDM_Odm->pbDriverStopped = (bool *)pValue; ++ break; + -+ case ODM_CMNINFO_PNP_IN: -+ pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep = (bool *)pValue; -+ break; ++ case ODM_CMNINFO_PNP_IN: ++ pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep = (bool *)pValue; ++ break; + -+ case ODM_CMNINFO_INIT_ON: -+ pDM_Odm->pinit_adpt_in_progress = (bool *)pValue; -+ break; ++ case ODM_CMNINFO_INIT_ON: ++ pDM_Odm->pinit_adpt_in_progress = (bool *)pValue; ++ break; + -+ case ODM_CMNINFO_ANT_TEST: -+ pDM_Odm->pAntennaTest = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_ANT_TEST: ++ pDM_Odm->pAntennaTest = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_NET_CLOSED: -+ pDM_Odm->pbNet_closed = (bool *)pValue; -+ break; ++ case ODM_CMNINFO_NET_CLOSED: ++ pDM_Odm->pbNet_closed = (bool *)pValue; ++ break; + -+ case ODM_CMNINFO_FORCED_RATE: -+ pDM_Odm->pForcedDataRate = (u16 *)pValue; -+ break; ++ case ODM_CMNINFO_FORCED_RATE: ++ pDM_Odm->pForcedDataRate = (u16 *)pValue; ++ break; + -+ case ODM_CMNINFO_FORCED_IGI_LB: -+ pDM_Odm->pu1ForcedIgiLb = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_FORCED_IGI_LB: ++ pDM_Odm->pu1ForcedIgiLb = (u8 *)pValue; ++ break; + -+ case ODM_CMNINFO_MP_MODE: -+ pDM_Odm->mp_mode = (u8 *)pValue; -+ break; ++ case ODM_CMNINFO_MP_MODE: ++ pDM_Odm->mp_mode = (u8 *)pValue; ++ break; + -+ /* case ODM_CMNINFO_RTSTA_AID: */ -+ /* pDM_Odm->pAidMap = (u8 *)pValue; */ -+ /* break; */ ++ /* case ODM_CMNINFO_RTSTA_AID: */ ++ /* pDM_Odm->pAidMap = (u8 *)pValue; */ ++ /* break; */ + -+ /* case ODM_CMNINFO_BT_COEXIST: */ -+ /* pDM_Odm->BTCoexist = (bool *)pValue; */ ++ /* case ODM_CMNINFO_BT_COEXIST: */ ++ /* pDM_Odm->BTCoexist = (bool *)pValue; */ + -+ /* case ODM_CMNINFO_STA_STATUS: */ -+ /* pDM_Odm->pODM_StaInfo[] = (PSTA_INFO_T)pValue; */ -+ /* break; */ ++ /* case ODM_CMNINFO_STA_STATUS: */ ++ /* pDM_Odm->pODM_StaInfo[] = (PSTA_INFO_T)pValue; */ ++ /* break; */ + -+ /* case ODM_CMNINFO_PHY_STATUS: */ -+ /* pDM_Odm->pPhyInfo = (ODM_PHY_INFO *)pValue; */ -+ /* break; */ -+ -+ /* case ODM_CMNINFO_MAC_STATUS: */ -+ /* pDM_Odm->pMacInfo = (ODM_MAC_INFO *)pValue; */ -+ /* break; */ -+ /* To remove the compiler warning, must add an empty default statement to handle the other values. */ -+ default: -+ /* do nothing */ -+ break; ++ /* case ODM_CMNINFO_PHY_STATUS: */ ++ /* pDM_Odm->pPhyInfo = (ODM_PHY_INFO *)pValue; */ ++ /* break; */ + ++ /* case ODM_CMNINFO_MAC_STATUS: */ ++ /* pDM_Odm->pMacInfo = (ODM_MAC_INFO *)pValue; */ ++ /* break; */ ++ /* To remove the compiler warning, must add an empty default statement to handle the other values. */ ++ default: ++ /* do nothing */ ++ break; + } + +} + + -+void -+ODM_CmnInfoPtrArrayHook( -+ PDM_ODM_T pDM_Odm, -+ ODM_CMNINFO_E CmnInfo, -+ u16 Index, -+ void * pValue -+ ) ++void ODM_CmnInfoPtrArrayHook( ++ PDM_ODM_T pDM_Odm, ++ ODM_CMNINFO_E CmnInfo, ++ u16 Index, ++ void *pValue ++) +{ + /* */ + /* Hook call by reference pointer. */ + /* */ -+ switch (CmnInfo) -+ { -+ /* */ -+ /* Dynamic call by reference pointer. */ -+ /* */ -+ case ODM_CMNINFO_STA_STATUS: -+ pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue; -+ break; -+ /* To remove the compiler warning, must add an empty default statement to handle the other values. */ -+ default: -+ /* do nothing */ -+ break; ++ switch (CmnInfo) { ++ /* */ ++ /* Dynamic call by reference pointer. */ ++ /* */ ++ case ODM_CMNINFO_STA_STATUS: ++ pDM_Odm->pODM_StaInfo[Index] = (PSTA_INFO_T)pValue; ++ break; ++ /* To remove the compiler warning, must add an empty default statement to handle the other values. */ ++ default: ++ /* do nothing */ ++ break; + } + +} @@ -57240,130 +55753,121 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* */ +/* Update Band/CHannel/.. The values are dynamic but non-per-packet. */ +/* */ -+void -+ODM_CmnInfoUpdate( -+ PDM_ODM_T pDM_Odm, -+ u32 CmnInfo, -+ u64 Value -+ ) ++void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value) +{ + /* */ + /* This init variable may be changed in run time. */ + /* */ -+ switch (CmnInfo) -+ { -+ case ODM_CMNINFO_LINK_IN_PROGRESS: -+ pDM_Odm->bLinkInProcess = (bool)Value; -+ break; ++ switch (CmnInfo) { ++ case ODM_CMNINFO_LINK_IN_PROGRESS: ++ pDM_Odm->bLinkInProcess = (bool)Value; ++ break; + -+ case ODM_CMNINFO_ABILITY: -+ pDM_Odm->SupportAbility = (u32)Value; -+ break; ++ case ODM_CMNINFO_ABILITY: ++ pDM_Odm->SupportAbility = (u32)Value; ++ break; + -+ case ODM_CMNINFO_RF_TYPE: -+ pDM_Odm->RFType = (u8)Value; -+ break; ++ case ODM_CMNINFO_RF_TYPE: ++ pDM_Odm->RFType = (u8)Value; ++ break; + -+ case ODM_CMNINFO_WIFI_DIRECT: -+ pDM_Odm->bWIFI_Direct = (bool)Value; -+ break; ++ case ODM_CMNINFO_WIFI_DIRECT: ++ pDM_Odm->bWIFI_Direct = (bool)Value; ++ break; + -+ case ODM_CMNINFO_WIFI_DISPLAY: -+ pDM_Odm->bWIFI_Display = (bool)Value; -+ break; ++ case ODM_CMNINFO_WIFI_DISPLAY: ++ pDM_Odm->bWIFI_Display = (bool)Value; ++ break; + -+ case ODM_CMNINFO_LINK: -+ pDM_Odm->bLinked = (bool)Value; -+ break; ++ case ODM_CMNINFO_LINK: ++ pDM_Odm->bLinked = (bool)Value; ++ break; + -+ case ODM_CMNINFO_STATION_STATE: -+ pDM_Odm->bsta_state = (bool)Value; -+ break; ++ case ODM_CMNINFO_STATION_STATE: ++ pDM_Odm->bsta_state = (bool)Value; ++ break; + -+ case ODM_CMNINFO_RSSI_MIN: -+ pDM_Odm->RSSI_Min = (u8)Value; -+ break; ++ case ODM_CMNINFO_RSSI_MIN: ++ pDM_Odm->RSSI_Min = (u8)Value; ++ break; + -+ case ODM_CMNINFO_DBG_COMP: -+ pDM_Odm->DebugComponents = Value; -+ break; ++ case ODM_CMNINFO_DBG_COMP: ++ pDM_Odm->DebugComponents = Value; ++ break; + -+ case ODM_CMNINFO_DBG_LEVEL: -+ pDM_Odm->DebugLevel = (u32)Value; -+ break; -+ case ODM_CMNINFO_RA_THRESHOLD_HIGH: -+ pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value; -+ break; ++ case ODM_CMNINFO_DBG_LEVEL: ++ pDM_Odm->DebugLevel = (u32)Value; ++ break; ++ case ODM_CMNINFO_RA_THRESHOLD_HIGH: ++ pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value; ++ break; + -+ case ODM_CMNINFO_RA_THRESHOLD_LOW: -+ pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value; -+ break; -+ /* The following is for BT HS mode and BT coexist mechanism. */ -+ case ODM_CMNINFO_BT_ENABLED: -+ pDM_Odm->bBtEnabled = (bool)Value; -+ break; ++ case ODM_CMNINFO_RA_THRESHOLD_LOW: ++ pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value; ++ break; ++ /* The following is for BT HS mode and BT coexist mechanism. */ ++ case ODM_CMNINFO_BT_ENABLED: ++ pDM_Odm->bBtEnabled = (bool)Value; ++ break; + -+ case ODM_CMNINFO_BT_HS_CONNECT_PROCESS: -+ pDM_Odm->bBtConnectProcess = (bool)Value; -+ break; ++ case ODM_CMNINFO_BT_HS_CONNECT_PROCESS: ++ pDM_Odm->bBtConnectProcess = (bool)Value; ++ break; + -+ case ODM_CMNINFO_BT_HS_RSSI: -+ pDM_Odm->btHsRssi = (u8)Value; -+ break; ++ case ODM_CMNINFO_BT_HS_RSSI: ++ pDM_Odm->btHsRssi = (u8)Value; ++ break; + -+ case ODM_CMNINFO_BT_OPERATION: -+ pDM_Odm->bBtHsOperation = (bool)Value; -+ break; ++ case ODM_CMNINFO_BT_OPERATION: ++ pDM_Odm->bBtHsOperation = (bool)Value; ++ break; + -+ case ODM_CMNINFO_BT_LIMITED_DIG: -+ pDM_Odm->bBtLimitedDig = (bool)Value; -+ break; ++ case ODM_CMNINFO_BT_LIMITED_DIG: ++ pDM_Odm->bBtLimitedDig = (bool)Value; ++ break; + -+ case ODM_CMNINFO_BT_DISABLE_EDCA: -+ pDM_Odm->bBtDisableEdcaTurbo = (bool)Value; -+ break; ++ case ODM_CMNINFO_BT_DISABLE_EDCA: ++ pDM_Odm->bBtDisableEdcaTurbo = (bool)Value; ++ break; + +/* -+ case ODM_CMNINFO_OP_MODE: -+ pDM_Odm->OPMode = (u8)Value; -+ break; ++ case ODM_CMNINFO_OP_MODE: ++ pDM_Odm->OPMode = (u8)Value; ++ break; + -+ case ODM_CMNINFO_WM_MODE: -+ pDM_Odm->WirelessMode = (u8)Value; -+ break; ++ case ODM_CMNINFO_WM_MODE: ++ pDM_Odm->WirelessMode = (u8)Value; ++ break; + -+ case ODM_CMNINFO_BAND: -+ pDM_Odm->BandType = (u8)Value; -+ break; ++ case ODM_CMNINFO_BAND: ++ pDM_Odm->BandType = (u8)Value; ++ break; + -+ case ODM_CMNINFO_SEC_CHNL_OFFSET: -+ pDM_Odm->SecChOffset = (u8)Value; -+ break; ++ case ODM_CMNINFO_SEC_CHNL_OFFSET: ++ pDM_Odm->SecChOffset = (u8)Value; ++ break; + -+ case ODM_CMNINFO_SEC_MODE: -+ pDM_Odm->Security = (u8)Value; -+ break; ++ case ODM_CMNINFO_SEC_MODE: ++ pDM_Odm->Security = (u8)Value; ++ break; + -+ case ODM_CMNINFO_BW: -+ pDM_Odm->BandWidth = (u8)Value; -+ break; ++ case ODM_CMNINFO_BW: ++ pDM_Odm->BandWidth = (u8)Value; ++ break; + -+ case ODM_CMNINFO_CHNL: -+ pDM_Odm->Channel = (u8)Value; -+ break; ++ case ODM_CMNINFO_CHNL: ++ pDM_Odm->Channel = (u8)Value; ++ break; +*/ -+ default: -+ /* do nothing */ -+ break; ++ default: ++ /* do nothing */ ++ break; + } + + +} + -+void -+odm_CommonInfoSelfInit( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_CommonInfoSelfInit(PDM_ODM_T pDM_Odm) +{ + pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm)); + pDM_Odm->RFPathRxEnable = (u8) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_RX_PATH, pDM_Odm), ODM_BIT(BB_RX_PATH, pDM_Odm)); @@ -57373,41 +55877,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + pDM_Odm->TxRate = 0xFF; +} + -+void -+odm_CommonInfoSelfUpdate( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_CommonInfoSelfUpdate(PDM_ODM_T pDM_Odm) +{ + u8 EntryCnt = 0; + u8 i; + PSTA_INFO_T pEntry; + -+ if (*(pDM_Odm->pBandWidth) == ODM_BW40M) -+ { ++ if (*(pDM_Odm->pBandWidth) == ODM_BW40M) { + if (*(pDM_Odm->pSecChOffset) == 1) -+ pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) -2; ++ pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)-2; + else if (*(pDM_Odm->pSecChOffset) == 2) -+ pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) +2; -+ } -+ else ++ pDM_Odm->ControlChannel = *(pDM_Odm->pChannel)+2; ++ } else + pDM_Odm->ControlChannel = *(pDM_Odm->pChannel); + -+ for (i = 0; ipODM_StaInfo[i]; + if (IS_STA_VALID(pEntry)) + EntryCnt++; + } ++ + if (EntryCnt == 1) + pDM_Odm->bOneEntryOnly = true; + else + pDM_Odm->bOneEntryOnly = false; +} + -+void -+odm_CmnInfoInit_Debug( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_CmnInfoInit_Debug(PDM_ODM_T pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug ==>\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform =%d\n", pDM_Odm->SupportPlatform)); @@ -57428,11 +55924,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + +} + -+void -+odm_BasicDbgMessage -+( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_BasicDbgMessage(PDM_ODM_T pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_BasicDbgMsg ==>\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked = %d, RSSI_Min = %d,\n", @@ -57458,7 +55950,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + * Revised History: + *When Who Remark + * -+ *---------------------------------------------------------------------------*/ ++ *--------------------------------------------------------------------------- ++ */ + +/* Remove DIG by yuchen */ + @@ -57478,12 +55971,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* 3 Rate Adaptive */ +/* 3 ============================================================ */ + -+void -+odm_RateAdaptiveMaskInit( -+PDM_ODM_T pDM_Odm -+ ) ++void odm_RateAdaptiveMaskInit(PDM_ODM_T pDM_Odm) +{ -+ PODM_RATE_ADAPTIVE pOdmRA = &pDM_Odm->RateAdaptive; ++ PODM_RATE_ADAPTIVE pOdmRA = &pDM_Odm->RateAdaptive; + + pOdmRA->Type = DM_Type_ByDriver; + if (pOdmRA->Type == DM_Type_ByDriver) @@ -57499,10 +55989,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +} + +u32 ODM_Get_Rate_Bitmap( -+PDM_ODM_T pDM_Odm, -+u32 macid, -+u32 ra_mask, -+u8 rssi_level) ++ PDM_ODM_T pDM_Odm, ++ u32 macid, ++ u32 ra_mask, ++ u8 rssi_level ++) +{ + PSTA_INFO_T pEntry; + u32 rate_bitmap = 0; @@ -57514,113 +56005,94 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + + WirelessMode = pEntry->wireless_mode; + -+ switch (WirelessMode) -+ { -+ case ODM_WM_B: -+ if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */ -+ rate_bitmap = 0x0000000d; -+ else -+ rate_bitmap = 0x0000000f; -+ break; ++ switch (WirelessMode) { ++ case ODM_WM_B: ++ if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */ ++ rate_bitmap = 0x0000000d; ++ else ++ rate_bitmap = 0x0000000f; ++ break; + -+ case (ODM_WM_G): -+ case (ODM_WM_A): -+ if (rssi_level == DM_RATR_STA_HIGH) -+ rate_bitmap = 0x00000f00; -+ else -+ rate_bitmap = 0x00000ff0; -+ break; ++ case (ODM_WM_G): ++ case (ODM_WM_A): ++ if (rssi_level == DM_RATR_STA_HIGH) ++ rate_bitmap = 0x00000f00; ++ else ++ rate_bitmap = 0x00000ff0; ++ break; + -+ case (ODM_WM_B|ODM_WM_G): ++ case (ODM_WM_B|ODM_WM_G): ++ if (rssi_level == DM_RATR_STA_HIGH) ++ rate_bitmap = 0x00000f00; ++ else if (rssi_level == DM_RATR_STA_MIDDLE) ++ rate_bitmap = 0x00000ff0; ++ else ++ rate_bitmap = 0x00000ff5; ++ break; ++ ++ case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G): ++ case (ODM_WM_B|ODM_WM_N24G): ++ case (ODM_WM_G|ODM_WM_N24G): ++ case (ODM_WM_A|ODM_WM_N5G): ++ if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) { + if (rssi_level == DM_RATR_STA_HIGH) -+ rate_bitmap = 0x00000f00; ++ rate_bitmap = 0x000f0000; + else if (rssi_level == DM_RATR_STA_MIDDLE) -+ rate_bitmap = 0x00000ff0; -+ else -+ rate_bitmap = 0x00000ff5; -+ break; -+ -+ case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G) : -+ case (ODM_WM_B|ODM_WM_N24G) : -+ case (ODM_WM_G|ODM_WM_N24G) : -+ case (ODM_WM_A|ODM_WM_N5G) : -+ { -+ if (pDM_Odm->RFType == ODM_1T2R ||pDM_Odm->RFType == ODM_1T1R) -+ { -+ if (rssi_level == DM_RATR_STA_HIGH) -+ { -+ rate_bitmap = 0x000f0000; -+ } -+ else if (rssi_level == DM_RATR_STA_MIDDLE) -+ { -+ rate_bitmap = 0x000ff000; -+ } -+ else { -+ if (*(pDM_Odm->pBandWidth) == ODM_BW40M) -+ rate_bitmap = 0x000ff015; -+ else -+ rate_bitmap = 0x000ff005; -+ } -+ } ++ rate_bitmap = 0x000ff000; ++ else { ++ if (*(pDM_Odm->pBandWidth) == ODM_BW40M) ++ rate_bitmap = 0x000ff015; + else -+ { -+ if (rssi_level == DM_RATR_STA_HIGH) -+ { -+ rate_bitmap = 0x0f8f0000; -+ } -+ else if (rssi_level == DM_RATR_STA_MIDDLE) -+ { -+ rate_bitmap = 0x0f8ff000; -+ } -+ else -+ { -+ if (*(pDM_Odm->pBandWidth) == ODM_BW40M) -+ rate_bitmap = 0x0f8ff015; -+ else -+ rate_bitmap = 0x0f8ff005; -+ } -+ } ++ rate_bitmap = 0x000ff005; + } -+ break; ++ } else { ++ if (rssi_level == DM_RATR_STA_HIGH) ++ rate_bitmap = 0x0f8f0000; ++ else if (rssi_level == DM_RATR_STA_MIDDLE) ++ rate_bitmap = 0x0f8ff000; ++ else { ++ if (*(pDM_Odm->pBandWidth) == ODM_BW40M) ++ rate_bitmap = 0x0f8ff015; ++ else ++ rate_bitmap = 0x0f8ff005; ++ } ++ } ++ break; + -+ case (ODM_WM_AC|ODM_WM_G): -+ if (rssi_level == 1) -+ rate_bitmap = 0xfc3f0000; ++ case (ODM_WM_AC|ODM_WM_G): ++ if (rssi_level == 1) ++ rate_bitmap = 0xfc3f0000; ++ else if (rssi_level == 2) ++ rate_bitmap = 0xfffff000; ++ else ++ rate_bitmap = 0xffffffff; ++ break; ++ ++ case (ODM_WM_AC|ODM_WM_A): ++ ++ if (pDM_Odm->RFType == RF_1T1R) { ++ if (rssi_level == 1) /* add by Gary for ac-series */ ++ rate_bitmap = 0x003f8000; + else if (rssi_level == 2) -+ rate_bitmap = 0xfffff000; ++ rate_bitmap = 0x003ff000; + else -+ rate_bitmap = 0xffffffff; -+ break; -+ -+ case (ODM_WM_AC|ODM_WM_A): -+ -+ if (pDM_Odm->RFType == RF_1T1R) -+ { -+ if (rssi_level == 1) /* add by Gary for ac-series */ -+ rate_bitmap = 0x003f8000; -+ else if (rssi_level == 2) -+ rate_bitmap = 0x003ff000; -+ else -+ rate_bitmap = 0x003ff010; -+ } ++ rate_bitmap = 0x003ff010; ++ } else { ++ if (rssi_level == 1) /* add by Gary for ac-series */ ++ rate_bitmap = 0xfe3f8000; /* VHT 2SS MCS3~9 */ ++ else if (rssi_level == 2) ++ rate_bitmap = 0xfffff000; /* VHT 2SS MCS0~9 */ + else -+ { -+ if (rssi_level == 1) /* add by Gary for ac-series */ -+ rate_bitmap = 0xfe3f8000; /* VHT 2SS MCS3~9 */ -+ else if (rssi_level == 2) -+ rate_bitmap = 0xfffff000; /* VHT 2SS MCS0~9 */ -+ else -+ rate_bitmap = 0xfffff010; /* All */ -+ } -+ break; -+ -+ default: -+ if (pDM_Odm->RFType == RF_1T2R) -+ rate_bitmap = 0x000fffff; -+ else -+ rate_bitmap = 0x0fffffff; -+ break; ++ rate_bitmap = 0xfffff010; /* All */ ++ } ++ break; + ++ default: ++ if (pDM_Odm->RFType == RF_1T2R) ++ rate_bitmap = 0x000fffff; ++ else ++ rate_bitmap = 0x0fffffff; ++ break; + } + + /* printk("%s ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", __func__, rssi_level, WirelessMode, rate_bitmap); */ @@ -57631,68 +56103,60 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +} + +/*----------------------------------------------------------------------------- -+ * Function: odm_RefreshRateAdaptiveMask() -+ * -+ * Overview: Update rate table mask according to rssi -+ * -+ * Input: NONE -+ * -+ * Output: NONE -+ * -+ * Return: NONE -+ * -+ * Revised History: -+ *When Who Remark -+ *05/27/2009 hpfan Create Version 0. -+ * -+ *---------------------------------------------------------------------------*/ -+void -+odm_RefreshRateAdaptiveMask( -+ PDM_ODM_T pDM_Odm -+ ) ++* Function: odm_RefreshRateAdaptiveMask() ++* ++* Overview: Update rate table mask according to rssi ++* ++* Input: NONE ++* ++* Output: NONE ++* ++* Return: NONE ++* ++* Revised History: ++*When Who Remark ++*05/27/2009 hpfan Create Version 0. ++* ++* -------------------------------------------------------------------------- ++*/ ++void odm_RefreshRateAdaptiveMask(PDM_ODM_T pDM_Odm) +{ + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask()---------->\n")); -+ if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) -+ { ++ if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("odm_RefreshRateAdaptiveMask(): Return cos not supported\n")); + return; + } + odm_RefreshRateAdaptiveMaskCE(pDM_Odm); +} + -+void -+odm_RefreshRateAdaptiveMaskCE( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_RefreshRateAdaptiveMaskCE(PDM_ODM_T pDM_Odm) +{ + u8 i; -+ struct adapter *padapter = pDM_Odm->Adapter; ++ struct adapter *padapter = pDM_Odm->Adapter; + -+ if (padapter->bDriverStopped) -+ { ++ if (padapter->bDriverStopped) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n")); + return; + } + -+ if (!pDM_Odm->bUseRAMask) -+ { ++ if (!pDM_Odm->bUseRAMask) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n")); + return; + } + + /* printk("==> %s\n", __func__); */ + -+ for (i = 0; ipODM_StaInfo[i]; ++ + if (IS_STA_VALID(pstat)) { + if (IS_MCAST(pstat->hwaddr)) /* if (psta->mac_id == 1) */ -+ continue; ++ continue; + if (IS_MCAST(pstat->hwaddr)) + continue; + -+ if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false , &pstat->rssi_level)) -+ { ++ if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level)); + /* printk("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level); */ + rtw_hal_update_ra_mask(pstat, pstat->rssi_level); @@ -57704,13 +56168,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + +/* Return Value: bool */ +/* - true: RATRState is changed. */ -+bool -+ODM_RAStateCheck( -+ PDM_ODM_T pDM_Odm, -+ s32 RSSI, -+ bool bForceUpdate, -+ u8 * pRATRState -+ ) ++bool ODM_RAStateCheck( ++ PDM_ODM_T pDM_Odm, ++ s32 RSSI, ++ bool bForceUpdate, ++ u8 *pRATRState ++) +{ + PODM_RATE_ADAPTIVE pRA = &pDM_Odm->RateAdaptive; + const u8 GoUpGap = 5; @@ -57721,24 +56184,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + /* Threshold Adjustment: */ + /* when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */ + /* Here GoUpGap is added to solve the boundary's level alternation issue. */ -+ switch (*pRATRState) -+ { -+ case DM_RATR_STA_INIT: -+ case DM_RATR_STA_HIGH: -+ break; ++ switch (*pRATRState) { ++ case DM_RATR_STA_INIT: ++ case DM_RATR_STA_HIGH: ++ break; + -+ case DM_RATR_STA_MIDDLE: -+ HighRSSIThreshForRA += GoUpGap; -+ break; ++ case DM_RATR_STA_MIDDLE: ++ HighRSSIThreshForRA += GoUpGap; ++ break; + -+ case DM_RATR_STA_LOW: -+ HighRSSIThreshForRA += GoUpGap; -+ LowRSSIThreshForRA += GoUpGap; -+ break; ++ case DM_RATR_STA_LOW: ++ HighRSSIThreshForRA += GoUpGap; ++ LowRSSIThreshForRA += GoUpGap; ++ break; + -+ default: -+ ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState)); -+ break; ++ default: ++ ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState)); ++ break; + } + + /* Decide RATRState by RSSI. */ @@ -57750,8 +56212,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + RATRState = DM_RATR_STA_LOW; + /* printk("==>%s, RATRState:0x%02x , RSSI:%d\n", __func__, RATRState, RSSI); */ + -+ if (*pRATRState!=RATRState || bForceUpdate) -+ { ++ if (*pRATRState != RATRState || bForceUpdate) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState)); + *pRATRState = RATRState; + return true; @@ -57773,21 +56234,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* 3 RSSI Monitor */ +/* 3 ============================================================ */ + -+void -+odm_RSSIMonitorInit( -+PDM_ODM_T pDM_Odm -+ ) ++void odm_RSSIMonitorInit(PDM_ODM_T pDM_Odm) +{ -+ pRA_T pRA_Table = &pDM_Odm->DM_RA_Table; ++ pRA_T pRA_Table = &pDM_Odm->DM_RA_Table; + + pRA_Table->firstconnect = false; + +} + -+void -+odm_RSSIMonitorCheck( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_RSSIMonitorCheck(PDM_ODM_T pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR)) + return; @@ -57800,39 +56255,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; -+ PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); ++ PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); + + /* 1 1.Determine the minimum RSSI */ + -+ if ((pDM_Odm->bLinked != true) && -+ (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)) -+ { ++ if ( ++ (pDM_Odm->bLinked != true) && ++ (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0) ++ ) { + pdmpriv->MinUndecoratedPWDBForDM = 0; + /* ODM_RT_TRACE(pDM_Odm, COMP_BB_POWERSAVING, DBG_LOUD, ("Not connected to any\n")); */ -+ } -+ else -+ { ++ } else + pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; -+ } + + /* DBG_8192C("%s =>MinUndecoratedPWDBForDM(%d)\n", __func__, pdmpriv->MinUndecoratedPWDBForDM); */ + /* ODM_RT_TRACE(pDM_Odm, COMP_DIG, DBG_LOUD, ("MinUndecoratedPWDBForDM =%d\n", pHalData->MinUndecoratedPWDBForDM)); */ +} + -+void -+odm_RSSIMonitorCheckCE( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_RSSIMonitorCheckCE(PDM_ODM_T pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; -+ int i; -+ int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff; ++ int i; ++ int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff; + u8 sta_cnt = 0; -+ u32 PWDB_rssi[NUM_STA]={0};/* 0~15]:MACID, [16~31]:PWDB_rssi */ -+ bool FirstConnect = false; -+ pRA_T pRA_Table = &pDM_Odm->DM_RA_Table; ++ u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */ ++ bool FirstConnect = false; ++ pRA_T pRA_Table = &pDM_Odm->DM_RA_Table; + + if (pDM_Odm->bLinked != true) + return; @@ -57844,36 +56294,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + { + struct sta_info *psta; + -+ for (i = 0; ipODM_StaInfo[i])) -+ { -+ if (IS_MCAST(psta->hwaddr)) /* if (psta->mac_id == 1) */ -+ continue; ++ for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { ++ psta = pDM_Odm->pODM_StaInfo[i]; ++ if (IS_STA_VALID(psta)) { ++ if (IS_MCAST(psta->hwaddr)) /* if (psta->mac_id == 1) */ ++ continue; + -+ if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1)) -+ continue; ++ if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1)) ++ continue; + -+ if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) -+ tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; ++ if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) ++ tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; + -+ if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB) -+ tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; ++ if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB) ++ tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; + -+ if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)) { -+ PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16)); -+ } ++ if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)) ++ PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16)); + } + } + + /* printk("%s ==> sta_cnt(%d)\n", __func__, sta_cnt); */ + -+ for (i = 0; i< sta_cnt; i++) -+ { ++ for (i = 0; i < sta_cnt; i++) { + if (PWDB_rssi[i] != (0)) { + if (pHalData->fw_ractrl == true)/* Report every sta's RSSI to FW */ -+ { + rtl8723b_set_rssi_cmd(Adapter, (u8 *)(&PWDB_rssi[i])); -+ } + } + } + } @@ -57881,22 +56327,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + + + if (tmpEntryMaxPWDB != 0) /* If associated entry is found */ -+ { + pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB; -+ } + else -+ { + pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0; -+ } + + if (tmpEntryMinPWDB != 0xff) /* If associated entry is found */ -+ { + pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB; -+ } + else -+ { + pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0; -+ } + + FindMinimumRSSI(Adapter);/* get pdmpriv->MinUndecoratedPWDBForDM */ + @@ -57908,24 +56346,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* 3 Tx Power Tracking */ +/* 3 ============================================================ */ + -+void -+odm_TXPowerTrackingInit( -+PDM_ODM_T pDM_Odm -+ ) ++void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm) +{ + odm_TXPowerTrackingThermalMeterInit(pDM_Odm); +} + -+static u8 -+getSwingIndex( -+PDM_ODM_T pDM_Odm -+ ) ++static u8 getSwingIndex(PDM_ODM_T pDM_Odm) +{ -+ struct adapter * Adapter = pDM_Odm->Adapter; -+ u8 i = 0; -+ u32 bbSwing; -+ u32 swingTableSize; -+ u32 * pSwingTable; ++ struct adapter *Adapter = pDM_Odm->Adapter; ++ u8 i = 0; ++ u32 bbSwing; ++ u32 swingTableSize; ++ u32 *pSwingTable; + + bbSwing = PHY_QueryBBReg(Adapter, rOFDM0_XATxIQImbalance, 0xFFC00000); + @@ -57943,15 +56375,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + return i; +} + -+void -+odm_TXPowerTrackingThermalMeterInit( -+PDM_ODM_T pDM_Odm -+ ) ++void odm_TXPowerTrackingThermalMeterInit(PDM_ODM_T pDM_Odm) +{ + u8 defaultSwingIndex = getSwingIndex(pDM_Odm); -+ u8 p = 0; -+ struct adapter * Adapter = pDM_Odm->Adapter; -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ u8 p = 0; ++ struct adapter *Adapter = pDM_Odm->Adapter; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + + struct dm_priv *pdmpriv = &pHalData->dmpriv; @@ -57980,8 +56409,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r + pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex; + pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex; + -+ for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) -+ { ++ for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) { + pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex; + pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex; + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0; @@ -57992,37 +56420,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +} + + -+void -+ODM_TXPowerTrackingCheck( -+ PDM_ODM_T pDM_Odm -+ ) ++void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm) +{ + odm_TXPowerTrackingCheckCE(pDM_Odm); +} + -+void -+odm_TXPowerTrackingCheckCE( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_TXPowerTrackingCheckCE(PDM_ODM_T pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + + if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK)) -+ { + return; -+ } + -+ if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) /* at least delay 1 sec */ -+ { ++ if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */ + PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03); + + /* DBG_871X("Trigger Thermal Meter!!\n"); */ + + pDM_Odm->RFCalibrateInfo.TM_Trigger = 1; + return; -+ } -+ else -+ { ++ } else { + /* DBG_871X("Schedule TxPowerTracking direct call!!\n"); */ + ODM_TXPowerTrackingCallback_ThermalMeter(Adapter); + pDM_Odm->RFCalibrateInfo.TM_Trigger = 0; @@ -58032,21 +56449,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.c linux-4.3-rtl8723bs/3rdparty/r +/* 3 ============================================================ */ +/* 3 SW Antenna Diversity */ +/* 3 ============================================================ */ -+void -+odm_SwAntDetectInit( -+ PDM_ODM_T pDM_Odm -+ ) ++void odm_SwAntDetectInit(PDM_ODM_T pDM_Odm) +{ -+ pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; ++ pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; ++ + pDM_SWAT_Table->SWAS_NoLink_BK_Reg92c = rtw_read32(pDM_Odm->Adapter, rDPDT_control); + pDM_SWAT_Table->PreAntenna = MAIN_ANT; + pDM_SWAT_Table->CurAntenna = MAIN_ANT; + pDM_SWAT_Table->SWAS_NoLink_State = 0; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_CfoTracking.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_CfoTracking.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,275 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux/3rdparty/rtl8723bs/hal/odm_CfoTracking.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_CfoTracking.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_CfoTracking.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,338 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -58064,19 +56479,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux-4.3-rtl8723b + +#include "odm_precomp.h" + -+static void -+odm_SetCrystalCap( -+ void * pDM_VOID, -+ u8 CrystalCap -+) ++static void odm_SetCrystalCap(void *pDM_VOID, u8 CrystalCap) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; -+ bool bEEPROMCheck; -+ struct adapter * Adapter = pDM_Odm->Adapter; -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; ++ bool bEEPROMCheck; ++ struct adapter *Adapter = pDM_Odm->Adapter; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + -+ bEEPROMCheck = (pHalData->EEPROMVersion >= 0x01)?true:false; ++ bEEPROMCheck = (pHalData->EEPROMVersion >= 0x01) ? true : false; + + if (pCfoTrack->CrystalCap == CrystalCap) + return; @@ -58085,21 +56496,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux-4.3-rtl8723b + + /* 0x2C[23:18] = 0x2C[17:12] = CrystalCap */ + CrystalCap = CrystalCap & 0x3F; -+ PHY_SetBBReg(pDM_Odm->Adapter, REG_MAC_PHY_CTRL, 0x00FFF000, (CrystalCap | (CrystalCap << 6))); ++ PHY_SetBBReg( ++ pDM_Odm->Adapter, ++ REG_MAC_PHY_CTRL, ++ 0x00FFF000, ++ (CrystalCap | (CrystalCap << 6)) ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("odm_SetCrystalCap(): CrystalCap = 0x%x\n", CrystalCap)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ( ++ "odm_SetCrystalCap(): CrystalCap = 0x%x\n", ++ CrystalCap ++ ) ++ ); +} + -+static u8 -+odm_GetDefaultCrytaltalCap( -+ void * pDM_VOID -+) ++static u8 odm_GetDefaultCrytaltalCap(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ u8 CrystalCap = 0x20; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ u8 CrystalCap = 0x20; + -+ struct adapter * Adapter = pDM_Odm->Adapter; -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct adapter *Adapter = pDM_Odm->Adapter; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + CrystalCap = pHalData->CrystalCap; + @@ -58108,41 +56529,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux-4.3-rtl8723b + return CrystalCap; +} + -+static void -+odm_SetATCStatus( -+ void * pDM_VOID, -+ bool ATCStatus -+) ++static void odm_SetATCStatus(void *pDM_VOID, bool ATCStatus) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; + + if (pCfoTrack->bATCStatus == ATCStatus) + return; + -+ PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG(BB_ATC, pDM_Odm), ODM_BIT(BB_ATC, pDM_Odm), ATCStatus); ++ PHY_SetBBReg( ++ pDM_Odm->Adapter, ++ ODM_REG(BB_ATC, pDM_Odm), ++ ODM_BIT(BB_ATC, pDM_Odm), ++ ATCStatus ++ ); + pCfoTrack->bATCStatus = ATCStatus; +} + -+static bool -+odm_GetATCStatus( -+ void * pDM_VOID -+) ++static bool odm_GetATCStatus(void *pDM_VOID) +{ -+ bool ATCStatus; -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ bool ATCStatus; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + -+ ATCStatus = (bool)PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(BB_ATC, pDM_Odm), ODM_BIT(BB_ATC, pDM_Odm)); ++ ATCStatus = (bool)PHY_QueryBBReg( ++ pDM_Odm->Adapter, ++ ODM_REG(BB_ATC, pDM_Odm), ++ ODM_BIT(BB_ATC, pDM_Odm) ++ ); + return ATCStatus; +} + -+void -+ODM_CfoTrackingReset( -+ void * pDM_VOID -+) ++void ODM_CfoTrackingReset(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; + + pCfoTrack->DefXCap = odm_GetDefaultCrytaltalCap(pDM_Odm); + pCfoTrack->bAdjust = true; @@ -58151,56 +56571,85 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux-4.3-rtl8723b + odm_SetATCStatus(pDM_Odm, true); +} + -+void -+ODM_CfoTrackingInit( -+ void * pDM_VOID -+) ++void ODM_CfoTrackingInit(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; + -+ pCfoTrack->DefXCap = pCfoTrack->CrystalCap = odm_GetDefaultCrytaltalCap(pDM_Odm); ++ pCfoTrack->DefXCap = ++ pCfoTrack->CrystalCap = odm_GetDefaultCrytaltalCap(pDM_Odm); + pCfoTrack->bATCStatus = odm_GetATCStatus(pDM_Odm); + pCfoTrack->bAdjust = true; -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking_init() =========>\n")); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking_init(): bATCStatus = %d, CrystalCap = 0x%x\n", pCfoTrack->bATCStatus, pCfoTrack->DefXCap)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ("ODM_CfoTracking_init() =========>\n") ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ( ++ "ODM_CfoTracking_init(): bATCStatus = %d, CrystalCap = 0x%x\n", ++ pCfoTrack->bATCStatus, ++ pCfoTrack->DefXCap ++ ) ++ ); +} + -+void -+ODM_CfoTracking( -+ void * pDM_VOID -+) ++void ODM_CfoTracking(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; -+ int CFO_kHz_A, CFO_kHz_B, CFO_ave = 0; -+ int CFO_ave_diff; -+ int CrystalCap = (int)pCfoTrack->CrystalCap; -+ u8 Adjust_Xtal = 1; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; ++ int CFO_kHz_A, CFO_kHz_B, CFO_ave = 0; ++ int CFO_ave_diff; ++ int CrystalCap = (int)pCfoTrack->CrystalCap; ++ u8 Adjust_Xtal = 1; + + /* 4 Support ability */ -+ if (!(pDM_Odm->SupportAbility & ODM_BB_CFO_TRACKING)) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Return: SupportAbility ODM_BB_CFO_TRACKING is disabled\n")); ++ if (!(pDM_Odm->SupportAbility & ODM_BB_CFO_TRACKING)) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ("ODM_CfoTracking(): Return: SupportAbility ODM_BB_CFO_TRACKING is disabled\n") ++ ); + return; + } + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking() =========>\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ("ODM_CfoTracking() =========>\n") ++ ); + -+ if (!pDM_Odm->bLinked || !pDM_Odm->bOneEntryOnly) -+ { ++ if (!pDM_Odm->bLinked || !pDM_Odm->bOneEntryOnly) { + /* 4 No link or more than one entry */ + ODM_CfoTrackingReset(pDM_Odm); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Reset: bLinked = %d, bOneEntryOnly = %d\n", -+ pDM_Odm->bLinked, pDM_Odm->bOneEntryOnly)); -+ } -+ else -+ { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ( ++ "ODM_CfoTracking(): Reset: bLinked = %d, bOneEntryOnly = %d\n", ++ pDM_Odm->bLinked, ++ pDM_Odm->bOneEntryOnly ++ ) ++ ); ++ } else { + /* 3 1. CFO Tracking */ + /* 4 1.1 No new packet */ -+ if (pCfoTrack->packetCount == pCfoTrack->packetCount_pre) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): packet counter doesn't change\n")); ++ if (pCfoTrack->packetCount == pCfoTrack->packetCount_pre) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ( ++ "ODM_CfoTracking(): packet counter doesn't change\n" ++ ) ++ ); + return; + } + pCfoTrack->packetCount_pre = pCfoTrack->packetCount; @@ -58213,55 +56662,77 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux-4.3-rtl8723b + CFO_ave = CFO_kHz_A; + else + CFO_ave = (int)(CFO_kHz_A + CFO_kHz_B) >> 1; -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): CFO_kHz_A = %dkHz, CFO_kHz_B = %dkHz, CFO_ave = %dkHz\n", -+ CFO_kHz_A, CFO_kHz_B, CFO_ave)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ( ++ "ODM_CfoTracking(): CFO_kHz_A = %dkHz, CFO_kHz_B = %dkHz, CFO_ave = %dkHz\n", ++ CFO_kHz_A, ++ CFO_kHz_B, ++ CFO_ave ++ ) ++ ); + + /* 4 1.3 Avoid abnormal large CFO */ -+ CFO_ave_diff = (pCfoTrack->CFO_ave_pre >= CFO_ave)?(pCfoTrack->CFO_ave_pre - CFO_ave):(CFO_ave - pCfoTrack->CFO_ave_pre); -+ if (CFO_ave_diff > 20 && pCfoTrack->largeCFOHit == 0 && !pCfoTrack->bAdjust) -+ { ++ CFO_ave_diff = ++ (pCfoTrack->CFO_ave_pre >= CFO_ave) ? ++ (pCfoTrack->CFO_ave_pre-CFO_ave) : ++ (CFO_ave-pCfoTrack->CFO_ave_pre); ++ ++ if ( ++ CFO_ave_diff > 20 && ++ pCfoTrack->largeCFOHit == 0 && ++ !pCfoTrack->bAdjust ++ ) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): first large CFO hit\n")); + pCfoTrack->largeCFOHit = 1; + return; -+ } -+ else ++ } else + pCfoTrack->largeCFOHit = 0; + pCfoTrack->CFO_ave_pre = CFO_ave; + + /* 4 1.4 Dynamic Xtal threshold */ -+ if (pCfoTrack->bAdjust == false) -+ { ++ if (pCfoTrack->bAdjust == false) { + if (CFO_ave > CFO_TH_XTAL_HIGH || CFO_ave < (-CFO_TH_XTAL_HIGH)) + pCfoTrack->bAdjust = true; -+ } -+ else -+ { ++ } else { + if (CFO_ave < CFO_TH_XTAL_LOW && CFO_ave > (-CFO_TH_XTAL_LOW)) + pCfoTrack->bAdjust = false; + } + + /* 4 1.5 BT case: Disable CFO tracking */ -+ if (pDM_Odm->bBtEnabled) -+ { ++ if (pDM_Odm->bBtEnabled) { + pCfoTrack->bAdjust = false; + odm_SetCrystalCap(pDM_Odm, pCfoTrack->DefXCap); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Disable CFO tracking for BT!!\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ("ODM_CfoTracking(): Disable CFO tracking for BT!!\n") ++ ); + } + + /* 4 1.6 Big jump */ -+ if (pCfoTrack->bAdjust) -+ { ++ if (pCfoTrack->bAdjust) { + if (CFO_ave > CFO_TH_XTAL_LOW) -+ Adjust_Xtal = Adjust_Xtal + ((CFO_ave - CFO_TH_XTAL_LOW) >> 2); ++ Adjust_Xtal = Adjust_Xtal+((CFO_ave-CFO_TH_XTAL_LOW)>>2); + else if (CFO_ave < (-CFO_TH_XTAL_LOW)) -+ Adjust_Xtal = Adjust_Xtal + ((CFO_TH_XTAL_LOW - CFO_ave) >> 2); ++ Adjust_Xtal = Adjust_Xtal+((CFO_TH_XTAL_LOW-CFO_ave)>>2); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Crystal cap offset = %d\n", Adjust_Xtal)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ( ++ "ODM_CfoTracking(): Crystal cap offset = %d\n", ++ Adjust_Xtal ++ ) ++ ); + } + + /* 4 1.7 Adjust Crystal Cap. */ -+ if (pCfoTrack->bAdjust) -+ { ++ if (pCfoTrack->bAdjust) { + if (CFO_ave > CFO_TH_XTAL_LOW) + CrystalCap = CrystalCap + Adjust_Xtal; + else if (CFO_ave < (-CFO_TH_XTAL_LOW)) @@ -58274,46 +56745,53 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux-4.3-rtl8723b + + odm_SetCrystalCap(pDM_Odm, (u8)CrystalCap); + } -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Crystal cap = 0x%x, Default Crystal cap = 0x%x\n", -+ pCfoTrack->CrystalCap, pCfoTrack->DefXCap)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ( ++ "ODM_CfoTracking(): Crystal cap = 0x%x, Default Crystal cap = 0x%x\n", ++ pCfoTrack->CrystalCap, ++ pCfoTrack->DefXCap ++ ) ++ ); + + /* 3 2. Dynamic ATC switch */ -+ if (CFO_ave < CFO_TH_ATC && CFO_ave > -CFO_TH_ATC) -+ { ++ if (CFO_ave < CFO_TH_ATC && CFO_ave > -CFO_TH_ATC) { + odm_SetATCStatus(pDM_Odm, false); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Disable ATC!!\n")); -+ } -+ else -+ { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ("ODM_CfoTracking(): Disable ATC!!\n") ++ ); ++ } else { + odm_SetATCStatus(pDM_Odm, true); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CFO_TRACKING, ODM_DBG_LOUD, ("ODM_CfoTracking(): Enable ATC!!\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CFO_TRACKING, ++ ODM_DBG_LOUD, ++ ("ODM_CfoTracking(): Enable ATC!!\n") ++ ); + } + } +} + -+void -+ODM_ParsingCFO( -+ void * pDM_VOID, -+ void * pPktinfo_VOID, -+ s8 * pcfotail -+ ) ++void ODM_ParsingCFO(void *pDM_VOID, void *pPktinfo_VOID, s8 *pcfotail) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ PODM_PACKET_INFO_T pPktinfo = (PODM_PACKET_INFO_T)pPktinfo_VOID; -+ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; -+ u8 i; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PODM_PACKET_INFO_T pPktinfo = (PODM_PACKET_INFO_T)pPktinfo_VOID; ++ PCFO_TRACKING pCfoTrack = &pDM_Odm->DM_CfoTrack; ++ u8 i; + + if (!(pDM_Odm->SupportAbility & ODM_BB_CFO_TRACKING)) + return; + -+ if (pPktinfo->StationID != 0) -+ { ++ if (pPktinfo->StationID != 0) { + /* 3 Update CFO report for path-A & path-B */ + /* Only paht-A and path-B have CFO tail and short CFO */ + for (i = ODM_RF_PATH_A; i <= ODM_RF_PATH_B; i++) -+ { + pCfoTrack->CFO_tail[i] = (int)pcfotail[i]; -+ } + + /* 3 Update packet counter */ + if (pCfoTrack->packetCount == 0xffffffff) @@ -58322,10 +56800,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.c linux-4.3-rtl8723b + pCfoTrack->packetCount++; + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_CfoTracking.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_CfoTracking.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,48 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_CfoTracking.h linux/3rdparty/rtl8723bs/hal/odm_CfoTracking.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_CfoTracking.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_CfoTracking.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,47 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -58348,20 +56826,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.h linux-4.3-rtl8723b +#define CFO_TH_XTAL_LOW 10 /* kHz */ +#define CFO_TH_ATC 80 /* kHz */ + -+typedef struct _CFO_TRACKING_ -+{ -+ bool bATCStatus; -+ bool largeCFOHit; -+ bool bAdjust; -+ u8 CrystalCap; -+ u8 DefXCap; -+ int CFO_tail[2]; -+ int CFO_ave_pre; -+ u32 packetCount; -+ u32 packetCount_pre; ++typedef struct _CFO_TRACKING_ { ++ bool bATCStatus; ++ bool largeCFOHit; ++ bool bAdjust; ++ u8 CrystalCap; ++ u8 DefXCap; ++ int CFO_tail[2]; ++ int CFO_ave_pre; ++ u32 packetCount; ++ u32 packetCount_pre; + -+ bool bForceXtalCap; -+ bool bReset; ++ bool bForceXtalCap; ++ bool bReset; +} CFO_TRACKING, *PCFO_TRACKING; + +void ODM_CfoTrackingReset(void *pDM_VOID @@ -58374,9 +56851,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_CfoTracking.h linux-4.3-rtl8723b +void ODM_ParsingCFO(void *pDM_VOID, void *pPktinfo_VOID, s8 *pcfotail); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_debug.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_debug.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_debug.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_debug.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_debug.c linux/3rdparty/rtl8723bs/hal/odm_debug.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_debug.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_debug.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,52 @@ +/****************************************************************************** + * @@ -58430,10 +56907,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_debug.c linux-4.3-rtl8723bs/3rdp +/* ODM_COMP_PSD | */ +0; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_debug.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_debug.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_debug.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_debug.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,154 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_debug.h linux/3rdparty/rtl8723bs/hal/odm_debug.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_debug.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_debug.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,165 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -58449,71 +56926,73 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_debug.h linux-4.3-rtl8723bs/3rdp + * + ******************************************************************************/ + -+#ifndef __ODM_DBG_H__ ++#ifndef __ODM_DBG_H__ +#define __ODM_DBG_H__ + + +/* */ -+/* Define the debug levels */ ++/* Define the debug levels */ +/* */ -+/* 1. DBG_TRACE and DBG_LOUD are used for normal cases. */ -+/* So that, they can help SW engineer to develope or trace states changed */ -+/* and also help HW enginner to trace every operation to and from HW, */ -+/* e.g IO, Tx, Rx. */ ++/* 1. DBG_TRACE and DBG_LOUD are used for normal cases. */ ++/* So that, they can help SW engineer to develope or trace states changed */ ++/* and also help HW enginner to trace every operation to and from HW, */ ++/* e.g IO, Tx, Rx. */ +/* */ -+/* 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, */ -+/* which help us to debug SW or HW. */ ++/* 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, */ ++/* which help us to debug SW or HW. */ +/* */ +/* */ +/* */ -+/* Never used in a call to ODM_RT_TRACE()! */ ++/* Never used in a call to ODM_RT_TRACE()! */ +/* */ +#define ODM_DBG_OFF 1 + +/* */ -+/* Fatal bug. */ -+/* For example, Tx/Rx/IO locked up, OS hangs, memory access violation, */ -+/* resource allocation failed, unexpected HW behavior, HW BUG and so on. */ ++/* Fatal bug. */ ++/* For example, Tx/Rx/IO locked up, OS hangs, memory access violation, */ ++/* resource allocation failed, unexpected HW behavior, HW BUG and so on. */ +/* */ +#define ODM_DBG_SERIOUS 2 + +/* */ -+/* Abnormal, rare, or unexpeted cases. */ -+/* For example, IRP/Packet/OID canceled, device suprisely unremoved and so on. */ ++/* Abnormal, rare, or unexpeted cases. */ ++/* For example, */ ++/* IRP/Packet/OID canceled, */ ++/* device suprisely unremoved and so on. */ +/* */ +#define ODM_DBG_WARNING 3 + +/* */ -+/* Normal case with useful information about current SW or HW state. */ -+/* For example, Tx/Rx descriptor to fill, Tx/Rx descriptor completed status, */ -+/* SW protocol state change, dynamic mechanism state change and so on. */ ++/* Normal case with useful information about current SW or HW state. */ ++/* For example, Tx/Rx descriptor to fill, Tx/Rx descriptor completed status, */ ++/* SW protocol state change, dynamic mechanism state change and so on. */ +/* */ -+#define ODM_DBG_LOUD 4 ++#define ODM_DBG_LOUD 4 + +/* */ -+/* Normal case with detail execution flow or information. */ ++/* Normal case with detail execution flow or information. */ +/* */ -+#define ODM_DBG_TRACE 5 ++#define ODM_DBG_TRACE 5 + +/* */ +/* Define the tracing components */ +/* */ +/* */ +/* BB Functions */ -+#define ODM_COMP_DIG BIT0 -+#define ODM_COMP_RA_MASK BIT1 ++#define ODM_COMP_DIG BIT0 ++#define ODM_COMP_RA_MASK BIT1 +#define ODM_COMP_DYNAMIC_TXPWR BIT2 +#define ODM_COMP_FA_CNT BIT3 +#define ODM_COMP_RSSI_MONITOR BIT4 +#define ODM_COMP_CCK_PD BIT5 -+#define ODM_COMP_ANT_DIV BIT6 ++#define ODM_COMP_ANT_DIV BIT6 +#define ODM_COMP_PWR_SAVE BIT7 +#define ODM_COMP_PWR_TRAIN BIT8 +#define ODM_COMP_RATE_ADAPTIVE BIT9 -+#define ODM_COMP_PATH_DIV BIT10 -+#define ODM_COMP_PSD BIT11 ++#define ODM_COMP_PATH_DIV BIT10 ++#define ODM_COMP_PSD BIT11 +#define ODM_COMP_DYNAMIC_PRICCA BIT12 -+#define ODM_COMP_RXHP BIT13 ++#define ODM_COMP_RXHP BIT13 +#define ODM_COMP_MP BIT14 +#define ODM_COMP_CFO_TRACKING BIT15 +/* MAC Functions */ @@ -58522,56 +57001,68 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_debug.h linux-4.3-rtl8723bs/3rdp +/* RF Functions */ +#define ODM_COMP_TX_PWR_TRACK BIT24 +#define ODM_COMP_RX_GAIN_TRACK BIT25 -+#define ODM_COMP_CALIBRATION BIT26 ++#define ODM_COMP_CALIBRATION BIT26 +/* Common Functions */ +#define ODM_COMP_COMMON BIT30 -+#define ODM_COMP_INIT BIT31 ++#define ODM_COMP_INIT BIT31 + +/*------------------------Export Marco Definition---------------------------*/ -+ #define DbgPrint printk -+ #define RT_PRINTK(fmt, args...) DbgPrint("%s(): " fmt, __func__, ## args); -+ #define RT_DISP(dbgtype, dbgflag, printstr) ++ #define DbgPrint printk ++ #define RT_PRINTK(fmt, args...)\ ++ DbgPrint("%s(): " fmt, __func__, ## args) ++ #define RT_DISP(dbgtype, dbgflag, printstr) + +#ifndef ASSERT + #define ASSERT(expr) +#endif + +#if DBG -+#define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ -+ if (((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel || level == ODM_DBG_SERIOUS)) \ -+ { \ -+ RT_PRINTK fmt; \ -+ } ++#define ODM_RT_TRACE(pDM_Odm, comp, level, fmt)\ ++ if (\ ++ (comp & pDM_Odm->DebugComponents) &&\ ++ (level <= pDM_Odm->DebugLevel || level == ODM_DBG_SERIOUS)\ ++ ) {\ ++ RT_PRINTK fmt;\ ++ } + -+#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \ -+ if (((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel)) \ -+ { \ -+ RT_PRINTK fmt; \ -+ } ++#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt)\ ++ if (\ ++ (comp & pDM_Odm->DebugComponents) &&\ ++ (level <= pDM_Odm->DebugLevel)\ ++ ) {\ ++ RT_PRINTK fmt;\ ++ } + -+#define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ -+ if (!(expr)) { \ -+ DbgPrint("Assertion failed! %s at ......\n", #expr); \ -+ DbgPrint(" ......%s,%s, line =%d\n", __FILE__, __func__, __LINE__); \ -+ RT_PRINTK fmt; \ -+ ASSERT(false); \ -+ } ++#define ODM_RT_ASSERT(pDM_Odm, expr, fmt)\ ++ if (!expr) {\ ++ DbgPrint("Assertion failed! %s at ......\n", #expr);\ ++ DbgPrint(\ ++ " ......%s,%s, line =%d\n",\ ++ __FILE__,\ ++ __func__,\ ++ __LINE__\ ++ );\ ++ RT_PRINTK fmt;\ ++ ASSERT(false);\ ++ } +#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); } +#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); } +#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); } + -+#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ -+ if (((comp) & pDM_Odm->DebugComponents) && (level <= pDM_Odm->DebugLevel)) \ -+ { \ -+ int __i; \ -+ u8 *__ptr = (u8 *)ptr; \ -+ DbgPrint("[ODM] "); \ -+ DbgPrint(title_str); \ -+ DbgPrint(" "); \ -+ for (__i = 0; __i<6; __i++) \ -+ DbgPrint("%02X%s", __ptr[__i], (__i ==5)?"":"-"); \ -+ DbgPrint("\n"); \ -+ } ++#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr)\ ++ if (\ ++ (comp & pDM_Odm->DebugComponents) &&\ ++ (level <= pDM_Odm->DebugLevel)\ ++ ) {\ ++ int __i;\ ++ u8 *__ptr = (u8 *)ptr;\ ++ DbgPrint("[ODM] ");\ ++ DbgPrint(title_str);\ ++ DbgPrint(" ");\ ++ for (__i = 0; __i < 6; __i++)\ ++ DbgPrint("%02X%s", __ptr[__i], (__i == 5) ? "" : "-");\ ++ DbgPrint("\n");\ ++ } +#else +#define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) +#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) @@ -58582,16 +57073,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_debug.h linux-4.3-rtl8723bs/3rdp +#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) +#endif + -+void -+ODM_InitDebugSetting( -+ PDM_ODM_T pDM_Odm -+ ); ++void ODM_InitDebugSetting(PDM_ODM_T pDM_Odm); + +#endif /* __ODM_DBG_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DIG.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DIG.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1104 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_DIG.c linux/3rdparty/rtl8723bs/hal/odm_DIG.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_DIG.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_DIG.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1221 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -58609,12 +57097,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + +#include "odm_precomp.h" + -+#define ADAPTIVITY_VERSION "5.0" ++#define ADAPTIVITY_VERSION "5.0" + -+void -+odm_NHMCounterStatisticsInit( -+ void * pDM_VOID -+ ) ++void odm_NHMCounterStatisticsInit(void *pDM_VOID) +{ + PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + @@ -58630,12 +57115,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_RSTC_11N, BIT7, 0x1); /* 0xc0c[7]= 1 max power among all RX ants */ +} + -+void -+odm_NHMCounterStatistics( -+ void * pDM_VOID -+ ) ++void odm_NHMCounterStatistics(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + /* Get NHM report */ + odm_GetNHMCounterStatistics(pDM_Odm); @@ -58644,36 +57126,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + odm_NHMCounterStatisticsReset(pDM_Odm); +} + -+void -+odm_GetNHMCounterStatistics( -+ void * pDM_VOID -+ ) ++void odm_GetNHMCounterStatistics(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ u32 value32 = 0; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ u32 value32 = 0; + + value32 = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_NHM_CNT_11N, bMaskDWord); + + pDM_Odm->NHM_cnt_0 = (u8)(value32 & bMaskByte0); +} + -+void -+odm_NHMCounterStatisticsReset( -+ void * pDM_VOID -+ ) ++void odm_NHMCounterStatisticsReset(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_NHM_TH9_TH10_11N, BIT1, 0); + PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_NHM_TH9_TH10_11N, BIT1, 1); +} + -+void -+odm_NHMBBInit( -+ void * pDM_VOID -+) ++void odm_NHMBBInit(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + pDM_Odm->adaptivity_flag = 0; + pDM_Odm->tolerance_cnt = 3; @@ -58684,62 +57157,61 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar +} + +/* */ -+void -+odm_NHMBB( -+ void * pDM_VOID -+) ++void odm_NHMBB(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + /* u8 test_status; */ + /* Pfalse_ALARM_STATISTICS pFalseAlmCnt = &(pDM_Odm->FalseAlmCnt); */ + -+ pDM_Odm->NHMCurTxOkcnt = *(pDM_Odm->pNumTxBytesUnicast) - pDM_Odm->NHMLastTxOkcnt; -+ pDM_Odm->NHMCurRxOkcnt = *(pDM_Odm->pNumRxBytesUnicast) - pDM_Odm->NHMLastRxOkcnt; -+ pDM_Odm->NHMLastTxOkcnt = *(pDM_Odm->pNumTxBytesUnicast); -+ pDM_Odm->NHMLastRxOkcnt = *(pDM_Odm->pNumRxBytesUnicast); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("NHM_cnt_0 =%d, NHMCurTxOkcnt = %llu, NHMCurRxOkcnt = %llu\n", -+ pDM_Odm->NHM_cnt_0, pDM_Odm->NHMCurTxOkcnt, pDM_Odm->NHMCurRxOkcnt)); ++ pDM_Odm->NHMCurTxOkcnt = ++ *(pDM_Odm->pNumTxBytesUnicast)-pDM_Odm->NHMLastTxOkcnt; ++ pDM_Odm->NHMCurRxOkcnt = ++ *(pDM_Odm->pNumRxBytesUnicast)-pDM_Odm->NHMLastRxOkcnt; ++ pDM_Odm->NHMLastTxOkcnt = ++ *(pDM_Odm->pNumTxBytesUnicast); ++ pDM_Odm->NHMLastRxOkcnt = ++ *(pDM_Odm->pNumRxBytesUnicast); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "NHM_cnt_0 =%d, NHMCurTxOkcnt = %llu, NHMCurRxOkcnt = %llu\n", ++ pDM_Odm->NHM_cnt_0, ++ pDM_Odm->NHMCurTxOkcnt, ++ pDM_Odm->NHMCurRxOkcnt ++ ) ++ ); + + -+ if ((pDM_Odm->NHMCurTxOkcnt) + 1 > (u64)(pDM_Odm->NHMCurRxOkcnt<<2) + 1) /* Tx > 4*Rx possible for adaptivity test */ -+ { -+ if (pDM_Odm->NHM_cnt_0 >= 190 || pDM_Odm->adaptivity_flag == true) -+ { ++ if ((pDM_Odm->NHMCurTxOkcnt) + 1 > (u64)(pDM_Odm->NHMCurRxOkcnt<<2) + 1) { /* Tx > 4*Rx possible for adaptivity test */ ++ if (pDM_Odm->NHM_cnt_0 >= 190 || pDM_Odm->adaptivity_flag == true) { + /* Enable EDCCA since it is possible running Adaptivity testing */ + /* test_status = 1; */ + pDM_Odm->adaptivity_flag = true; + pDM_Odm->tolerance_cnt = 0; -+ } -+ else -+ { -+ if (pDM_Odm->tolerance_cnt<3) ++ } else { ++ if (pDM_Odm->tolerance_cnt < 3) + pDM_Odm->tolerance_cnt = pDM_Odm->tolerance_cnt + 1; + else + pDM_Odm->tolerance_cnt = 4; + /* test_status = 5; */ -+ if (pDM_Odm->tolerance_cnt > 3) -+ { ++ if (pDM_Odm->tolerance_cnt > 3) { + /* test_status = 3; */ + pDM_Odm->adaptivity_flag = false; + } + } -+ } -+ else /* TXadaptivity_flag == true && pDM_Odm->NHM_cnt_0 <= 200) -+ { ++ } else { /* TXadaptivity_flag == true && pDM_Odm->NHM_cnt_0 <= 200) { + /* test_status = 2; */ + pDM_Odm->tolerance_cnt = 0; -+ } -+ else -+ { -+ if (pDM_Odm->tolerance_cnt<3) ++ } else { ++ if (pDM_Odm->tolerance_cnt < 3) + pDM_Odm->tolerance_cnt = pDM_Odm->tolerance_cnt + 1; + else + pDM_Odm->tolerance_cnt = 4; + /* test_status = 5; */ -+ if (pDM_Odm->tolerance_cnt >3) -+ { ++ if (pDM_Odm->tolerance_cnt > 3) { + /* test_status = 4; */ + pDM_Odm->adaptivity_flag = false; + } @@ -58749,24 +57221,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("adaptivity_flag = %d\n ", pDM_Odm->adaptivity_flag)); +} + -+void -+odm_SearchPwdBLowerBound( -+ void * pDM_VOID, -+ u8 IGI_target -+) ++void odm_SearchPwdBLowerBound(void *pDM_VOID, u8 IGI_target) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ u32 value32 = 0; -+ u8 cnt, IGI; -+ bool bAdjust =true; -+ s8 TH_L2H_dmc, TH_H2L_dmc; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ u32 value32 = 0; ++ u8 cnt, IGI; ++ bool bAdjust = true; ++ s8 TH_L2H_dmc, TH_H2L_dmc; + s8 Diff; + + IGI = 0x50; /* find H2L, L2H lower bound */ + ODM_Write_DIG(pDM_Odm, IGI); + + -+ Diff = IGI_target -(s8)IGI; ++ Diff = IGI_target-(s8)IGI; + TH_L2H_dmc = pDM_Odm->TH_L2H_ini + Diff; + if (TH_L2H_dmc > 10) + TH_L2H_dmc = 10; @@ -58777,7 +57245,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + mdelay(5); + + while (bAdjust) { -+ for (cnt = 0; cnt<20; cnt ++) { ++ for (cnt = 0; cnt < 20; cnt++) { + value32 = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_RPT_11N, bMaskDWord); + + if (value32 & BIT30) @@ -58790,7 +57258,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + /* DbgPrint("txEdcca1 = %d, txEdcca0 = %d\n", pDM_Odm->txEdcca1, pDM_Odm->txEdcca0); */ + + if (pDM_Odm->txEdcca1 > 5) { -+ IGI = IGI -1; ++ IGI = IGI-1; + TH_L2H_dmc = TH_L2H_dmc + 1; + if (TH_L2H_dmc > 10) + TH_L2H_dmc = 10; @@ -58822,20 +57290,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + } + } + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("IGI = 0x%x, H2L_lb = 0x%x, L2H_lb = 0x%x\n", IGI, pDM_Odm->H2L_lb , pDM_Odm->L2H_lb)); ++ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("IGI = 0x%x, H2L_lb = 0x%x, L2H_lb = 0x%x\n", IGI, pDM_Odm->H2L_lb, pDM_Odm->L2H_lb)); +} + -+void -+odm_AdaptivityInit( -+void * pDM_VOID -+) ++void odm_AdaptivityInit(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + if (pDM_Odm->Carrier_Sense_enable == false) -+ { + pDM_Odm->TH_L2H_ini = 0xf7; /* -7 */ -+ } + else + pDM_Odm->TH_L2H_ini = 0xa; + @@ -58858,19 +57321,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar +} + + -+void -+odm_Adaptivity( -+ void * pDM_VOID, -+ u8 IGI -+) ++void odm_Adaptivity(void *pDM_VOID, u8 IGI) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + s8 TH_L2H_dmc, TH_H2L_dmc; + s8 Diff, IGI_target; + bool EDCCA_State = false; + -+ if (!(pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY)) -+ { ++ if (!(pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("Go to odm_DynamicEDCCA()\n")); + return; + } @@ -58889,38 +57347,48 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + pDM_Odm->IGI_target = (u8) IGI_target; + + /* Search pwdB lower bound */ -+ if (pDM_Odm->TxHangFlg == true) -+ { ++ if (pDM_Odm->TxHangFlg == true) { + PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_DBG_RPT_11N, bMaskDWord, 0x208); + odm_SearchPwdBLowerBound(pDM_Odm, pDM_Odm->IGI_target); + } + -+ if ((!pDM_Odm->bLinked)||(*pDM_Odm->pChannel > 149)) /* Band4 doesn't need adaptivity */ -+ { ++ if ((!pDM_Odm->bLinked) || (*pDM_Odm->pChannel > 149)) { /* Band4 doesn't need adaptivity */ + PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, bMaskByte0, 0x7f); + PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, bMaskByte2, 0x7f); + return; + } + -+ if (!pDM_Odm->ForceEDCCA) -+ { ++ if (!pDM_Odm->ForceEDCCA) { + if (pDM_Odm->RSSI_Min > pDM_Odm->AdapEn_RSSI) + EDCCA_State = 1; + else if (pDM_Odm->RSSI_Min < (pDM_Odm->AdapEn_RSSI - 5)) + EDCCA_State = 0; -+ } -+ else ++ } else + EDCCA_State = 1; + -+ if (pDM_Odm->bLinked && pDM_Odm->Carrier_Sense_enable == false && pDM_Odm->NHM_disable == false &&pDM_Odm->TxHangFlg == false) ++ if ( ++ pDM_Odm->bLinked && ++ pDM_Odm->Carrier_Sense_enable == false && ++ pDM_Odm->NHM_disable == false && ++ pDM_Odm->TxHangFlg == false ++ ) + odm_NHMBB(pDM_Odm); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("BandWidth =%s, IGI_target = 0x%x, EDCCA_State =%d\n", -+ (*pDM_Odm->pBandWidth ==ODM_BW80M)?"80M":((*pDM_Odm->pBandWidth ==ODM_BW40M)?"40M":"20M"), IGI_target, EDCCA_State)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "BandWidth =%s, IGI_target = 0x%x, EDCCA_State =%d\n", ++ (*pDM_Odm->pBandWidth == ODM_BW80M) ? "80M" : ++ ((*pDM_Odm->pBandWidth == ODM_BW40M) ? "40M" : "20M"), ++ IGI_target, ++ EDCCA_State ++ ) ++ ); + -+ if (EDCCA_State == 1) -+ { -+ Diff = IGI_target -(s8)IGI; ++ if (EDCCA_State == 1) { ++ Diff = IGI_target-(s8)IGI; + TH_L2H_dmc = pDM_Odm->TH_L2H_ini + Diff; + if (TH_L2H_dmc > 10) + TH_L2H_dmc = 10; @@ -58932,9 +57400,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + TH_H2L_dmc = pDM_Odm->H2L_lb; + if (TH_L2H_dmc < pDM_Odm->L2H_lb) + TH_L2H_dmc = pDM_Odm->L2H_lb; -+ } -+ else -+ { ++ } else { + TH_L2H_dmc = 0x7f; + TH_H2L_dmc = 0x7f; + } @@ -58944,17 +57410,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, bMaskByte2, (u8)TH_H2L_dmc); +} + -+void -+ODM_Write_DIG( -+void * pDM_VOID, -+u8 CurrentIGI -+ ) ++void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; + -+ if (pDM_DigTable->bStopDIG) -+ { ++ if (pDM_DigTable->bStopDIG) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("Stop Writing IGI\n")); + return; + } @@ -58962,13 +57423,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_TRACE, ("ODM_REG(IGI_A, pDM_Odm) = 0x%x, ODM_BIT(IGI, pDM_Odm) = 0x%x\n", + ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm))); + -+ if (pDM_DigTable->CurIGValue != CurrentIGI) -+ { ++ if (pDM_DigTable->CurIGValue != CurrentIGI) { + /* 1 Check initial gain by upper bound */ -+ if (!pDM_DigTable->bPSDInProgress) -+ { -+ if (CurrentIGI > pDM_DigTable->rx_gain_range_max) -+ { ++ if (!pDM_DigTable->bPSDInProgress) { ++ if (CurrentIGI > pDM_DigTable->rx_gain_range_max) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_TRACE, ("CurrentIGI(0x%02x) is larger than upper bound !!\n", pDM_DigTable->rx_gain_range_max)); + CurrentIGI = pDM_DigTable->rx_gain_range_max; + } @@ -58988,104 +57446,107 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + +} + -+void -+odm_PauseDIG( -+ void * pDM_VOID, -+ ODM_Pause_DIG_TYPE PauseType, -+ u8 IGIValue ++void odm_PauseDIG( ++ void *pDM_VOID, ++ ODM_Pause_DIG_TYPE PauseType, ++ u8 IGIValue +) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; -+ static bool bPaused = false; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ static bool bPaused = false; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG() =========>\n")); + -+ if ((pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY) && pDM_Odm->TxHangFlg == true) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Dynamic adjust threshold in progress !!\n")); ++ if ( ++ (pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY) && ++ pDM_Odm->TxHangFlg == true ++ ) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_PauseDIG(): Dynamic adjust threshold in progress !!\n") ++ ); + return; + } + -+ if (!bPaused && (!(pDM_Odm->SupportAbility & ODM_BB_DIG) || !(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n")); ++ if ( ++ !bPaused && (!(pDM_Odm->SupportAbility & ODM_BB_DIG) || ++ !(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) ++ ){ ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_PauseDIG(): Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n") ++ ); + return; + } + -+ switch (PauseType) -+ { -+ /* 1 Pause DIG */ -+ case ODM_PAUSE_DIG: -+ /* 2 Disable DIG */ -+ ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pDM_Odm->SupportAbility & (~ODM_BB_DIG)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Pause DIG !!\n")); ++ switch (PauseType) { ++ /* 1 Pause DIG */ ++ case ODM_PAUSE_DIG: ++ /* 2 Disable DIG */ ++ ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pDM_Odm->SupportAbility & (~ODM_BB_DIG)); ++ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Pause DIG !!\n")); + -+ /* 2 Backup IGI value */ -+ if (!bPaused) -+ { -+ pDM_DigTable->IGIBackup = pDM_DigTable->CurIGValue; -+ bPaused = true; -+ } -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Backup IGI = 0x%x\n", pDM_DigTable->IGIBackup)); ++ /* 2 Backup IGI value */ ++ if (!bPaused) { ++ pDM_DigTable->IGIBackup = pDM_DigTable->CurIGValue; ++ bPaused = true; ++ } ++ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Backup IGI = 0x%x\n", pDM_DigTable->IGIBackup)); + -+ /* 2 Write new IGI value */ -+ ODM_Write_DIG(pDM_Odm, IGIValue); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Write new IGI = 0x%x\n", IGIValue)); -+ break; ++ /* 2 Write new IGI value */ ++ ODM_Write_DIG(pDM_Odm, IGIValue); ++ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Write new IGI = 0x%x\n", IGIValue)); ++ break; + -+ /* 1 Resume DIG */ -+ case ODM_RESUME_DIG: -+ if (bPaused) -+ { -+ /* 2 Write backup IGI value */ -+ ODM_Write_DIG(pDM_Odm, pDM_DigTable->IGIBackup); -+ bPaused = false; -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Write original IGI = 0x%x\n", pDM_DigTable->IGIBackup)); ++ /* 1 Resume DIG */ ++ case ODM_RESUME_DIG: ++ if (bPaused) { ++ /* 2 Write backup IGI value */ ++ ODM_Write_DIG(pDM_Odm, pDM_DigTable->IGIBackup); ++ bPaused = false; ++ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Write original IGI = 0x%x\n", pDM_DigTable->IGIBackup)); + -+ /* 2 Enable DIG */ -+ ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pDM_Odm->SupportAbility | ODM_BB_DIG); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Resume DIG !!\n")); -+ } -+ break; ++ /* 2 Enable DIG */ ++ ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pDM_Odm->SupportAbility | ODM_BB_DIG); ++ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Resume DIG !!\n")); ++ } ++ break; + -+ default: -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Wrong type !!\n")); -+ break; ++ default: ++ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_PauseDIG(): Wrong type !!\n")); ++ break; + } +} + -+bool -+odm_DigAbort( -+ void * pDM_VOID -+ ) ++bool odm_DigAbort(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + /* SupportAbility */ -+ if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) -+ { ++ if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Return: SupportAbility ODM_BB_FA_CNT is disabled\n")); + return true; + } + + /* SupportAbility */ -+ if (!(pDM_Odm->SupportAbility & ODM_BB_DIG)) -+ { ++ if (!(pDM_Odm->SupportAbility & ODM_BB_DIG)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Return: SupportAbility ODM_BB_DIG is disabled\n")); + return true; + } + + /* ScanInProcess */ -+ if (*(pDM_Odm->pbScanInProcess)) -+ { ++ if (*(pDM_Odm->pbScanInProcess)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Return: In Scan Progress\n")); + return true; + } + + /* add by Neil Chen to avoid PSD is processing */ -+ if (pDM_Odm->bDMInitialGainEnable == false) -+ { ++ if (pDM_Odm->bDMInitialGainEnable == false) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Return: PSD is Processing\n")); + return true; + } @@ -59093,13 +57554,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + return false; +} + -+void -+odm_DIGInit( -+ void * pDM_VOID -+ ) ++void odm_DIGInit(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; + + pDM_DigTable->bStopDIG = false; + pDM_DigTable->bPSDInProgress = false; @@ -59128,13 +57586,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + /* To Initi BT30 IGI */ + pDM_DigTable->BT30_CurIGI = 0x32; + -+ if (pDM_Odm->BoardType & (ODM_BOARD_EXT_PA|ODM_BOARD_EXT_LNA)) -+ { ++ if (pDM_Odm->BoardType & (ODM_BOARD_EXT_PA|ODM_BOARD_EXT_LNA)) { + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; -+ } -+ else -+ { ++ } else { + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; + } @@ -59142,26 +57597,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar +} + + -+void -+odm_DIG( -+ void * pDM_VOID -+ ) ++void odm_DIG(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + /* Common parameters */ -+ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; -+ Pfalse_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; -+ bool FirstConnect, FirstDisConnect; -+ u8 DIG_MaxOfMin, DIG_Dynamic_MIN; -+ u8 dm_dig_max, dm_dig_min; -+ u8 CurrentIGI = pDM_DigTable->CurIGValue; -+ u8 offset; -+ u32 dm_FA_thres[3]; -+ u8 Adap_IGI_Upper = 0; -+ u32 TxTp = 0, RxTp = 0; -+ bool bDFSBand = false; -+ bool bPerformance = true, bFirstTpTarget = false, bFirstCoverage = false; ++ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ Pfalse_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; ++ bool FirstConnect, FirstDisConnect; ++ u8 DIG_MaxOfMin, DIG_Dynamic_MIN; ++ u8 dm_dig_max, dm_dig_min; ++ u8 CurrentIGI = pDM_DigTable->CurIGValue; ++ u8 offset; ++ u32 dm_FA_thres[3]; ++ u8 Adap_IGI_Upper = 0; ++ u32 TxTp = 0, RxTp = 0; ++ bool bDFSBand = false; ++ bool bPerformance = true, bFirstTpTarget = false, bFirstCoverage = false; + + if (odm_DigAbort(pDM_Odm) == true) + return; @@ -59186,16 +57638,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Absolutly upper bound = 0x%x, lower bound = 0x%x\n", dm_dig_max, dm_dig_min)); + + /* 1 Adjust boundary by RSSI */ -+ if (pDM_Odm->bLinked && bPerformance) -+ { ++ if (pDM_Odm->bLinked && bPerformance) { + /* 2 Modify DIG upper bound */ + /* 4 Modify DIG upper bound for 92E, 8723A\B, 8821 & 8812 BT */ -+ if (pDM_Odm->bBtLimitedDig == 1) -+ { ++ if (pDM_Odm->bBtLimitedDig == 1) { + offset = 10; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Coex. case: Force upper bound to RSSI + %d !!!!!!\n", offset)); -+ } -+ else ++ } else + offset = 15; + + if ((pDM_Odm->RSSI_Min + offset) > dm_dig_max) @@ -59215,63 +57664,107 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + else + DIG_Dynamic_MIN = pDM_Odm->RSSI_Min; + } -+ } -+ else -+ { -+ { -+ pDM_DigTable->rx_gain_range_max = dm_dig_max; -+ } ++ } else { ++ pDM_DigTable->rx_gain_range_max = dm_dig_max; + DIG_Dynamic_MIN = dm_dig_min; + } + + /* 1 Force Lower Bound for AntDiv */ -+ if (pDM_Odm->bLinked && !pDM_Odm->bOneEntryOnly) -+ { -+ if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) -+ { -+ if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV || pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV ||pDM_Odm->AntDivType == S0S1_SW_ANTDIV) -+ { ++ if (pDM_Odm->bLinked && !pDM_Odm->bOneEntryOnly) { ++ if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) { ++ if ( ++ pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV || ++ pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV || ++ pDM_Odm->AntDivType == S0S1_SW_ANTDIV ++ ) { + if (pDM_DigTable->AntDiv_RSSI_max > DIG_MaxOfMin) + DIG_Dynamic_MIN = DIG_MaxOfMin; + else + DIG_Dynamic_MIN = (u8) pDM_DigTable->AntDiv_RSSI_max; -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_DIG(): Antenna diversity case: Force lower bound to 0x%x !!!!!!\n", DIG_Dynamic_MIN)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_DIG(): Antenna diversity case: RSSI_max = 0x%x !!!!!!\n", pDM_DigTable->AntDiv_RSSI_max)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_ANT_DIV, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): Antenna diversity case: Force lower bound to 0x%x !!!!!!\n", ++ DIG_Dynamic_MIN ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_ANT_DIV, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): Antenna diversity case: RSSI_max = 0x%x !!!!!!\n", ++ pDM_DigTable->AntDiv_RSSI_max ++ ) ++ ); + } + } + } -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Adjust boundary by RSSI Upper bound = 0x%x, Lower bound = 0x%x\n", -+ pDM_DigTable->rx_gain_range_max, DIG_Dynamic_MIN)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Link status: bLinked = %d, RSSI = %d, bFirstConnect = %d, bFirsrDisConnect = %d\n\n", -+ pDM_Odm->bLinked, pDM_Odm->RSSI_Min, FirstConnect, FirstDisConnect)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): Adjust boundary by RSSI Upper bound = 0x%x, Lower bound = 0x%x\n", ++ pDM_DigTable->rx_gain_range_max, ++ DIG_Dynamic_MIN ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): Link status: bLinked = %d, RSSI = %d, bFirstConnect = %d, bFirsrDisConnect = %d\n\n", ++ pDM_Odm->bLinked, ++ pDM_Odm->RSSI_Min, ++ FirstConnect, ++ FirstDisConnect ++ ) ++ ); + + /* 1 Modify DIG lower bound, deal with abnormal case */ + /* 2 Abnormal false alarm case */ -+ { -+ if (FirstDisConnect) -+ { -+ pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; -+ pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; -+ } -+ else -+ pDM_DigTable->rx_gain_range_min = odm_ForbiddenIGICheck(pDM_Odm, DIG_Dynamic_MIN, CurrentIGI); -+ } ++ if (FirstDisConnect) { ++ pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; ++ pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; ++ } else ++ pDM_DigTable->rx_gain_range_min = ++ odm_ForbiddenIGICheck(pDM_Odm, DIG_Dynamic_MIN, CurrentIGI); + -+ if (pDM_Odm->bLinked && !FirstConnect) -+ { -+ if ((pDM_Odm->PhyDbgInfo.NumQryBeaconPkt < 5) && (pDM_Odm->bsta_state)) -+ { ++ if (pDM_Odm->bLinked && !FirstConnect) { ++ if ( ++ (pDM_Odm->PhyDbgInfo.NumQryBeaconPkt < 5) && ++ pDM_Odm->bsta_state ++ ) { + pDM_DigTable->rx_gain_range_min = dm_dig_min; -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Abnrormal #beacon (%d) case in STA mode: Force lower bound to 0x%x !!!!!!\n\n", -+ pDM_Odm->PhyDbgInfo.NumQryBeaconPkt, pDM_DigTable->rx_gain_range_min)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): Abnrormal #beacon (%d) case in STA mode: Force lower bound to 0x%x !!!!!!\n\n", ++ pDM_Odm->PhyDbgInfo.NumQryBeaconPkt, ++ pDM_DigTable->rx_gain_range_min ++ ) ++ ); + } + } + + /* 2 Abnormal lower bound case */ -+ if (pDM_DigTable->rx_gain_range_min > pDM_DigTable->rx_gain_range_max) -+ { ++ if (pDM_DigTable->rx_gain_range_min > pDM_DigTable->rx_gain_range_max) { + pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max; -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Abnrormal lower bound case: Force lower bound to 0x%x !!!!!!\n\n", pDM_DigTable->rx_gain_range_min)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): Abnrormal lower bound case: Force lower bound to 0x%x !!!!!!\n\n", ++ pDM_DigTable->rx_gain_range_min ++ ) ++ ); + } + + @@ -59280,33 +57773,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): False alarm threshold = %d, %d, %d\n\n", dm_FA_thres[0], dm_FA_thres[1], dm_FA_thres[2])); + + /* 1 Adjust initial gain by false alarm */ -+ if (pDM_Odm->bLinked && bPerformance) -+ { ++ if (pDM_Odm->bLinked && bPerformance) { + /* 2 After link */ -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Adjust IGI after link\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_DIG(): Adjust IGI after link\n") ++ ); + -+ if (bFirstTpTarget || (FirstConnect && bPerformance)) -+ { ++ if (bFirstTpTarget || (FirstConnect && bPerformance)) { + pDM_DigTable->LargeFAHit = 0; + -+ { -+ if (pDM_Odm->RSSI_Min < DIG_MaxOfMin) -+ { -+ if (CurrentIGI < pDM_Odm->RSSI_Min) -+ CurrentIGI = pDM_Odm->RSSI_Min; -+ } -+ else -+ { -+ if (CurrentIGI < DIG_MaxOfMin) -+ CurrentIGI = DIG_MaxOfMin; -+ } ++ if (pDM_Odm->RSSI_Min < DIG_MaxOfMin) { ++ if (CurrentIGI < pDM_Odm->RSSI_Min) ++ CurrentIGI = pDM_Odm->RSSI_Min; ++ } else { ++ if (CurrentIGI < DIG_MaxOfMin) ++ CurrentIGI = DIG_MaxOfMin; + } + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): First connect case: IGI does on-shot to 0x%x\n", CurrentIGI)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): First connect case: IGI does on-shot to 0x%x\n", ++ CurrentIGI ++ ) ++ ); + -+ } -+ else -+ { ++ } else { + if (pFalseAlmCnt->Cnt_all > dm_FA_thres[2]) + CurrentIGI = CurrentIGI + 4; + else if (pFalseAlmCnt->Cnt_all > dm_FA_thres[1]) @@ -59314,26 +57811,42 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + else if (pFalseAlmCnt->Cnt_all < dm_FA_thres[0]) + CurrentIGI = CurrentIGI - 2; + -+ if ((pDM_Odm->PhyDbgInfo.NumQryBeaconPkt < 5) && (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH1) && (pDM_Odm->bsta_state)) -+ { ++ if ( ++ (pDM_Odm->PhyDbgInfo.NumQryBeaconPkt < 5) && ++ (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH1) && ++ (pDM_Odm->bsta_state) ++ ) { + CurrentIGI = pDM_DigTable->rx_gain_range_min; -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Abnormal #beacon (%d) case: IGI does one-shot to 0x%x\n", -+ pDM_Odm->PhyDbgInfo.NumQryBeaconPkt, CurrentIGI)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): Abnormal #beacon (%d) case: IGI does one-shot to 0x%x\n", ++ pDM_Odm->PhyDbgInfo.NumQryBeaconPkt, ++ CurrentIGI ++ ) ++ ); + } + } -+ } -+ else -+ { ++ } else { + /* 2 Before link */ -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Adjust IGI before link\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_DIG(): Adjust IGI before link\n") ++ ); + -+ if (FirstDisConnect || bFirstCoverage) -+ { ++ if (FirstDisConnect || bFirstCoverage) { + CurrentIGI = dm_dig_min; -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): First disconnect case: IGI does on-shot to lower bound\n")); -+ } -+ else -+ { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_DIG(): First disconnect case: IGI does on-shot to lower bound\n") ++ ); ++ } else { + if (pFalseAlmCnt->Cnt_all > dm_FA_thres[2]) + CurrentIGI = CurrentIGI + 4; + else if (pFalseAlmCnt->Cnt_all > dm_FA_thres[1]) @@ -59350,16 +57863,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + if (CurrentIGI > pDM_DigTable->rx_gain_range_max) + CurrentIGI = pDM_DigTable->rx_gain_range_max; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): CurIGValue = 0x%x, TotalFA = %d\n\n", CurrentIGI, pFalseAlmCnt->Cnt_all)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ( ++ "odm_DIG(): CurIGValue = 0x%x, TotalFA = %d\n\n", ++ CurrentIGI, ++ pFalseAlmCnt->Cnt_all ++ ) ++ ); + + /* 1 Force upper bound and lower bound for adaptivity */ -+ if (pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY && pDM_Odm->adaptivity_flag == true) -+ { ++ if ( ++ pDM_Odm->SupportAbility & ODM_BB_ADAPTIVITY && ++ pDM_Odm->adaptivity_flag == true ++ ) { + if (CurrentIGI > Adap_IGI_Upper) + CurrentIGI = Adap_IGI_Upper; + -+ if (pDM_Odm->IGI_LowerBound != 0) -+ { ++ if (pDM_Odm->IGI_LowerBound != 0) { + if (CurrentIGI < pDM_Odm->IGI_LowerBound) + CurrentIGI = pDM_Odm->IGI_LowerBound; + } @@ -59369,10 +57892,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + + + /* 1 Update status */ -+ if (pDM_Odm->bBtHsOperation) -+ { -+ if (pDM_Odm->bLinked) -+ { ++ if (pDM_Odm->bBtHsOperation) { ++ if (pDM_Odm->bLinked) { + if (pDM_DigTable->BT30_CurIGI > (CurrentIGI)) + ODM_Write_DIG(pDM_Odm, CurrentIGI); + else @@ -59380,9 +57901,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + + pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked; + pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN; -+ } -+ else -+ { ++ } else { + if (pDM_Odm->bLinkInProcess) + ODM_Write_DIG(pDM_Odm, 0x1c); + else if (pDM_Odm->bBtConnectProcess) @@ -59390,33 +57909,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + else + ODM_Write_DIG(pDM_Odm, pDM_DigTable->BT30_CurIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ + } -+ } -+ else /* BT is not using */ -+ { ++ } else { /* BT is not using */ + ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ + pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked; + pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN; + } +} + -+void -+odm_DIGbyRSSI_LPS( -+ void * pDM_VOID -+ ) ++void odm_DIGbyRSSI_LPS(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ Pfalse_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ Pfalse_ALARM_STATISTICS pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; + -+ u8 RSSI_Lower =DM_DIG_MIN_NIC; /* 0x1E or 0x1C */ -+ u8 CurrentIGI =pDM_Odm->RSSI_Min; ++ u8 RSSI_Lower = DM_DIG_MIN_NIC; /* 0x1E or 0x1C */ ++ u8 CurrentIGI = pDM_Odm->RSSI_Min; + -+ CurrentIGI =CurrentIGI+RSSI_OFFSET_DIG; ++ CurrentIGI = CurrentIGI+RSSI_OFFSET_DIG; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIGbyRSSI_LPS() ==>\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_DIGbyRSSI_LPS() ==>\n") ++ ); + + /* Using FW PS mode to make IGI */ + /* Adjust by FA in LPS MODE */ -+ if (pFalseAlmCnt->Cnt_all> DM_DIG_FA_TH2_LPS) ++ if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS) + CurrentIGI = CurrentIGI+4; + else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_LPS) + CurrentIGI = CurrentIGI+2; @@ -59428,163 +57947,252 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + + /* RSSI Lower bound check */ + if ((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC) -+ RSSI_Lower =(pDM_Odm->RSSI_Min-10); ++ RSSI_Lower = pDM_Odm->RSSI_Min-10; + else -+ RSSI_Lower =DM_DIG_MIN_NIC; ++ RSSI_Lower = DM_DIG_MIN_NIC; + + /* Upper and Lower Bound checking */ + if (CurrentIGI > DM_DIG_MAX_NIC) -+ CurrentIGI =DM_DIG_MAX_NIC; ++ CurrentIGI = DM_DIG_MAX_NIC; + else if (CurrentIGI < RSSI_Lower) -+ CurrentIGI =RSSI_Lower; ++ CurrentIGI = RSSI_Lower; + + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIGbyRSSI_LPS(): pFalseAlmCnt->Cnt_all = %d\n", pFalseAlmCnt->Cnt_all)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIGbyRSSI_LPS(): pDM_Odm->RSSI_Min = %d\n", pDM_Odm->RSSI_Min)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIGbyRSSI_LPS(): CurrentIGI = 0x%x\n", CurrentIGI)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_DIGbyRSSI_LPS(): pFalseAlmCnt->Cnt_all = %d\n", pFalseAlmCnt->Cnt_all) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_DIGbyRSSI_LPS(): pDM_Odm->RSSI_Min = %d\n", pDM_Odm->RSSI_Min) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_DIG, ++ ODM_DBG_LOUD, ++ ("odm_DIGbyRSSI_LPS(): CurrentIGI = 0x%x\n", CurrentIGI) ++ ); + -+ ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ ++ ODM_Write_DIG(pDM_Odm, CurrentIGI); ++ /* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ +} + +/* 3 ============================================================ */ +/* 3 FASLE ALARM CHECK */ +/* 3 ============================================================ */ + -+void -+odm_FalseAlarmCounterStatistics( -+ void * pDM_VOID -+ ) ++void odm_FalseAlarmCounterStatistics(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ Pfalse_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); -+ u32 ret_value; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ Pfalse_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); ++ u32 ret_value; + + if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) + return; + + /* hold ofdm counter */ -+ PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); /* hold page C counter */ -+ PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); /* hold page D counter */ ++ /* hold page C counter */ ++ PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); ++ /* hold page D counter */ ++ PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); + -+ ret_value = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); ++ ret_value = PHY_QueryBBReg( ++ pDM_Odm->Adapter, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord ++ ); + FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); + FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16); + -+ ret_value = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); ++ ret_value = PHY_QueryBBReg( ++ pDM_Odm->Adapter, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord ++ ); + FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + -+ ret_value = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); ++ ret_value = PHY_QueryBBReg( ++ pDM_Odm->Adapter, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord ++ ); + FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); + FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); + -+ ret_value = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); ++ ret_value = PHY_QueryBBReg( ++ pDM_Odm->Adapter, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord ++ ); + FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); + -+ FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + -+ FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + -+ FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; ++ FalseAlmCnt->Cnt_Ofdm_fail = ++ FalseAlmCnt->Cnt_Parity_Fail + ++ FalseAlmCnt->Cnt_Rate_Illegal + ++ FalseAlmCnt->Cnt_Crc8_fail + ++ FalseAlmCnt->Cnt_Mcs_fail + ++ FalseAlmCnt->Cnt_Fast_Fsync + ++ FalseAlmCnt->Cnt_SB_Search_fail; + + { + /* hold cck counter */ + PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_CCK_FA_RST_11N, BIT12, 1); + PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG_CCK_FA_RST_11N, BIT14, 1); + -+ ret_value = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); ++ ret_value = PHY_QueryBBReg( ++ pDM_Odm->Adapter, ODM_REG_CCK_FA_LSB_11N, bMaskByte0 ++ ); + FalseAlmCnt->Cnt_Cck_fail = ret_value; + -+ ret_value = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_CCK_FA_MSB_11N, bMaskByte3); -+ FalseAlmCnt->Cnt_Cck_fail += (ret_value& 0xff)<<8; ++ ret_value = PHY_QueryBBReg( ++ pDM_Odm->Adapter, ODM_REG_CCK_FA_MSB_11N, bMaskByte3 ++ ); ++ FalseAlmCnt->Cnt_Cck_fail += (ret_value&0xff)<<8; + -+ ret_value = PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord); -+ FalseAlmCnt->Cnt_CCK_CCA = ((ret_value&0xFF)<<8) |((ret_value&0xFF00)>>8); ++ ret_value = PHY_QueryBBReg( ++ pDM_Odm->Adapter, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord ++ ); ++ FalseAlmCnt->Cnt_CCK_CCA = ++ ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8); + } + -+ FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync + -+ FalseAlmCnt->Cnt_SB_Search_fail + -+ FalseAlmCnt->Cnt_Parity_Fail + -+ FalseAlmCnt->Cnt_Rate_Illegal + -+ FalseAlmCnt->Cnt_Crc8_fail + -+ FalseAlmCnt->Cnt_Mcs_fail + -+ FalseAlmCnt->Cnt_Cck_fail); ++ FalseAlmCnt->Cnt_all = ( ++ FalseAlmCnt->Cnt_Fast_Fsync + ++ FalseAlmCnt->Cnt_SB_Search_fail + ++ FalseAlmCnt->Cnt_Parity_Fail + ++ FalseAlmCnt->Cnt_Rate_Illegal + ++ FalseAlmCnt->Cnt_Crc8_fail + ++ FalseAlmCnt->Cnt_Mcs_fail + ++ FalseAlmCnt->Cnt_Cck_fail ++ ); + -+ FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA; ++ FalseAlmCnt->Cnt_CCA_all = ++ FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics\n")); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Fast_Fsync =%d, Cnt_SB_Search_fail =%d\n", -+ FalseAlmCnt->Cnt_Fast_Fsync, FalseAlmCnt->Cnt_SB_Search_fail)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Parity_Fail =%d, Cnt_Rate_Illegal =%d\n", -+ FalseAlmCnt->Cnt_Parity_Fail, FalseAlmCnt->Cnt_Rate_Illegal)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Crc8_fail =%d, Cnt_Mcs_fail =%d\n", -+ FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ("Enter odm_FalseAlarmCounterStatistics\n") ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ( ++ "Cnt_Fast_Fsync =%d, Cnt_SB_Search_fail =%d\n", ++ FalseAlmCnt->Cnt_Fast_Fsync, ++ FalseAlmCnt->Cnt_SB_Search_fail ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ( ++ "Cnt_Parity_Fail =%d, Cnt_Rate_Illegal =%d\n", ++ FalseAlmCnt->Cnt_Parity_Fail, ++ FalseAlmCnt->Cnt_Rate_Illegal ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ( ++ "Cnt_Crc8_fail =%d, Cnt_Mcs_fail =%d\n", ++ FalseAlmCnt->Cnt_Crc8_fail, ++ FalseAlmCnt->Cnt_Mcs_fail ++ ) ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_OFDM_CCA =%d\n", FalseAlmCnt->Cnt_OFDM_CCA)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_CCK_CCA =%d\n", FalseAlmCnt->Cnt_CCK_CCA)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_CCA_all =%d\n", FalseAlmCnt->Cnt_CCA_all)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail =%d\n", FalseAlmCnt->Cnt_Cck_fail)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail)); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Total False Alarm =%d\n", FalseAlmCnt->Cnt_all)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ("Cnt_OFDM_CCA =%d\n", FalseAlmCnt->Cnt_OFDM_CCA) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ("Cnt_CCK_CCA =%d\n", FalseAlmCnt->Cnt_CCK_CCA) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ("Cnt_CCA_all =%d\n", FalseAlmCnt->Cnt_CCA_all) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ("Cnt_Cck_fail =%d\n", FalseAlmCnt->Cnt_Cck_fail) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ("Cnt_Ofdm_fail =%d\n", FalseAlmCnt->Cnt_Ofdm_fail) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_FA_CNT, ++ ODM_DBG_LOUD, ++ ("Total False Alarm =%d\n", FalseAlmCnt->Cnt_all) ++ ); +} + + -+void -+odm_FAThresholdCheck( -+ void * pDM_VOID, -+ bool bDFSBand, -+ bool bPerformance, -+ u32 RxTp, -+ u32 TxTp, -+ u32* dm_FA_thres -+ ) ++void odm_FAThresholdCheck( ++ void *pDM_VOID, ++ bool bDFSBand, ++ bool bPerformance, ++ u32 RxTp, ++ u32 TxTp, ++ u32 *dm_FA_thres ++) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + -+ if (pDM_Odm->bLinked && (bPerformance||bDFSBand)) -+ { ++ if (pDM_Odm->bLinked && (bPerformance || bDFSBand)) { + /* For NIC */ + dm_FA_thres[0] = DM_DIG_FA_TH0; + dm_FA_thres[1] = DM_DIG_FA_TH1; + dm_FA_thres[2] = DM_DIG_FA_TH2; -+ } -+ else -+ { -+ { -+ dm_FA_thres[0] = 2000; -+ dm_FA_thres[1] = 4000; -+ dm_FA_thres[2] = 5000; -+ } ++ } else { ++ dm_FA_thres[0] = 2000; ++ dm_FA_thres[1] = 4000; ++ dm_FA_thres[2] = 5000; + } + return; +} + -+u8 -+odm_ForbiddenIGICheck( -+ void * pDM_VOID, -+ u8 DIG_Dynamic_MIN, -+ u8 CurrentIGI -+ ) ++u8 odm_ForbiddenIGICheck(void *pDM_VOID, u8 DIG_Dynamic_MIN, u8 CurrentIGI) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; -+ Pfalse_ALARM_STATISTICS pFalseAlmCnt = &(pDM_Odm->FalseAlmCnt); -+ u8 rx_gain_range_min = pDM_DigTable->rx_gain_range_min; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ Pfalse_ALARM_STATISTICS pFalseAlmCnt = &(pDM_Odm->FalseAlmCnt); ++ u8 rx_gain_range_min = pDM_DigTable->rx_gain_range_min; + -+ if (pFalseAlmCnt->Cnt_all > 10000) -+ { ++ if (pFalseAlmCnt->Cnt_all > 10000) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Abnormally false alarm case.\n")); + + if (pDM_DigTable->LargeFAHit != 3) + pDM_DigTable->LargeFAHit++; + -+ if (pDM_DigTable->ForbiddenIGI < CurrentIGI)/* if (pDM_DigTable->ForbiddenIGI < pDM_DigTable->CurIGValue) */ -+ { -+ pDM_DigTable->ForbiddenIGI = CurrentIGI;/* pDM_DigTable->ForbiddenIGI = pDM_DigTable->CurIGValue; */ ++ /* if (pDM_DigTable->ForbiddenIGI < pDM_DigTable->CurIGValue) */ ++ if (pDM_DigTable->ForbiddenIGI < CurrentIGI) { ++ pDM_DigTable->ForbiddenIGI = CurrentIGI; ++ /* pDM_DigTable->ForbiddenIGI = pDM_DigTable->CurIGValue; */ + pDM_DigTable->LargeFAHit = 1; + } + -+ if (pDM_DigTable->LargeFAHit >= 3) -+ { ++ if (pDM_DigTable->LargeFAHit >= 3) { + if ((pDM_DigTable->ForbiddenIGI + 2) > pDM_DigTable->rx_gain_range_max) + rx_gain_range_min = pDM_DigTable->rx_gain_range_max; + else @@ -59592,35 +58200,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + pDM_DigTable->Recover_cnt = 1800; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Abnormally false alarm case: Recover_cnt = %d\n", pDM_DigTable->Recover_cnt)); + } -+ } -+ else -+ { -+ if (pDM_DigTable->Recover_cnt != 0) -+ { -+ pDM_DigTable->Recover_cnt --; ++ } else { ++ if (pDM_DigTable->Recover_cnt != 0) { ++ pDM_DigTable->Recover_cnt--; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: Recover_cnt = %d\n", pDM_DigTable->Recover_cnt)); -+ } -+ else -+ { -+ if (pDM_DigTable->LargeFAHit < 3) -+ { -+ if ((pDM_DigTable->ForbiddenIGI - 2) < DIG_Dynamic_MIN) /* DM_DIG_MIN) */ -+ { ++ } else { ++ if (pDM_DigTable->LargeFAHit < 3) { ++ if ((pDM_DigTable->ForbiddenIGI - 2) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ + pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ + rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: At Lower Bound\n")); -+ } -+ else -+ { ++ } else { + pDM_DigTable->ForbiddenIGI -= 2; + rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 2); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: Approach Lower Bound\n")); + } -+ } -+ else -+ { ++ } else + pDM_DigTable->LargeFAHit = 0; -+ } + } + } + @@ -59632,43 +58228,48 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar +/* 3 CCK Packet Detect Threshold */ +/* 3 ============================================================ */ + -+void -+odm_CCKPacketDetectionThresh( -+ void * pDM_VOID -+ ) ++void odm_CCKPacketDetectionThresh(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ Pfalse_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); -+ u8 CurCCK_CCAThres; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ Pfalse_ALARM_STATISTICS FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); ++ u8 CurCCK_CCAThres; + + -+ if ((!(pDM_Odm->SupportAbility & ODM_BB_CCK_PD)) ||(!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))) -+ { -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CCK_PD, ODM_DBG_LOUD, ("odm_CCKPacketDetectionThresh() return ==========\n")); ++ if ( ++ !(pDM_Odm->SupportAbility & ODM_BB_CCK_PD) || ++ !(pDM_Odm->SupportAbility & ODM_BB_FA_CNT) ++ ) { ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CCK_PD, ++ ODM_DBG_LOUD, ++ ("odm_CCKPacketDetectionThresh() return ==========\n") ++ ); + return; + } + + if (pDM_Odm->ExtLNA) + return; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CCK_PD, ODM_DBG_LOUD, ("odm_CCKPacketDetectionThresh() ==========>\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CCK_PD, ++ ODM_DBG_LOUD, ++ ("odm_CCKPacketDetectionThresh() ==========>\n") ++ ); + -+ if (pDM_Odm->bLinked) -+ { ++ if (pDM_Odm->bLinked) { + if (pDM_Odm->RSSI_Min > 25) + CurCCK_CCAThres = 0xcd; + else if ((pDM_Odm->RSSI_Min <= 25) && (pDM_Odm->RSSI_Min > 10)) + CurCCK_CCAThres = 0x83; -+ else -+ { ++ else { + if (FalseAlmCnt->Cnt_Cck_fail > 1000) + CurCCK_CCAThres = 0x83; + else + CurCCK_CCAThres = 0x40; + } -+ } -+ else -+ { ++ } else { + if (FalseAlmCnt->Cnt_Cck_fail > 1000) + CurCCK_CCAThres = 0x83; + else @@ -59677,29 +58278,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.c linux-4.3-rtl8723bs/3rdpar + + ODM_Write_CCK_CCA_Thres(pDM_Odm, CurCCK_CCAThres); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_CCK_PD, ODM_DBG_LOUD, ("odm_CCKPacketDetectionThresh() CurCCK_CCAThres = 0x%x\n", CurCCK_CCAThres)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_CCK_PD, ++ ODM_DBG_LOUD, ++ ( ++ "odm_CCKPacketDetectionThresh() CurCCK_CCAThres = 0x%x\n", ++ CurCCK_CCAThres ++ ) ++ ); +} + -+void -+ODM_Write_CCK_CCA_Thres( -+void * pDM_VOID, -+u8 CurCCK_CCAThres -+ ) ++void ODM_Write_CCK_CCA_Thres(void *pDM_VOID, u8 CurCCK_CCAThres) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; + -+ if (pDM_DigTable->CurCCK_CCAThres!=CurCCK_CCAThres) /* modify by Guo.Mingzhi 2012-01-03 */ -+ { ++ /* modify by Guo.Mingzhi 2012-01-03 */ ++ if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres) + rtw_write8(pDM_Odm->Adapter, ODM_REG(CCK_CCA, pDM_Odm), CurCCK_CCAThres); -+ } ++ + pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres; + pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DIG.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DIG.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,263 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_DIG.h linux/3rdparty/rtl8723bs/hal/odm_DIG.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_DIG.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_DIG.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,195 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -59715,22 +58320,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.h linux-4.3-rtl8723bs/3rdpar + * + ******************************************************************************/ + -+#ifndef __ODMDIG_H__ -+#define __ODMDIG_H__ ++#ifndef __ODMDIG_H__ ++#define __ODMDIG_H__ + -+typedef struct _Dynamic_Initial_Gain_Threshold_ -+{ -+ bool bStopDIG; -+ bool bPSDInProgress; ++typedef struct _Dynamic_Initial_Gain_Threshold_ { ++ bool bStopDIG; ++ bool bPSDInProgress; + + u8 Dig_Enable_Flag; + u8 Dig_Ext_Port_Stage; + -+ int RssiLowThresh; -+ int RssiHighThresh; ++ int RssiLowThresh; ++ int RssiHighThresh; + -+ u32 FALowThresh; -+ u32 FAHighThresh; ++ u32 FALowThresh; ++ u32 FAHighThresh; + + u8 CurSTAConnectState; + u8 PreSTAConnectState; @@ -59742,9 +58346,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.h linux-4.3-rtl8723bs/3rdpar + u8 BT30_CurIGI; + u8 IGIBackup; + -+ s8 BackoffVal; -+ s8 BackoffVal_range_max; -+ s8 BackoffVal_range_min; ++ s8 BackoffVal; ++ s8 BackoffVal_range_max; ++ s8 BackoffVal_range_min; + u8 rx_gain_range_max; + u8 rx_gain_range_min; + u8 Rssi_val_min; @@ -59757,26 +58361,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.h linux-4.3-rtl8723bs/3rdpar + + u8 LargeFAHit; + u8 ForbiddenIGI; -+ u32 Recover_cnt; ++ u32 Recover_cnt; + + u8 DIG_Dynamic_MIN_0; + u8 DIG_Dynamic_MIN_1; -+ bool bMediaConnect_0; -+ bool bMediaConnect_1; ++ bool bMediaConnect_0; ++ bool bMediaConnect_1; + -+ u32 AntDiv_RSSI_max; -+ u32 RSSI_max; ++ u32 AntDiv_RSSI_max; ++ u32 RSSI_max; + + u8 *pbP2pLinkInProgress; -+}DIG_T,*pDIG_T; ++} DIG_T, *pDIG_T; + -+typedef struct false_ALARM_STATISTICS{ ++typedef struct false_ALARM_STATISTICS { + u32 Cnt_Parity_Fail; + u32 Cnt_Rate_Illegal; + u32 Cnt_Crc8_fail; + u32 Cnt_Mcs_fail; + u32 Cnt_Ofdm_fail; -+ u32 Cnt_Ofdm_fail_pre; /* For RTL8881A */ ++ u32 Cnt_Ofdm_fail_pre; /* For RTL8881A */ + u32 Cnt_Cck_fail; + u32 Cnt_all; + u32 Cnt_Fast_Fsync; @@ -59784,30 +58388,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.h linux-4.3-rtl8723bs/3rdpar + u32 Cnt_OFDM_CCA; + u32 Cnt_CCK_CCA; + u32 Cnt_CCA_all; -+ u32 Cnt_BW_USC; /* Gary */ -+ u32 Cnt_BW_LSC; /* Gary */ -+}false_ALARM_STATISTICS, *Pfalse_ALARM_STATISTICS; ++ u32 Cnt_BW_USC; /* Gary */ ++ u32 Cnt_BW_LSC; /* Gary */ ++} false_ALARM_STATISTICS, *Pfalse_ALARM_STATISTICS; + -+typedef enum tag_Dynamic_Init_Gain_Operation_Type_Definition -+{ -+ DIG_TYPE_THRESH_HIGH = 0, -+ DIG_TYPE_THRESH_LOW = 1, -+ DIG_TYPE_BACKOFF = 2, -+ DIG_TYPE_RX_GAIN_MIN = 3, -+ DIG_TYPE_RX_GAIN_MAX = 4, -+ DIG_TYPE_ENABLE = 5, -+ DIG_TYPE_DISABLE = 6, ++typedef enum tag_Dynamic_Init_Gain_Operation_Type_Definition { ++ DIG_TYPE_THRESH_HIGH = 0, ++ DIG_TYPE_THRESH_LOW = 1, ++ DIG_TYPE_BACKOFF = 2, ++ DIG_TYPE_RX_GAIN_MIN = 3, ++ DIG_TYPE_RX_GAIN_MAX = 4, ++ DIG_TYPE_ENABLE = 5, ++ DIG_TYPE_DISABLE = 6, + DIG_OP_TYPE_MAX -+}DM_DIG_OP_E; ++} DM_DIG_OP_E; + +typedef enum tag_ODM_PauseDIG_Type { -+ ODM_PAUSE_DIG = BIT0, -+ ODM_RESUME_DIG = BIT1 ++ ODM_PAUSE_DIG = BIT0, ++ ODM_RESUME_DIG = BIT1 +} ODM_Pause_DIG_TYPE; + +typedef enum tag_ODM_PauseCCKPD_Type { -+ ODM_PAUSE_CCKPD = BIT0, -+ ODM_RESUME_CCKPD = BIT1 ++ ODM_PAUSE_CCKPD = BIT0, ++ ODM_RESUME_CCKPD = BIT1 +} ODM_Pause_CCKPD_TYPE; + +#define DM_DIG_THRESH_HIGH 40 @@ -59849,124 +58452,58 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DIG.h linux-4.3-rtl8723bs/3rdpar +#define DM_DIG_FA_TH2_LPS 30 /* 30 lps */ +#define RSSI_OFFSET_DIG 0x05 + -+void -+odm_NHMCounterStatisticsInit( -+ void * pDM_VOID -+ ); ++void odm_NHMCounterStatisticsInit(void *pDM_VOID); + -+void -+odm_NHMCounterStatistics( -+ void * pDM_VOID -+ ); ++void odm_NHMCounterStatistics(void *pDM_VOID); + -+void -+odm_NHMBBInit( -+ void * pDM_VOID ++void odm_NHMBBInit(void *pDM_VOID); ++ ++void odm_NHMBB(void *pDM_VOID); ++ ++void odm_NHMCounterStatisticsReset(void *pDM_VOID); ++ ++void odm_GetNHMCounterStatistics(void *pDM_VOID); ++ ++void odm_SearchPwdBLowerBound(void *pDM_VOID, u8 IGI_target); ++ ++void odm_AdaptivityInit(void *pDM_VOID); ++ ++void odm_Adaptivity(void *pDM_VOID, u8 IGI); ++ ++void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI); ++ ++void odm_PauseDIG(void *pDM_VOID, ODM_Pause_DIG_TYPE PauseType, u8 IGIValue); ++ ++void odm_DIGInit(void *pDM_VOID); ++ ++void odm_DIG(void *pDM_VOID); ++ ++void odm_DIGbyRSSI_LPS(void *pDM_VOID); ++ ++void odm_FalseAlarmCounterStatistics(void *pDM_VOID); ++ ++void odm_FAThresholdCheck( ++ void *pDM_VOID, ++ bool bDFSBand, ++ bool bPerformance, ++ u32 RxTp, ++ u32 TxTp, ++ u32 *dm_FA_thres +); + -+void -+odm_NHMBB( -+ void * pDM_VOID -+); ++u8 odm_ForbiddenIGICheck(void *pDM_VOID, u8 DIG_Dynamic_MIN, u8 CurrentIGI); + -+void -+odm_NHMCounterStatisticsReset( -+ void * pDM_VOID -+); ++bool odm_DigAbort(void *pDM_VOID); + -+void -+odm_GetNHMCounterStatistics( -+ void * pDM_VOID -+); ++void odm_CCKPacketDetectionThresh(void *pDM_VOID); + -+void -+odm_SearchPwdBLowerBound( -+ void * pDM_VOID, -+ u8 IGI_target -+); -+ -+void -+odm_AdaptivityInit( -+ void * pDM_VOID -+ ); -+ -+void -+odm_Adaptivity( -+ void * pDM_VOID, -+ u8 IGI -+ ); -+ -+void -+ODM_Write_DIG( -+ void * pDM_VOID, -+ u8 CurrentIGI -+ ); -+ -+void -+odm_PauseDIG( -+ void * pDM_VOID, -+ ODM_Pause_DIG_TYPE PauseType, -+ u8 IGIValue -+ ); -+ -+void -+odm_DIGInit( -+ void * pDM_VOID -+ ); -+ -+void -+odm_DIG( -+ void * pDM_VOID -+ ); -+ -+void -+odm_DIGbyRSSI_LPS( -+ void * pDM_VOID -+ ); -+ -+void -+odm_FalseAlarmCounterStatistics( -+ void * pDM_VOID -+ ); -+ -+void -+odm_FAThresholdCheck( -+ void * pDM_VOID, -+ bool bDFSBand, -+ bool bPerformance, -+ u32 RxTp, -+ u32 TxTp, -+ u32* dm_FA_thres -+ ); -+ -+u8 -+odm_ForbiddenIGICheck( -+ void * pDM_VOID, -+ u8 DIG_Dynamic_MIN, -+ u8 CurrentIGI -+ ); -+ -+bool -+odm_DigAbort( -+ void * pDM_VOID -+ ); -+ -+void -+odm_CCKPacketDetectionThresh( -+ void * pDM_VOID -+ ); -+ -+void -+ODM_Write_CCK_CCA_Thres( -+ void * pDM_VOID, -+ u8 CurCCK_CCAThres -+ ); ++void ODM_Write_CCK_CCA_Thres(void *pDM_VOID, u8 CurCCK_CCAThres); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,107 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c linux/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,89 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -59984,13 +58521,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c linux-4.3 + +#include "odm_precomp.h" + -+void -+odm_DynamicBBPowerSavingInit( -+ void * pDM_VOID -+ ) ++void odm_DynamicBBPowerSavingInit(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable; + + pDM_PSTable->PreCCAState = CCA_MAX; + pDM_PSTable->CurCCAState = CCA_MAX; @@ -60000,21 +58534,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c linux-4.3 + pDM_PSTable->initialize = 0; +} + -+void -+ODM_RF_Saving( -+ void * pDM_VOID, -+u8 bForceInNormal -+ ) ++void ODM_RF_Saving(void *pDM_VOID, u8 bForceInNormal) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable; -+ u8 Rssi_Up_bound = 30 ; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ pPS_T pDM_PSTable = &pDM_Odm->DM_PSTable; ++ u8 Rssi_Up_bound = 30; + u8 Rssi_Low_bound = 25; -+ if (pDM_Odm->PatchID == 40) /* RT_CID_819x_FUNAI_TV */ -+ { -+ Rssi_Up_bound = 50 ; ++ ++ if (pDM_Odm->PatchID == 40) { /* RT_CID_819x_FUNAI_TV */ ++ Rssi_Up_bound = 50; + Rssi_Low_bound = 45; + } ++ + if (pDM_PSTable->initialize == 0) { + + pDM_PSTable->Reg874 = (PHY_QueryBBReg(pDM_Odm->Adapter, 0x874, bMaskDWord)&0x1CC000)>>14; @@ -60025,59 +58556,47 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.c linux-4.3 + pDM_PSTable->initialize = 1; + } + -+ if (!bForceInNormal) -+ { -+ if (pDM_Odm->RSSI_Min != 0xFF) -+ { -+ if (pDM_PSTable->PreRFState == RF_Normal) -+ { ++ if (!bForceInNormal) { ++ if (pDM_Odm->RSSI_Min != 0xFF) { ++ if (pDM_PSTable->PreRFState == RF_Normal) { + if (pDM_Odm->RSSI_Min >= Rssi_Up_bound) + pDM_PSTable->CurRFState = RF_Save; + else + pDM_PSTable->CurRFState = RF_Normal; -+ } -+ else { ++ } else { + if (pDM_Odm->RSSI_Min <= Rssi_Low_bound) + pDM_PSTable->CurRFState = RF_Normal; + else + pDM_PSTable->CurRFState = RF_Save; + } -+ } -+ else -+ pDM_PSTable->CurRFState =RF_MAX; -+ } -+ else -+ { ++ } else ++ pDM_PSTable->CurRFState = RF_MAX; ++ } else + pDM_PSTable->CurRFState = RF_Normal; -+ } + -+ if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) -+ { -+ if (pDM_PSTable->CurRFState == RF_Save) -+ { -+ PHY_SetBBReg(pDM_Odm->Adapter, 0x874 , 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ ++ if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) { ++ if (pDM_PSTable->CurRFState == RF_Save) { ++ PHY_SetBBReg(pDM_Odm->Adapter, 0x874, 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ + PHY_SetBBReg(pDM_Odm->Adapter, 0xc70, BIT3, 0); /* RegC70[3]= 1'b0 */ + PHY_SetBBReg(pDM_Odm->Adapter, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]= 0x63 */ + PHY_SetBBReg(pDM_Odm->Adapter, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */ + PHY_SetBBReg(pDM_Odm->Adapter, 0xa74, 0xF000, 0x3); /* RegA75[7:4]= 0x3 */ + PHY_SetBBReg(pDM_Odm->Adapter, 0x818, BIT28, 0x0); /* Reg818[28]= 1'b0 */ + PHY_SetBBReg(pDM_Odm->Adapter, 0x818, BIT28, 0x1); /* Reg818[28]= 1'b1 */ -+ } -+ else -+ { -+ PHY_SetBBReg(pDM_Odm->Adapter, 0x874 , 0x1CC000, pDM_PSTable->Reg874); ++ } else { ++ PHY_SetBBReg(pDM_Odm->Adapter, 0x874, 0x1CC000, pDM_PSTable->Reg874); + PHY_SetBBReg(pDM_Odm->Adapter, 0xc70, BIT3, pDM_PSTable->RegC70); + PHY_SetBBReg(pDM_Odm->Adapter, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); + PHY_SetBBReg(pDM_Odm->Adapter, 0xa74, 0xF000, pDM_PSTable->RegA74); + PHY_SetBBReg(pDM_Odm->Adapter, 0x818, BIT28, 0x0); + } -+ pDM_PSTable->PreRFState =pDM_PSTable->CurRFState; ++ pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,46 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h linux/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,39 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -60096,38 +58615,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicBBPowerSaving.h linux-4.3 +#ifndef __ODMDYNAMICBBPOWERSAVING_H__ +#define __ODMDYNAMICBBPOWERSAVING_H__ + -+typedef struct _Dynamic_Power_Saving_ -+{ ++typedef struct _Dynamic_Power_Saving_ { + u8 PreCCAState; + u8 CurCCAState; + + u8 PreRFState; + u8 CurRFState; + -+ int Rssi_val_min; ++ int Rssi_val_min; + + u8 initialize; -+ u32 Reg874, RegC70, Reg85C, RegA74; ++ u32 Reg874, RegC70, Reg85C, RegA74; + -+}PS_T,*pPS_T; ++} PS_T, *pPS_T; + -+#define dm_RF_Saving ODM_RF_Saving ++#define dm_RF_Saving ODM_RF_Saving + -+void ODM_RF_Saving( -+ void * pDM_VOID, -+u8 bForceInNormal -+ ); ++void ODM_RF_Saving(void *pDM_VOID, u8 bForceInNormal); + -+void -+odm_DynamicBBPowerSavingInit( -+ void * pDM_VOID -+ ); ++void odm_DynamicBBPowerSavingInit(void *pDM_VOID); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,32 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c linux/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,30 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -60145,25 +58657,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.c linux-4.3-rtl87 + +#include "odm_precomp.h" + -+void -+odm_DynamicTxPowerInit( -+ void * pDM_VOID -+ ) ++void odm_DynamicTxPowerInit(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + struct adapter *Adapter = pDM_Odm->Adapter; -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; ++ + pdmpriv->bDynamicTxPowerEnable = false; + + pdmpriv->LastDTPLvl = TxHighPwrLevel_Normal; + pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,40 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h linux/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,37 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -60198,16 +58708,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_DynamicTxPower.h linux-4.3-rtl87 +#define TxHighPwrLevel_70 8 +#define TxHighPwrLevel_100 9 + -+void -+odm_DynamicTxPowerInit( -+ void * pDM_VOID -+ ); ++void odm_DynamicTxPowerInit(void *pDM_VOID); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,187 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c linux/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,186 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -60249,7 +58756,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c linux-4.3-rtl87 + +void ODM_EdcaTurboInit(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + struct adapter *Adapter = pDM_Odm->Adapter; + + pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; @@ -60291,8 +58798,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c linux-4.3-rtl87 + +void odm_EdcaTurboCheckCE(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -+ struct adapter * Adapter = pDM_Odm->Adapter; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ struct adapter *Adapter = pDM_Odm->Adapter; + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(Adapter); + struct recv_priv *precvpriv = &(Adapter->recvpriv); + struct registry_priv *pregpriv = &Adapter->registrypriv; @@ -60389,16 +58896,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.c linux-4.3-rtl87 + /* Turn Off EDCA turbo here. */ + /* Restore original EDCA according to the declaration of AP. */ + if (pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA) { -+ rtw_write32(Adapter, REG_EDCA_BE_PARAM, -+ pHalData->AcParam_BE); ++ rtw_write32(Adapter, REG_EDCA_BE_PARAM, pHalData->AcParam_BE); + pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; + } + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,41 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h linux/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,31 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -60414,36 +58920,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_EdcaTurboCheck.h linux-4.3-rtl87 + * + ******************************************************************************/ + -+#ifndef __ODMEDCATURBOCHECK_H__ -+#define __ODMEDCATURBOCHECK_H__ ++#ifndef __ODMEDCATURBOCHECK_H__ ++#define __ODMEDCATURBOCHECK_H__ + -+typedef struct _EDCA_TURBO_ -+{ ++typedef struct _EDCA_TURBO_ { + bool bCurrentTurboEDCA; + bool bIsCurRDLState; + + u32 prv_traffic_idx; /* edca turbo */ -+}EDCA_T,*pEDCA_T; ++} EDCA_T, *pEDCA_T; + -+void -+odm_EdcaTurboCheck( -+void * pDM_VOID -+ ); -+void -+ODM_EdcaTurboInit( -+void * pDM_VOID -+); ++void odm_EdcaTurboCheck(void *pDM_VOID); ++void ODM_EdcaTurboInit(void *pDM_VOID); + -+void -+odm_EdcaTurboCheckCE( -+void * pDM_VOID -+ ); ++void odm_EdcaTurboCheckCE(void *pDM_VOID); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1558 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm.h linux/3rdparty/rtl8723bs/hal/odm.h +--- linux.old/3rdparty/rtl8723bs/hal/odm.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1465 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -60539,7 +59035,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + +/* Remove DIG by yuchen */ + -+typedef struct _Dynamic_Primary_CCA{ ++typedef struct _Dynamic_Primary_CCA { + u8 PriCCA_flag; + u8 intf_flag; + u8 intf_type; @@ -60547,14 +59043,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u8 Monitor_flag; + u8 CH_offset; + u8 MF_state; -+}Pri_CCA_T, *pPri_CCA_T; ++} Pri_CCA_T, *pPri_CCA_T; + -+typedef struct _Rate_Adaptive_Table_{ ++typedef struct _Rate_Adaptive_Table_ { + u8 firstconnect; -+}RA_T, *pRA_T; ++} RA_T, *pRA_T; + -+typedef struct _RX_High_Power_ -+{ ++typedef struct _RX_High_Power_ { + u8 RXHP_flag; + u8 PSD_func_trigger; + u8 PSD_bitmap_RXHP[80]; @@ -60562,11 +59057,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u8 Cur_IGI; + u8 Pre_pw_th; + u8 Cur_pw_th; -+ bool First_time_enter; -+ bool RXHP_enable; ++ bool First_time_enter; ++ bool RXHP_enable; + u8 TP_Mode; -+ RT_TIMER PSDTimer; -+}RXHP_T, *pRXHP_T; ++ RT_TIMER PSDTimer; ++} RXHP_T, *pRXHP_T; + +#define ASSOCIATE_ENTRY_NUM 32 /* Max size of AsocEntry[]. */ +#define ODM_ASSOCIATE_ENTRY_NUM ASSOCIATE_ENTRY_NUM @@ -60584,11 +59079,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r +#define TRAFFIC_HIGH 1 +#define TRAFFIC_UltraLOW 2 + -+typedef struct _SW_Antenna_Switch_ -+{ ++typedef struct _SW_Antenna_Switch_ { + u8 Double_chk_flag; + u8 try_flag; -+ s32 PreRSSI; ++ s32 PreRSSI; + u8 CurAntenna; + u8 PreAntenna; + u8 RSSI_Trying; @@ -60597,55 +59091,54 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u8 SelectAntennaMap; + u8 RSSI_target; + u8 reset_idx; -+ u16 Single_Ant_Counter; -+ u16 Dual_Ant_Counter; -+ u16 Aux_FailDetec_Counter; -+ u16 Retry_Counter; ++ u16 Single_Ant_Counter; ++ u16 Dual_Ant_Counter; ++ u16 Aux_FailDetec_Counter; ++ u16 Retry_Counter; + + /* Before link Antenna Switch check */ + u8 SWAS_NoLink_State; -+ u32 SWAS_NoLink_BK_Reg860; -+ u32 SWAS_NoLink_BK_Reg92c; -+ u32 SWAS_NoLink_BK_Reg948; -+ bool ANTA_ON; /* To indicate Ant A is or not */ -+ bool ANTB_ON; /* To indicate Ant B is on or not */ -+ bool Pre_Aux_FailDetec; -+ bool RSSI_AntDect_bResult; ++ u32 SWAS_NoLink_BK_Reg860; ++ u32 SWAS_NoLink_BK_Reg92c; ++ u32 SWAS_NoLink_BK_Reg948; ++ bool ANTA_ON; /* To indicate Ant A is or not */ ++ bool ANTB_ON; /* To indicate Ant B is on or not */ ++ bool Pre_Aux_FailDetec; ++ bool RSSI_AntDect_bResult; + u8 Ant5G; + u8 Ant2G; + -+ s32 RSSI_sum_A; -+ s32 RSSI_sum_B; -+ s32 RSSI_cnt_A; -+ s32 RSSI_cnt_B; ++ s32 RSSI_sum_A; ++ s32 RSSI_sum_B; ++ s32 RSSI_cnt_A; ++ s32 RSSI_cnt_B; + -+ u64 lastTxOkCnt; -+ u64 lastRxOkCnt; -+ u64 TXByteCnt_A; -+ u64 TXByteCnt_B; -+ u64 RXByteCnt_A; -+ u64 RXByteCnt_B; ++ u64 lastTxOkCnt; ++ u64 lastRxOkCnt; ++ u64 TXByteCnt_A; ++ u64 TXByteCnt_B; ++ u64 RXByteCnt_A; ++ u64 RXByteCnt_B; + u8 TrafficLoad; + u8 Train_time; + u8 Train_time_flag; -+ RT_TIMER SwAntennaSwitchTimer; -+ RT_TIMER SwAntennaSwitchTimer_8723B; -+ u32 PktCnt_SWAntDivByCtrlFrame; -+ bool bSWAntDivByCtrlFrame; -+}SWAT_T, *pSWAT_T; ++ RT_TIMER SwAntennaSwitchTimer; ++ RT_TIMER SwAntennaSwitchTimer_8723B; ++ u32 PktCnt_SWAntDivByCtrlFrame; ++ bool bSWAntDivByCtrlFrame; ++} SWAT_T, *pSWAT_T; + +/* Remove Edca by YuChen */ + + -+typedef struct _ODM_RATE_ADAPTIVE -+{ -+ u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */ -+ u8 LdpcThres; /* if RSSI > LdpcThres => switch from LPDC to BCC */ -+ bool bUseLdpc; -+ bool bLowerRtsRate; -+ u8 HighRSSIThresh; /* if RSSI > HighRSSIThresh => RATRState is DM_RATR_STA_HIGH */ -+ u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */ -+ u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_STA_LOW */ ++typedef struct _ODM_RATE_ADAPTIVE { ++ u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */ ++ u8 LdpcThres; /* if RSSI > LdpcThres => switch from LPDC to BCC */ ++ bool bUseLdpc; ++ bool bLowerRtsRate; ++ u8 HighRSSIThresh; /* if RSSI > HighRSSIThresh => RATRState is DM_RATR_STA_HIGH */ ++ u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */ ++ u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_STA_LOW */ + +} ODM_RATE_ADAPTIVE, *PODM_RATE_ADAPTIVE; + @@ -60679,8 +59172,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r +#define IQK_THRESHOLD 8 +#define DPK_THRESHOLD 4 + -+typedef struct _ODM_Phy_Status_Info_ -+{ ++typedef struct _ODM_Phy_Status_Info_ { + /* */ + /* Be care, if you want to add any element please insert between */ + /* RxPWDBAll & SignalStrength. */ @@ -60688,84 +59180,79 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u8 RxPWDBAll; + + u8 SignalQuality; /* in 0-100 index. */ -+ s8 RxMIMOSignalQuality[4]; /* per-path's EVM */ ++ s8 RxMIMOSignalQuality[4]; /* per-path's EVM */ + u8 RxMIMOEVMdbm[4]; /* per-path's EVM dbm */ + + u8 RxMIMOSignalStrength[4];/* in 0~100 index */ + -+ u16 Cfo_short[4]; /* per-path's Cfo_short */ -+ u16 Cfo_tail[4]; /* per-path's Cfo_tail */ ++ u16 Cfo_short[4]; /* per-path's Cfo_short */ ++ u16 Cfo_tail[4]; /* per-path's Cfo_tail */ + -+ s8 RxPower; /* in dBm Translate from PWdB */ -+ s8 RecvSignalPower; /* Real power in dBm for this packet, no beautification and aggregation. Keep this raw info to be used for the other procedures. */ ++ s8 RxPower; /* in dBm Translate from PWdB */ ++ s8 RecvSignalPower; /* Real power in dBm for this packet, no beautification and aggregation. Keep this raw info to be used for the other procedures. */ + u8 BTRxRSSIPercentage; + u8 SignalStrength; /* in 0-100 index. */ + -+ s8 RxPwr[4]; /* per-path's pwdb */ ++ s8 RxPwr[4]; /* per-path's pwdb */ + + u8 RxSNR[4]; /* per-path's SNR */ + u8 BandWidth; + u8 btCoexPwrAdjust; -+}ODM_PHY_INFO_T,*PODM_PHY_INFO_T; ++} ODM_PHY_INFO_T, *PODM_PHY_INFO_T; + + -+typedef struct _ODM_Per_Pkt_Info_ -+{ ++typedef struct _ODM_Per_Pkt_Info_ { + /* u8 Rate; */ + u8 DataRate; + u8 StationID; -+ bool bPacketMatchBSSID; -+ bool bPacketToSelf; -+ bool bPacketBeacon; -+ bool bToSelf; -+}ODM_PACKET_INFO_T,*PODM_PACKET_INFO_T; ++ bool bPacketMatchBSSID; ++ bool bPacketToSelf; ++ bool bPacketBeacon; ++ bool bToSelf; ++} ODM_PACKET_INFO_T, *PODM_PACKET_INFO_T; + + -+typedef struct _ODM_Phy_Dbg_Info_ -+{ ++typedef struct _ODM_Phy_Dbg_Info_ { + /* ODM Write, debug info */ -+ s8 RxSNRdB[4]; -+ u32 NumQryPhyStatus; -+ u32 NumQryPhyStatusCCK; -+ u32 NumQryPhyStatusOFDM; ++ s8 RxSNRdB[4]; ++ u32 NumQryPhyStatus; ++ u32 NumQryPhyStatusCCK; ++ u32 NumQryPhyStatusOFDM; + u8 NumQryBeaconPkt; + /* Others */ -+ s32 RxEVM[4]; ++ s32 RxEVM[4]; + -+}ODM_PHY_DBG_INFO_T; ++} ODM_PHY_DBG_INFO_T; + + -+typedef struct _ODM_Mac_Status_Info_ -+{ ++typedef struct _ODM_Mac_Status_Info_ { + u8 test; -+ -+}ODM_MAC_INFO; ++} ODM_MAC_INFO; + + -+typedef enum tag_Dynamic_ODM_Support_Ability_Type -+{ ++typedef enum tag_Dynamic_ODM_Support_Ability_Type { + /* BB Team */ + ODM_DIG = 0x00000001, + ODM_HIGH_POWER = 0x00000002, + ODM_CCK_CCA_TH = 0x00000004, -+ ODM_FA_STATISTICS = 0x00000008, ++ ODM_FA_STATISTICS = 0x00000008, + ODM_RAMASK = 0x00000010, -+ ODM_RSSI_MONITOR = 0x00000020, ++ ODM_RSSI_MONITOR = 0x00000020, + ODM_SW_ANTDIV = 0x00000040, + ODM_HW_ANTDIV = 0x00000080, -+ ODM_BB_PWRSV = 0x00000100, -+ ODM_2TPATHDIV = 0x00000200, -+ ODM_1TPATHDIV = 0x00000400, ++ ODM_BB_PWRSV = 0x00000100, ++ ODM_2TPATHDIV = 0x00000200, ++ ODM_1TPATHDIV = 0x00000400, + ODM_PSD2AFH = 0x00000800 -+}ODM_Ability_E; ++} ODM_Ability_E; + +/* */ +/* 2011/20/20 MH For MP driver RT_WLAN_STA = STA_INFO_T */ +/* Please declare below ODM relative info in your STA info structure. */ +/* */ -+typedef struct _ODM_STA_INFO{ ++typedef struct _ODM_STA_INFO { + /* Driver Write */ -+ bool bUsed; /* record the sta status link or not? */ ++ bool bUsed; /* record the sta status link or not? */ + /* u8 WirelessMode; */ + u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */ + @@ -60786,13 +59273,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + /* */ + /* ODM Write Wilson will handle this part(said by Luke.Lee) */ + /* TX_RPT_T pTxRpt; Define in IC folder. Move lower layer. */ -+}ODM_STA_INFO_T, *PODM_STA_INFO_T; ++} ODM_STA_INFO_T, *PODM_STA_INFO_T; + +/* */ +/* 2011/10/20 MH Define Common info enum for all team. */ +/* */ -+typedef enum _ODM_Common_Info_Definition -+{ ++typedef enum _ODM_Common_Info_Definition { + /* Fixed value: */ + + /* HOOK BEFORE REG INIT----------- */ @@ -60882,11 +59368,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + ODM_CMNINFO_MAX, + + -+}ODM_CMNINFO_E; ++} ODM_CMNINFO_E; + +/* 2011/10/20 MH Define ODM support ability. ODM_CMNINFO_ABILITY */ -+typedef enum _ODM_Support_Ability_Definition -+{ ++typedef enum _ODM_Support_Ability_Definition { + /* */ + /* BB ODM section BIT 0-15 */ + /* */ @@ -60912,26 +59397,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + + /* RF ODM section BIT 24-31 */ + ODM_RF_TX_PWR_TRACK = BIT24, -+ ODM_RF_RX_GAIN_TRACK = BIT25, ++ ODM_RF_RX_GAIN_TRACK = BIT25, + ODM_RF_CALIBRATION = BIT26, -+}ODM_ABILITY_E; ++} ODM_ABILITY_E; + +/* ODM_CMNINFO_INTERFACE */ -+typedef enum tag_ODM_Support_Interface_Definition -+{ ++typedef enum tag_ODM_Support_Interface_Definition { + ODM_ITRF_SDIO = 0x4, + ODM_ITRF_ALL = 0x7, -+}ODM_INTERFACE_E; ++} ODM_INTERFACE_E; + +/* ODM_CMNINFO_IC_TYPE */ -+typedef enum tag_ODM_Support_IC_Type_Definition -+{ ++typedef enum tag_ODM_Support_IC_Type_Definition { + ODM_RTL8723B = BIT8, -+}ODM_IC_TYPE_E; ++} ODM_IC_TYPE_E; + +/* ODM_CMNINFO_CUT_VER */ -+typedef enum tag_ODM_Cut_Version_Definition -+{ ++typedef enum tag_ODM_Cut_Version_Definition { + ODM_CUT_A = 0, + ODM_CUT_B = 1, + ODM_CUT_C = 2, @@ -60943,21 +59425,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + ODM_CUT_J = 9, + ODM_CUT_K = 10, + ODM_CUT_TEST = 15, -+}ODM_CUT_VERSION_E; ++} ODM_CUT_VERSION_E; + +/* ODM_CMNINFO_FAB_VER */ -+typedef enum tag_ODM_Fab_Version_Definition -+{ ++typedef enum tag_ODM_Fab_Version_Definition { + ODM_TSMC = 0, + ODM_UMC = 1, -+}ODM_FAB_E; ++} ODM_FAB_E; + +/* ODM_CMNINFO_RF_TYPE */ +/* */ +/* For example 1T2R (A+AB = BIT0|BIT4|BIT5) */ +/* */ -+typedef enum tag_ODM_RF_Path_Bit_Definition -+{ ++typedef enum tag_ODM_RF_Path_Bit_Definition { + ODM_RF_TX_A = BIT0, + ODM_RF_TX_B = BIT1, + ODM_RF_TX_C = BIT2, @@ -60966,11 +59446,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + ODM_RF_RX_B = BIT5, + ODM_RF_RX_C = BIT6, + ODM_RF_RX_D = BIT7, -+}ODM_RF_PATH_E; ++} ODM_RF_PATH_E; + + -+typedef enum tag_ODM_RF_Type_Definition -+{ ++typedef enum tag_ODM_RF_Type_Definition { + ODM_1T1R = 0, + ODM_1T2R = 1, + ODM_2T2R = 2, @@ -60979,7 +59458,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + ODM_3T3R = 5, + ODM_3T4R = 6, + ODM_4T4R = 7, -+}ODM_RF_TYPE_E; ++} ODM_RF_TYPE_E; + + +/* */ @@ -60992,154 +59471,137 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r +/* DUALMAC_SINGLEPHY, */ +/* MACPHY_MODE_8192D,*PMACPHY_MODE_8192D; */ +/* Above is the original define in MP driver. Please use the same define. THX. */ -+typedef enum tag_ODM_MAC_PHY_Mode_Definition -+{ ++typedef enum tag_ODM_MAC_PHY_Mode_Definition { + ODM_SMSP = 0, + ODM_DMSP = 1, + ODM_DMDP = 2, -+}ODM_MAC_PHY_MODE_E; ++} ODM_MAC_PHY_MODE_E; + + -+typedef enum tag_BT_Coexist_Definition -+{ ++typedef enum tag_BT_Coexist_Definition { + ODM_BT_BUSY = 1, -+ ODM_BT_ON = 2, ++ ODM_BT_ON = 2, + ODM_BT_OFF = 3, + ODM_BT_NONE = 4, -+}ODM_BT_COEXIST_E; ++} ODM_BT_COEXIST_E; + +/* ODM_CMNINFO_OP_MODE */ -+typedef enum tag_Operation_Mode_Definition -+{ -+ ODM_NO_LINK = BIT0, -+ ODM_LINK = BIT1, -+ ODM_SCAN = BIT2, -+ ODM_POWERSAVE = BIT3, -+ ODM_AP_MODE = BIT4, -+ ODM_CLIENT_MODE = BIT5, -+ ODM_AD_HOC = BIT6, -+ ODM_WIFI_DIRECT = BIT7, -+ ODM_WIFI_DISPLAY = BIT8, -+}ODM_OPERATION_MODE_E; ++typedef enum tag_Operation_Mode_Definition { ++ ODM_NO_LINK = BIT0, ++ ODM_LINK = BIT1, ++ ODM_SCAN = BIT2, ++ ODM_POWERSAVE = BIT3, ++ ODM_AP_MODE = BIT4, ++ ODM_CLIENT_MODE = BIT5, ++ ODM_AD_HOC = BIT6, ++ ODM_WIFI_DIRECT = BIT7, ++ ODM_WIFI_DISPLAY = BIT8, ++} ODM_OPERATION_MODE_E; + +/* ODM_CMNINFO_WM_MODE */ -+typedef enum tag_Wireless_Mode_Definition -+{ -+ ODM_WM_UNKNOW = 0x0, -+ ODM_WM_B = BIT0, -+ ODM_WM_G = BIT1, -+ ODM_WM_A = BIT2, -+ ODM_WM_N24G = BIT3, -+ ODM_WM_N5G = BIT4, -+ ODM_WM_AUTO = BIT5, -+ ODM_WM_AC = BIT6, -+}ODM_WIRELESS_MODE_E; ++typedef enum tag_Wireless_Mode_Definition { ++ ODM_WM_UNKNOW = 0x0, ++ ODM_WM_B = BIT0, ++ ODM_WM_G = BIT1, ++ ODM_WM_A = BIT2, ++ ODM_WM_N24G = BIT3, ++ ODM_WM_N5G = BIT4, ++ ODM_WM_AUTO = BIT5, ++ ODM_WM_AC = BIT6, ++} ODM_WIRELESS_MODE_E; + +/* ODM_CMNINFO_BAND */ -+typedef enum tag_Band_Type_Definition -+{ -+ ODM_BAND_2_4G = 0, -+ ODM_BAND_5G, -+ ODM_BAND_ON_BOTH, -+ ODM_BANDMAX -+ -+}ODM_BAND_TYPE_E; ++typedef enum tag_Band_Type_Definition { ++ ODM_BAND_2_4G = 0, ++ ODM_BAND_5G, ++ ODM_BAND_ON_BOTH, ++ ODM_BANDMAX ++} ODM_BAND_TYPE_E; + +/* ODM_CMNINFO_SEC_CHNL_OFFSET */ -+typedef enum tag_Secondary_Channel_Offset_Definition -+{ ++typedef enum tag_Secondary_Channel_Offset_Definition { + ODM_DONT_CARE = 0, + ODM_BELOW = 1, -+ ODM_ABOVE = 2 -+}ODM_SEC_CHNL_OFFSET_E; ++ ODM_ABOVE = 2 ++} ODM_SEC_CHNL_OFFSET_E; + +/* ODM_CMNINFO_SEC_MODE */ -+typedef enum tag_Security_Definition -+{ -+ ODM_SEC_OPEN = 0, ++typedef enum tag_Security_Definition { ++ ODM_SEC_OPEN = 0, + ODM_SEC_WEP40 = 1, -+ ODM_SEC_TKIP = 2, -+ ODM_SEC_RESERVE = 3, -+ ODM_SEC_AESCCMP = 4, ++ ODM_SEC_TKIP = 2, ++ ODM_SEC_RESERVE = 3, ++ ODM_SEC_AESCCMP = 4, + ODM_SEC_WEP104 = 5, -+ ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */ -+ ODM_SEC_SMS4 = 7, -+}ODM_SECURITY_E; ++ ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */ ++ ODM_SEC_SMS4 = 7, ++} ODM_SECURITY_E; + +/* ODM_CMNINFO_BW */ -+typedef enum tag_Bandwidth_Definition -+{ ++typedef enum tag_Bandwidth_Definition { + ODM_BW20M = 0, + ODM_BW40M = 1, + ODM_BW80M = 2, + ODM_BW160M = 3, + ODM_BW10M = 4, -+}ODM_BW_E; ++} ODM_BW_E; + + +/* ODM_CMNINFO_BOARD_TYPE */ +/* For non-AC-series IC , ODM_BOARD_5G_EXT_PA and ODM_BOARD_5G_EXT_LNA are ignored */ +/* For AC-series IC, external PA & LNA can be indivisuallly added on 2.4G and/or 5G */ -+typedef enum tag_Board_Definition -+{ -+ ODM_BOARD_DEFAULT = 0, /* The DEFAULT case. */ -+ ODM_BOARD_MINICARD = BIT(0), /* 0 = non-mini card, 1 = mini card. */ -+ ODM_BOARD_SLIM = BIT(1), /* 0 = non-slim card, 1 = slim card */ -+ ODM_BOARD_BT = BIT(2), /* 0 = without BT card, 1 = with BT */ -+ ODM_BOARD_EXT_PA = BIT(3), /* 0 = no 2G ext-PA, 1 = existing 2G ext-PA */ -+ ODM_BOARD_EXT_LNA = BIT(4), /* 0 = no 2G ext-LNA, 1 = existing 2G ext-LNA */ -+ ODM_BOARD_EXT_TRSW = BIT(5), /* 0 = no ext-TRSW, 1 = existing ext-TRSW */ -+ ODM_BOARD_EXT_PA_5G = BIT(6), /* 0 = no 5G ext-PA, 1 = existing 5G ext-PA */ -+ ODM_BOARD_EXT_LNA_5G = BIT(7), /* 0 = no 5G ext-LNA, 1 = existing 5G ext-LNA */ -+}ODM_BOARD_TYPE_E; ++typedef enum tag_Board_Definition { ++ ODM_BOARD_DEFAULT = 0, /* The DEFAULT case. */ ++ ODM_BOARD_MINICARD = BIT(0), /* 0 = non-mini card, 1 = mini card. */ ++ ODM_BOARD_SLIM = BIT(1), /* 0 = non-slim card, 1 = slim card */ ++ ODM_BOARD_BT = BIT(2), /* 0 = without BT card, 1 = with BT */ ++ ODM_BOARD_EXT_PA = BIT(3), /* 0 = no 2G ext-PA, 1 = existing 2G ext-PA */ ++ ODM_BOARD_EXT_LNA = BIT(4), /* 0 = no 2G ext-LNA, 1 = existing 2G ext-LNA */ ++ ODM_BOARD_EXT_TRSW = BIT(5), /* 0 = no ext-TRSW, 1 = existing ext-TRSW */ ++ ODM_BOARD_EXT_PA_5G = BIT(6), /* 0 = no 5G ext-PA, 1 = existing 5G ext-PA */ ++ ODM_BOARD_EXT_LNA_5G = BIT(7), /* 0 = no 5G ext-LNA, 1 = existing 5G ext-LNA */ ++} ODM_BOARD_TYPE_E; + -+typedef enum tag_ODM_Package_Definition -+{ -+ ODM_PACKAGE_DEFAULT = 0, -+ ODM_PACKAGE_QFN68 = BIT(0), -+ ODM_PACKAGE_TFBGA90 = BIT(1), -+ ODM_PACKAGE_TFBGA79 = BIT(2), -+}ODM_Package_TYPE_E; ++typedef enum tag_ODM_Package_Definition { ++ ODM_PACKAGE_DEFAULT = 0, ++ ODM_PACKAGE_QFN68 = BIT(0), ++ ODM_PACKAGE_TFBGA90 = BIT(1), ++ ODM_PACKAGE_TFBGA79 = BIT(2), ++} ODM_Package_TYPE_E; + -+typedef enum tag_ODM_TYPE_GPA_Definition -+{ -+ TYPE_GPA0 = 0, -+ TYPE_GPA1 = BIT(1)|BIT(0) -+}ODM_TYPE_GPA_E; ++typedef enum tag_ODM_TYPE_GPA_Definition { ++ TYPE_GPA0 = 0, ++ TYPE_GPA1 = BIT(1)|BIT(0) ++} ODM_TYPE_GPA_E; + -+typedef enum tag_ODM_TYPE_APA_Definition -+{ -+ TYPE_APA0 = 0, -+ TYPE_APA1 = BIT(1)|BIT(0) -+}ODM_TYPE_APA_E; ++typedef enum tag_ODM_TYPE_APA_Definition { ++ TYPE_APA0 = 0, ++ TYPE_APA1 = BIT(1)|BIT(0) ++} ODM_TYPE_APA_E; + -+typedef enum tag_ODM_TYPE_GLNA_Definition -+{ -+ TYPE_GLNA0 = 0, -+ TYPE_GLNA1 = BIT(2)|BIT(0), -+ TYPE_GLNA2 = BIT(3)|BIT(1), -+ TYPE_GLNA3 = BIT(3)|BIT(2)|BIT(1)|BIT(0) -+}ODM_TYPE_GLNA_E; ++typedef enum tag_ODM_TYPE_GLNA_Definition { ++ TYPE_GLNA0 = 0, ++ TYPE_GLNA1 = BIT(2)|BIT(0), ++ TYPE_GLNA2 = BIT(3)|BIT(1), ++ TYPE_GLNA3 = BIT(3)|BIT(2)|BIT(1)|BIT(0) ++} ODM_TYPE_GLNA_E; + -+typedef enum tag_ODM_TYPE_ALNA_Definition -+{ -+ TYPE_ALNA0 = 0, -+ TYPE_ALNA1 = BIT(2)|BIT(0), -+ TYPE_ALNA2 = BIT(3)|BIT(1), -+ TYPE_ALNA3 = BIT(3)|BIT(2)|BIT(1)|BIT(0) -+}ODM_TYPE_ALNA_E; ++typedef enum tag_ODM_TYPE_ALNA_Definition { ++ TYPE_ALNA0 = 0, ++ TYPE_ALNA1 = BIT(2)|BIT(0), ++ TYPE_ALNA2 = BIT(3)|BIT(1), ++ TYPE_ALNA3 = BIT(3)|BIT(2)|BIT(1)|BIT(0) ++} ODM_TYPE_ALNA_E; + +/* ODM_CMNINFO_ONE_PATH_CCA */ -+typedef enum tag_CCA_Path -+{ ++typedef enum tag_CCA_Path { + ODM_CCA_2R = 0, + ODM_CCA_1R_A = 1, + ODM_CCA_1R_B = 2, -+}ODM_CCA_PATH_E; ++} ODM_CCA_PATH_E; + + -+typedef struct _ODM_RA_Info_ -+{ ++typedef struct _ODM_RA_Info_ { + u8 RateID; + u32 RateMask; + u32 RAUseRate; @@ -61169,26 +59631,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u8 PTModeSS; /* decide whitch rate should do PT */ + u8 RAstage; /* StageRA, decide how many times RA will be done between PT */ + u8 PTSmoothFactor; -+} ODM_RA_INFO_T,*PODM_RA_INFO_T; ++} ODM_RA_INFO_T, *PODM_RA_INFO_T; + -+typedef struct _IQK_MATRIX_REGS_SETTING{ -+ bool bIQKDone; -+ s32 Value[3][IQK_Matrix_REG_NUM]; -+ bool bBWIqkResultSaved[3]; -+}IQK_MATRIX_REGS_SETTING,*PIQK_MATRIX_REGS_SETTING; ++typedef struct _IQK_MATRIX_REGS_SETTING { ++ bool bIQKDone; ++ s32 Value[3][IQK_Matrix_REG_NUM]; ++ bool bBWIqkResultSaved[3]; ++} IQK_MATRIX_REGS_SETTING, *PIQK_MATRIX_REGS_SETTING; + + +/* Remove PATHDIV_PARA struct to odm_PathDiv.h */ + -+typedef struct ODM_RF_Calibration_Structure -+{ ++typedef struct ODM_RF_Calibration_Structure { + /* for tx power tracking */ + + u32 RegA24; /* for TempCCK */ -+ s32 RegE94; -+ s32 RegE9C; -+ s32 RegEB4; -+ s32 RegEBC; ++ s32 RegE94; ++ s32 RegE9C; ++ s32 RegEB4; ++ s32 RegEBC; + + u8 TXPowercount; + bool bTXPowerTrackingInit; @@ -61208,9 +59669,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u8 ThermalValue_Crystal; + u8 ThermalValue_DPKstore; + u8 ThermalValue_DPKtrack; -+ bool TxPowerTrackingInProgress; ++ bool TxPowerTrackingInProgress; + -+ bool bReloadtxpowerindex; ++ bool bReloadtxpowerindex; + u8 bRfPiEnable; + u32 TXPowerTrackingCallbackCnt; /* cosa add for debug */ + @@ -61219,33 +59680,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u8 bCCKinCH14; + u8 CCK_index; + u8 OFDM_index[MAX_RF_PATH]; -+ s8 PowerIndexOffset[MAX_RF_PATH]; -+ s8 DeltaPowerIndex[MAX_RF_PATH]; -+ s8 DeltaPowerIndexLast[MAX_RF_PATH]; ++ s8 PowerIndexOffset[MAX_RF_PATH]; ++ s8 DeltaPowerIndex[MAX_RF_PATH]; ++ s8 DeltaPowerIndexLast[MAX_RF_PATH]; + bool bTxPowerChanged; + + u8 ThermalValue_HP[HP_THERMAL_NUM]; + u8 ThermalValue_HP_index; + IQK_MATRIX_REGS_SETTING IQKMatrixRegSetting[IQK_Matrix_Settings_NUM]; -+ bool bNeedIQK; -+ bool bIQKInProgress; ++ bool bNeedIQK; ++ bool bIQKInProgress; + u8 Delta_IQK; + u8 Delta_LCK; -+ s8 BBSwingDiff2G, BBSwingDiff5G; /* Unit: dB */ -+ u8 DeltaSwingTableIdx_2GCCKA_P[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GCCKA_N[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GCCKB_P[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GCCKB_N[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GA_P[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GA_N[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GB_P[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GB_N[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_5GA_P[BAND_NUM][DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_5GA_N[BAND_NUM][DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_5GB_P[BAND_NUM][DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_5GB_N[BAND_NUM][DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GA_P_8188E[DELTA_SWINGIDX_SIZE]; -+ u8 DeltaSwingTableIdx_2GA_N_8188E[DELTA_SWINGIDX_SIZE]; ++ s8 BBSwingDiff2G, BBSwingDiff5G; /* Unit: dB */ ++ u8 DeltaSwingTableIdx_2GCCKA_P[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GCCKA_N[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GCCKB_P[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GCCKB_N[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GA_P[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GA_N[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GB_P[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GB_N[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_5GA_P[BAND_NUM][DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_5GA_N[BAND_NUM][DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_5GB_P[BAND_NUM][DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_5GB_N[BAND_NUM][DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GA_P_8188E[DELTA_SWINGIDX_SIZE]; ++ u8 DeltaSwingTableIdx_2GA_N_8188E[DELTA_SWINGIDX_SIZE]; + + /* */ + @@ -61259,9 +59720,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u32 Reg860; + u32 Reg864; + -+ bool bIQKInitialized; ++ bool bIQKInitialized; + bool bLCKInProgress; -+ bool bAntennaDetected; ++ bool bAntennaDetected; + u32 ADDA_backup[IQK_ADDA_REG_NUM]; + u32 IQK_MAC_backup[IQK_MAC_REG_NUM]; + u32 IQK_BB_backup_recover[9]; @@ -61283,13 +59744,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + + u32 TxLOK[2]; + -+}ODM_RF_CAL_T,*PODM_RF_CAL_T; ++} ODM_RF_CAL_T, *PODM_RF_CAL_T; +/* */ +/* ODM Dynamic common info value definition */ +/* */ + -+typedef struct _FAST_ANTENNA_TRAINNING_ -+{ ++typedef struct _FAST_ANTENNA_TRAINNING_ { + u8 Bssid[6]; + u8 antsel_rx_keep_0; + u8 antsel_rx_keep_1; @@ -61313,31 +59773,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + u8 idx_AntDiv_counter_2G; + u8 idx_AntDiv_counter_5G; + u32 AntDiv_2G_5G; -+ u32 CCK_counter_main; -+ u32 CCK_counter_aux; -+ u32 OFDM_counter_main; -+ u32 OFDM_counter_aux; ++ u32 CCK_counter_main; ++ u32 CCK_counter_aux; ++ u32 OFDM_counter_main; ++ u32 OFDM_counter_aux; + + -+ u32 CCK_CtrlFrame_Cnt_main; -+ u32 CCK_CtrlFrame_Cnt_aux; -+ u32 OFDM_CtrlFrame_Cnt_main; -+ u32 OFDM_CtrlFrame_Cnt_aux; ++ u32 CCK_CtrlFrame_Cnt_main; ++ u32 CCK_CtrlFrame_Cnt_aux; ++ u32 OFDM_CtrlFrame_Cnt_main; ++ u32 OFDM_CtrlFrame_Cnt_aux; + u32 MainAnt_CtrlFrame_Sum; + u32 AuxAnt_CtrlFrame_Sum; + u32 MainAnt_CtrlFrame_Cnt; + u32 AuxAnt_CtrlFrame_Cnt; + -+}FAT_T,*pFAT_T; ++} FAT_T, *pFAT_T; + -+typedef enum _FAT_STATE -+{ ++typedef enum _FAT_STATE { + FAT_NORMAL_STATE = 0, + FAT_TRAINING_STATE = 1, -+}FAT_STATE_E, *PFAT_STATE_E; ++} FAT_STATE_E, *PFAT_STATE_E; + -+typedef enum _ANT_DIV_TYPE -+{ ++typedef enum _ANT_DIV_TYPE { + NO_ANTDIV = 0xFF, + CG_TRX_HW_ANTDIV = 0x01, + CGCS_RX_HW_ANTDIV = 0x02, @@ -61345,17 +59803,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + CG_TRX_SMART_ANTDIV = 0x04, + CGCS_RX_SW_ANTDIV = 0x05, + S0S1_SW_ANTDIV = 0x06 /* 8723B intrnal switch S0 S1 */ -+}ANT_DIV_TYPE_E, *PANT_DIV_TYPE_E; ++} ANT_DIV_TYPE_E, *PANT_DIV_TYPE_E; + -+typedef struct _ODM_PATH_DIVERSITY_ -+{ ++typedef struct _ODM_PATH_DIVERSITY_ { + u8 RespTxPath; + u8 PathSel[ODM_ASSOCIATE_ENTRY_NUM]; + u32 PathA_Sum[ODM_ASSOCIATE_ENTRY_NUM]; + u32 PathB_Sum[ODM_ASSOCIATE_ENTRY_NUM]; + u32 PathA_Cnt[ODM_ASSOCIATE_ENTRY_NUM]; + u32 PathB_Cnt[ODM_ASSOCIATE_ENTRY_NUM]; -+}PATHDIV_T, *pPATHDIV_T; ++} PATHDIV_T, *pPATHDIV_T; + + +typedef enum _BASEBAND_CONFIG_PHY_REG_PG_VALUE_TYPE{ @@ -61367,42 +59824,41 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r +/* */ +/* Antenna detection information from single tone mechanism, added by Roger, 2012.11.27. */ +/* */ -+typedef struct _ANT_DETECTED_INFO{ -+ bool bAntDetected; -+ u32 dBForAntA; -+ u32 dBForAntB; -+ u32 dBForAntO; -+}ANT_DETECTED_INFO, *PANT_DETECTED_INFO; ++typedef struct _ANT_DETECTED_INFO { ++ bool bAntDetected; ++ u32 dBForAntA; ++ u32 dBForAntB; ++ u32 dBForAntO; ++} ANT_DETECTED_INFO, *PANT_DETECTED_INFO; + +/* */ +/* 2011/09/22 MH Copy from SD4 defined structure. We use to support PHY DM integration. */ +/* */ -+typedef struct DM_Out_Source_Dynamic_Mechanism_Structure -+{ ++typedef struct DM_Out_Source_Dynamic_Mechanism_Structure { + /* RT_TIMER FastAntTrainingTimer; */ + /* */ + /* Add for different team use temporarily */ + /* */ -+ struct adapter * Adapter; /* For CE/NIC team */ ++ struct adapter *Adapter; /* For CE/NIC team */ + /* WHen you use Adapter or priv pointer, you must make sure the pointer is ready. */ -+ bool odm_ready; ++ bool odm_ready; + -+ PHY_REG_PG_TYPE PhyRegPgValueType; -+ u8 PhyRegPgVersion; ++ PHY_REG_PG_TYPE PhyRegPgValueType; ++ u8 PhyRegPgVersion; + -+ u64 DebugComponents; -+ u32 DebugLevel; ++ u64 DebugComponents; ++ u32 DebugLevel; + -+ u32 NumQryPhyStatusAll; /* CCK + OFDM */ -+ u32 LastNumQryPhyStatusAll; -+ u32 RxPWDBAve; -+ bool MPDIG_2G; /* off MPDIG */ -+ u8 Times_2G; ++ u32 NumQryPhyStatusAll; /* CCK + OFDM */ ++ u32 LastNumQryPhyStatusAll; ++ u32 RxPWDBAve; ++ bool MPDIG_2G; /* off MPDIG */ ++ u8 Times_2G; + +/* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ -+ bool bCckHighPower; -+ u8 RFPathRxEnable; /* ODM_CMNINFO_RFPATH_ENABLE */ -+ u8 ControlChannel; ++ bool bCckHighPower; ++ u8 RFPathRxEnable; /* ODM_CMNINFO_RFPATH_ENABLE */ ++ u8 ControlChannel; +/* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ + +/* REMOVED COMMON INFO---------- */ @@ -61424,42 +59880,42 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + /* */ +/* HOOK BEFORE REG INIT----------- */ + /* ODM Platform info AP/ADSL/CE/MP = 1/2/3/4 */ -+ u8 SupportPlatform; ++ u8 SupportPlatform; + /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/ ?K?K = 1/2/3/?K */ -+ u32 SupportAbility; ++ u32 SupportAbility; + /* ODM PCIE/USB/SDIO = 1/2/3 */ -+ u8 SupportInterface; ++ u8 SupportInterface; + /* ODM composite or independent. Bit oriented/ 92C+92D+ .... or any other type = 1/2/3/... */ -+ u32 SupportICType; ++ u32 SupportICType; + /* Cut Version TestChip/A-cut/B-cut... = 0/1/2/3/... */ -+ u8 CutVersion; ++ u8 CutVersion; + /* Fab Version TSMC/UMC = 0/1 */ -+ u8 FabVersion; ++ u8 FabVersion; + /* RF Type 4T4R/3T3R/2T2R/1T2R/1T1R/... */ -+ u8 RFType; -+ u8 RFEType; ++ u8 RFType; ++ u8 RFEType; + /* Board Type Normal/HighPower/MiniCard/SLIM/Combo/... = 0/1/2/3/4/... */ -+ u8 BoardType; -+ u8 PackageType; -+ u8 TypeGLNA; -+ u8 TypeGPA; -+ u8 TypeALNA; -+ u8 TypeAPA; ++ u8 BoardType; ++ u8 PackageType; ++ u8 TypeGLNA; ++ u8 TypeGPA; ++ u8 TypeALNA; ++ u8 TypeAPA; + /* with external LNA NO/Yes = 0/1 */ -+ u8 ExtLNA; -+ u8 ExtLNA5G; ++ u8 ExtLNA; ++ u8 ExtLNA5G; + /* with external PA NO/Yes = 0/1 */ -+ u8 ExtPA; -+ u8 ExtPA5G; ++ u8 ExtPA; ++ u8 ExtPA5G; + /* with external TRSW NO/Yes = 0/1 */ -+ u8 ExtTRSW; -+ u8 PatchID; /* Customer ID */ -+ bool bInHctTest; -+ bool bWIFITest; ++ u8 ExtTRSW; ++ u8 PatchID; /* Customer ID */ ++ bool bInHctTest; ++ bool bWIFITest; + -+ bool bDualMacSmartConcurrent; -+ u32 BK_SupportAbility; -+ u8 AntDivType; ++ bool bDualMacSmartConcurrent; ++ u32 BK_SupportAbility; ++ u8 AntDivType; +/* HOOK BEFORE REG INIT----------- */ + + /* */ @@ -61467,126 +59923,126 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + /* */ +/* POINTER REFERENCE----------- */ + -+ u8 u8_temp; -+ bool bool_temp; ++ u8 u8_temp; ++ bool bool_temp; + struct adapter *adapter_temp; + + /* MAC PHY Mode SMSP/DMSP/DMDP = 0/1/2 */ -+ u8 *pMacPhyMode; ++ u8 *pMacPhyMode; + /* TX Unicast byte count */ -+ u64 *pNumTxBytesUnicast; ++ u64 *pNumTxBytesUnicast; + /* RX Unicast byte count */ -+ u64 *pNumRxBytesUnicast; ++ u64 *pNumRxBytesUnicast; + /* Wireless mode B/G/A/N = BIT0/BIT1/BIT2/BIT3 */ -+ u8 *pwirelessmode; /* ODM_WIRELESS_MODE_E */ ++ u8 *pwirelessmode; /* ODM_WIRELESS_MODE_E */ + /* Frequence band 2.4G/5G = 0/1 */ -+ u8 *pBandType; ++ u8 *pBandType; + /* Secondary channel offset don't_care/below/above = 0/1/2 */ -+ u8 *pSecChOffset; ++ u8 *pSecChOffset; + /* Security mode Open/WEP/AES/TKIP = 0/1/2/3 */ -+ u8 *pSecurity; ++ u8 *pSecurity; + /* BW info 20M/40M/80M = 0/1/2 */ -+ u8 *pBandWidth; ++ u8 *pBandWidth; + /* Central channel location Ch1/Ch2/.... */ -+ u8 *pChannel; /* central channel number */ -+ bool DPK_Done; ++ u8 *pChannel; /* central channel number */ ++ bool DPK_Done; + /* Common info for 92D DMSP */ + -+ bool *pbGetValueFromOtherMac; -+ struct adapter * *pBuddyAdapter; -+ bool *pbMasterOfDMSP; /* MAC0: master, MAC1: slave */ ++ bool *pbGetValueFromOtherMac; ++ struct adapter **pBuddyAdapter; ++ bool *pbMasterOfDMSP; /* MAC0: master, MAC1: slave */ + /* Common info for Status */ -+ bool *pbScanInProcess; -+ bool *pbPowerSaving; ++ bool *pbScanInProcess; ++ bool *pbPowerSaving; + /* CCA Path 2-path/path-A/path-B = 0/1/2; using ODM_CCA_PATH_E. */ -+ u8 *pOnePathCCA; ++ u8 *pOnePathCCA; + /* pMgntInfo->AntennaTest */ -+ u8 *pAntennaTest; -+ bool *pbNet_closed; -+ u8 *mp_mode; ++ u8 *pAntennaTest; ++ bool *pbNet_closed; ++ u8 *mp_mode; + /* u8 *pAidMap; */ -+ u8 *pu1ForcedIgiLb; ++ u8 *pu1ForcedIgiLb; +/* For 8723B IQK----------- */ -+ bool *pIs1Antenna; -+ u8 *pRFDefaultPath; ++ bool *pIs1Antenna; ++ u8 *pRFDefaultPath; + /* 0:S1, 1:S0 */ + +/* POINTER REFERENCE----------- */ -+ u16 * pForcedDataRate; ++ u16 *pForcedDataRate; +/* CALL BY VALUE------------- */ -+ bool bLinkInProcess; -+ bool bWIFI_Direct; -+ bool bWIFI_Display; -+ bool bLinked; ++ bool bLinkInProcess; ++ bool bWIFI_Direct; ++ bool bWIFI_Display; ++ bool bLinked; + -+ bool bsta_state; -+ u8 RSSI_Min; -+ u8 InterfaceIndex; /* Add for 92D dual MAC: 0--Mac0 1--Mac1 */ -+ bool bIsMPChip; -+ bool bOneEntryOnly; ++ bool bsta_state; ++ u8 RSSI_Min; ++ u8 InterfaceIndex; /* Add for 92D dual MAC: 0--Mac0 1--Mac1 */ ++ bool bIsMPChip; ++ bool bOneEntryOnly; + /* Common info for BTDM */ -+ bool bBtEnabled; /* BT is disabled */ -+ bool bBtConnectProcess; /* BT HS is under connection progress. */ -+ u8 btHsRssi; /* BT HS mode wifi rssi value. */ -+ bool bBtHsOperation; /* BT HS mode is under progress */ -+ bool bBtDisableEdcaTurbo; /* Under some condition, don't enable the EDCA Turbo */ -+ bool bBtLimitedDig; /* BT is busy. */ ++ bool bBtEnabled; /* BT is disabled */ ++ bool bBtConnectProcess; /* BT HS is under connection progress. */ ++ u8 btHsRssi; /* BT HS mode wifi rssi value. */ ++ bool bBtHsOperation; /* BT HS mode is under progress */ ++ bool bBtDisableEdcaTurbo; /* Under some condition, don't enable the EDCA Turbo */ ++ bool bBtLimitedDig; /* BT is busy. */ +/* CALL BY VALUE------------- */ -+ u8 RSSI_A; -+ u8 RSSI_B; -+ u64 RSSI_TRSW; -+ u64 RSSI_TRSW_H; -+ u64 RSSI_TRSW_L; -+ u64 RSSI_TRSW_iso; ++ u8 RSSI_A; ++ u8 RSSI_B; ++ u64 RSSI_TRSW; ++ u64 RSSI_TRSW_H; ++ u64 RSSI_TRSW_L; ++ u64 RSSI_TRSW_iso; + -+ u8 RxRate; -+ bool bNoisyState; -+ u8 TxRate; -+ u8 LinkedInterval; -+ u8 preChannel; -+ u32 TxagcOffsetValueA; -+ bool IsTxagcOffsetPositiveA; -+ u32 TxagcOffsetValueB; -+ bool IsTxagcOffsetPositiveB; -+ u64 lastTxOkCnt; -+ u64 lastRxOkCnt; -+ u32 BbSwingOffsetA; -+ bool IsBbSwingOffsetPositiveA; -+ u32 BbSwingOffsetB; -+ bool IsBbSwingOffsetPositiveB; -+ s8 TH_L2H_ini; -+ s8 TH_EDCCA_HL_diff; -+ s8 IGI_Base; -+ u8 IGI_target; -+ bool ForceEDCCA; -+ u8 AdapEn_RSSI; -+ s8 Force_TH_H; -+ s8 Force_TH_L; -+ u8 IGI_LowerBound; -+ u8 antdiv_rssi; -+ u8 AntType; -+ u8 pre_AntType; -+ u8 antdiv_period; -+ u8 antdiv_select; -+ u8 NdpaPeriod; -+ bool H2C_RARpt_connect; ++ u8 RxRate; ++ bool bNoisyState; ++ u8 TxRate; ++ u8 LinkedInterval; ++ u8 preChannel; ++ u32 TxagcOffsetValueA; ++ bool IsTxagcOffsetPositiveA; ++ u32 TxagcOffsetValueB; ++ bool IsTxagcOffsetPositiveB; ++ u64 lastTxOkCnt; ++ u64 lastRxOkCnt; ++ u32 BbSwingOffsetA; ++ bool IsBbSwingOffsetPositiveA; ++ u32 BbSwingOffsetB; ++ bool IsBbSwingOffsetPositiveB; ++ s8 TH_L2H_ini; ++ s8 TH_EDCCA_HL_diff; ++ s8 IGI_Base; ++ u8 IGI_target; ++ bool ForceEDCCA; ++ u8 AdapEn_RSSI; ++ s8 Force_TH_H; ++ s8 Force_TH_L; ++ u8 IGI_LowerBound; ++ u8 antdiv_rssi; ++ u8 AntType; ++ u8 pre_AntType; ++ u8 antdiv_period; ++ u8 antdiv_select; ++ u8 NdpaPeriod; ++ bool H2C_RARpt_connect; + + /* add by Yu Cehn for adaptivtiy */ -+ bool adaptivity_flag; -+ bool NHM_disable; -+ bool TxHangFlg; -+ bool Carrier_Sense_enable; -+ u8 tolerance_cnt; -+ u64 NHMCurTxOkcnt; -+ u64 NHMCurRxOkcnt; -+ u64 NHMLastTxOkcnt; -+ u64 NHMLastRxOkcnt; -+ u8 txEdcca1; -+ u8 txEdcca0; -+ s8 H2L_lb; -+ s8 L2H_lb; -+ u8 Adaptivity_IGI_upper; -+ u8 NHM_cnt_0; ++ bool adaptivity_flag; ++ bool NHM_disable; ++ bool TxHangFlg; ++ bool Carrier_Sense_enable; ++ u8 tolerance_cnt; ++ u64 NHMCurTxOkcnt; ++ u64 NHMCurRxOkcnt; ++ u64 NHMLastTxOkcnt; ++ u64 NHMLastRxOkcnt; ++ u8 txEdcca1; ++ u8 txEdcca0; ++ s8 H2L_lb; ++ s8 L2H_lb; ++ u8 Adaptivity_IGI_upper; ++ u8 NHM_cnt_0; + + + ODM_NOISE_MONITOR noise_level;/* ODM_MAX_CHANNEL_NUM]; */ @@ -61594,22 +60050,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + /* 2 Define STA info. */ + /* _ODM_STA_INFO */ + /* 2012/01/12 MH For MP, we need to reduce one array pointer for default port.?? */ -+ PSTA_INFO_T pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM]; ++ PSTA_INFO_T pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM]; + + /* */ + /* 2012/02/14 MH Add to share 88E ra with other SW team. */ + /* We need to colelct all support abilit to a proper area. */ + /* */ -+ bool RaSupport88E; ++ bool RaSupport88E; + + /* Define ........... */ + + /* Latest packet phy info (ODM write) */ -+ ODM_PHY_DBG_INFO_T PhyDbgInfo; ++ ODM_PHY_DBG_INFO_T PhyDbgInfo; + /* PHY_INFO_88E PhyInfo; */ + + /* Latest packet phy info (ODM write) */ -+ ODM_MAC_INFO *pMacInfo; ++ ODM_MAC_INFO *pMacInfo; + /* MAC_INFO_88E MacInfo; */ + + /* Different Team independt structure?? */ @@ -61622,21 +60078,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + /* */ + /* ODM Structure */ + /* */ -+ FAT_T DM_FatTable; -+ DIG_T DM_DigTable; -+ PS_T DM_PSTable; -+ Pri_CCA_T DM_PriCCA; -+ RXHP_T DM_RXHP_Table; -+ RA_T DM_RA_Table; -+ false_ALARM_STATISTICS FalseAlmCnt; -+ false_ALARM_STATISTICS FlaseAlmCntBuddyAdapter; -+ SWAT_T DM_SWAT_Table; -+ bool RSSI_test; -+ CFO_TRACKING DM_CfoTrack; ++ FAT_T DM_FatTable; ++ DIG_T DM_DigTable; ++ PS_T DM_PSTable; ++ Pri_CCA_T DM_PriCCA; ++ RXHP_T DM_RXHP_Table; ++ RA_T DM_RA_Table; ++ false_ALARM_STATISTICS FalseAlmCnt; ++ false_ALARM_STATISTICS FlaseAlmCntBuddyAdapter; ++ SWAT_T DM_SWAT_Table; ++ bool RSSI_test; ++ CFO_TRACKING DM_CfoTrack; + -+ EDCA_T DM_EDCA_Table; -+ u32 WMMEDCA_BE; -+ PATHDIV_T DM_PathDiv; ++ EDCA_T DM_EDCA_Table; ++ u32 WMMEDCA_BE; ++ PATHDIV_T DM_PathDiv; + /* Copy from SD4 structure */ + /* */ + /* ================================================== */ @@ -61653,126 +60109,126 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + /* u8 AntDivCfg; 0:OFF , 1:ON, 2:by efuse */ + /* PSTA_INFO_T RSSI_target; */ + -+ bool *pbDriverStopped; -+ bool *pbDriverIsGoingToPnpSetPowerSleep; -+ bool *pinit_adpt_in_progress; ++ bool *pbDriverStopped; ++ bool *pbDriverIsGoingToPnpSetPowerSleep; ++ bool *pinit_adpt_in_progress; + + /* PSD */ -+ bool bUserAssignLevel; -+ RT_TIMER PSDTimer; -+ u8 RSSI_BT; /* come from BT */ -+ bool bPSDinProcess; -+ bool bPSDactive; -+ bool bDMInitialGainEnable; ++ bool bUserAssignLevel; ++ RT_TIMER PSDTimer; ++ u8 RSSI_BT; /* come from BT */ ++ bool bPSDinProcess; ++ bool bPSDactive; ++ bool bDMInitialGainEnable; + + /* MPT DIG */ -+ RT_TIMER MPT_DIGTimer; ++ RT_TIMER MPT_DIGTimer; + + /* for rate adaptive, in fact, 88c/92c fw will handle this */ -+ u8 bUseRAMask; ++ u8 bUseRAMask; + -+ ODM_RATE_ADAPTIVE RateAdaptive; ++ ODM_RATE_ADAPTIVE RateAdaptive; + -+ ANT_DETECTED_INFO AntDetectedInfo; /* Antenna detected information for RSSI tool */ ++ ANT_DETECTED_INFO AntDetectedInfo; /* Antenna detected information for RSSI tool */ + -+ ODM_RF_CAL_T RFCalibrateInfo; ++ ODM_RF_CAL_T RFCalibrateInfo; + + /* */ + /* TX power tracking */ + /* */ -+ u8 BbSwingIdxOfdm[MAX_RF_PATH]; -+ u8 BbSwingIdxOfdmCurrent; -+ u8 BbSwingIdxOfdmBase[MAX_RF_PATH]; -+ bool BbSwingFlagOfdm; -+ u8 BbSwingIdxCck; -+ u8 BbSwingIdxCckCurrent; -+ u8 BbSwingIdxCckBase; -+ u8 DefaultOfdmIndex; -+ u8 DefaultCckIndex; -+ bool BbSwingFlagCck; ++ u8 BbSwingIdxOfdm[MAX_RF_PATH]; ++ u8 BbSwingIdxOfdmCurrent; ++ u8 BbSwingIdxOfdmBase[MAX_RF_PATH]; ++ bool BbSwingFlagOfdm; ++ u8 BbSwingIdxCck; ++ u8 BbSwingIdxCckCurrent; ++ u8 BbSwingIdxCckBase; ++ u8 DefaultOfdmIndex; ++ u8 DefaultCckIndex; ++ bool BbSwingFlagCck; + -+ s8 Absolute_OFDMSwingIdx[MAX_RF_PATH]; -+ s8 Remnant_OFDMSwingIdx[MAX_RF_PATH]; -+ s8 Remnant_CCKSwingIdx; -+ s8 Modify_TxAGC_Value; /* Remnat compensate value at TxAGC */ -+ bool Modify_TxAGC_Flag_PathA; -+ bool Modify_TxAGC_Flag_PathB; -+ bool Modify_TxAGC_Flag_PathC; -+ bool Modify_TxAGC_Flag_PathD; -+ bool Modify_TxAGC_Flag_PathA_CCK; ++ s8 Absolute_OFDMSwingIdx[MAX_RF_PATH]; ++ s8 Remnant_OFDMSwingIdx[MAX_RF_PATH]; ++ s8 Remnant_CCKSwingIdx; ++ s8 Modify_TxAGC_Value; /* Remnat compensate value at TxAGC */ ++ bool Modify_TxAGC_Flag_PathA; ++ bool Modify_TxAGC_Flag_PathB; ++ bool Modify_TxAGC_Flag_PathC; ++ bool Modify_TxAGC_Flag_PathD; ++ bool Modify_TxAGC_Flag_PathA_CCK; + -+ s8 KfreeOffset[MAX_RF_PATH]; ++ s8 KfreeOffset[MAX_RF_PATH]; + /* */ + /* ODM system resource. */ + /* */ + + /* ODM relative time. */ -+ RT_TIMER PathDivSwitchTimer; ++ RT_TIMER PathDivSwitchTimer; + /* 2011.09.27 add for Path Diversity */ -+ RT_TIMER CCKPathDiversityTimer; -+ RT_TIMER FastAntTrainingTimer; ++ RT_TIMER CCKPathDiversityTimer; ++ RT_TIMER FastAntTrainingTimer; + + /* ODM relative workitem. */ + + #if (BEAMFORMING_SUPPORT == 1) + RT_BEAMFORMING_INFO BeamformingInfo; + #endif -+} DM_ODM_T, *PDM_ODM_T; /* DM_Dynamic_Mechanism_Structure */ ++} DM_ODM_T, *PDM_ODM_T; /* DM_Dynamic_Mechanism_Structure */ + +#define ODM_RF_PATH_MAX 2 + +typedef enum _ODM_RF_RADIO_PATH { -+ ODM_RF_PATH_A = 0, /* Radio Path A */ -+ ODM_RF_PATH_B = 1, /* Radio Path B */ -+ ODM_RF_PATH_C = 2, /* Radio Path C */ -+ ODM_RF_PATH_D = 3, /* Radio Path D */ -+ ODM_RF_PATH_AB, -+ ODM_RF_PATH_AC, -+ ODM_RF_PATH_AD, -+ ODM_RF_PATH_BC, -+ ODM_RF_PATH_BD, -+ ODM_RF_PATH_CD, -+ ODM_RF_PATH_ABC, -+ ODM_RF_PATH_ACD, -+ ODM_RF_PATH_BCD, -+ ODM_RF_PATH_ABCD, -+ /* ODM_RF_PATH_MAX, Max RF number 90 support */ ++ ODM_RF_PATH_A = 0, /* Radio Path A */ ++ ODM_RF_PATH_B = 1, /* Radio Path B */ ++ ODM_RF_PATH_C = 2, /* Radio Path C */ ++ ODM_RF_PATH_D = 3, /* Radio Path D */ ++ ODM_RF_PATH_AB, ++ ODM_RF_PATH_AC, ++ ODM_RF_PATH_AD, ++ ODM_RF_PATH_BC, ++ ODM_RF_PATH_BD, ++ ODM_RF_PATH_CD, ++ ODM_RF_PATH_ABC, ++ ODM_RF_PATH_ACD, ++ ODM_RF_PATH_BCD, ++ ODM_RF_PATH_ABCD, ++ /* ODM_RF_PATH_MAX, Max RF number 90 support */ +} ODM_RF_RADIO_PATH_E, *PODM_RF_RADIO_PATH_E; + -+ typedef enum _ODM_RF_CONTENT{ ++ typedef enum _ODM_RF_CONTENT { + odm_radioa_txt = 0x1000, + odm_radiob_txt = 0x1001, + odm_radioc_txt = 0x1002, + odm_radiod_txt = 0x1003 +} ODM_RF_CONTENT; + -+typedef enum _ODM_BB_Config_Type{ -+ CONFIG_BB_PHY_REG, -+ CONFIG_BB_AGC_TAB, -+ CONFIG_BB_AGC_TAB_2G, -+ CONFIG_BB_AGC_TAB_5G, -+ CONFIG_BB_PHY_REG_PG, -+ CONFIG_BB_PHY_REG_MP, -+ CONFIG_BB_AGC_TAB_DIFF, ++typedef enum _ODM_BB_Config_Type { ++ CONFIG_BB_PHY_REG, ++ CONFIG_BB_AGC_TAB, ++ CONFIG_BB_AGC_TAB_2G, ++ CONFIG_BB_AGC_TAB_5G, ++ CONFIG_BB_PHY_REG_PG, ++ CONFIG_BB_PHY_REG_MP, ++ CONFIG_BB_AGC_TAB_DIFF, +} ODM_BB_Config_Type, *PODM_BB_Config_Type; + -+typedef enum _ODM_RF_Config_Type{ ++typedef enum _ODM_RF_Config_Type { + CONFIG_RF_RADIO, -+ CONFIG_RF_TXPWR_LMT, ++ CONFIG_RF_TXPWR_LMT, +} ODM_RF_Config_Type, *PODM_RF_Config_Type; + -+typedef enum _ODM_FW_Config_Type{ -+ CONFIG_FW_NIC, -+ CONFIG_FW_NIC_2, -+ CONFIG_FW_AP, -+ CONFIG_FW_WoWLAN, -+ CONFIG_FW_WoWLAN_2, -+ CONFIG_FW_AP_WoWLAN, -+ CONFIG_FW_BT, ++typedef enum _ODM_FW_Config_Type { ++ CONFIG_FW_NIC, ++ CONFIG_FW_NIC_2, ++ CONFIG_FW_AP, ++ CONFIG_FW_WoWLAN, ++ CONFIG_FW_WoWLAN_2, ++ CONFIG_FW_AP_WoWLAN, ++ CONFIG_FW_BT, +} ODM_FW_Config_Type; + +/* Status code */ -+typedef enum _RT_STATUS{ ++typedef enum _RT_STATUS { + RT_STATUS_SUCCESS, + RT_STATUS_FAILURE, + RT_STATUS_PENDING, @@ -61781,7 +60237,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + RT_STATUS_INVALID_PARAMETER, + RT_STATUS_NOT_SUPPORT, + RT_STATUS_OS_API_FAILED, -+}RT_STATUS,*PRT_STATUS; ++} RT_STATUS, *PRT_STATUS; + +#ifdef REMOVE_PACK +#pragma pack() @@ -61822,36 +60278,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r +/* 3 =========================================================== */ +#define DM_RATR_STA_INIT 0 +#define DM_RATR_STA_HIGH 1 -+#define DM_RATR_STA_MIDDLE 2 -+#define DM_RATR_STA_LOW 3 ++#define DM_RATR_STA_MIDDLE 2 ++#define DM_RATR_STA_LOW 3 + +/* 3 =========================================================== */ +/* 3 BB Power Save */ +/* 3 =========================================================== */ + -+typedef enum tag_1R_CCA_Type_Definition -+{ ++typedef enum tag_1R_CCA_Type_Definition { + CCA_1R = 0, + CCA_2R = 1, + CCA_MAX = 2, -+}DM_1R_CCA_E; ++} DM_1R_CCA_E; + -+typedef enum tag_RF_Type_Definition -+{ ++typedef enum tag_RF_Type_Definition { + RF_Save = 0, + RF_Normal = 1, + RF_MAX = 2, -+}DM_RF_E; ++} DM_RF_E; + +/* 3 =========================================================== */ +/* 3 Antenna Diversity */ +/* 3 =========================================================== */ -+typedef enum tag_SW_Antenna_Switch_Definition -+{ ++typedef enum tag_SW_Antenna_Switch_Definition { + Antenna_A = 1, + Antenna_B = 2, + Antenna_MAX = 3, -+}DM_SWAS_E; ++} DM_SWAS_E; + + +/* Maximal number of antenna detection mechanism needs to perform, added by Roger, 2011.12.28. */ @@ -61862,11 +60315,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r +/* */ +extern u32 OFDMSwingTable[OFDM_TABLE_SIZE]; +extern u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8]; -+extern u8 CCKSwingTable_Ch14 [CCK_TABLE_SIZE][8]; ++extern u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8]; + +extern u32 OFDMSwingTable_New[OFDM_TABLE_SIZE]; +extern u8 CCKSwingTable_Ch1_Ch13_New[CCK_TABLE_SIZE][8]; -+extern u8 CCKSwingTable_Ch14_New [CCK_TABLE_SIZE][8]; ++extern u8 CCKSwingTable_Ch14_New[CCK_TABLE_SIZE][8]; + +extern u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE]; + @@ -61884,128 +60337,78 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm.h linux-4.3-rtl8723bs/3rdparty/r + +/* Remove DIG by yuchen */ + -+void -+ODM_SetAntenna( -+PDM_ODM_T pDM_Odm, -+u8 Antenna); ++void ODM_SetAntenna(PDM_ODM_T pDM_Odm, u8 Antenna); + + +/* Remove BB power saving by Yuchen */ + -+#define dm_CheckTXPowerTracking ODM_TXPowerTrackingCheck -+void -+ODM_TXPowerTrackingCheck( -+ PDM_ODM_T pDM_Odm -+ ); ++#define dm_CheckTXPowerTracking ODM_TXPowerTrackingCheck ++void ODM_TXPowerTrackingCheck(PDM_ODM_T pDM_Odm); + -+bool -+ODM_RAStateCheck( -+ PDM_ODM_T pDM_Odm, -+ s32 RSSI, -+ bool bForceUpdate, -+ u8 * pRATRState -+ ); ++bool ODM_RAStateCheck( ++ PDM_ODM_T pDM_Odm, ++ s32 RSSI, ++ bool bForceUpdate, ++ u8 *pRATRState ++); + +#define dm_SWAW_RSSI_Check ODM_SwAntDivChkPerPktRssi +void ODM_SwAntDivChkPerPktRssi( -+ PDM_ODM_T pDM_Odm, -+ u8 StationID, ++ PDM_ODM_T pDM_Odm, ++ u8 StationID, + PODM_PHY_INFO_T pPhyInfo -+ ); ++); + +u32 ODM_Get_Rate_Bitmap( -+ PDM_ODM_T pDM_Odm, -+ u32 macid, -+ u32 ra_mask, -+ u8 rssi_level); ++ PDM_ODM_T pDM_Odm, ++ u32 macid, ++ u32 ra_mask, ++ u8 rssi_level ++); + +#if (BEAMFORMING_SUPPORT == 1) -+BEAMFORMING_CAP -+Beamforming_GetEntryBeamCapByMacId( -+ PMGNT_INFO pMgntInfo, -+ u8 MacId -+); ++BEAMFORMING_CAP Beamforming_GetEntryBeamCapByMacId(PMGNT_INFO pMgntInfo, u8 MacId); +#endif + -+void -+odm_TXPowerTrackingInit( -+ PDM_ODM_T pDM_Odm -+ ); ++void odm_TXPowerTrackingInit(PDM_ODM_T pDM_Odm); + -+void -+ODM_DMInit( -+ PDM_ODM_T pDM_Odm ++void ODM_DMInit(PDM_ODM_T pDM_Odm); ++ ++void ODM_DMWatchdog(PDM_ODM_T pDM_Odm); /* For common use in the future */ ++ ++void ODM_CmnInfoInit(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, u32 Value); ++ ++void ODM_CmnInfoHook(PDM_ODM_T pDM_Odm, ODM_CMNINFO_E CmnInfo, void *pValue); ++ ++void ODM_CmnInfoPtrArrayHook( ++ PDM_ODM_T pDM_Odm, ++ ODM_CMNINFO_E CmnInfo, ++ u16 Index, ++ void *pValue +); + -+void -+ODM_DMWatchdog( -+ PDM_ODM_T pDM_Odm /* For common use in the future */ -+ ); ++void ODM_CmnInfoUpdate(PDM_ODM_T pDM_Odm, u32 CmnInfo, u64 Value); + -+void -+ODM_CmnInfoInit( -+ PDM_ODM_T pDM_Odm, -+ ODM_CMNINFO_E CmnInfo, -+ u32 Value -+ ); ++void ODM_InitAllTimers(PDM_ODM_T pDM_Odm); + -+void -+ODM_CmnInfoHook( -+ PDM_ODM_T pDM_Odm, -+ ODM_CMNINFO_E CmnInfo, -+ void * pValue -+ ); ++void ODM_CancelAllTimers(PDM_ODM_T pDM_Odm); + -+void -+ODM_CmnInfoPtrArrayHook( -+ PDM_ODM_T pDM_Odm, -+ ODM_CMNINFO_E CmnInfo, -+ u16 Index, -+ void * pValue -+ ); ++void ODM_ReleaseAllTimers(PDM_ODM_T pDM_Odm); + -+void -+ODM_CmnInfoUpdate( -+ PDM_ODM_T pDM_Odm, -+ u32 CmnInfo, -+ u64 Value -+ ); -+ -+void -+ODM_InitAllTimers( -+ PDM_ODM_T pDM_Odm -+ ); -+ -+void -+ODM_CancelAllTimers( -+ PDM_ODM_T pDM_Odm -+ ); -+ -+void -+ODM_ReleaseAllTimers( -+ PDM_ODM_T pDM_Odm -+ ); -+ -+void -+ODM_AntselStatistics_88C( -+ PDM_ODM_T pDM_Odm, -+ u8 MacId, -+ u32 PWDBAll, -+ bool isCCKrate ++void ODM_AntselStatistics_88C( ++ PDM_ODM_T pDM_Odm, ++ u8 MacId, ++ u32 PWDBAll, ++ bool isCCKrate +); + -+void -+ODM_DynamicARFBSelect( -+ PDM_ODM_T pDM_Odm, -+ u8 rate, -+ bool Collision_State -+ ); ++void ODM_DynamicARFBSelect(PDM_ODM_T pDM_Odm, u8 rate, bool Collision_State); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_HWConfig.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_HWConfig.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,608 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux/3rdparty/rtl8723bs/hal/odm_HWConfig.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_HWConfig.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_HWConfig.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,535 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -62025,88 +60428,52 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + +#define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig_MP_##ic##txt(pDM_Odm)) +#define READ_AND_CONFIG READ_AND_CONFIG_MP -+#define GET_VERSION_MP(ic, txt) (ODM_GetVersion_MP_##ic##txt()) ++#define GET_VERSION_MP(ic, txt) (ODM_GetVersion_MP_##ic##txt()) +#define GET_VERSION(ic, txt) (pDM_Odm->bIsMPChip?GET_VERSION_MP(ic, txt):GET_VERSION_TC(ic, txt)) + -+static u8 -+odm_QueryRxPwrPercentage( -+ s8 AntPower -+ ) ++static u8 odm_QueryRxPwrPercentage(s8 AntPower) +{ + if ((AntPower <= -100) || (AntPower >= 20)) -+ { + return 0; -+ } + else if (AntPower >= 0) -+ { + return 100; -+ } + else -+ { + return (100+AntPower); -+ } + +} + -+static s32 -+odm_SignalScaleMapping_92CSeries( -+ PDM_ODM_T pDM_Odm, -+ s32 CurrSig -+) ++static s32 odm_SignalScaleMapping_92CSeries(PDM_ODM_T pDM_Odm, s32 CurrSig) +{ + s32 RetSig = 0; + -+ if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO) -+ { ++ if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO) { + if (CurrSig >= 51 && CurrSig <= 100) -+ { + RetSig = 100; -+ } + else if (CurrSig >= 41 && CurrSig <= 50) -+ { + RetSig = 80 + ((CurrSig - 40)*2); -+ } + else if (CurrSig >= 31 && CurrSig <= 40) -+ { + RetSig = 66 + (CurrSig - 30); -+ } + else if (CurrSig >= 21 && CurrSig <= 30) -+ { + RetSig = 54 + (CurrSig - 20); -+ } + else if (CurrSig >= 10 && CurrSig <= 20) -+ { + RetSig = 42 + (((CurrSig - 10) * 2) / 3); -+ } + else if (CurrSig >= 5 && CurrSig <= 9) -+ { + RetSig = 22 + (((CurrSig - 5) * 3) / 2); -+ } + else if (CurrSig >= 1 && CurrSig <= 4) -+ { + RetSig = 6 + (((CurrSig - 1) * 3) / 2); -+ } + else -+ { + RetSig = CurrSig; -+ } + } + + return RetSig; +} -+s32 -+odm_SignalScaleMapping( -+ PDM_ODM_T pDM_Odm, -+s32 CurrSig -+) ++ ++s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig) +{ + return odm_SignalScaleMapping_92CSeries(pDM_Odm, CurrSig); +} + -+static u8 -+odm_EVMdbToPercentage( -+ s8 Value -+ ) ++static u8 odm_EVMdbToPercentage(s8 Value) +{ + /* */ + /* -33dB~0dB to 0%~99% */ @@ -62125,33 +60492,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + ret_val = -33; + + ret_val = 0 - ret_val; -+ ret_val*=3; ++ ret_val *= 3; + + if (ret_val == 99) + ret_val = 100; + -+ return(ret_val); ++ return ret_val; +} + -+static void -+odm_RxPhyStatus92CSeries_Parsing( -+ PDM_ODM_T pDM_Odm, -+ PODM_PHY_INFO_T pPhyInfo, -+ u8 * pPhyStatus, -+ PODM_PACKET_INFO_T pPktinfo -+ ) ++static void odm_RxPhyStatus92CSeries_Parsing( ++ PDM_ODM_T pDM_Odm, ++ PODM_PHY_INFO_T pPhyInfo, ++ u8 *pPhyStatus, ++ PODM_PACKET_INFO_T pPktinfo ++) +{ -+ u8 i, Max_spatial_stream; -+ s8 rx_pwr[4], rx_pwr_all = 0; -+ u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; -+ u8 RSSI, total_rssi = 0; -+ bool isCCKrate =false; -+ u8 rf_rx_num = 0; -+ u8 cck_highpwr = 0; -+ u8 LNA_idx, VGA_idx; ++ u8 i, Max_spatial_stream; ++ s8 rx_pwr[4], rx_pwr_all = 0; ++ u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; ++ u8 RSSI, total_rssi = 0; ++ bool isCCKrate = false; ++ u8 rf_rx_num = 0; ++ u8 cck_highpwr = 0; ++ u8 LNA_idx, VGA_idx; + PPHY_STATUS_RPT_8192CD_T pPhyStaRpt = (PPHY_STATUS_RPT_8192CD_T)pPhyStatus; + -+ isCCKrate = (pPktinfo->DataRate <= DESC_RATE11M)?true :false; ++ isCCKrate = (pPktinfo->DataRate <= DESC_RATE11M) ? true : false; + pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = -1; + pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1; + @@ -62168,18 +60534,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + /* if (pHalData->eRFPowerState == eRfOn) */ + cck_highpwr = pDM_Odm->bCckHighPower; + /* else */ -+ /* cck_highpwr = false; */ ++ /* cck_highpwr = false; */ + + cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a ; + + /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */ + /* The RSSI formula should be modified according to the gain table */ + /* In 88E, cck_highpwr is always set to 1 */ -+ LNA_idx = ((cck_agc_rpt & 0xE0) >>5); ++ LNA_idx = ((cck_agc_rpt & 0xE0)>>5); + VGA_idx = (cck_agc_rpt & 0x1F); + rx_pwr_all = odm_CCKRSSI_8723B(LNA_idx, VGA_idx); + PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); -+ if (PWDB_ALL>100) ++ if (PWDB_ALL > 100) + PWDB_ALL = 100; + + pPhyInfo->RxPWDBAll = PWDB_ALL; @@ -62192,9 +60558,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + { + u8 SQ, SQ_rpt; + -+ if (pPhyInfo->RxPWDBAll > 40 && !pDM_Odm->bInHctTest) { ++ if (pPhyInfo->RxPWDBAll > 40 && !pDM_Odm->bInHctTest) + SQ = 100; -+ } + else { + SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all; + @@ -62212,9 +60577,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = SQ; + pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1; + } -+ } -+ else /* is OFDM rate */ -+ { ++ } else { /* is OFDM rate */ + pDM_Odm->PhyDbgInfo.NumQryPhyStatusOFDM++; + + /* */ @@ -62228,7 +60591,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + /* else */ + /* continue; */ + -+ rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain& 0x3F)*2) - 110; ++ rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain&0x3F)*2) - 110; + + + pPhyInfo->RxPwr[i] = rx_pwr[i]; @@ -62238,7 +60601,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + total_rssi += RSSI; + /* RT_DISP(FRX, RX_PHY_SS, ("RF-%d RXPWR =%x RSSI =%d\n", i, rx_pwr[i], RSSI)); */ + -+ pPhyInfo->RxMIMOSignalStrength[i] =(u8) RSSI; ++ pPhyInfo->RxMIMOSignalStrength[i] = (u8) RSSI; + + /* Get Rx snr value in DB */ + pPhyInfo->RxSNR[i] = pDM_Odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); @@ -62248,7 +60611,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + /* */ + /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ + /* */ -+ rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1)& 0x7f) -110; ++ rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1)&0x7f)-110; + + PWDB_ALL_BT = PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + /* RT_DISP(FRX, RX_PHY_SS, ("PWDB_ALL =%d\n", PWDB_ALL)); */ @@ -62263,13 +60626,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + /* */ + /* (3)EVM of HT rate */ + /* */ -+ if (pPktinfo->DataRate >=DESC_RATEMCS8 && pPktinfo->DataRate <=DESC_RATEMCS15) ++ if (pPktinfo->DataRate >= DESC_RATEMCS8 && pPktinfo->DataRate <= DESC_RATEMCS15) + Max_spatial_stream = 2; /* both spatial stream make sense */ + else + Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ + -+ for (i = 0; i>= 1" because the compilor of free build environment */ + /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ + /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ @@ -62280,10 +60642,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + + /* if (pPktinfo->bPacketMatchBSSID) */ + { -+ if (i ==ODM_RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ -+ { ++ if (i == ODM_RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ + pPhyInfo->SignalQuality = (u8)(EVM & 0xff); -+ } ++ + pPhyInfo->RxMIMOSignalQuality[i] = (u8)(EVM & 0xff); + } + } @@ -62295,23 +60656,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + + /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */ + /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */ -+ if (isCCKrate) -+ { ++ if (isCCKrate) { +#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING + pPhyInfo->SignalStrength = (u8)PWDB_ALL; +#else + pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(pDM_Odm, PWDB_ALL));/* PWDB_ALL; */ +#endif -+ } -+ else -+ { -+ if (rf_rx_num != 0) -+ { ++ } else { ++ if (rf_rx_num != 0) { +#ifdef CONFIG_SKIP_SIGNAL_SCALE_MAPPING -+ total_rssi/=rf_rx_num; ++ total_rssi /= rf_rx_num; + pPhyInfo->SignalStrength = (u8)total_rssi; +#else -+ pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(pDM_Odm, total_rssi/=rf_rx_num)); ++ pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(pDM_Odm, total_rssi /= rf_rx_num)); +#endif + } + } @@ -62320,20 +60677,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + /* isCCKrate, pPhyInfo->RxPWDBAll, pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a); */ +} + -+static void -+odm_Process_RSSIForDM( -+ PDM_ODM_T pDM_Odm, -+ PODM_PHY_INFO_T pPhyInfo, -+ PODM_PACKET_INFO_T pPktinfo -+ ) ++static void odm_Process_RSSIForDM( ++ PDM_ODM_T pDM_Odm, PODM_PHY_INFO_T pPhyInfo, PODM_PACKET_INFO_T pPktinfo ++) +{ + -+ s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK, UndecoratedSmoothedOFDM, RSSI_Ave; -+ u8 isCCKrate = 0; -+ u8 RSSI_max, RSSI_min, i; -+ u32 OFDM_pkt = 0; -+ u32 Weighting = 0; -+ PSTA_INFO_T pEntry; ++ s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK, UndecoratedSmoothedOFDM, RSSI_Ave; ++ u8 isCCKrate = 0; ++ u8 RSSI_max, RSSI_min, i; ++ u32 OFDM_pkt = 0; ++ u32 Weighting = 0; ++ PSTA_INFO_T pEntry; + + + if (pPktinfo->StationID == 0xFF) @@ -62341,13 +60695,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + + pEntry = pDM_Odm->pODM_StaInfo[pPktinfo->StationID]; + -+ if (!IS_STA_VALID(pEntry)) { ++ if (!IS_STA_VALID(pEntry)) + return; -+ } ++ + if ((!pPktinfo->bPacketMatchBSSID)) -+ { + return; -+ } + + if (pPktinfo->bPacketBeacon) + pDM_Odm->PhyDbgInfo.NumQryBeaconPkt++; @@ -62356,48 +60708,45 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + pDM_Odm->RxRate = pPktinfo->DataRate; + + /* Statistic for antenna/path diversity------------------ */ -+ if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) -+ { ++ if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) { ++ + } + + /* Smart Antenna Debug Message------------------ */ + -+ UndecoratedSmoothedCCK = pEntry->rssi_stat.UndecoratedSmoothedCCK; ++ UndecoratedSmoothedCCK = pEntry->rssi_stat.UndecoratedSmoothedCCK; + UndecoratedSmoothedOFDM = pEntry->rssi_stat.UndecoratedSmoothedOFDM; + UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB; + -+ if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) -+ { ++ if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { + -+ if (!isCCKrate)/* ofdm rate */ -+ { ++ if (!isCCKrate) { /* ofdm rate */ + if (pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B] == 0) { + RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + pDM_Odm->RSSI_A = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + pDM_Odm->RSSI_B = 0; -+ } -+ else -+ { ++ } else { + /* DbgPrint("pRfd->Status.RxMIMOSignalStrength[0] = %d, pRfd->Status.RxMIMOSignalStrength[1] = %d\n", */ + /* pRfd->Status.RxMIMOSignalStrength[0], pRfd->Status.RxMIMOSignalStrength[1]); */ + pDM_Odm->RSSI_A = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + pDM_Odm->RSSI_B = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]; + -+ if (pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A] > pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]) -+ { ++ if ( ++ pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A] > ++ pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B] ++ ) { + RSSI_max = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + RSSI_min = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]; -+ } -+ else -+ { ++ } else { + RSSI_max = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]; + RSSI_min = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + } -+ if ((RSSI_max -RSSI_min) < 3) ++ ++ if ((RSSI_max-RSSI_min) < 3) + RSSI_Ave = RSSI_max; -+ else if ((RSSI_max -RSSI_min) < 6) ++ else if ((RSSI_max-RSSI_min) < 6) + RSSI_Ave = RSSI_max - 1; -+ else if ((RSSI_max -RSSI_min) < 10) ++ else if ((RSSI_max-RSSI_min) < 10) + RSSI_Ave = RSSI_max - 2; + else + RSSI_Ave = RSSI_max - 3; @@ -62405,54 +60754,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + + /* 1 Process OFDM RSSI */ + if (UndecoratedSmoothedOFDM <= 0) /* initialize */ -+ { + UndecoratedSmoothedOFDM = pPhyInfo->RxPWDBAll; -+ } -+ else -+ { -+ if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedOFDM) -+ { ++ else { ++ if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedOFDM) { + UndecoratedSmoothedOFDM = -+ (((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) + -+ (RSSI_Ave)) /(Rx_Smooth_Factor); ++ ((UndecoratedSmoothedOFDM*(Rx_Smooth_Factor-1)) + ++ RSSI_Ave)/Rx_Smooth_Factor; + UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1; -+ } -+ else -+ { ++ } else { + UndecoratedSmoothedOFDM = -+ (((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) + -+ (RSSI_Ave)) /(Rx_Smooth_Factor); ++ ((UndecoratedSmoothedOFDM*(Rx_Smooth_Factor-1)) + ++ RSSI_Ave)/Rx_Smooth_Factor; + } + } + + pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT0; + -+ } -+ else -+ { ++ } else { + RSSI_Ave = pPhyInfo->RxPWDBAll; + pDM_Odm->RSSI_A = (u8) pPhyInfo->RxPWDBAll; + pDM_Odm->RSSI_B = 0; + + /* 1 Process CCK RSSI */ + if (UndecoratedSmoothedCCK <= 0) /* initialize */ -+ { + UndecoratedSmoothedCCK = pPhyInfo->RxPWDBAll; -+ } -+ else -+ { -+ if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedCCK) -+ { ++ else { ++ if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedCCK) { + UndecoratedSmoothedCCK = -+ (((UndecoratedSmoothedCCK)*(Rx_Smooth_Factor-1)) + -+ (pPhyInfo->RxPWDBAll)) /(Rx_Smooth_Factor); ++ ((UndecoratedSmoothedCCK*(Rx_Smooth_Factor-1)) + ++ pPhyInfo->RxPWDBAll)/Rx_Smooth_Factor; + UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1; -+ } -+ else -+ { ++ } else { + UndecoratedSmoothedCCK = -+ (((UndecoratedSmoothedCCK)*(Rx_Smooth_Factor-1)) + -+ (pPhyInfo->RxPWDBAll)) /(Rx_Smooth_Factor); ++ ((UndecoratedSmoothedCCK*(Rx_Smooth_Factor-1)) + ++ pPhyInfo->RxPWDBAll)/Rx_Smooth_Factor; + } + } + pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap<<1; @@ -62466,16 +60801,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + else + pEntry->rssi_stat.ValidBit++; + -+ for (i = 0; irssi_stat.ValidBit; i++) ++ for (i = 0; i < pEntry->rssi_stat.ValidBit; i++) + OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i)&BIT0; + -+ if (pEntry->rssi_stat.ValidBit == 64) -+ { ++ if (pEntry->rssi_stat.ValidBit == 64) { + Weighting = ((OFDM_pkt<<4) > 64)?64:(OFDM_pkt<<4); + UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6; -+ } -+ else -+ { ++ } else { + if (pEntry->rssi_stat.ValidBit != 0) + UndecoratedSmoothedPWDB = (OFDM_pkt*UndecoratedSmoothedOFDM+(pEntry->rssi_stat.ValidBit-OFDM_pkt)*UndecoratedSmoothedCCK)/pEntry->rssi_stat.ValidBit; + else @@ -62488,7 +60820,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + + /* DbgPrint("OFDM_pkt =%d, Weighting =%d\n", OFDM_pkt, Weighting); */ + /* DbgPrint("UndecoratedSmoothedOFDM =%d, UndecoratedSmoothedPWDB =%d, UndecoratedSmoothedCCK =%d\n", */ -+ /* UndecoratedSmoothedOFDM, UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK); */ ++ /* UndecoratedSmoothedOFDM, UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK); */ + + } + @@ -62499,32 +60831,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 +/* */ +/* Endianness before calling this API */ +/* */ -+static void -+ODM_PhyStatusQuery_92CSeries( -+ PDM_ODM_T pDM_Odm, -+ PODM_PHY_INFO_T pPhyInfo, -+ u8 * pPhyStatus, -+ PODM_PACKET_INFO_T pPktinfo -+ ) ++static void ODM_PhyStatusQuery_92CSeries( ++ PDM_ODM_T pDM_Odm, ++ PODM_PHY_INFO_T pPhyInfo, ++ u8 *pPhyStatus, ++ PODM_PACKET_INFO_T pPktinfo ++) +{ + -+ odm_RxPhyStatus92CSeries_Parsing( -+ pDM_Odm, -+ pPhyInfo, -+ pPhyStatus, -+ pPktinfo); ++ odm_RxPhyStatus92CSeries_Parsing(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo); + + if (!pDM_Odm->RSSI_test) + odm_Process_RSSIForDM(pDM_Odm, pPhyInfo, pPktinfo); +} + -+void -+ODM_PhyStatusQuery( -+ PDM_ODM_T pDM_Odm, -+ PODM_PHY_INFO_T pPhyInfo, -+ u8 * pPhyStatus, -+ PODM_PACKET_INFO_T pPktinfo -+ ) ++void ODM_PhyStatusQuery( ++ PDM_ODM_T pDM_Odm, ++ PODM_PHY_INFO_T pPhyInfo, ++ u8 *pPhyStatus, ++ PODM_PACKET_INFO_T pPktinfo ++) +{ + + ODM_PhyStatusQuery_92CSeries(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo); @@ -62535,12 +60861,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 +/* */ +/* */ + -+HAL_STATUS -+ODM_ConfigRFWithHeaderFile( -+PDM_ODM_T pDM_Odm, -+ODM_RF_Config_Type ConfigType, -+ODM_RF_RADIO_PATH_E eRFPath -+ ) ++HAL_STATUS ODM_ConfigRFWithHeaderFile( ++ PDM_ODM_T pDM_Odm, ++ ODM_RF_Config_Type ConfigType, ++ ODM_RF_RADIO_PATH_E eRFPath ++) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, + ("===>ODM_ConfigRFWithHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip")); @@ -62548,20 +60873,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n", + pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType)); + -+ if (ConfigType == CONFIG_RF_RADIO) { ++ if (ConfigType == CONFIG_RF_RADIO) + READ_AND_CONFIG(8723B, _RadioA); -+ } -+ else if (ConfigType == CONFIG_RF_TXPWR_LMT) { ++ else if (ConfigType == CONFIG_RF_TXPWR_LMT) + READ_AND_CONFIG(8723B, _TXPWR_LMT); -+ } + + return HAL_STATUS_SUCCESS; +} + -+HAL_STATUS -+ODM_ConfigRFWithTxPwrTrackHeaderFile( -+PDM_ODM_T pDM_Odm -+ ) ++HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, + ("===>ODM_ConfigRFWithTxPwrTrackHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip")); @@ -62575,11 +60895,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + return HAL_STATUS_SUCCESS; +} + -+HAL_STATUS -+ODM_ConfigBBWithHeaderFile( -+PDM_ODM_T pDM_Odm, -+ODM_BB_Config_Type ConfigType -+ ) ++HAL_STATUS ODM_ConfigBBWithHeaderFile( ++ PDM_ODM_T pDM_Odm, ODM_BB_Config_Type ConfigType ++) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, + ("===>ODM_ConfigBBWithHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip")); @@ -62597,27 +60915,39 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.c linux-4.3-rtl8723bs/3 + return HAL_STATUS_SUCCESS; +} + -+HAL_STATUS -+ODM_ConfigMACWithHeaderFile( -+PDM_ODM_T pDM_Odm -+ ) ++HAL_STATUS ODM_ConfigMACWithHeaderFile(PDM_ODM_T pDM_Odm) +{ + u8 result = HAL_STATUS_SUCCESS; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, -+ ("===>ODM_ConfigMACWithHeaderFile (%s)\n", (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip")); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, -+ ("pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n", -+ pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface, pDM_Odm->BoardType)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ( ++ "===>ODM_ConfigMACWithHeaderFile (%s)\n", ++ (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip" ++ ) ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ( ++ "pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n", ++ pDM_Odm->SupportPlatform, ++ pDM_Odm->SupportInterface, ++ pDM_Odm->BoardType ++ ) ++ ); + + READ_AND_CONFIG(8723B, _MAC_REG); + + return result; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_HWConfig.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_HWConfig.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,179 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_HWConfig.h linux/3rdparty/rtl8723bs/hal/odm_HWConfig.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_HWConfig.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_HWConfig.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,162 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -62634,40 +60964,39 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.h linux-4.3-rtl8723bs/3 + ******************************************************************************/ + + -+#ifndef __HALHWOUTSRC_H__ ++#ifndef __HALHWOUTSRC_H__ +#define __HALHWOUTSRC_H__ + + +/*--------------------------Define -------------------------------------------*/ +/* define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = Array[i]; v2 = Array[i+1]; } while (0) */ +#define AGC_DIFF_CONFIG_MP(ic, band) (ODM_ReadAndConfig_MP_##ic##_AGC_TAB_DIFF(pDM_Odm, Array_MP_##ic##_AGC_TAB_DIFF_##band, \ -+ sizeof(Array_MP_##ic##_AGC_TAB_DIFF_##band)/sizeof(u32))) ++ sizeof(Array_MP_##ic##_AGC_TAB_DIFF_##band)/sizeof(u32))) +#define AGC_DIFF_CONFIG_TC(ic, band) (ODM_ReadAndConfig_TC_##ic##_AGC_TAB_DIFF(pDM_Odm, Array_TC_##ic##_AGC_TAB_DIFF_##band, \ -+ sizeof(Array_TC_##ic##_AGC_TAB_DIFF_##band)/sizeof(u32))) ++ sizeof(Array_TC_##ic##_AGC_TAB_DIFF_##band)/sizeof(u32))) + -+#define AGC_DIFF_CONFIG(ic, band) do {\ -+ if (pDM_Odm->bIsMPChip)\ -+ AGC_DIFF_CONFIG_MP(ic, band);\ -+ else\ -+ AGC_DIFF_CONFIG_TC(ic, band);\ -+ } while (0) ++#define AGC_DIFF_CONFIG(ic, band)\ ++ do {\ ++ if (pDM_Odm->bIsMPChip)\ ++ AGC_DIFF_CONFIG_MP(ic, band);\ ++ else\ ++ AGC_DIFF_CONFIG_TC(ic, band);\ ++ } while (0) + + +/* */ +/* structure and define */ +/* */ + -+typedef struct _Phy_Rx_AGC_Info -+{ ++typedef struct _Phy_Rx_AGC_Info { + #if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE) + u8 gain:7, trsw:1; + #else + u8 trsw:1, gain:7; + #endif -+} PHY_RX_AGC_INFO_T,*pPHY_RX_AGC_INFO_T; ++} PHY_RX_AGC_INFO_T, *pPHY_RX_AGC_INFO_T; + -+typedef struct _Phy_Status_Rpt_8192cd -+{ ++typedef struct _Phy_Status_Rpt_8192cd { + PHY_RX_AGC_INFO_T path_agc[2]; + u8 ch_corr[2]; + u8 cck_sig_qual_ofdm_pwdb_all; @@ -62675,9 +61004,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.h linux-4.3-rtl8723bs/3 + u8 cck_rpt_b_ofdm_cfosho_b; + u8 rsvd_1;/* ch_corr_msb; */ + u8 noise_power_db_msb; -+ s8 path_cfotail[2]; ++ s8 path_cfotail[2]; + u8 pcts_mask[2]; -+ s8 stream_rxevm[2]; ++ s8 stream_rxevm[2]; + u8 path_rxsnr[2]; + u8 noise_power_db_lsb; + u8 rsvd_2[3]; @@ -62703,104 +61032,88 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_HWConfig.h linux-4.3-rtl8723bs/3 + u8 sgi_en:1; + u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ +#endif -+} PHY_STATUS_RPT_8192CD_T,*PPHY_STATUS_RPT_8192CD_T; ++} PHY_STATUS_RPT_8192CD_T, *PPHY_STATUS_RPT_8192CD_T; + + -+typedef struct _Phy_Status_Rpt_8812 -+{ ++typedef struct _Phy_Status_Rpt_8812 { + /* 2012.05.24 LukeLee: This structure should take big/little endian in consideration later..... */ + + /* DWORD 0 */ -+ u8 gain_trsw[2]; ++ u8 gain_trsw[2]; +#if (ODM_ENDIAN_TYPE == ODM_ENDIAN_LITTLE) -+ u16 chl_num:10; -+ u16 sub_chnl:4; -+ u16 r_RFMOD:2; ++ u16 chl_num:10; ++ u16 sub_chnl:4; ++ u16 r_RFMOD:2; +#else /* _BIG_ENDIAN_ */ -+ u16 r_RFMOD:2; -+ u16 sub_chnl:4; -+ u16 chl_num:10; ++ u16 r_RFMOD:2; ++ u16 sub_chnl:4; ++ u16 chl_num:10; +#endif + + /* DWORD 1 */ -+ u8 pwdb_all; -+ u8 cfosho[4]; /* DW 1 byte 1 DW 2 byte 0 */ ++ u8 pwdb_all; ++ u8 cfosho[4]; /* DW 1 byte 1 DW 2 byte 0 */ + + /* DWORD 2 */ -+ s8 cfotail[4]; /* DW 2 byte 1 DW 3 byte 0 */ ++ s8 cfotail[4]; /* DW 2 byte 1 DW 3 byte 0 */ + + /* DWORD 3 */ -+ s8 rxevm[2]; /* DW 3 byte 1 DW 3 byte 2 */ -+ s8 rxsnr[2]; /* DW 3 byte 3 DW 4 byte 0 */ ++ s8 rxevm[2]; /* DW 3 byte 1 DW 3 byte 2 */ ++ s8 rxsnr[2]; /* DW 3 byte 3 DW 4 byte 0 */ + + /* DWORD 4 */ -+ u8 PCTS_MSK_RPT[2]; -+ u8 pdsnr[2]; /* DW 4 byte 3 DW 5 Byte 0 */ ++ u8 PCTS_MSK_RPT[2]; ++ u8 pdsnr[2]; /* DW 4 byte 3 DW 5 Byte 0 */ + + /* DWORD 5 */ -+ u8 csi_current[2]; -+ u8 rx_gain_c; ++ u8 csi_current[2]; ++ u8 rx_gain_c; + + /* DWORD 6 */ -+ u8 rx_gain_d; -+ s8 sigevm; -+ u8 resvd_0; -+ u8 antidx_anta:3; -+ u8 antidx_antb:3; -+ u8 resvd_1:2; -+} PHY_STATUS_RPT_8812_T,*PPHY_STATUS_RPT_8812_T; ++ u8 rx_gain_d; ++ s8 sigevm; ++ u8 resvd_0; ++ u8 antidx_anta:3; ++ u8 antidx_antb:3; ++ u8 resvd_1:2; ++} PHY_STATUS_RPT_8812_T, *PPHY_STATUS_RPT_8812_T; + + -+void -+ODM_PhyStatusQuery( -+ PDM_ODM_T pDM_Odm, -+ PODM_PHY_INFO_T pPhyInfo, -+ u8 * pPhyStatus, -+ PODM_PACKET_INFO_T pPktinfo -+ ); -+ -+HAL_STATUS -+ODM_ConfigRFWithTxPwrTrackHeaderFile( -+PDM_ODM_T pDM_Odm -+ ); -+ -+HAL_STATUS -+ODM_ConfigRFWithHeaderFile( -+PDM_ODM_T pDM_Odm, -+ODM_RF_Config_Type ConfigType, -+ODM_RF_RADIO_PATH_E eRFPath -+ ); -+ -+HAL_STATUS -+ODM_ConfigBBWithHeaderFile( -+PDM_ODM_T pDM_Odm, -+ODM_BB_Config_Type ConfigType -+ ); -+ -+HAL_STATUS -+ODM_ConfigMACWithHeaderFile( -+PDM_ODM_T pDM_Odm -+ ); -+ -+HAL_STATUS -+ODM_ConfigFWWithHeaderFile( -+PDM_ODM_T pDM_Odm, -+ODM_FW_Config_Type ConfigType, -+ u8 *pFirmware, -+ u32 *pSize -+ ); -+ -+s32 -+odm_SignalScaleMapping( ++void ODM_PhyStatusQuery( + PDM_ODM_T pDM_Odm, -+s32 CurrSig -+ ); ++ PODM_PHY_INFO_T pPhyInfo, ++ u8 *pPhyStatus, ++ PODM_PACKET_INFO_T pPktinfo ++); ++ ++HAL_STATUS ODM_ConfigRFWithTxPwrTrackHeaderFile(PDM_ODM_T pDM_Odm); ++ ++HAL_STATUS ODM_ConfigRFWithHeaderFile( ++ PDM_ODM_T pDM_Odm, ++ ODM_RF_Config_Type ConfigType, ++ ODM_RF_RADIO_PATH_E eRFPath ++); ++ ++HAL_STATUS ODM_ConfigBBWithHeaderFile( ++ PDM_ODM_T pDM_Odm, ODM_BB_Config_Type ConfigType ++); ++ ++HAL_STATUS ODM_ConfigMACWithHeaderFile(PDM_ODM_T pDM_Odm); ++ ++HAL_STATUS ODM_ConfigFWWithHeaderFile( ++ PDM_ODM_T pDM_Odm, ++ ODM_FW_Config_Type ConfigType, ++ u8 *pFirmware, ++ u32 *pSize ++); ++ ++s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_interface.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_interface.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_interface.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_interface.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,60 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_interface.h linux/3rdparty/rtl8723bs/hal/odm_interface.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_interface.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_interface.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,59 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -62850,21 +61163,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_interface.h linux-4.3-rtl8723bs/ +#define ODM_REG(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _reg) +#define ODM_BIT(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _bit) + -+typedef enum _ODM_H2C_CMD -+{ ++typedef enum _ODM_H2C_CMD { + ODM_H2C_RSSI_REPORT = 0, + ODM_H2C_PSD_RESULT = 1, + ODM_H2C_PathDiv = 2, + ODM_H2C_WIFI_CALIBRATION = 3, + ODM_MAX_H2CCMD -+}ODM_H2C_CMD; ++} ODM_H2C_CMD; + + +#endif /* __ODM_INTERFACE_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,172 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,175 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -62887,24 +61199,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723 +/* 1. disable DIG and Power Saving */ +/* 2. Set initial gain = 0x1a */ +/* 3. Stop updating idle time pwer report (for driver read) */ -+/* - 0x80c[25] */ ++/* - 0x80c[25] */ + +#define Valid_Min -35 +#define Valid_Max 10 +#define ValidCnt 5 + -+static s16 odm_InbandNoise_Monitor_NSeries(PDM_ODM_T pDM_Odm, u8 bPauseDIG, u8 IGIValue, u32 max_time) ++static s16 odm_InbandNoise_Monitor_NSeries( ++ PDM_ODM_T pDM_Odm, ++ u8 bPauseDIG, ++ u8 IGIValue, ++ u32 max_time ++) +{ -+ u32 tmp4b; -+ u8 max_rf_path = 0, rf_path; -+ u8 reg_c50, reg_c58, valid_done = 0; -+ struct noise_level noise_data; -+ u32 start = 0, func_start = 0, func_end = 0; ++ u32 tmp4b; ++ u8 max_rf_path = 0, rf_path; ++ u8 reg_c50, reg_c58, valid_done = 0; ++ struct noise_level noise_data; ++ u32 start = 0, func_start = 0, func_end = 0; + + func_start = jiffies; + pDM_Odm->noise_level.noise_all = 0; + -+ if ((pDM_Odm->RFType == ODM_1T2R) ||(pDM_Odm->RFType == ODM_2T2R)) ++ if ((pDM_Odm->RFType == ODM_1T2R) || (pDM_Odm->RFType == ODM_2T2R)) + max_rf_path = 2; + else + max_rf_path = 1; @@ -62918,9 +61235,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723 + /* */ + + if (bPauseDIG) -+ { + odm_PauseDIG(pDM_Odm, ODM_PAUSE_DIG, IGIValue); -+ } + /* */ + /* Step 2. Disable all power save for read registers */ + /* */ @@ -62930,8 +61245,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723 + /* Step 3. Get noise power level */ + /* */ + start = jiffies; -+ while (1) -+ { ++ while (1) { + + /* Stop updating idle time pwer report (for driver read) */ + PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_TxGainStage, BIT25, 1); @@ -62942,7 +61256,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723 + + /* PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XAAGCCore1, bMaskByte0, TestInitialGain); */ + /* if (max_rf_path == 2) */ -+ /* PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XBAGCCore1, bMaskByte0, TestInitialGain); */ ++ /* PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XBAGCCore1, bMaskByte0, TestInitialGain); */ + + /* update idle time pwer report per 5us */ + PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_TxGainStage, BIT25, 0); @@ -62953,11 +61267,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723 + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("value_a = 0x%x(%d), value_b = 0x%x(%d)\n", + noise_data.value[ODM_RF_PATH_A], noise_data.value[ODM_RF_PATH_A], noise_data.value[ODM_RF_PATH_B], noise_data.value[ODM_RF_PATH_B])); + -+ for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) -+ { ++ for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) { + noise_data.sval[rf_path] = (s8)noise_data.value[rf_path]; + noise_data.sval[rf_path] /= 2; -+ } ++ } + + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("sval_a = %d, sval_b = %d\n", @@ -62965,16 +61278,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723 + /* mdelay(10); */ + /* msleep(10); */ + -+ for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) -+ { -+ if ((noise_data.valid_cnt[rf_path] < ValidCnt) && (noise_data.sval[rf_path] < Valid_Max && noise_data.sval[rf_path] >= Valid_Min)) -+ { ++ for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) { ++ if ((noise_data.valid_cnt[rf_path] < ValidCnt) && (noise_data.sval[rf_path] < Valid_Max && noise_data.sval[rf_path] >= Valid_Min)) { + noise_data.valid_cnt[rf_path]++; + noise_data.sum[rf_path] += noise_data.sval[rf_path]; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RF_Path:%d Valid sval = %d\n", rf_path, noise_data.sval[rf_path])); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("Sum of sval = %d,\n", noise_data.sum[rf_path])); -+ if (noise_data.valid_cnt[rf_path] == ValidCnt) -+ { ++ if (noise_data.valid_cnt[rf_path] == ValidCnt) { + valid_done++; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("After divided, RF_Path:%d , sum = %d\n", rf_path, noise_data.sum[rf_path])); + } @@ -62984,10 +61294,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723 + } + + /* printk("####### valid_done:%d #############\n", valid_done); */ -+ if ((valid_done ==max_rf_path) || (jiffies_to_msecs(jiffies - start) > max_time)) -+ { -+ for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) -+ { ++ if ((valid_done == max_rf_path) || (jiffies_to_msecs(jiffies - start) > max_time)) { ++ for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) { + /* printk("%s PATH_%d - sum = %d, valid_cnt = %d\n", __func__, rf_path, noise_data.sum[rf_path], noise_data.valid_cnt[rf_path]); */ + if (noise_data.valid_cnt[rf_path]) + noise_data.sum[rf_path] /= noise_data.valid_cnt[rf_path]; @@ -63012,35 +61320,42 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.c linux-4.3-rtl8723 + } + pDM_Odm->noise_level.noise_all /= max_rf_path; + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("noise_a = %d, noise_b = %d\n", -+ pDM_Odm->noise_level.noise[ODM_RF_PATH_A], -+ pDM_Odm->noise_level.noise[ODM_RF_PATH_B])); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_COMMON, ++ ODM_DBG_LOUD, ++ ( ++ "noise_a = %d, noise_b = %d\n", ++ pDM_Odm->noise_level.noise[ODM_RF_PATH_A], ++ pDM_Odm->noise_level.noise[ODM_RF_PATH_B] ++ ) ++ ); + + /* */ + /* Step 4. Recover the Dig */ + /* */ + if (bPauseDIG) -+ { + odm_PauseDIG(pDM_Odm, ODM_RESUME_DIG, IGIValue); -+ } -+ func_end = jiffies_to_msecs(jiffies - func_start) ; ++ ++ func_end = jiffies_to_msecs(jiffies - func_start); + /* printk("%s noise_a = %d, noise_b = %d noise_all:%d (%d ms)\n", __func__, */ -+ /* pDM_Odm->noise_level.noise[ODM_RF_PATH_A], */ -+ /* pDM_Odm->noise_level.noise[ODM_RF_PATH_B], */ -+ /* pDM_Odm->noise_level.noise_all, func_end); */ ++ /* pDM_Odm->noise_level.noise[ODM_RF_PATH_A], */ ++ /* pDM_Odm->noise_level.noise[ODM_RF_PATH_B], */ ++ /* pDM_Odm->noise_level.noise_all, func_end); */ + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_DebugControlInbandNoise_Nseries() <==\n")); + return pDM_Odm->noise_level.noise_all; + +} ++ +s16 ODM_InbandNoise_Monitor(void *pDM_VOID, u8 bPauseDIG, u8 IGIValue, u32 max_time) +{ + return odm_InbandNoise_Monitor_NSeries(pDM_VOID, bPauseDIG, IGIValue, max_time); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,44 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h linux/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,47 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -63059,36 +61374,39 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_NoiseMonitor.h linux-4.3-rtl8723 +#define __ODMNOISEMONITOR_H__ + +#define ODM_MAX_CHANNEL_NUM 38/* 14+24 */ -+struct noise_level -+{ -+ /* u8 value_a, value_b; */ -+ u8 value[MAX_RF_PATH]; -+ /* s8 sval_a, sval_b; */ -+ s8 sval[MAX_RF_PATH]; ++struct noise_level { ++ /* u8 value_a, value_b; */ ++ u8 value[MAX_RF_PATH]; ++ /* s8 sval_a, sval_b; */ ++ s8 sval[MAX_RF_PATH]; + -+ /* s32 noise_a = 0, noise_b = 0, sum_a = 0, sum_b = 0; */ -+ /* s32 noise[ODM_RF_PATH_MAX]; */ -+ s32 sum[MAX_RF_PATH]; -+ /* u8 valid_cnt_a = 0, valid_cnt_b = 0, */ -+ u8 valid[MAX_RF_PATH]; -+ u8 valid_cnt[MAX_RF_PATH]; ++ /* s32 noise_a = 0, noise_b = 0, sum_a = 0, sum_b = 0; */ ++ /* s32 noise[ODM_RF_PATH_MAX]; */ ++ s32 sum[MAX_RF_PATH]; ++ /* u8 valid_cnt_a = 0, valid_cnt_b = 0, */ ++ u8 valid[MAX_RF_PATH]; ++ u8 valid_cnt[MAX_RF_PATH]; + +}; + + -+typedef struct _ODM_NOISE_MONITOR_ -+{ -+ s8 noise[MAX_RF_PATH]; -+ s16 noise_all; -+}ODM_NOISE_MONITOR; ++typedef struct _ODM_NOISE_MONITOR_ { ++ s8 noise[MAX_RF_PATH]; ++ s16 noise_all; ++} ODM_NOISE_MONITOR; + -+s16 ODM_InbandNoise_Monitor(void *pDM_VOID, u8 bPauseDIG, u8 IGIValue, u32 max_time); ++s16 ODM_InbandNoise_Monitor( ++ void *pDM_VOID, ++ u8 bPauseDIG, ++ u8 IGIValue, ++ u32 max_time ++); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_PathDiv.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_PathDiv.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_PathDiv.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_PathDiv.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,34 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_PathDiv.c linux/3rdparty/rtl8723bs/hal/odm_PathDiv.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_PathDiv.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_PathDiv.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,42 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -63108,24 +61426,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_PathDiv.c linux-4.3-rtl8723bs/3r + +void odm_PathDiversityInit(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + if (!(pDM_Odm->SupportAbility & ODM_BB_PATH_DIV)) -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_PATH_DIV, ODM_DBG_LOUD, -+ ("Return: Not Support PathDiv\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_PATH_DIV, ++ ODM_DBG_LOUD, ++ ("Return: Not Support PathDiv\n") ++ ); +} + +void odm_PathDiversity(void *pDM_VOID) +{ -+ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; ++ PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; + + if (!(pDM_Odm->SupportAbility & ODM_BB_PATH_DIV)) -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_PATH_DIV, ODM_DBG_LOUD, -+ ("Return: Not Support PathDiv\n")); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_PATH_DIV, ++ ODM_DBG_LOUD, ++ ("Return: Not Support PathDiv\n") ++ ); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_PathDiv.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_PathDiv.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_PathDiv.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_PathDiv.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_PathDiv.h linux/3rdparty/rtl8723bs/hal/odm_PathDiv.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_PathDiv.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_PathDiv.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,29 @@ +/****************************************************************************** + * @@ -63156,9 +61482,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_PathDiv.h linux-4.3-rtl8723bs/3r + ); + + #endif /* ifndef __ODMPATHDIV_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_precomp.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_precomp.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_precomp.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_precomp.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_precomp.h linux/3rdparty/rtl8723bs/hal/odm_precomp.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_precomp.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_precomp.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,60 @@ +/****************************************************************************** + * @@ -63220,10 +61546,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_precomp.h linux-4.3-rtl8723bs/3r +#include "odm_RegConfig8723B.h" + +#endif /* __ODM_PRECOMP_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,189 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c linux/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,257 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -63241,65 +61567,98 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c linux-4.3-rtl87 + +#include "odm_precomp.h" + -+void -+odm_ConfigRFReg_8723B( -+PDM_ODM_T pDM_Odm, -+u32 Addr, -+u32 Data, -+ ODM_RF_RADIO_PATH_E RF_PATH, -+u32 RegAddr -+ ) ++void odm_ConfigRFReg_8723B( ++ PDM_ODM_T pDM_Odm, ++ u32 Addr, ++ u32 Data, ++ ODM_RF_RADIO_PATH_E RF_PATH, ++ u32 RegAddr ++) +{ -+ if (Addr == 0xfe || Addr == 0xffe) -+ { ++ if (Addr == 0xfe || Addr == 0xffe) + msleep(50); -+ } -+ else -+ { ++ else { + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH, RegAddr, bRFRegOffsetMask, Data); + /* Add 1us delay between BB/RF register setting. */ + udelay(1); + + /* For disable/enable test in high temperature, the B6 value will fail to fill. Suggestion by BB Stanley, 2013.06.25. */ -+ if (Addr == 0xb6) -+ { ++ if (Addr == 0xb6) { + u32 getvalue = 0; + u8 count = 0; -+ getvalue = PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH, Addr, bMaskDWord); ++ ++ getvalue = PHY_QueryRFReg( ++ pDM_Odm->Adapter, RF_PATH, Addr, bMaskDWord ++ ); + + udelay(1); + -+ while ((getvalue>>8)!=(Data>>8)) -+ { ++ while ((getvalue>>8) != (Data>>8)) { + count++; + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH, RegAddr, bRFRegOffsetMask, Data); + udelay(1); + getvalue = PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH, Addr, bMaskDWord); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [B6] getvalue 0x%x, Data 0x%x, count %d\n", getvalue, Data, count)); -+ if (count>5) ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> ODM_ConfigRFWithHeaderFile: [B6] getvalue 0x%x, Data 0x%x, count %d\n", ++ getvalue, ++ Data, ++ count ++ ) ++ ); ++ if (count > 5) + break; + } + } + -+ if (Addr == 0xb2) -+ { ++ if (Addr == 0xb2) { + u32 getvalue = 0; + u8 count = 0; -+ getvalue = PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH, Addr, bMaskDWord); ++ ++ getvalue = PHY_QueryRFReg( ++ pDM_Odm->Adapter, RF_PATH, Addr, bMaskDWord ++ ); + + udelay(1); + -+ while (getvalue!=Data) -+ { ++ while (getvalue != Data) { + count++; -+ PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH, RegAddr, bRFRegOffsetMask, Data); ++ PHY_SetRFReg( ++ pDM_Odm->Adapter, ++ RF_PATH, ++ RegAddr, ++ bRFRegOffsetMask, ++ Data ++ ); + udelay(1); + /* Do LCK againg */ -+ PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH, 0x18, bRFRegOffsetMask, 0x0fc07); ++ PHY_SetRFReg( ++ pDM_Odm->Adapter, ++ RF_PATH, ++ 0x18, ++ bRFRegOffsetMask, ++ 0x0fc07 ++ ); + udelay(1); -+ getvalue = PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH, Addr, bMaskDWord); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [B2] getvalue 0x%x, Data 0x%x, count %d\n", getvalue, Data, count)); -+ if (count>5) ++ getvalue = PHY_QueryRFReg( ++ pDM_Odm->Adapter, RF_PATH, Addr, bMaskDWord ++ ); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> ODM_ConfigRFWithHeaderFile: [B2] getvalue 0x%x, Data 0x%x, count %d\n", ++ getvalue, ++ Data, ++ count ++ ) ++ ); ++ ++ if (count > 5) + break; + } + } @@ -63307,74 +61666,103 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c linux-4.3-rtl87 +} + + -+void -+odm_ConfigRF_RadioA_8723B( -+PDM_ODM_T pDM_Odm, -+u32 Addr, -+u32 Data -+ ) ++void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data) +{ + u32 content = 0x1000; /* RF_Content: radioa_txt */ + u32 maskforPhySet = (u32)(content&0xE000); + -+ odm_ConfigRFReg_8723B(pDM_Odm, Addr, Data, ODM_RF_PATH_A, Addr|maskforPhySet); ++ odm_ConfigRFReg_8723B( ++ pDM_Odm, ++ Addr, ++ Data, ++ ODM_RF_PATH_A, ++ Addr|maskforPhySet ++ ); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioA] %08X %08X\n", Addr, Data)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> ODM_ConfigRFWithHeaderFile: [RadioA] %08X %08X\n", ++ Addr, ++ Data ++ ) ++ ); +} + -+void -+odm_ConfigMAC_8723B( -+PDM_ODM_T pDM_Odm, -+u32 Addr, -+u8 Data -+ ) ++void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data) +{ + rtw_write8(pDM_Odm->Adapter, Addr, Data); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigMACWithHeaderFile: [MAC_REG] %08X %08X\n", Addr, Data)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> ODM_ConfigMACWithHeaderFile: [MAC_REG] %08X %08X\n", ++ Addr, ++ Data ++ ) ++ ); +} + -+void -+odm_ConfigBB_AGC_8723B( -+ PDM_ODM_T pDM_Odm, -+ u32 Addr, -+ u32 Bitmask, -+ u32 Data -+ ) ++void odm_ConfigBB_AGC_8723B( ++ PDM_ODM_T pDM_Odm, ++ u32 Addr, ++ u32 Bitmask, ++ u32 Data ++) +{ + PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data); + /* Add 1us delay between BB/RF register setting. */ + udelay(1); + -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigBBWithHeaderFile: [AGC_TAB] %08X %08X\n", Addr, Data)); ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_TRACE, ++ ( ++ "===> ODM_ConfigBBWithHeaderFile: [AGC_TAB] %08X %08X\n", ++ Addr, ++ Data ++ ) ++ ); +} + -+void -+odm_ConfigBB_PHY_REG_PG_8723B( -+PDM_ODM_T pDM_Odm, -+u32 Band, -+u32 RfPath, -+u32 TxNum, -+ u32 Addr, -+ u32 Bitmask, -+ u32 Data -+ ) ++void odm_ConfigBB_PHY_REG_PG_8723B( ++ PDM_ODM_T pDM_Odm, ++ u32 Band, ++ u32 RfPath, ++ u32 TxNum, ++ u32 Addr, ++ u32 Bitmask, ++ u32 Data ++) +{ + if (Addr == 0xfe || Addr == 0xffe) + msleep(50); -+ else -+ { -+ PHY_StoreTxPowerByRate(pDM_Odm->Adapter, Band, RfPath, TxNum, Addr, Bitmask, Data); -+ } -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X %08X\n", Addr, Bitmask, Data)); ++ else { ++ PHY_StoreTxPowerByRate(pDM_Odm->Adapter, Band, RfPath, TxNum, Addr, Bitmask, Data); ++ } ++ ODM_RT_TRACE( ++ pDM_Odm, ++ ODM_COMP_INIT, ++ ODM_DBG_LOUD, ++ ( ++ "===> ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X %08X\n", ++ Addr, ++ Bitmask, ++ Data ++ ) ++ ); +} + -+void -+odm_ConfigBB_PHY_8723B( -+PDM_ODM_T pDM_Odm, -+ u32 Addr, -+ u32 Bitmask, -+ u32 Data -+ ) ++void odm_ConfigBB_PHY_8723B( ++ PDM_ODM_T pDM_Odm, ++ u32 Addr, ++ u32 Bitmask, ++ u32 Data ++) +{ + if (Addr == 0xfe) + msleep(50); @@ -63388,35 +61776,41 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.c linux-4.3-rtl87 + udelay(5); + else if (Addr == 0xf9) + udelay(1); -+ else -+ { ++ else { + PHY_SetBBReg(pDM_Odm->Adapter, Addr, Bitmask, Data); + } + + /* Add 1us delay between BB/RF register setting. */ + udelay(1); -+ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X\n", Addr, Data)); ++ ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X\n", Addr, Data)); +} + -+void -+odm_ConfigBB_TXPWR_LMT_8723B( -+PDM_ODM_T pDM_Odm, -+u8 * Regulation, -+u8 * Band, -+u8 * Bandwidth, -+u8 * RateSection, -+u8 * RfPath, -+u8 * Channel, -+u8 * PowerLimit -+ ) ++void odm_ConfigBB_TXPWR_LMT_8723B( ++ PDM_ODM_T pDM_Odm, ++ u8 *Regulation, ++ u8 *Band, ++ u8 *Bandwidth, ++ u8 *RateSection, ++ u8 *RfPath, ++ u8 *Channel, ++ u8 *PowerLimit ++) +{ -+ PHY_SetTxPowerLimit(pDM_Odm->Adapter, Regulation, Band, -+ Bandwidth, RateSection, RfPath, Channel, PowerLimit); ++ PHY_SetTxPowerLimit( ++ pDM_Odm->Adapter, ++ Regulation, ++ Band, ++ Bandwidth, ++ RateSection, ++ RfPath, ++ Channel, ++ PowerLimit ++ ); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,80 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h linux/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,65 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -63434,72 +61828,57 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RegConfig8723B.h linux-4.3-rtl87 +#ifndef __INC_ODM_REGCONFIG_H_8723B +#define __INC_ODM_REGCONFIG_H_8723B + -+void -+odm_ConfigRFReg_8723B( -+PDM_ODM_T pDM_Odm, -+u32 Addr, -+u32 Data, -+ ODM_RF_RADIO_PATH_E RF_PATH, -+u32 RegAddr -+ ); ++void odm_ConfigRFReg_8723B( ++ PDM_ODM_T pDM_Odm, ++ u32 Addr, ++ u32 Data, ++ ODM_RF_RADIO_PATH_E RF_PATH, ++ u32 RegAddr ++); + -+void -+odm_ConfigRF_RadioA_8723B( -+PDM_ODM_T pDM_Odm, -+u32 Addr, -+u32 Data -+ ); ++void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data); + -+void -+odm_ConfigMAC_8723B( -+PDM_ODM_T pDM_Odm, -+u32 Addr, -+u8 Data -+ ); ++void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data); + -+void -+odm_ConfigBB_AGC_8723B( -+ PDM_ODM_T pDM_Odm, -+ u32 Addr, -+ u32 Bitmask, -+ u32 Data -+ ); ++void odm_ConfigBB_AGC_8723B( ++ PDM_ODM_T pDM_Odm, ++ u32 Addr, ++ u32 Bitmask, ++ u32 Data ++); + -+void -+odm_ConfigBB_PHY_REG_PG_8723B( -+PDM_ODM_T pDM_Odm, -+u32 Band, -+u32 RfPath, -+u32 TxNum, -+ u32 Addr, -+ u32 Bitmask, -+ u32 Data -+ ); ++void odm_ConfigBB_PHY_REG_PG_8723B( ++ PDM_ODM_T pDM_Odm, ++ u32 Band, ++ u32 RfPath, ++ u32 TxNum, ++ u32 Addr, ++ u32 Bitmask, ++ u32 Data ++); + -+void -+odm_ConfigBB_PHY_8723B( -+PDM_ODM_T pDM_Odm, -+ u32 Addr, -+ u32 Bitmask, -+ u32 Data -+ ); ++void odm_ConfigBB_PHY_8723B( ++ PDM_ODM_T pDM_Odm, ++ u32 Addr, ++ u32 Bitmask, ++ u32 Data ++); + -+void -+odm_ConfigBB_TXPWR_LMT_8723B( -+PDM_ODM_T pDM_Odm, -+u8 * Regulation, -+u8 * Band, -+u8 * Bandwidth, -+u8 * RateSection, -+u8 * RfPath, -+u8 * Channel, -+u8 * PowerLimit -+ ); ++void odm_ConfigBB_TXPWR_LMT_8723B( ++ PDM_ODM_T pDM_Odm, ++ u8 *Regulation, ++ u8 *Band, ++ u8 *Bandwidth, ++ u8 *RateSection, ++ u8 *RfPath, ++ u8 *Channel, ++ u8 *PowerLimit ++); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h linux/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,172 @@ +/****************************************************************************** + * @@ -63673,9 +62052,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RegDefine11N.h linux-4.3-rtl8723 +#define ODM_BIT_BB_ATC_11N BIT11 + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_reg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_reg.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_reg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_reg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_reg.h linux/3rdparty/rtl8723bs/hal/odm_reg.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_reg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_reg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,103 @@ +/****************************************************************************** + * @@ -63780,10 +62159,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_reg.h linux-4.3-rtl8723bs/3rdpar +#define BIT_FA_RESET BIT0 + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RTL8723B.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RTL8723B.c ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_RTL8723B.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RTL8723B.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,49 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_RTL8723B.c linux/3rdparty/rtl8723bs/hal/odm_RTL8723B.c +--- linux.old/3rdparty/rtl8723bs/hal/odm_RTL8723B.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_RTL8723B.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,45 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -63801,41 +62180,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RTL8723B.c linux-4.3-rtl8723bs/3 + +#include "odm_precomp.h" + -+ s8 -+odm_CCKRSSI_8723B( -+ u8 LNA_idx, -+ u8 VGA_idx -+ ) ++s8 odm_CCKRSSI_8723B(u8 LNA_idx, u8 VGA_idx) +{ -+ s8 rx_pwr_all = 0x00; -+ switch (LNA_idx) -+ { -+ /* 46 53 73 95 201301231630 */ -+ /* 46 53 77 99 201301241630 */ ++ s8 rx_pwr_all = 0x00; + -+ case 6: -+ rx_pwr_all = -34 - (2 * VGA_idx); -+ break; -+ case 4: -+ rx_pwr_all = -14 - (2 * VGA_idx); -+ break; -+ case 1: -+ rx_pwr_all = 6 - (2 * VGA_idx); -+ break; -+ case 0: -+ rx_pwr_all = 16 - (2 * VGA_idx); -+ break; -+ default: -+ /* rx_pwr_all = -53+(2*(31-VGA_idx)); */ -+ /* DbgPrint("wrong LNA index\n"); */ -+ break; ++ switch (LNA_idx) { ++ /* 46 53 73 95 201301231630 */ ++ /* 46 53 77 99 201301241630 */ ++ ++ case 6: ++ rx_pwr_all = -34 - (2 * VGA_idx); ++ break; ++ case 4: ++ rx_pwr_all = -14 - (2 * VGA_idx); ++ break; ++ case 1: ++ rx_pwr_all = 6 - (2 * VGA_idx); ++ break; ++ case 0: ++ rx_pwr_all = 16 - (2 * VGA_idx); ++ break; ++ default: ++ /* rx_pwr_all = -53+(2*(31-VGA_idx)); */ ++ /* DbgPrint("wrong LNA index\n"); */ ++ break; + + } -+ return rx_pwr_all; ++ return rx_pwr_all; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RTL8723B.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RTL8723B.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_RTL8723B.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_RTL8723B.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_RTL8723B.h linux/3rdparty/rtl8723bs/hal/odm_RTL8723B.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_RTL8723B.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_RTL8723B.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,22 @@ +/****************************************************************************** + * @@ -63859,9 +62234,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_RTL8723B.h linux-4.3-rtl8723bs/3 +s8 odm_CCKRSSI_8723B(u8 LNA_idx, u8 VGA_idx); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_types.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_types.h ---- linux-4.3/3rdparty/rtl8723bs/hal/odm_types.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/odm_types.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/odm_types.h linux/3rdparty/rtl8723bs/hal/odm_types.h +--- linux.old/3rdparty/rtl8723bs/hal/odm_types.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/odm_types.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,102 @@ +/****************************************************************************** + * @@ -63888,7 +62263,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_types.h linux-4.3-rtl8723bs/3rdp + +#define GET_ODM(__padapter) ((PDM_ODM_T)(&((GET_HAL_DATA(__padapter))->odmpriv))) + -+typedef enum _HAL_STATUS{ ++typedef enum _HAL_STATUS { + HAL_STATUS_SUCCESS, + HAL_STATUS_FAILURE, + /*RT_STATUS_PENDING, @@ -63897,13 +62272,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_types.h linux-4.3-rtl8723bs/3rdp + RT_STATUS_INVALID_PARAMETER, + RT_STATUS_NOT_SUPPORT, + RT_STATUS_OS_API_FAILED,*/ -+}HAL_STATUS,*PHAL_STATUS; ++} HAL_STATUS, *PHAL_STATUS; + + +/* */ +/* Declare for ODM spin lock defintion temporarily fro compile pass. */ +/* */ -+typedef enum _RT_SPINLOCK_TYPE{ ++typedef enum _RT_SPINLOCK_TYPE { + RT_TX_SPINLOCK = 1, + RT_RX_SPINLOCK = 2, + RT_RM_SPINLOCK = 3, @@ -63919,12 +62294,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_types.h linux-4.3-rtl8723bs/3rdp + RT_PORT_SPINLOCK = 16, + RT_H2C_SPINLOCK = 20, /* For H2C cmd. Added by tynli. 2009.11.09. */ + -+ RT_BTData_SPINLOCK =25, ++ RT_BTData_SPINLOCK = 25, + -+ RT_WAPI_OPTION_SPINLOCK =26, -+ RT_WAPI_RX_SPINLOCK =27, ++ RT_WAPI_OPTION_SPINLOCK = 26, ++ RT_WAPI_RX_SPINLOCK = 27, + -+ /* add for 92D CCK control issue */ ++ /* add for 92D CCK control issue */ + RT_CCK_PAGEA_SPINLOCK = 28, + RT_BUFFER_SPINLOCK = 29, + RT_CHANNEL_AND_BANDWIDTH_SPINLOCK = 30, @@ -63939,7 +62314,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_types.h linux-4.3-rtl8723bs/3rdp + RT_PENDED_OID_SPINLOCK = 39, + RT_CHNLLIST_SPINLOCK = 40, + RT_INDIC_SPINLOCK = 41, /* protect indication */ -+}RT_SPINLOCK_TYPE; ++} RT_SPINLOCK_TYPE; + + #if defined(__LITTLE_ENDIAN) + #define ODM_ENDIAN_TYPE ODM_ENDIAN_LITTLE @@ -63948,7 +62323,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_types.h linux-4.3-rtl8723bs/3rdp + #endif + + typedef struct timer_list RT_TIMER, *PRT_TIMER; -+ typedef void * RT_TIMER_CALL_BACK; ++ typedef void *RT_TIMER_CALL_BACK; + #define STA_INFO_T struct sta_info + #define PSTA_INFO_T struct sta_info * + @@ -63965,10 +62340,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/odm_types.h linux-4.3-rtl8723bs/3rdp +#define COND_ENDIF 3 + +#endif /* __ODM_TYPES_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c ---- linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,2412 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c +--- linux.old/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,2358 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -63991,7 +62366,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#include "hal_com_h2c.h" + +#define MAX_H2C_BOX_NUMS 4 -+#define MESSAGE_BOX_SIZE 4 ++#define MESSAGE_BOX_SIZE 4 + +#define RTL8723B_MAX_CMD_LEN 7 +#define RTL8723B_EX_MESSAGE_BOX_SIZE 4 @@ -63999,13 +62374,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +static u8 _is_fw_read_cmd_down(struct adapter *padapter, u8 msgbox_num) +{ + u8 read_down = false; -+ int retry_cnts = 100; ++ int retry_cnts = 100; + + u8 valid; + + /* DBG_8192C(" _is_fw_read_cmd_down , reg_1cc(%x), msg_box(%d)...\n", rtw_read8(padapter, REG_HMETFR), msgbox_num); */ + -+ do{ ++ do { + valid = rtw_read8(padapter, REG_HMETFR) & BIT(msgbox_num); + if (0 == valid) { + read_down = true; @@ -64014,7 +62389,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + else + msleep(1); +#endif -+ }while ((!read_down) && (retry_cnts--)); ++ } while ((!read_down) && (retry_cnts--)); + + return read_down; + @@ -64047,14 +62422,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + if (!pCmdBuffer) { + goto exit; + } ++ + if (CmdLen > RTL8723B_MAX_CMD_LEN) { + goto exit; + } ++ + if (padapter->bSurpriseRemoved == true) + goto exit; + + /* pay attention to if race condition happened in H2C cmd setting. */ -+ do{ ++ do { + h2c_box_num = pHalData->LastHMEBoxNum; + + if (!_is_fw_read_cmd_down(padapter, h2c_box_num)) { @@ -64064,10 +62441,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + goto exit; + } + -+ if (CmdLen<=3) -+ { ++ if (CmdLen <= 3) + memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, CmdLen); -+ } + else { + memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, 3); + memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer+3, CmdLen-3); @@ -64076,11 +62451,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + *(u8 *)(&h2c_cmd) |= ElementID; + -+ if (CmdLen>3) { -+ msgbox_ex_addr = REG_HMEBOX_EXT0_8723B + (h2c_box_num *RTL8723B_EX_MESSAGE_BOX_SIZE); ++ if (CmdLen > 3) { ++ msgbox_ex_addr = REG_HMEBOX_EXT0_8723B + (h2c_box_num*RTL8723B_EX_MESSAGE_BOX_SIZE); + rtw_write32(padapter, msgbox_ex_addr, h2c_cmd_ex); + } -+ msgbox_addr =REG_HMEBOX_0 + (h2c_box_num *MESSAGE_BOX_SIZE); ++ msgbox_addr = REG_HMEBOX_0 + (h2c_box_num*MESSAGE_BOX_SIZE); + rtw_write32(padapter, msgbox_addr, h2c_cmd); + + /* DBG_8192C("MSG_BOX:%d, CmdLen(%d), CmdID(0x%x), reg:0x%x =>h2c_cmd:0x%.8x, reg:0x%x =>h2c_cmd_ex:0x%.8x\n" */ @@ -64088,7 +62463,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + pHalData->LastHMEBoxNum = (h2c_box_num+1) % MAX_H2C_BOX_NUMS; + -+ }while (0); ++ } while (0); + + ret = _SUCCESS; + @@ -64100,12 +62475,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) +{ -+ struct ieee80211_hdr *pwlanhdr; ++ struct ieee80211_hdr *pwlanhdr; + __le16 *fctrl; -+ u32 rate_len, pktlen; ++ u32 rate_len, pktlen; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); ++ struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + @@ -64143,8 +62518,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + pframe += 2; + pktlen += 2; + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + /* DBG_871X("ie len =%d\n", cur_network->IELength); */ + pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fix_ie); + memcpy(pframe, cur_network->IEs+sizeof(struct ndis_802_11_fix_ie), pktlen); @@ -64159,13 +62533,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8)? 8: rate_len), cur_network->SupportedRates, &pktlen); ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); + -+ if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) -+ { ++ if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + u32 ATIMWindow; + /* IBSS Parameter Set... */ + /* ATIMWindow = cur->Configuration.ATIMWindow; */ @@ -64179,17 +62552,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + /* EXTERNDED SUPPORTED RATE */ + if (rate_len > 8) -+ { + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); -+ } + + + /* todo:HT for adhoc */ + +_ConstructBeacon: + -+ if ((pktlen + TXDESC_SIZE) > 512) -+ { ++ if ((pktlen + TXDESC_SIZE) > 512) { + DBG_871X("beacon frame too large\n"); + return; + } @@ -64202,7 +62572,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +static void ConstructPSPoll(struct adapter *padapter, u8 *pframe, u32 *pLength) +{ -+ struct ieee80211_hdr *pwlanhdr; ++ struct ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -64232,53 +62602,51 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +static void ConstructNullFunctionData( + struct adapter *padapter, + u8 *pframe, -+ u32 *pLength, ++ u32 *pLength, + u8 *StaAddr, + u8 bQoS, + u8 AC, + u8 bEosp, -+ u8 bForcePowerSave) ++ u8 bForcePowerSave ++) +{ -+ struct ieee80211_hdr *pwlanhdr; ++ struct ieee80211_hdr *pwlanhdr; + __le16 *fctrl; -+ u32 pktlen; -+ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -+ struct wlan_network *cur_network = &pmlmepriv->cur_network; ++ u32 pktlen; ++ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; ++ struct wlan_network *cur_network = &pmlmepriv->cur_network; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + + /* DBG_871X("%s:%d\n", __func__, bForcePowerSave); */ + -+ pwlanhdr = (struct ieee80211_hdr*)pframe; ++ pwlanhdr = (struct ieee80211_hdr *)pframe; + + fctrl = &pwlanhdr->frame_control; + *(fctrl) = 0; + if (bForcePowerSave) -+ { + SetPwrMgt(fctrl); -+ } + -+ switch (cur_network->network.InfrastructureMode) -+ { -+ case Ndis802_11Infrastructure: -+ SetToDs(fctrl); -+ memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); -+ memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); -+ memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN); -+ break; -+ case Ndis802_11APMode: -+ SetFrDs(fctrl); -+ memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); -+ memcpy(pwlanhdr->addr2, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); -+ memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); -+ break; -+ case Ndis802_11IBSS: -+ default: -+ memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); -+ memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); -+ memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); -+ break; ++ switch (cur_network->network.InfrastructureMode) { ++ case Ndis802_11Infrastructure: ++ SetToDs(fctrl); ++ memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); ++ memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ++ memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN); ++ break; ++ case Ndis802_11APMode: ++ SetFrDs(fctrl); ++ memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); ++ memcpy(pwlanhdr->addr2, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); ++ memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); ++ break; ++ case Ndis802_11IBSS: ++ default: ++ memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); ++ memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); ++ memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); ++ break; + } + + SetSeqNum(pwlanhdr, 0); @@ -64288,7 +62656,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); + -+ pwlanqoshdr = (struct ieee80211_qos_hdr*)pframe; ++ pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe; + SetPriority(&pwlanqoshdr->qos_ctrl, AC); + SetEOSP(&pwlanqoshdr->qos_ctrl, bEosp); + @@ -64310,10 +62678,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +/* */ +static void ConstructARPResponse( + struct adapter *padapter, -+ u8 *pframe, -+ u32 *pLength, -+ u8 *pIPAddress -+ ) ++ u8 *pframe, ++ u32 *pLength, ++ u8 *pIPAddress ++) +{ + struct ieee80211_hdr *pwlanhdr; + __le16 *fctrl; @@ -64327,7 +62695,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + u8 EncryptionHeadOverhead = 0; + /* DBG_871X("%s:%d\n", __func__, bForcePowerSave); */ + -+ pwlanhdr = (struct ieee80211_hdr*)pframe; ++ pwlanhdr = (struct ieee80211_hdr *)pframe; + + fctrl = &pwlanhdr->frame_control; + *(fctrl) = 0; @@ -64359,24 +62727,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + /* Security Header: leave space for it if necessary. */ + /* */ + -+ switch (psecuritypriv->dot11PrivacyAlgrthm) -+ { -+ case _WEP40_: -+ case _WEP104_: -+ EncryptionHeadOverhead = 4; -+ break; -+ case _TKIP_: -+ EncryptionHeadOverhead = 8; -+ break; -+ case _AES_: -+ EncryptionHeadOverhead = 8; -+ break; -+ default: -+ EncryptionHeadOverhead = 0; ++ switch (psecuritypriv->dot11PrivacyAlgrthm) { ++ case _WEP40_: ++ case _WEP104_: ++ EncryptionHeadOverhead = 4; ++ break; ++ case _TKIP_: ++ EncryptionHeadOverhead = 8; ++ break; ++ case _AES_: ++ EncryptionHeadOverhead = 8; ++ break; ++ default: ++ EncryptionHeadOverhead = 0; + } + -+ if (EncryptionHeadOverhead > 0) -+ { ++ if (EncryptionHeadOverhead > 0) { + memset(&(pframe[*pLength]), 0, EncryptionHeadOverhead); + *pLength += EncryptionHeadOverhead; + SetPrivacy(fctrl); @@ -64385,7 +62751,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + /* */ + /* Frame Body. */ + /* */ -+ pARPRspPkt = (u8 *)(pframe+ *pLength); ++ pARPRspPkt = (u8 *)(pframe + *pLength); + payload = pARPRspPkt; /* Get Payload pointer */ + /* LLC header */ + memcpy(pARPRspPkt, ARPLLCHeader, 8); @@ -64409,13 +62775,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + *pLength += 28; + -+ if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_) -+ { ++ if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_) { + u8 mic[8]; + struct mic_data micdata; + struct sta_info *psta = NULL; -+ u8 priority[4]={0x0, 0x0, 0x0, 0x0}; -+ u8 null_key[16]={0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; ++ u8 priority[4] = { ++ 0x0, 0x0, 0x0, 0x0 ++ }; ++ u8 null_key[16] = { ++ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ++ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ++ }; + + DBG_871X("%s(): Add MIC\n", __func__); + @@ -64432,12 +62802,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + rtw_secmicappend(&micdata, pwlanhdr->addr2, 6); /* SA */ + -+ priority[0]= 0; ++ priority[0] = 0; + rtw_secmicappend(&micdata, &priority[0], 4); + + rtw_secmicappend(&micdata, payload, 36); /* payload length = 8 + 28 */ + -+ rtw_secgetmic(&micdata,&(mic[0])); ++ rtw_secgetmic(&micdata, &(mic[0])); + + pARPRspPkt += 28; + memcpy(pARPRspPkt, &(mic[0]), 8); @@ -64448,60 +62818,56 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +#ifdef CONFIG_PNO_SUPPORT +static void ConstructPnoInfo( -+ struct adapter *padapter, -+ u8 *pframe, -+ u32 *pLength -+ ) ++ struct adapter *padapter, u8 *pframe, u32 *pLength ++) +{ + + struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); + + u8 *pPnoInfoPkt = pframe; -+ pPnoInfoPkt = (u8 *)(pframe+ *pLength); ++ pPnoInfoPkt = (u8 *)(pframe + *pLength); + memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_num, 4); + -+ *pLength+=4; ++ *pLength += 4; + pPnoInfoPkt += 4; + memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->fast_scan_period, 4); + -+ *pLength+=4; ++ *pLength += 4; + pPnoInfoPkt += 4; + memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->fast_scan_iterations, 4); + -+ *pLength+=4; ++ *pLength += 4; + pPnoInfoPkt += 4; + memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->slow_scan_period, 4); + -+ *pLength+=4; ++ *pLength += 4; + pPnoInfoPkt += 4; + memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_length, + MAX_PNO_LIST_COUNT); + -+ *pLength+=MAX_PNO_LIST_COUNT; ++ *pLength += MAX_PNO_LIST_COUNT; + pPnoInfoPkt += MAX_PNO_LIST_COUNT; + memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_cipher_info, + MAX_PNO_LIST_COUNT); + -+ *pLength+=MAX_PNO_LIST_COUNT; ++ *pLength += MAX_PNO_LIST_COUNT; + pPnoInfoPkt += MAX_PNO_LIST_COUNT; + memcpy(pPnoInfoPkt, &pwrctl->pnlo_info->ssid_channel_info, + MAX_PNO_LIST_COUNT); + -+ *pLength+=MAX_PNO_LIST_COUNT; ++ *pLength += MAX_PNO_LIST_COUNT; + pPnoInfoPkt += MAX_PNO_LIST_COUNT; +} + +static void ConstructSSIDList( -+ struct adapter *padapter, -+ u8 *pframe, -+ u32 *pLength -+ ) ++ struct adapter *padapter, u8 *pframe, u32 *pLength ++) +{ + int i = 0; + u8 *pSSIDListPkt = pframe; + struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); + -+ pSSIDListPkt = (u8 *)(pframe+ *pLength); ++ pSSIDListPkt = (u8 *)(pframe + *pLength); + + for (i = 0; i < pwrctl->pnlo_info->ssid_num ; i++) { + memcpy(pSSIDListPkt, &pwrctl->pno_ssid_list->node[i].SSID, @@ -64513,60 +62879,57 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +} + +static void ConstructScanInfo( -+ struct adapter *padapter, -+ u8 *pframe, -+ u32 *pLength -+ ) ++ struct adapter *padapter, u8 *pframe, u32 *pLength ++) +{ + int i = 0; + u8 *pScanInfoPkt = pframe; + struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); + -+ pScanInfoPkt = (u8 *)(pframe+ *pLength); ++ pScanInfoPkt = (u8 *)(pframe + *pLength); + + memcpy(pScanInfoPkt, &pwrctl->pscan_info->channel_num, 1); + -+ *pLength+= 1; ++ *pLength += 1; + pScanInfoPkt += 1; + memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_ch, 1); + + -+ *pLength+= 1; ++ *pLength += 1; + pScanInfoPkt += 1; + memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_bw, 1); + + -+ *pLength+= 1; ++ *pLength += 1; + pScanInfoPkt += 1; + memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_40_offset, 1); + -+ *pLength+= 1; ++ *pLength += 1; + pScanInfoPkt += 1; + memcpy(pScanInfoPkt, &pwrctl->pscan_info->orig_80_offset, 1); + -+ *pLength+= 1; ++ *pLength += 1; + pScanInfoPkt += 1; + memcpy(pScanInfoPkt, &pwrctl->pscan_info->periodScan, 1); + -+ *pLength+= 1; ++ *pLength += 1; + pScanInfoPkt += 1; + memcpy(pScanInfoPkt, &pwrctl->pscan_info->period_scan_time, 1); + -+ *pLength+= 1; ++ *pLength += 1; + pScanInfoPkt += 1; + memcpy(pScanInfoPkt, &pwrctl->pscan_info->enableRFE, 1); + -+ *pLength+= 1; ++ *pLength += 1; + pScanInfoPkt += 1; + memcpy(pScanInfoPkt, &pwrctl->pscan_info->rfe_type, 8); + -+ *pLength+=8; ++ *pLength += 8; + pScanInfoPkt += 8; + -+ for (i = 0 ; i < MAX_SCAN_LIST_COUNT ; i ++) { -+ memcpy(pScanInfoPkt, -+ &pwrctl->pscan_info->ssid_channel_info[i], 4); -+ *pLength+=4; ++ for (i = 0; i < MAX_SCAN_LIST_COUNT; i++) { ++ memcpy(pScanInfoPkt, &pwrctl->pscan_info->ssid_channel_info[i], 4); ++ *pLength += 4; + pScanInfoPkt += 4; + } +} @@ -64574,23 +62937,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +#ifdef CONFIG_GTK_OL +static void ConstructGTKResponse( -+ struct adapter *padapter, -+ u8 *pframe, -+ u32 *pLength -+ ) ++ struct adapter *padapter, u8 *pframe, u32 *pLength ++) +{ -+ struct ieee80211_hdr *pwlanhdr; -+ u16 *fctrl; ++ struct ieee80211_hdr *pwlanhdr; ++ u16 *fctrl; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct security_priv *psecuritypriv = &padapter->securitypriv; -+ static u8 LLCHeader[8] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8E}; -+ static u8 GTKbody_a[11] ={0x01, 0x03, 0x00, 0x5F, 0x02, 0x03, 0x12, 0x00, 0x10, 0x42, 0x0B}; -+ u8 *pGTKRspPkt = pframe; -+ u8 EncryptionHeadOverhead = 0; ++ static u8 LLCHeader[8] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8E}; ++ static u8 GTKbody_a[11] = {0x01, 0x03, 0x00, 0x5F, 0x02, 0x03, 0x12, 0x00, 0x10, 0x42, 0x0B}; ++ u8 *pGTKRspPkt = pframe; ++ u8 EncryptionHeadOverhead = 0; + /* DBG_871X("%s:%d\n", __func__, bForcePowerSave); */ + -+ pwlanhdr = (struct ieee80211_hdr*)pframe; ++ pwlanhdr = (struct ieee80211_hdr *)pframe; + + fctrl = &pwlanhdr->frame_control; + *(fctrl) = 0; @@ -64614,24 +62975,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + /* Security Header: leave space for it if necessary. */ + /* */ + -+ switch (psecuritypriv->dot11PrivacyAlgrthm) -+ { -+ case _WEP40_: -+ case _WEP104_: -+ EncryptionHeadOverhead = 4; -+ break; -+ case _TKIP_: -+ EncryptionHeadOverhead = 8; -+ break; -+ case _AES_: -+ EncryptionHeadOverhead = 8; -+ break; -+ default: -+ EncryptionHeadOverhead = 0; ++ switch (psecuritypriv->dot11PrivacyAlgrthm) { ++ case _WEP40_: ++ case _WEP104_: ++ EncryptionHeadOverhead = 4; ++ break; ++ case _TKIP_: ++ EncryptionHeadOverhead = 8; ++ break; ++ case _AES_: ++ EncryptionHeadOverhead = 8; ++ break; ++ default: ++ EncryptionHeadOverhead = 0; + } + -+ if (EncryptionHeadOverhead > 0) -+ { ++ if (EncryptionHeadOverhead > 0) { + memset(&(pframe[*pLength]), 0, EncryptionHeadOverhead); + *pLength += EncryptionHeadOverhead; + /* GTK's privacy bit is done by FW */ @@ -64641,7 +63000,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + /* */ + /* Frame Body. */ + /* */ -+ pGTKRspPkt = (u8 *)(pframe+ *pLength); ++ pGTKRspPkt = (u8 *)(pframe + *pLength); + /* LLC header */ + memcpy(pGTKRspPkt, LLCHeader, 8); + *pLength += 8; @@ -64664,16 +63023,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#ifdef CONFIG_PNO_SUPPORT +static void ConstructProbeReq(struct adapter *padapter, u8 *pframe, u32 *pLength) +{ -+ struct ieee80211_hdr *pwlanhdr; -+ u16 *fctrl; -+ u32 pktlen; -+ unsigned char *mac; -+ unsigned char bssrate[NumRates]; -+ struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); ++ struct ieee80211_hdr *pwlanhdr; ++ u16 *fctrl; ++ u32 pktlen; ++ unsigned char *mac; ++ unsigned char bssrate[NumRates]; ++ struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ int bssrate_len = 0; ++ int bssrate_len = 0; + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + pwlanhdr = (struct ieee80211_hdr *)pframe; @@ -64698,15 +63057,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + get_rate_set(padapter, bssrate, &bssrate_len); + -+ if (bssrate_len > 8) -+ { -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &pktlen); -+ pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &pktlen); -+ } -+ else -+ { -+ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &pktlen); -+ } ++ if (bssrate_len > 8) { ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pktlen); ++ pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &pktlen); ++ } else ++ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pktlen); + + *pLength = pktlen; +} @@ -64716,13 +63071,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#ifdef CONFIG_AP_WOWLAN +static void ConstructProbeRsp(struct adapter *padapter, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID) +{ -+ struct ieee80211_hdr *pwlanhdr; -+ u16 *fctrl; -+ u8 *mac, *bssid; -+ u32 pktlen; ++ struct ieee80211_hdr *pwlanhdr; ++ u16 *fctrl; ++ u8 *mac, *bssid; ++ u32 pktlen; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); ++ struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + u8 *pwps_ie; + uint wps_ielen; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -64749,14 +63104,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + pktlen = sizeof(struct ieee80211_hdr_3addr); + pframe += pktlen; + -+ if (cur_network->IELength>MAX_IE_SZ) ++ if (cur_network->IELength > MAX_IE_SZ) + return; + + pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, + cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + + /* inerset & update wps_probe_resp_ie */ -+ if ((pmlmepriv->wps_probe_resp_ie!= NULL) && pwps_ie && (wps_ielen>0)) { ++ if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie && (wps_ielen > 0)) { + uint wps_offset, remainder_ielen; + u8 *premainder_ie; + @@ -64771,13 +63126,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + pktlen += wps_offset; + + wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */ -+ if ((wps_offset+wps_ielen+2)<=MAX_IE_SZ) { ++ if ((wps_offset+wps_ielen+2) <= MAX_IE_SZ) { + memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2); + pframe += wps_ielen+2; + pktlen += wps_ielen+2; + } + -+ if ((wps_offset+wps_ielen+2+remainder_ielen)<=MAX_IE_SZ) { ++ if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { + memcpy(pframe, premainder_ie, remainder_ielen); + pframe += remainder_ielen; + pktlen += remainder_ielen; @@ -64828,16 +63183,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +/* To check if reserved page content is destroyed by beacon beacuse beacon is too large. */ +/* 2010.06.23. Added by tynli. */ -+void -+CheckFwRsvdPageContent( -+ struct adapter * Adapter -+) ++void CheckFwRsvdPageContent(struct adapter *Adapter) +{ +} + +static void rtl8723b_set_FwRsvdPage_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc) +{ -+ u8 u1H2CRsvdPageParm[H2C_RSVDPAGE_LOC_LEN]={0}; ++ u8 u1H2CRsvdPageParm[H2C_RSVDPAGE_LOC_LEN] = {0}; + + DBG_871X("8723BRsvdPageLoc: ProbeRsp =%d PsPoll =%d Null =%d QoSNull =%d BTNull =%d\n", + rsvdpageloc->LocProbeRsp, rsvdpageloc->LocPsPoll, @@ -64858,7 +63210,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +{ +#ifdef CONFIG_WOWLAN + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -+ u8 u1H2CAoacRsvdPageParm[H2C_AOAC_RSVDPAGE_LOC_LEN]={0}; ++ u8 u1H2CAoacRsvdPageParm[H2C_AOAC_RSVDPAGE_LOC_LEN] = {0}; + + DBG_871X("8723BAOACRsvdPageLoc: RWC =%d ArpRsp =%d NbrAdv =%d GtkRsp =%d GtkInfo =%d ProbeReq =%d NetworkList =%d\n", + rsvdpageloc->LocRemoteCtrlInfo, rsvdpageloc->LocArpRsp, @@ -64893,11 +63245,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +} + +#ifdef CONFIG_AP_WOWLAN -+static void rtl8723b_set_ap_wow_rsvdpage_cmd(struct adapter *padapter, -+ PRSVDPAGE_LOC rsvdpageloc) ++static void rtl8723b_set_ap_wow_rsvdpage_cmd( ++ struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc ++) +{ + u8 header; -+ u8 rsvdparm[H2C_AOAC_RSVDPAGE_LOC_LEN]={0}; ++ u8 rsvdparm[H2C_AOAC_RSVDPAGE_LOC_LEN] = {0}; + + header = rtw_read8(padapter, REG_BCNQ_BDNY); + @@ -64929,7 +63282,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +void rtl8723b_set_FwMediaStatusRpt_cmd(struct adapter *padapter, u8 mstatus, u8 macid) +{ -+ u8 u1H2CMediaStatusRptParm[H2C_MEDIA_STATUS_RPT_LEN]={0}; ++ u8 u1H2CMediaStatusRptParm[H2C_MEDIA_STATUS_RPT_LEN] = {0}; + u8 macid_end = 0; + + DBG_871X("%s(): mstatus = %d macid =%d\n", __func__, mstatus, macid); @@ -64946,7 +63299,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#ifdef CONFIG_WOWLAN +static void rtl8723b_set_FwKeepAlive_cmd(struct adapter *padapter, u8 benable, u8 pkt_type) +{ -+ u8 u1H2CKeepAliveParm[H2C_KEEP_ALIVE_CTRL_LEN]={0}; ++ u8 u1H2CKeepAliveParm[H2C_KEEP_ALIVE_CTRL_LEN] = {0}; + u8 adopt = 1, check_period = 5; + + DBG_871X("%s(): benable = %d\n", __func__, benable); @@ -64962,7 +63315,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +static void rtl8723b_set_FwDisconDecision_cmd(struct adapter *padapter, u8 benable) +{ -+ u8 u1H2CDisconDecisionParm[H2C_DISCON_DECISION_LEN]={0}; ++ u8 u1H2CDisconDecisionParm[H2C_DISCON_DECISION_LEN] = {0}; + u8 adopt = 1, check_period = 10, trypkt_num = 0; + + DBG_871X("%s(): benable = %d\n", __func__, benable); @@ -64979,16 +63332,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +void rtl8723b_set_FwMacIdConfig_cmd(struct adapter *padapter, u8 mac_id, u8 raid, u8 bw, u8 sgi, u32 mask) +{ -+ u8 u1H2CMacIdConfigParm[H2C_MACID_CFG_LEN]={0}; ++ u8 u1H2CMacIdConfigParm[H2C_MACID_CFG_LEN] = {0}; + + DBG_871X("%s(): mac_id =%d raid = 0x%x bw =%d mask = 0x%x\n", __func__, mac_id, raid, bw, mask); + + SET_8723B_H2CCMD_MACID_CFG_MACID(u1H2CMacIdConfigParm, mac_id); + SET_8723B_H2CCMD_MACID_CFG_RAID(u1H2CMacIdConfigParm, raid); -+ SET_8723B_H2CCMD_MACID_CFG_SGI_EN(u1H2CMacIdConfigParm, (sgi)? 1:0); ++ SET_8723B_H2CCMD_MACID_CFG_SGI_EN(u1H2CMacIdConfigParm, sgi ? 1 : 0); + SET_8723B_H2CCMD_MACID_CFG_BW(u1H2CMacIdConfigParm, bw); + SET_8723B_H2CCMD_MACID_CFG_RATE_MASK0(u1H2CMacIdConfigParm, (u8)(mask & 0x000000ff)); -+ SET_8723B_H2CCMD_MACID_CFG_RATE_MASK1(u1H2CMacIdConfigParm, (u8)((mask & 0x0000ff00) >>8)); ++ SET_8723B_H2CCMD_MACID_CFG_RATE_MASK1(u1H2CMacIdConfigParm, (u8)((mask & 0x0000ff00) >> 8)); + SET_8723B_H2CCMD_MACID_CFG_RATE_MASK2(u1H2CMacIdConfigParm, (u8)((mask & 0x00ff0000) >> 16)); + SET_8723B_H2CCMD_MACID_CFG_RATE_MASK3(u1H2CMacIdConfigParm, (u8)((mask & 0xff000000) >> 24)); + @@ -64998,7 +63351,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +static void rtl8723b_set_FwRssiSetting_cmd(struct adapter *padapter, u8 *param) +{ -+ u8 u1H2CRssiSettingParm[H2C_RSSI_SETTING_LEN]={0}; ++ u8 u1H2CRssiSettingParm[H2C_RSSI_SETTING_LEN] = {0}; + u8 mac_id = *param; + u8 rssi = *(param+2); + u8 uldl_state = 0; @@ -65019,7 +63372,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + int i; + struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -+ u8 u1H2CPwrModeParm[H2C_PWRMODE_LEN]={0}; ++ u8 u1H2CPwrModeParm[H2C_PWRMODE_LEN] = {0}; + u8 PowerState = 0, awake_intvl = 1, byte5 = 0, rlbm = 0; + + if (pwrpriv->dtim > 0) @@ -65028,12 +63381,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + DBG_871X("%s(): FW LPS mode = %d, SmartPS =%d\n", __func__, psmode, pwrpriv->smart_ps); + +#ifdef CONFIG_WOWLAN -+ if (psmode == PS_MODE_DTIM) /* For WOWLAN LPS, DTIM = (awake_intvl - 1) */ -+ { ++ if (psmode == PS_MODE_DTIM) { /* For WOWLAN LPS, DTIM = (awake_intvl - 1) */ + awake_intvl = 3;/* DTIM =2 */ + rlbm = 2; -+ } -+ else ++ } else +#endif /* CONFIG_WOWLAN */ + { + if (pwrpriv->dtim > 0 && pwrpriv->dtim < 16) @@ -65045,50 +63396,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + } + + -+ if (padapter->registrypriv.wifi_spec == 1) -+ { ++ if (padapter->registrypriv.wifi_spec == 1) { + awake_intvl = 2; + rlbm = 2; + } + -+ if (psmode > 0) -+ { -+ if (rtw_btcoex_IsBtControlLps(padapter) == true) -+ { ++ if (psmode > 0) { ++ if (rtw_btcoex_IsBtControlLps(padapter) == true) { + PowerState = rtw_btcoex_RpwmVal(padapter); + byte5 = rtw_btcoex_LpsVal(padapter); + -+ if ((rlbm == 2) && (byte5 & BIT(4))) -+ { ++ if ((rlbm == 2) && (byte5 & BIT(4))) { + /* Keep awake interval to 1 to prevent from */ + /* decreasing coex performance */ + awake_intvl = 2; + rlbm = 2; + } -+ } -+ else -+ { ++ } else { + PowerState = 0x00;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ + byte5 = 0x40; + } -+ } -+ else -+ { ++ } else { + PowerState = 0x0C;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ + byte5 = 0x40; + } + -+ SET_8723B_H2CCMD_PWRMODE_PARM_MODE(u1H2CPwrModeParm, (psmode>0)?1:0); ++ SET_8723B_H2CCMD_PWRMODE_PARM_MODE(u1H2CPwrModeParm, (psmode > 0) ? 1 : 0); + SET_8723B_H2CCMD_PWRMODE_PARM_SMART_PS(u1H2CPwrModeParm, pwrpriv->smart_ps); + SET_8723B_H2CCMD_PWRMODE_PARM_RLBM(u1H2CPwrModeParm, rlbm); + SET_8723B_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1H2CPwrModeParm, awake_intvl); + SET_8723B_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(u1H2CPwrModeParm, padapter->registrypriv.uapsd_enable); + SET_8723B_H2CCMD_PWRMODE_PARM_PWR_STATE(u1H2CPwrModeParm, PowerState); + SET_8723B_H2CCMD_PWRMODE_PARM_BYTE5(u1H2CPwrModeParm, byte5); -+ if (psmode != PS_MODE_ACTIVE) -+ { -+ if (pmlmeext ->adaptive_tsf_done == false && pmlmeext->bcn_cnt>0) -+ { ++ if (psmode != PS_MODE_ACTIVE) { ++ if (pmlmeext->adaptive_tsf_done == false && pmlmeext->bcn_cnt > 0) { + u8 ratio_20_delay, ratio_80_delay; + + /* byte 6 for adaptive_early_32k */ @@ -65101,24 +63442,27 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + DBG_871X("%s(): bcn_cnt = %d\n", __func__, pmlmeext->bcn_cnt); + -+ for (i = 0; i<9; i++) -+ { -+ pmlmeext->bcn_delay_ratio[i] = (pmlmeext->bcn_delay_cnt[i] * 100) /pmlmeext->bcn_cnt; ++ for (i = 0; i < 9; i++) { ++ pmlmeext->bcn_delay_ratio[i] = (pmlmeext->bcn_delay_cnt[i]*100)/pmlmeext->bcn_cnt; + -+ DBG_871X("%s(): bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d] = %d\n", __func__, i, pmlmeext->bcn_delay_cnt[i] -+ , i , pmlmeext->bcn_delay_ratio[i]); ++ DBG_871X( ++ "%s(): bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d] = %d\n", ++ __func__, ++ i, ++ pmlmeext->bcn_delay_cnt[i], ++ i, ++ pmlmeext->bcn_delay_ratio[i] ++ ); + + ratio_20_delay += pmlmeext->bcn_delay_ratio[i]; + ratio_80_delay += pmlmeext->bcn_delay_ratio[i]; + -+ if (ratio_20_delay > 20 && pmlmeext->DrvBcnEarly == 0xff) -+ { ++ if (ratio_20_delay > 20 && pmlmeext->DrvBcnEarly == 0xff) { + pmlmeext->DrvBcnEarly = i; + DBG_871X("%s(): DrvBcnEarly = %d\n", __func__, pmlmeext->DrvBcnEarly); + } + -+ if (ratio_80_delay > 80 && pmlmeext->DrvBcnTimeOut == 0xff) -+ { ++ if (ratio_80_delay > 80 && pmlmeext->DrvBcnTimeOut == 0xff) { + pmlmeext->DrvBcnTimeOut = i; + DBG_871X("%s(): DrvBcnTimeOut = %d\n", __func__, pmlmeext->DrvBcnTimeOut); + } @@ -65130,11 +63474,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + } + + pmlmeext->bcn_cnt = 0; -+ pmlmeext ->adaptive_tsf_done = true; ++ pmlmeext->adaptive_tsf_done = true; + -+ } -+ else -+ { ++ } else { + DBG_871X("%s(): DrvBcnEarly = %d\n", __func__, pmlmeext->DrvBcnEarly); + DBG_871X("%s(): DrvBcnTimeOut = %d\n", __func__, pmlmeext->DrvBcnTimeOut); + } @@ -65158,7 +63500,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +void rtl8723b_set_FwPsTuneParam_cmd(struct adapter *padapter) +{ -+ u8 u1H2CPsTuneParm[H2C_PSTUNEPARAM_LEN]={0}; ++ u8 u1H2CPsTuneParm[H2C_PSTUNEPARAM_LEN] = {0}; + u8 bcn_to_limit = 10; /* 10 * 100 * awakeinterval (ms) */ + u8 dtim_timeout = 5; /* ms wait broadcast data timer */ + u8 ps_timeout = 20; /* ms Keep awake when tx */ @@ -65190,7 +63532,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +static void rtl8723b_set_FwWoWlanCtrl_Cmd(struct adapter *padapter, u8 bFuncEn) +{ + struct security_priv *psecpriv = &padapter->securitypriv; -+ u8 u1H2CWoWlanCtrlParm[H2C_WOWLAN_LEN]={0}; ++ u8 u1H2CWoWlanCtrlParm[H2C_WOWLAN_LEN] = {0}; + u8 discont_wake = 1, gpionum = 0, gpio_dur = 0, hw_unicast = 0; + u8 sdio_wakeup_enable = 1; + u8 gpio_high_active = 0; /* 0: low active, 1: high active */ @@ -65202,9 +63544,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#endif + +#ifdef CONFIG_PNO_SUPPORT -+ if (!ppwrpriv->wowlan_pno_enable) { ++ if (!ppwrpriv->wowlan_pno_enable) + magic_pkt = 1; -+ } +#endif + + if (psecpriv->dot11PrivacyAlgrthm == _WEP40_ || psecpriv->dot11PrivacyAlgrthm == _WEP104_) @@ -65232,8 +63573,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +static void rtl8723b_set_FwRemoteWakeCtrl_Cmd(struct adapter *padapter, u8 benable) +{ -+ u8 u1H2CRemoteWakeCtrlParm[H2C_REMOTE_WAKE_CTRL_LEN]={0}; -+ struct security_priv* psecuritypriv =&(padapter->securitypriv); ++ u8 u1H2CRemoteWakeCtrlParm[H2C_REMOTE_WAKE_CTRL_LEN] = {0}; ++ struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct pwrctrl_priv *ppwrpriv = adapter_to_pwrctl(padapter); + + DBG_871X("%s(): Enable =%d\n", __func__, benable); @@ -65285,7 +63626,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +static void rtl8723b_set_FwAOACGlobalInfo_Cmd(struct adapter *padapter, u8 group_alg, u8 pairwise_alg) +{ -+ u8 u1H2CAOACGlobalInfoParm[H2C_AOAC_GLOBAL_INFO_LEN]={0}; ++ u8 u1H2CAOACGlobalInfoParm[H2C_AOAC_GLOBAL_INFO_LEN] = {0}; + + DBG_871X("%s(): group_alg =%d pairwise_alg =%d\n", __func__, group_alg, pairwise_alg); + @@ -65300,7 +63641,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#ifdef CONFIG_PNO_SUPPORT +static void rtl8723b_set_FwScanOffloadInfo_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc, u8 enable) +{ -+ u8 u1H2CScanOffloadInfoParm[H2C_SCAN_OFFLOAD_CTRL_LEN]={0}; ++ u8 u1H2CScanOffloadInfoParm[H2C_SCAN_OFFLOAD_CTRL_LEN] = {0}; + u8 res = 0, count = 0; + struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); + @@ -65333,41 +63674,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT); /* RT_MEDIA_CONNECT will confuse in the future */ + -+ if (!(ppwrpriv->wowlan_pno_enable)) -+ { ++ if (!(ppwrpriv->wowlan_pno_enable)) { + psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv)); + if (psta != NULL) + rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id); -+ } -+ else ++ } else + DBG_871X("%s(): Disconnected, no FwMediaStatusRpt CONNECT\n", __func__); + + msleep(2); + + if (!(ppwrpriv->wowlan_pno_enable)) { -+ rtl8723b_set_FwDisconDecision_cmd(padapter, enable); -+ msleep(2); ++ rtl8723b_set_FwDisconDecision_cmd(padapter, enable); ++ msleep(2); + + if ((psecpriv->dot11PrivacyAlgrthm != _WEP40_) || (psecpriv->dot11PrivacyAlgrthm != _WEP104_)) + pkt_type = 1; ++ + rtl8723b_set_FwKeepAlive_cmd(padapter, enable, pkt_type); -+ msleep(2); ++ msleep(2); + } + + rtl8723b_set_FwWoWlanCtrl_Cmd(padapter, enable); + msleep(2); + + rtl8723b_set_FwRemoteWakeCtrl_Cmd(padapter, enable); -+ } -+ else -+ { ++ } else { + rtl8723b_set_FwRemoteWakeCtrl_Cmd(padapter, enable); + msleep(2); + rtl8723b_set_FwWoWlanCtrl_Cmd(padapter, enable); + } + + DBG_871X_LEVEL(_drv_always_, "-%s()-\n", __func__); -+ return ; +} + +void rtl8723b_set_wowlan_cmd(struct adapter *padapter, u8 enable) @@ -65379,7 +63716,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#ifdef CONFIG_AP_WOWLAN +static void rtl8723b_set_FwAPWoWlanCtrl_Cmd(struct adapter *padapter, u8 bFuncEn) +{ -+ u8 u1H2CAPWoWlanCtrlParm[H2C_WOWLAN_LEN]={0}; ++ u8 u1H2CAPWoWlanCtrlParm[H2C_WOWLAN_LEN] = {0}; + u8 gpionum = 0, gpio_dur = 0; + u8 gpio_high_active = 1; /* 0: low active, 1: high active */ + u8 gpio_pulse = bFuncEn; @@ -65411,7 +63748,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + +static void rtl8723b_set_Fw_AP_Offload_Cmd(struct adapter *padapter, u8 bFuncEn) +{ -+ u8 u1H2CAPOffloadCtrlParm[H2C_WOWLAN_LEN]={0}; ++ u8 u1H2CAPOffloadCtrlParm[H2C_WOWLAN_LEN] = {0}; + + DBG_871X("%s(): bFuncEn =%d\n", __func__, bFuncEn); + @@ -65453,11 +63790,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +/* true: At the second time, we should send the first packet (default:beacon) */ +/* to Hw again and set the lengh in descriptor to the real beacon lengh. */ +/* 2009.10.15 by tynli. */ -+static void rtl8723b_set_FwRsvdPagePkt(struct adapter *padapter, bool bDLFinished) ++static void rtl8723b_set_FwRsvdPagePkt( ++ struct adapter *padapter, bool bDLFinished ++) +{ + struct hal_com_data *pHalData; -+ struct xmit_frame *pcmdframe; -+ struct pkt_attrib *pattrib; ++ struct xmit_frame *pcmdframe; ++ struct pkt_attrib *pattrib; + struct xmit_priv *pxmitpriv; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; @@ -65470,14 +63809,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + u8 TotalPageNum = 0, CurtPktPageNum = 0, RsvdPageNum = 0; + u16 BufIndex, PageSize = 128; + u32 TotalPacketLen, MaxRsvdPageBufSize = 0; -+ RSVDPAGE_LOC RsvdPageLoc; ++ RSVDPAGE_LOC RsvdPageLoc; +#ifdef CONFIG_WOWLAN + u32 ARPLegnth = 0, GTKLegnth = 0; + u8 currentip[4]; + u8 cur_dot11txpn[8]; +#ifdef CONFIG_GTK_OL + struct sta_priv *pstapriv = &padapter->stapriv; -+ struct sta_info * psta; ++ struct sta_info *psta; + u8 kek[RTW_KEK_LEN]; + u8 kck[RTW_KCK_LEN]; +#endif @@ -65512,9 +63851,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + CurtPktPageNum = (u8)PageNum_128(TxDescLen + BeaconLength); + /* If we don't add 1 more page, the WOWLAN function has a problem. Baron thinks it's a bug of firmware */ + if (CurtPktPageNum == 1) -+ { + CurtPktPageNum += 1; -+ } ++ + TotalPageNum += CurtPktPageNum; + + BufIndex += (CurtPktPageNum*PageSize); @@ -65540,7 +63878,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + &ReservedPagePacket[BufIndex], + &NullDataLength, + get_my_bssid(&pmlmeinfo->network), -+ false, 0, 0, false); ++ false, 0, 0, false ++ ); + rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], NullDataLength, false, false, false); + + /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: NULL DATA %p %d\n", */ @@ -65559,7 +63898,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + &ReservedPagePacket[BufIndex], + &QosNullLength, + get_my_bssid(&pmlmeinfo->network), -+ true, 0, 0, false); ++ true, 0, 0, false ++ ); + rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], QosNullLength, false, false, false); + + /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: QOS NULL DATA %p %d\n", */ @@ -65578,7 +63918,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + &ReservedPagePacket[BufIndex], + &BTQosNullLength, + get_my_bssid(&pmlmeinfo->network), -+ true, 0, 0, false); ++ true, 0, 0, false ++ ); + rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], BTQosNullLength, false, true, false); + + /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: BT QOS NULL DATA %p %d\n", */ @@ -65633,14 +63974,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + /* if the ap staion info. exists, get the kek, kck from staion info. */ + psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); -+ if (psta == NULL) -+ { ++ if (psta == NULL) { + memset(kek, 0, RTW_KEK_LEN); + memset(kck, 0, RTW_KCK_LEN); + DBG_8192C("%s, KEK, KCK download rsvd page all zero\n", __func__); -+ } -+ else -+ { ++ } else { + memcpy(kek, psta->kek, RTW_KEK_LEN); + memcpy(kck, psta->kck, RTW_KCK_LEN); + } @@ -65665,7 +64003,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + padapter, + &ReservedPagePacket[BufIndex], + >KLegnth -+ ); ++ ); + + rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], GTKLegnth, false, false, true); + /* DBG_871X("%s(): HW_VAR_SET_TX_CMD: GTK RSP %p %d\n", */ @@ -65708,9 +64046,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + { + int gj; + printk("probe req pkt =>\n"); -+ for (gj = 0; gj < ProbeReqLength + TxDescLen; gj++) { -+ printk(" %02x ", ReservedPagePacket[BufIndex- TxDescLen + gj]); -+ if ((gj + 1)%8 == 0) ++ for (gj = 0; gj < ProbeReqLength+TxDescLen; gj++) { ++ printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]); ++ if ((gj+1)%8 == 0) + printk("\n"); + } + printk(" <=end\n"); @@ -65725,13 +64063,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + /* PNO INFO Page */ + RsvdPageLoc.LocPNOInfo = TotalPageNum; -+ ConstructPnoInfo(padapter, &ReservedPagePacket[BufIndex -TxDescLen], &PNOLength); ++ ConstructPnoInfo(padapter, &ReservedPagePacket[BufIndex-TxDescLen], &PNOLength); +#ifdef CONFIG_PNO_SET_DEBUG + { + int gj; + printk("PNO pkt =>\n"); + for (gj = 0; gj < PNOLength; gj++) { -+ printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen +gj]); ++ printk(" %02x ", ReservedPagePacket[BufIndex-TxDescLen+gj]); + if ((gj + 1)%8 == 0) + printk("\n"); + } @@ -65790,14 +64128,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#endif + } + -+ if (TotalPacketLen > MaxRsvdPageBufSize) -+ { ++ if (TotalPacketLen > MaxRsvdPageBufSize) { + DBG_871X("%s(): ERROR: The rsvd page size is not enough!!TotalPacketLen %d, MaxRsvdPageBufSize %d\n", __func__, + TotalPacketLen, MaxRsvdPageBufSize); + goto error; -+ } -+ else -+ { ++ } else { + /* update attribute */ + pattrib = &pcmdframe->attrib; + update_mgntframe_attrib(padapter, pattrib); @@ -65841,12 +64176,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +/* true: At the second time, we should send the first packet (default:beacon) */ +/* to Hw again and set the lengh in descriptor to the real beacon lengh. */ +/* 2009.10.15 by tynli. */ -+static void rtl8723b_set_AP_FwRsvdPagePkt(struct adapter *padapter, -+ bool bDLFinished) ++static void rtl8723b_set_AP_FwRsvdPagePkt( ++ struct adapter *padapter, bool bDLFinished ++) +{ + struct hal_com_data *pHalData; -+ struct xmit_frame *pcmdframe; -+ struct pkt_attrib *pattrib; ++ struct xmit_frame *pcmdframe; ++ struct pkt_attrib *pattrib; + struct xmit_priv *pxmitpriv; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; @@ -65858,7 +64194,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + u8 currentip[4]; + u16 BufIndex, PageSize = 128; + u32 TotalPacketLen = 0, MaxRsvdPageBufSize = 0; -+ RSVDPAGE_LOC RsvdPageLoc; ++ RSVDPAGE_LOC RsvdPageLoc; + + /* DBG_871X("%s---->\n", __func__); */ + DBG_8192C("+" FUNC_ADPT_FMT ": iface_type =%d\n", @@ -65891,9 +64227,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + CurtPktPageNum = (u8)PageNum_128(TxDescLen + BeaconLength); + /* If we don't add 1 more page, the WOWLAN function has a problem. Baron thinks it's a bug of firmware */ + if (CurtPktPageNum == 1) -+ { + CurtPktPageNum += 1; -+ } + TotalPageNum += CurtPktPageNum; + + BufIndex += (CurtPktPageNum*PageSize); @@ -65950,7 +64284,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +} +#endif /* CONFIG_AP_WOWLAN */ + -+ void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus) ++void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); +#ifdef CONFIG_AP_WOWLAN @@ -65958,7 +64292,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +#endif + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); -+ bool bcn_valid = false; ++ bool bcn_valid = false; + u8 DLBcnCount = 0; + u32 poll = 0; + u8 val8; @@ -65966,8 +64300,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + DBG_8192C("+" FUNC_ADPT_FMT ": iface_type =%d mstatus(%x)\n", + FUNC_ADPT_ARG(padapter), get_iface_type(padapter), mstatus); + -+ if (mstatus == RT_MEDIA_CONNECT) -+ { ++ if (mstatus == RT_MEDIA_CONNECT) { + bool bRecover = false; + u8 v8; + @@ -65978,7 +64311,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + /* set REG_CR bit 8 */ + v8 = rtw_read8(padapter, REG_CR+1); + v8 |= BIT(0); /* ENSWBCN */ -+ rtw_write8(padapter, REG_CR+1, v8); ++ rtw_write8(padapter, REG_CR+1, v8); + + /* Disable Hw protection for a time which revserd for Hw sending beacon. */ + /* Fix download reserved page packet fail that access collision with the protection time. */ @@ -66013,23 +64346,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + rtl8723b_set_FwRsvdPagePkt(padapter, 0); +#endif + DLBcnCount++; -+ do -+ { ++ do { + yield(); + /* mdelay(10); */ + /* check rsvd page download OK. */ + rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); + poll++; -+ } while (!bcn_valid && (poll%10)!= 0 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); ++ } while (!bcn_valid && (poll%10) != 0 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + -+ }while (!bcn_valid && DLBcnCount<= 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); ++ } while (!bcn_valid && DLBcnCount <= 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + -+ if (padapter->bSurpriseRemoved || padapter->bDriverStopped) -+ { -+ } -+ else if (!bcn_valid) ++ if (padapter->bSurpriseRemoved || padapter->bDriverStopped) { ++ } else if (!bcn_valid) + DBG_871X(ADPT_FMT": 1 DL RSVD page failed! DLBcnCount:%u, poll:%u\n", -+ ADPT_ARG(padapter) , DLBcnCount, poll); ++ ADPT_ARG(padapter), DLBcnCount, poll); + else { + struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); + pwrctl->fw_psmode_iface_id = padapter->iface_id; @@ -66048,8 +64378,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + /* prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */ + /* the beacon cannot be sent by HW. */ + /* 2010.06.23. Added by tynli. */ -+ if (bRecover) -+ { ++ if (bRecover) { + rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl | BIT(6)); + pHalData->RegFwHwTxQCtrl |= BIT(6); + } @@ -66076,7 +64405,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 +/* arg[1] = raid */ +/* arg[2] = shortGIrate */ +/* arg[3] = init_rate */ -+void rtl8723b_Add_RateATid(struct adapter *padapter, u32 bitmap, u8 *arg, u8 rssi_level) ++void rtl8723b_Add_RateATid( ++ struct adapter *padapter, ++ u32 bitmap, ++ u8 *arg, ++ u8 rssi_level ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -66090,9 +64424,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + + psta = pmlmeinfo->FW_sta_info[mac_id].psta; + if (psta == NULL) -+ { + return; -+ } + + bw = psta->bw_mode; + @@ -66111,7 +64443,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + u8 bQoS, + u8 AC, + u8 bEosp, -+ u8 bForcePowerSave) ++ u8 bForcePowerSave ++) +{ + struct ieee80211_hdr *pwlanhdr; + __le16 *fctrl; @@ -66124,12 +64457,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + DBG_871X("+" FUNC_ADPT_FMT ": qos =%d eosp =%d ps =%d\n", + FUNC_ADPT_ARG(padapter), bQoS, bEosp, bForcePowerSave); + -+ pwlanhdr = (struct ieee80211_hdr*)pframe; ++ pwlanhdr = (struct ieee80211_hdr *)pframe; + pmlmeext = &padapter->mlmeextpriv; + pmlmeinfo = &pmlmeext->mlmext_info; + -+ if (NULL == StaAddr) -+ { ++ if (NULL == StaAddr) { + memcpy(bssid, myid(&padapter->eeprompriv), ETH_ALEN); + StaAddr = bssid; + } @@ -66147,20 +64479,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + SetDuration(pwlanhdr, 0); + SetSeqNum(pwlanhdr, 0); + -+ if (bQoS == true) -+ { ++ if (bQoS == true) { + struct ieee80211_qos_hdr *pwlanqoshdr; + + SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); + -+ pwlanqoshdr = (struct ieee80211_qos_hdr*)pframe; ++ pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe; + SetPriority(&pwlanqoshdr->qos_ctrl, AC); + SetEOSP(&pwlanqoshdr->qos_ctrl, bEosp); + + pktlen = sizeof(struct ieee80211_qos_hdr); -+ } -+ else -+ { ++ } else { + SetFrameSubType(pframe, WIFI_DATA_NULL); + + pktlen = sizeof(struct ieee80211_hdr_3addr); @@ -66218,16 +64547,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + CurtPktPageNum = (u8)PageNum_128(TxDescLen + BeaconLength); + /* If we don't add 1 more page, the WOWLAN function has a problem. Baron thinks it's a bug of firmware */ + if (CurtPktPageNum == 1) -+ { + CurtPktPageNum += 1; -+ } + TotalPageNum += CurtPktPageNum; + + BufIndex += (CurtPktPageNum*PageSize); + + /* Jump to lastest page */ -+ if (BufIndex < (MaxRsvdPageBufSize - PageSize)) -+ { ++ if (BufIndex < (MaxRsvdPageBufSize - PageSize)) { + BufIndex = TxDescOffset + (MaxRsvdPageBufSize - PageSize); + TotalPageNum = BCNQ_PAGE_NUM_8723B - 1; + } @@ -66239,7 +64565,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + &ReservedPagePacket[BufIndex], + &BTQosNullLength, + NULL, -+ true, 0, 0, false); ++ true, 0, 0, false ++ ); + rtl8723b_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex-TxDescLen], BTQosNullLength, false, true, false); + + CurtPktPageNum = (u8)PageNum_128(TxDescLen + BTQosNullLength); @@ -66247,8 +64574,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + TotalPageNum += CurtPktPageNum; + + TotalPacketLen = BufIndex + BTQosNullLength; -+ if (TotalPacketLen > MaxRsvdPageBufSize) -+ { ++ if (TotalPacketLen > MaxRsvdPageBufSize) { + DBG_8192C(FUNC_ADPT_FMT ": ERROR: The rsvd page size is not enough!!TotalPacketLen %d, MaxRsvdPageBufSize %d\n", + FUNC_ADPT_ARG(padapter), TotalPacketLen, MaxRsvdPageBufSize); + goto error; @@ -66288,8 +64614,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + FUNC_ADPT_ARG(padapter), get_iface_type(padapter), get_fwstate(&padapter->mlmepriv)); + +#ifdef CONFIG_DEBUG -+ if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == false) -+ { ++ if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == false) { + DBG_8192C(FUNC_ADPT_FMT ": [WARNING] not in AP mode!!\n", + FUNC_ADPT_ARG(padapter)); + } @@ -66339,18 +64664,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + /* check rsvd page download OK. */ + rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, &bcn_valid); + poll++; -+ } while (!bcn_valid && (poll%10)!= 0 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); -+ } while (!bcn_valid && (DLBcnCount<= 100) && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); ++ } while (!bcn_valid && (poll%10) != 0 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); ++ } while (!bcn_valid && (DLBcnCount <= 100) && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + -+ if (true == bcn_valid) -+ { ++ if (true == bcn_valid) { + struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); + pwrctl->fw_psmode_iface_id = padapter->iface_id; + DBG_8192C(ADPT_FMT": DL RSVD page success! DLBcnCount:%d, poll:%d\n", + ADPT_ARG(padapter), DLBcnCount, poll); -+ } -+ else -+ { ++ } else { + DBG_8192C(ADPT_FMT": DL RSVD page fail! DLBcnCount:%d, poll:%d\n", + ADPT_ARG(padapter), DLBcnCount, poll); + DBG_8192C(ADPT_FMT": DL RSVD page fail! bSurpriseRemoved =%d\n", @@ -66370,8 +64692,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + /* prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */ + /* the beacon cannot be sent by HW. */ + /* 2010.06.23. Added by tynli. */ -+ if (bRecover) -+ { ++ if (bRecover) { + pHalData->RegFwHwTxQCtrl |= BIT(6); + rtw_write8(padapter, REG_FWHW_TXQ_CTRL+2, pHalData->RegFwHwTxQCtrl); + } @@ -66381,10 +64702,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_cmd.c linux-4.3-rtl8723bs/3 + val8 &= ~BIT(0); /* ~ENSWBCN */ + rtw_write8(padapter, REG_CR+1, val8); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_dm.c ---- linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_dm.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,314 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux/3rdparty/rtl8723bs/hal/rtl8723b_dm.c +--- linux.old/3rdparty/rtl8723bs/hal/rtl8723b_dm.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/rtl8723b_dm.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,300 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -66410,10 +64731,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + +/* Global var */ + -+static void -+dm_CheckStatistics( -+struct adapter *Adapter -+ ) ++static void dm_CheckStatistics(struct adapter *Adapter) +{ +} +/* */ @@ -66423,7 +64741,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r +{ + + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); ++ PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + u8 cut_ver, fab_ver; + @@ -66454,17 +64772,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + + if (pHalData->rf_type == RF_1T1R) { + ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_1T1R); -+ } -+ else if (pHalData->rf_type == RF_2T2R) { ++ } else if (pHalData->rf_type == RF_2T2R) { + ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_2T2R); -+ } -+ else if (pHalData->rf_type == RF_1T2R) { ++ } else if (pHalData->rf_type == RF_1T2R) { + ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_1T2R); + } + -+ pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | -+ ODM_RF_TX_PWR_TRACK /* */ -+ ; ++ pdmpriv->InitODMFlag = ODM_RF_CALIBRATION|ODM_RF_TX_PWR_TRACK; + + ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); +} @@ -66472,11 +64786,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r +static void Update_ODM_ComInfo_8723b(struct adapter *Adapter) +{ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; -+ struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; ++ struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + struct dvobj_priv *dvobj = adapter_to_dvobj(Adapter); + struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(Adapter); + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); ++ PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + int i; + u8 zero = 0; @@ -66506,35 +64820,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + + ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); + -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_TX_UNI,&(dvobj->traffic_stat.tx_bytes)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_RX_UNI,&(dvobj->traffic_stat.rx_bytes)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_WM_MODE,&(pmlmeext->cur_wireless_mode)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SEC_CHNL_OFFSET,&(pHalData->nCur40MhzPrimeSC)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SEC_MODE,&(Adapter->securitypriv.dot11PrivacyAlgrthm)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_BW,&(pHalData->CurrentChannelBW)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_CHNL,&(pHalData->CurrentChannel)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_NET_CLOSED,&(Adapter->net_closed)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_TX_UNI, &(dvobj->traffic_stat.tx_bytes)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_RX_UNI, &(dvobj->traffic_stat.rx_bytes)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_WM_MODE, &(pmlmeext->cur_wireless_mode)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SEC_CHNL_OFFSET, &(pHalData->nCur40MhzPrimeSC)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SEC_MODE, &(Adapter->securitypriv.dot11PrivacyAlgrthm)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_BW, &(pHalData->CurrentChannelBW)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_CHNL, &(pHalData->CurrentChannel)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_NET_CLOSED, &(Adapter->net_closed)); + ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_MP_MODE, &zero); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_BAND,&(pHalData->CurrentBandType)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_FORCED_IGI_LB,&(pHalData->u1ForcedIgiLb)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_FORCED_RATE,&(pHalData->ForcedDataRate)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_BAND, &(pHalData->CurrentBandType)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_FORCED_IGI_LB, &(pHalData->u1ForcedIgiLb)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_FORCED_RATE, &(pHalData->ForcedDataRate)); + -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SCAN,&(pmlmepriv->bScanInProcess)); -+ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_POWER_SAVING,&(pwrctrlpriv->bpower_saving)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_SCAN, &(pmlmepriv->bScanInProcess)); ++ ODM_CmnInfoHook(pDM_Odm, ODM_CMNINFO_POWER_SAVING, &(pwrctrlpriv->bpower_saving)); + + + for (i = 0; i < NUM_STA; i++) + ODM_CmnInfoPtrArrayHook(pDM_Odm, ODM_CMNINFO_STA_STATUS, i, NULL); +} + -+void -+rtl8723b_InitHalDm( -+struct adapter *Adapter -+ ) ++void rtl8723b_InitHalDm(struct adapter *Adapter) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; -+ PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); ++ PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); + + pdmpriv->DM_Type = DM_Type_ByDriver; + pdmpriv->DMFlag = DYNAMIC_FUNC_DISABLE; @@ -66548,13 +64859,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + ODM_DMInit(pDM_Odm); +} + -+void -+rtl8723b_HalDmWatchDog( -+struct adapter *Adapter -+ ) ++void rtl8723b_HalDmWatchDog(struct adapter *Adapter) +{ -+ bool bFwCurrentInPSMode = false; -+ bool bFwPSAwake = true; ++ bool bFwCurrentInPSMode = false; ++ bool bFwPSAwake = true; + u8 hw_init_completed = false; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + @@ -66566,9 +64874,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + bFwCurrentInPSMode = adapter_to_pwrctl(Adapter)->bFwCurrentInPSMode; + rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bFwPSAwake)); + -+ if ((hw_init_completed == true) -+ && ((!bFwCurrentInPSMode) && bFwPSAwake)) -+ { ++ if ( ++ (hw_init_completed == true) && ++ ((!bFwCurrentInPSMode) && bFwPSAwake) ++ ) { + /* */ + /* Calculate Tx/Rx statistics. */ + /* */ @@ -66577,10 +64886,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + } + + /* ODM */ -+ if (hw_init_completed == true) -+ { -+ u8 bLinked =false; -+ u8 bsta_state =false; ++ if (hw_init_completed == true) { ++ u8 bLinked = false; ++ u8 bsta_state = false; + u8 bBtDisabled = true; + + if (rtw_linked_check(Adapter)) { @@ -66589,8 +64897,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + bsta_state = true; + } + -+ ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_LINK, bLinked); -+ ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_STATION_STATE, bsta_state); ++ ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_LINK, bLinked); ++ ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_STATION_STATE, bsta_state); + + /* ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); */ + @@ -66610,7 +64918,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + u32 PWDB_rssi = 0; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *psta = NULL; + @@ -66622,8 +64930,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + + /* set rssi to fw */ + psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); -+ if (psta && (psta->rssi_stat.UndecoratedSmoothedPWDB > 0)) -+ { ++ if (psta && (psta->rssi_stat.UndecoratedSmoothedPWDB > 0)) { + PWDB_rssi = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16)); + + rtl8723b_set_rssi_cmd(padapter, (u8 *)&PWDB_rssi); @@ -66633,12 +64940,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + +void rtl8723b_HalDmWatchDog_in_LPS(struct adapter *Adapter) +{ -+ u8 bLinked =false; ++ u8 bLinked = false; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + struct dm_priv *pdmpriv = &pHalData->dmpriv; -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; -+ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ pDIG_T pDM_DigTable = &pDM_Odm->DM_DigTable; + struct sta_priv *pstapriv = &Adapter->stapriv; + struct sta_info *psta = NULL; + @@ -66649,7 +64956,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + if (rtw_linked_check(Adapter)) + bLinked = true; + -+ ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_LINK, bLinked); ++ ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_LINK, bLinked); + + if (bLinked == false) + goto skip_lps_dm; @@ -66678,12 +64985,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + pDM_Odm->RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM; + + /* if (pDM_DigTable->CurIGValue != pDM_Odm->RSSI_Min) */ -+ if ((pDM_DigTable->CurIGValue > pDM_Odm->RSSI_Min + 5) || -+ (pDM_DigTable->CurIGValue < pDM_Odm->RSSI_Min - 5)) -+ -+ { ++ if ( ++ (pDM_DigTable->CurIGValue > pDM_Odm->RSSI_Min + 5) || ++ (pDM_DigTable->CurIGValue < pDM_Odm->RSSI_Min - 5) ++ ) + rtw_dm_in_lps_wk_cmd(Adapter); -+ } + + +skip_lps_dm: @@ -66692,17 +64998,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_dm.c linux-4.3-rtl8723bs/3r + +} + -+void rtl8723b_init_dm_priv(struct adapter * Adapter) ++void rtl8723b_init_dm_priv(struct adapter *Adapter) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; ++ + memset(pdmpriv, 0, sizeof(struct dm_priv)); + Init_ODM_ComInfo_8723b(Adapter); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c ---- linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,4844 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c +--- linux.old/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,4546 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved. @@ -66726,16 +65033,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +#include +#include "hal_com_h2c.h" + -+static void -+_FWDownloadEnable( -+struct adapter * padapter, -+bool enable -+ ) ++static void _FWDownloadEnable(struct adapter *padapter, bool enable) +{ + u8 tmp, count = 0; + -+ if (enable) -+ { ++ if (enable) { + /* 8051 enable */ + tmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); + rtw_write8(padapter, REG_SYS_FUNC_EN+1, tmp|0x04); @@ -66743,44 +65045,38 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + tmp = rtw_read8(padapter, REG_MCUFWDL); + rtw_write8(padapter, REG_MCUFWDL, tmp|0x01); + -+ do{ ++ do { + tmp = rtw_read8(padapter, REG_MCUFWDL); + if (tmp & 0x01) + break; + rtw_write8(padapter, REG_MCUFWDL, tmp|0x01); + msleep(1); -+ }while (count++<100); ++ } while (count++ < 100); ++ + if (count > 0) + DBG_871X("%s: !!!!!!!!Write 0x80 Fail!: count = %d\n", __func__, count); + + /* 8051 reset */ + tmp = rtw_read8(padapter, REG_MCUFWDL+2); + rtw_write8(padapter, REG_MCUFWDL+2, tmp&0xf7); -+ } -+ else -+ { ++ } else { + /* MCU firmware download disable. */ + tmp = rtw_read8(padapter, REG_MCUFWDL); + rtw_write8(padapter, REG_MCUFWDL, tmp&0xfe); + } +} + -+static int -+_BlockWrite( -+ struct adapter * padapter, -+ void * buffer, -+ u32 buffSize -+ ) ++static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) +{ + int ret = _SUCCESS; + -+ u32 blockSize_p1 = 4; /* (Default) Phase #1 : PCI muse use 4-byte write to download FW */ -+ u32 blockSize_p2 = 8; /* Phase #2 : Use 8-byte, if Phase#1 use big size to write FW. */ -+ u32 blockSize_p3 = 1; /* Phase #3 : Use 1-byte, the remnant of FW image. */ -+ u32 blockCount_p1 = 0, blockCount_p2 = 0, blockCount_p3 = 0; -+ u32 remainSize_p1 = 0, remainSize_p2 = 0; -+ u8 *bufferPtr = (u8 *)buffer; -+ u32 i = 0, offset = 0; ++ u32 blockSize_p1 = 4; /* (Default) Phase #1 : PCI muse use 4-byte write to download FW */ ++ u32 blockSize_p2 = 8; /* Phase #2 : Use 8-byte, if Phase#1 use big size to write FW. */ ++ u32 blockSize_p3 = 1; /* Phase #3 : Use 1-byte, the remnant of FW image. */ ++ u32 blockCount_p1 = 0, blockCount_p2 = 0, blockCount_p3 = 0; ++ u32 remainSize_p1 = 0, remainSize_p2 = 0; ++ u8 *bufferPtr = (u8 *)buffer; ++ u32 i = 0, offset = 0; + +/* printk("====>%s %d\n", __func__, __LINE__); */ + @@ -66789,14 +65085,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + remainSize_p1 = buffSize % blockSize_p1; + + if (blockCount_p1) { -+ RT_TRACE(_module_hal_init_c_, _drv_notice_, -+ ("_BlockWrite: [P1] buffSize(%d) blockSize_p1(%d) blockCount_p1(%d) remainSize_p1(%d)\n", -+ buffSize, blockSize_p1, blockCount_p1, remainSize_p1)); ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_notice_, ++ ( ++ "_BlockWrite: [P1] buffSize(%d) blockSize_p1(%d) blockCount_p1(%d) remainSize_p1(%d)\n", ++ buffSize, ++ blockSize_p1, ++ blockCount_p1, ++ remainSize_p1 ++ ) ++ ); + } + -+ for (i = 0; i < blockCount_p1; i++) -+ { -+ ret = rtw_write32(padapter, (FW_8723B_START_ADDRESS + i * blockSize_p1), *((u32*)(bufferPtr + i * blockSize_p1))); ++ for (i = 0; i < blockCount_p1; i++) { ++ ret = rtw_write32(padapter, (FW_8723B_START_ADDRESS + i * blockSize_p1), *((u32 *)(bufferPtr + i * blockSize_p1))); + if (ret == _FAIL) { + printk("====>%s %d i:%d\n", __func__, __LINE__, i); + goto exit; @@ -66804,24 +65107,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } + + /* 3 Phase #2 */ -+ if (remainSize_p1) -+ { ++ if (remainSize_p1) { + offset = blockCount_p1 * blockSize_p1; + + blockCount_p2 = remainSize_p1/blockSize_p2; + remainSize_p2 = remainSize_p1%blockSize_p2; + + if (blockCount_p2) { -+ RT_TRACE(_module_hal_init_c_, _drv_notice_, -+ ("_BlockWrite: [P2] buffSize_p2(%d) blockSize_p2(%d) blockCount_p2(%d) remainSize_p2(%d)\n", -+ (buffSize-offset), blockSize_p2 , blockCount_p2, remainSize_p2)); ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_notice_, ++ ( ++ "_BlockWrite: [P2] buffSize_p2(%d) blockSize_p2(%d) blockCount_p2(%d) remainSize_p2(%d)\n", ++ (buffSize-offset), ++ blockSize_p2, ++ blockCount_p2, ++ remainSize_p2 ++ ) ++ ); + } + + } + + /* 3 Phase #3 */ -+ if (remainSize_p2) -+ { ++ if (remainSize_p2) { + offset = (blockCount_p1 * blockSize_p1) + (blockCount_p2 * blockSize_p2); + + blockCount_p3 = remainSize_p2 / blockSize_p3; @@ -66830,7 +65139,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + ("_BlockWrite: [P3] buffSize_p3(%d) blockSize_p3(%d) blockCount_p3(%d)\n", + (buffSize-offset), blockSize_p3, blockCount_p3)); + -+ for (i = 0 ; i < blockCount_p3 ; i++) { ++ for (i = 0; i < blockCount_p3; i++) { + ret = rtw_write8(padapter, (FW_8723B_START_ADDRESS + offset + i), *(bufferPtr + offset + i)); + + if (ret == _FAIL) { @@ -66843,38 +65152,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return ret; +} + -+static int -+_PageWrite( ++static int _PageWrite( + struct adapter *padapter, -+ u32 page, -+ void * buffer, -+ u32 size -+ ) ++ u32 page, ++ void *buffer, ++ u32 size ++) +{ + u8 value8; -+ u8 u8Page = (u8) (page & 0x07) ; ++ u8 u8Page = (u8) (page & 0x07); + -+ value8 = (rtw_read8(padapter, REG_MCUFWDL+2) & 0xF8) | u8Page ; ++ value8 = (rtw_read8(padapter, REG_MCUFWDL+2) & 0xF8) | u8Page; + rtw_write8(padapter, REG_MCUFWDL+2, value8); + + return _BlockWrite(padapter, buffer, size); +} + -+static int -+_WriteFW( -+ struct adapter * padapter, -+ void * buffer, -+ u32 size -+ ) ++static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) +{ + /* Since we need dynamic decide method of dwonload fw, so we call this function to get chip version. */ + /* We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */ + int ret = _SUCCESS; -+ u32 pageNums, remainSize ; ++ u32 pageNums, remainSize; + u32 page, offset; + u8 *bufferPtr = (u8 *)buffer; + -+ pageNums = size / MAX_DLFW_PAGE_SIZE ; ++ pageNums = size / MAX_DLFW_PAGE_SIZE; + /* RT_ASSERT((pageNums <= 4), ("Page numbers should not greater then 4\n")); */ + remainSize = size % MAX_DLFW_PAGE_SIZE; + @@ -66887,6 +65190,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + goto exit; + } + } ++ + if (remainSize) { + offset = pageNums * MAX_DLFW_PAGE_SIZE; + page = pageNums; @@ -66933,7 +65237,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + DBG_8192C("%s: Finish\n", __func__); +} + -+static s32 polling_fwdl_chksum(struct adapter *adapter, u32 min_cnt, u32 timeout_ms) ++static s32 polling_fwdl_chksum( ++ struct adapter *adapter, u32 min_cnt, u32 timeout_ms ++) +{ + s32 ret = _FAIL; + u32 value32; @@ -66947,7 +65253,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + if (value32 & FWDL_ChkSum_rpt || adapter->bSurpriseRemoved || adapter->bDriverStopped) + break; + yield(); -+ } while (jiffies_to_msecs(jiffies - start) < timeout_ms || cnt < min_cnt); ++ } while (jiffies_to_msecs(jiffies-start) < timeout_ms || cnt < min_cnt); + + if (!(value32 & FWDL_ChkSum_rpt)) { + goto exit; @@ -66962,8 +65268,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + ret = _SUCCESS; + +exit: -+ DBG_871X("%s: Checksum report %s! (%u, %dms), REG_MCUFWDL:0x%08x\n", __func__ -+ , (ret == _SUCCESS)?"OK":"Fail", cnt, jiffies_to_msecs(jiffies - start), value32); ++ DBG_871X( ++ "%s: Checksum report %s! (%u, %dms), REG_MCUFWDL:0x%08x\n", ++ __func__, ++ (ret == _SUCCESS) ? "OK" : "Fail", ++ cnt, ++ jiffies_to_msecs(jiffies-start), ++ value32 ++ ); + + return ret; +} @@ -67004,8 +65316,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + ret = _SUCCESS; + +exit: -+ DBG_871X("%s: Polling FW ready %s! (%u, %dms), REG_MCUFWDL:0x%08x\n", __func__ -+ , (ret == _SUCCESS)?"OK":"Fail", cnt, jiffies_to_msecs(jiffies - start), value32); ++ DBG_871X( ++ "%s: Polling FW ready %s! (%u, %dms), REG_MCUFWDL:0x%08x\n", ++ __func__, ++ (ret == _SUCCESS) ? "OK" : "Fail", ++ cnt, ++ jiffies_to_msecs(jiffies-start), ++ value32 ++ ); + + return ret; +} @@ -67014,21 +65332,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + +void rtl8723b_FirmwareSelfReset(struct adapter *padapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + u8 u1bTmp; + u8 Delay = 100; + -+ if (!(IS_FW_81xxC(padapter) && -+ ((pHalData->FirmwareVersion < 0x21) || -+ (pHalData->FirmwareVersion == 0x21 && -+ pHalData->FirmwareSubVersion < 0x01)))) /* after 88C Fw v33.1 */ -+ { ++ if ( ++ !(IS_FW_81xxC(padapter) && ((pHalData->FirmwareVersion < 0x21) || (pHalData->FirmwareVersion == 0x21 && pHalData->FirmwareSubVersion < 0x01))) ++ ) { /* after 88C Fw v33.1 */ + /* 0x1cf = 0x20. Inform 8051 to reset. 2009.12.25. tynli_test */ + rtw_write8(padapter, REG_HMETFR+3, 0x20); + + u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); -+ while (u1bTmp & BIT2) -+ { ++ while (u1bTmp & BIT2) { + Delay--; + if (Delay == 0) + break; @@ -67037,8 +65352,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } + RT_TRACE(_module_hal_init_c_, _drv_notice_, ("-%s: 8051 reset success (%d)\n", __func__, Delay)); + -+ if (Delay == 0) -+ { ++ if (Delay == 0) { + RT_TRACE(_module_hal_init_c_, _drv_notice_, ("%s: Force 8051 reset!!!\n", __func__)); + /* force firmware reset */ + u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); @@ -67054,15 +65368,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +/* */ +s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool bUsedWoWLANFw) +{ -+ s32 rtStatus = _SUCCESS; ++ s32 rtStatus = _SUCCESS; + u8 write_fw = 0; + unsigned long fwdl_start_time; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + struct rt_firmware *pFirmware; + struct rt_firmware *pBTFirmware; + struct rt_firmware_hdr *pFwHdr = NULL; -+ u8 *pFirmwareBuf; -+ u32 FirmwareLen; ++ u8 *pFirmwareBuf; ++ u32 FirmwareLen; + const struct firmware *fw; + struct device *device = dvobj_to_dev(padapter->dvobj); + u8 *fwfilepath; @@ -67077,7 +65391,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL); + pBTFirmware = kzalloc(sizeof(struct rt_firmware), GFP_KERNEL); + -+ if (!pFirmware||!pBTFirmware) { ++ if (!pFirmware || !pBTFirmware) { + rtStatus = _FAIL; + goto exit; + } @@ -67094,6 +65408,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + DBG_871X(FUNC_ADPT_FMT" tmp_ps =%x\n", FUNC_ADPT_ARG(padapter), tmp_ps); + pdbgpriv->dbg_downloadfw_pwr_state_cnt++; + } ++ +#ifdef CONFIG_WOWLAN + if (bUsedWoWLANFw) + fwfilepath = "rtlwifi/rtl8723bs_wowlan.bin"; @@ -67109,23 +65424,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + rtStatus = _FAIL; + goto exit; + } ++ + if (!fw) { + pr_err("Firmware %s not available\n", fwfilepath); + rtStatus = _FAIL; + goto exit; + } ++ + if (fw->size > FW_8723B_SIZE) { + rtStatus = _FAIL; -+ RT_TRACE(_module_hal_init_c_, _drv_err_, -+ ("Firmware size exceed 0x%X. Check it.\n", -+ FW_8188E_SIZE)); ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_err_, ++ ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE) ++ ); + goto exit; + } ++ + pFirmware->szFwBuffer = kzalloc(fw->size, GFP_KERNEL); -+ if (! pFirmware->szFwBuffer) { ++ if (!pFirmware->szFwBuffer) { + rtStatus = _FAIL; + goto exit; -+ } ++ } ++ + memcpy(pFirmware->szFwBuffer, fw->data, fw->size); + pFirmware->ulFwLength = fw->size; + release_firmware(fw); @@ -67145,12 +65466,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pHalData->FirmwareSubVersion = le16_to_cpu(pFwHdr->Subversion); + pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->Signature); + -+ DBG_871X("%s: fw_ver =%x fw_subver =%04x sig = 0x%x, Month =%02x, Date =%02x, Hour =%02x, Minute =%02x\n", -+ __func__, pHalData->FirmwareVersion, pHalData->FirmwareSubVersion, pHalData->FirmwareSignature -+ , pFwHdr->Month, pFwHdr->Date, pFwHdr->Hour, pFwHdr->Minute); ++ DBG_871X( ++ "%s: fw_ver =%x fw_subver =%04x sig = 0x%x, Month =%02x, Date =%02x, Hour =%02x, Minute =%02x\n", ++ __func__, ++ pHalData->FirmwareVersion, ++ pHalData->FirmwareSubVersion, ++ pHalData->FirmwareSignature, ++ pFwHdr->Month, ++ pFwHdr->Date, ++ pFwHdr->Hour, ++ pFwHdr->Minute ++ ); + -+ if (IS_FW_HEADER_EXIST_8723B(pFwHdr)) -+ { ++ if (IS_FW_HEADER_EXIST_8723B(pFwHdr)) { + DBG_871X("%s(): Shift for fw header!\n", __func__); + /* Shift 32 bytes for FW header */ + pFirmwareBuf = pFirmwareBuf + 32; @@ -67159,17 +65487,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + /* Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */ + /* or it will cause download Fw fail. 2010.02.01. by tynli. */ -+ if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) /* 8051 RAM code */ -+ { ++ if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */ + rtw_write8(padapter, REG_MCUFWDL, 0x00); + rtl8723b_FirmwareSelfReset(padapter); + } + + _FWDownloadEnable(padapter, true); + fwdl_start_time = jiffies; -+ while (!padapter->bDriverStopped && !padapter->bSurpriseRemoved -+ && (write_fw++ < 3 || jiffies_to_msecs(jiffies - fwdl_start_time) < 500)) -+ { ++ while ( ++ !padapter->bDriverStopped && ++ !padapter->bSurpriseRemoved && ++ (write_fw++ < 3 || jiffies_to_msecs(jiffies - fwdl_start_time) < 500) ++ ) { + /* reset FWDL chksum */ + rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL)|FWDL_ChkSum_rpt); + @@ -67190,10 +65519,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + goto fwdl_stat; + +fwdl_stat: -+ DBG_871X("FWDL %s. write_fw:%u, %dms\n" -+ , (rtStatus == _SUCCESS)?"success":"fail" -+ , write_fw -+ , jiffies_to_msecs(jiffies - fwdl_start_time) ++ DBG_871X( ++ "FWDL %s. write_fw:%u, %dms\n", ++ (rtStatus == _SUCCESS)?"success":"fail", ++ write_fw, ++ jiffies_to_msecs(jiffies - fwdl_start_time) + ); + +exit: @@ -67216,9 +65546,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + /* Init H2C counter. by tynli. 2009.12.09. */ + pHalData->LastHMEBoxNum = 0; -+/* pHalData->H2CQueueHead = 0; */ -+/* pHalData->H2CQueueTail = 0; */ -+/* pHalData->H2CStopInsertQueue = false; */ ++/* pHalData->H2CQueueHead = 0; */ ++/* pHalData->H2CQueueTail = 0; */ ++/* pHalData->H2CStopInsertQueue = false; */ +} + +#if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN) @@ -67226,16 +65556,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + +/* */ +/* Description: Prepare some information to Fw for WoWLAN. */ -+/* (1) Download wowlan Fw. */ -+/* (2) Download RSVD page packets. */ -+/* (3) Enable AP offload if needed. */ ++/* (1) Download wowlan Fw. */ ++/* (2) Download RSVD page packets. */ ++/* (3) Enable AP offload if needed. */ +/* */ +/* 2011.04.12 by tynli. */ +/* */ -+void -+SetFwRelatedForWoWLAN8723b( -+ struct adapter * padapter, -+ u8 bHostIsGoingtoSleep ++void SetFwRelatedForWoWLAN8723b( ++ struct adapter *padapter, u8 bHostIsGoingtoSleep +) +{ + int status = _FAIL; @@ -67263,11 +65591,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +/* */ +/* Efuse related code */ +/* */ -+static u8 -+hal_EfuseSwitchToBank( -+ struct adapter *padapter, -+ u8 bank, -+ bool bPseudoTest) ++static u8 hal_EfuseSwitchToBank( ++ struct adapter *padapter, u8 bank, bool bPseudoTest ++) +{ + u8 bRet = false; + u32 value32 = 0; @@ -67278,37 +65604,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + + DBG_8192C("%s: Efuse switch bank to %d\n", __func__, bank); -+ if (bPseudoTest) -+ { ++ if (bPseudoTest) { +#ifdef HAL_EFUSE_MEMORY + pEfuseHal->fakeEfuseBank = bank; +#else + fakeEfuseBank = bank; +#endif + bRet = true; -+ } -+ else -+ { ++ } else { + value32 = rtw_read32(padapter, EFUSE_TEST); + bRet = true; -+ switch (bank) -+ { -+ case 0: -+ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0); -+ break; -+ case 1: -+ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_BT_SEL_0); -+ break; -+ case 2: -+ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_BT_SEL_1); -+ break; -+ case 3: -+ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_BT_SEL_2); -+ break; -+ default: -+ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0); -+ bRet = false; -+ break; ++ switch (bank) { ++ case 0: ++ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0); ++ break; ++ case 1: ++ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_BT_SEL_0); ++ break; ++ case 2: ++ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_BT_SEL_1); ++ break; ++ case 3: ++ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_BT_SEL_2); ++ break; ++ default: ++ value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0); ++ bRet = false; ++ break; + } + rtw_write32(padapter, EFUSE_TEST, value32); + } @@ -67316,107 +65638,106 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return bRet; +} + -+static void -+Hal_GetEfuseDefinition( ++static void Hal_GetEfuseDefinition( + struct adapter *padapter, -+ u8 efuseType, -+ u8 type, -+ void *pOut, -+ bool bPseudoTest) ++ u8 efuseType, ++ u8 type, ++ void *pOut, ++ bool bPseudoTest ++) +{ -+ switch (type) -+ { -+ case TYPE_EFUSE_MAX_SECTION: -+ { -+ u8 *pMax_section; -+ pMax_section = (u8 *)pOut; ++ switch (type) { ++ case TYPE_EFUSE_MAX_SECTION: ++ { ++ u8 *pMax_section; ++ pMax_section = (u8 *)pOut; + -+ if (efuseType == EFUSE_WIFI) -+ *pMax_section = EFUSE_MAX_SECTION_8723B; -+ else -+ *pMax_section = EFUSE_BT_MAX_SECTION; -+ } -+ break; ++ if (efuseType == EFUSE_WIFI) ++ *pMax_section = EFUSE_MAX_SECTION_8723B; ++ else ++ *pMax_section = EFUSE_BT_MAX_SECTION; ++ } ++ break; + -+ case TYPE_EFUSE_REAL_CONTENT_LEN: -+ { -+ u16 *pu2Tmp; -+ pu2Tmp = (u16*)pOut; ++ case TYPE_EFUSE_REAL_CONTENT_LEN: ++ { ++ u16 *pu2Tmp; ++ pu2Tmp = (u16 *)pOut; + -+ if (efuseType == EFUSE_WIFI) -+ *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723B; -+ else -+ *pu2Tmp = EFUSE_BT_REAL_CONTENT_LEN; -+ } -+ break; ++ if (efuseType == EFUSE_WIFI) ++ *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723B; ++ else ++ *pu2Tmp = EFUSE_BT_REAL_CONTENT_LEN; ++ } ++ break; + -+ case TYPE_AVAILABLE_EFUSE_BYTES_BANK: -+ { -+ u16 *pu2Tmp; -+ pu2Tmp = (u16*)pOut; ++ case TYPE_AVAILABLE_EFUSE_BYTES_BANK: ++ { ++ u16 *pu2Tmp; ++ pu2Tmp = (u16 *)pOut; + -+ if (efuseType == EFUSE_WIFI) -+ *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723B-EFUSE_OOB_PROTECT_BYTES); -+ else -+ *pu2Tmp = (EFUSE_BT_REAL_BANK_CONTENT_LEN-EFUSE_PROTECT_BYTES_BANK); -+ } -+ break; ++ if (efuseType == EFUSE_WIFI) ++ *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723B-EFUSE_OOB_PROTECT_BYTES); ++ else ++ *pu2Tmp = (EFUSE_BT_REAL_BANK_CONTENT_LEN-EFUSE_PROTECT_BYTES_BANK); ++ } ++ break; + -+ case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: -+ { -+ u16 *pu2Tmp; -+ pu2Tmp = (u16*)pOut; ++ case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: ++ { ++ u16 *pu2Tmp; ++ pu2Tmp = (u16 *)pOut; + -+ if (efuseType == EFUSE_WIFI) -+ *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723B-EFUSE_OOB_PROTECT_BYTES); -+ else -+ *pu2Tmp = (EFUSE_BT_REAL_CONTENT_LEN-(EFUSE_PROTECT_BYTES_BANK*3)); -+ } -+ break; ++ if (efuseType == EFUSE_WIFI) ++ *pu2Tmp = (EFUSE_REAL_CONTENT_LEN_8723B-EFUSE_OOB_PROTECT_BYTES); ++ else ++ *pu2Tmp = (EFUSE_BT_REAL_CONTENT_LEN-(EFUSE_PROTECT_BYTES_BANK*3)); ++ } ++ break; + -+ case TYPE_EFUSE_MAP_LEN: -+ { -+ u16 *pu2Tmp; -+ pu2Tmp = (u16*)pOut; ++ case TYPE_EFUSE_MAP_LEN: ++ { ++ u16 *pu2Tmp; ++ pu2Tmp = (u16 *)pOut; + -+ if (efuseType == EFUSE_WIFI) -+ *pu2Tmp = EFUSE_MAX_MAP_LEN; -+ else -+ *pu2Tmp = EFUSE_BT_MAP_LEN; -+ } -+ break; ++ if (efuseType == EFUSE_WIFI) ++ *pu2Tmp = EFUSE_MAX_MAP_LEN; ++ else ++ *pu2Tmp = EFUSE_BT_MAP_LEN; ++ } ++ break; + -+ case TYPE_EFUSE_PROTECT_BYTES_BANK: -+ { -+ u8 *pu1Tmp; -+ pu1Tmp = (u8 *)pOut; ++ case TYPE_EFUSE_PROTECT_BYTES_BANK: ++ { ++ u8 *pu1Tmp; ++ pu1Tmp = (u8 *)pOut; + -+ if (efuseType == EFUSE_WIFI) -+ *pu1Tmp = EFUSE_OOB_PROTECT_BYTES; -+ else -+ *pu1Tmp = EFUSE_PROTECT_BYTES_BANK; -+ } -+ break; ++ if (efuseType == EFUSE_WIFI) ++ *pu1Tmp = EFUSE_OOB_PROTECT_BYTES; ++ else ++ *pu1Tmp = EFUSE_PROTECT_BYTES_BANK; ++ } ++ break; + -+ case TYPE_EFUSE_CONTENT_LEN_BANK: -+ { -+ u16 *pu2Tmp; -+ pu2Tmp = (u16*)pOut; ++ case TYPE_EFUSE_CONTENT_LEN_BANK: ++ { ++ u16 *pu2Tmp; ++ pu2Tmp = (u16 *)pOut; + -+ if (efuseType == EFUSE_WIFI) -+ *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723B; -+ else -+ *pu2Tmp = EFUSE_BT_REAL_BANK_CONTENT_LEN; -+ } -+ break; ++ if (efuseType == EFUSE_WIFI) ++ *pu2Tmp = EFUSE_REAL_CONTENT_LEN_8723B; ++ else ++ *pu2Tmp = EFUSE_BT_REAL_BANK_CONTENT_LEN; ++ } ++ break; + -+ default: -+ { -+ u8 *pu1Tmp; -+ pu1Tmp = (u8 *)pOut; -+ *pu1Tmp = 0; -+ } -+ break; ++ default: ++ { ++ u8 *pu1Tmp; ++ pu1Tmp = (u8 *)pOut; ++ *pu1Tmp = 0; ++ } ++ break; + } +} + @@ -67433,13 +65754,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + +/* */ +static void Hal_BT_EfusePowerSwitch( -+ struct adapter *padapter, -+ u8 bWrite, -+ u8 PwrState) ++ struct adapter *padapter, u8 bWrite, u8 PwrState ++) +{ + u8 tempval; -+ if (PwrState == true) -+ { ++ if (PwrState == true) { + /* enable BT power cut */ + /* 0x6A[14] = 1 */ + tempval = rtw_read8(padapter, 0x6B); @@ -67454,9 +65773,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + tempval = rtw_read8(padapter, 0x6B); + tempval &= ~BIT(7); + rtw_write8(padapter, 0x6B, tempval); -+ } -+ else -+ { ++ } else { + /* enable BT output isolation */ + /* 0x6A[15] = 1 */ + tempval = rtw_read8(padapter, 0x6B); @@ -67474,23 +65791,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } + +} -+static void -+Hal_EfusePowerSwitch( -+ struct adapter *padapter, -+ u8 bWrite, -+ u8 PwrState) ++static void Hal_EfusePowerSwitch( ++ struct adapter *padapter, u8 bWrite, u8 PwrState ++) +{ + u8 tempval; + u16 tmpV16; + + -+ if (PwrState == true) -+ { ++ if (PwrState == true) { + /* To avoid cannot access efuse regsiters after disable/enable several times during DTM test. */ + /* Suggested by SD1 IsaacHsu. 2013.07.08, added by tynli. */ + tempval = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HSUS_CTRL); -+ if (tempval & BIT(0)) /* SDIO local register is suspend */ -+ { ++ if (tempval & BIT(0)) { /* SDIO local register is suspend */ + u8 count = 0; + + @@ -67511,13 +65824,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + mdelay(10); + } while (1); + -+ if (count >= 100) -+ { ++ if (count >= 100) { + DBG_8192C(FUNC_ADPT_FMT ": Leave SDIO local register suspend fail! Local 0x86 =%#X\n", + FUNC_ADPT_ARG(padapter), tempval); -+ } -+ else -+ { ++ } else { + DBG_8192C(FUNC_ADPT_FMT ": Leave SDIO local register suspend OK! Local 0x86 =%#X\n", + FUNC_ADPT_ARG(padapter), tempval); + } @@ -67528,19 +65838,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* Reset: 0x0000h[28], default valid */ + tmpV16 = rtw_read16(padapter, REG_SYS_FUNC_EN); + if (!(tmpV16 & FEN_ELDR)) { -+ tmpV16 |= FEN_ELDR ; ++ tmpV16 |= FEN_ELDR; + rtw_write16(padapter, REG_SYS_FUNC_EN, tmpV16); + } + + /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ + tmpV16 = rtw_read16(padapter, REG_SYS_CLKR); + if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { -+ tmpV16 |= (LOADER_CLK_EN | ANA8M) ; ++ tmpV16 |= (LOADER_CLK_EN | ANA8M); + rtw_write16(padapter, REG_SYS_CLKR, tmpV16); + } + -+ if (bWrite == true) -+ { ++ if (bWrite == true) { + /* Enable LDO 2.5V before read/write action */ + tempval = rtw_read8(padapter, EFUSE_TEST+3); + tempval &= 0x0F; @@ -67549,9 +65858,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + /* rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); */ + } -+ } -+ else -+ { ++ } else { + rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); + + if (bWrite == true) { @@ -67563,17 +65870,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } +} + -+static void -+hal_ReadEFuse_WiFi( ++static void hal_ReadEFuse_WiFi( + struct adapter *padapter, -+ u16 _offset, -+ u16 _size_byte, -+ u8 *pbuf, -+ bool bPseudoTest) ++ u16 _offset, ++ u16 _size_byte, ++ u8 *pbuf, ++ bool bPseudoTest ++) +{ +#ifdef HAL_EFUSE_MEMORY + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal; ++ PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal; +#endif + u8 *efuseTbl = NULL; + u16 eFuse_Addr = 0; @@ -67586,15 +65893,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* */ + /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ + /* */ -+ if ((_offset+_size_byte) > EFUSE_MAX_MAP_LEN) -+ { ++ if ((_offset+_size_byte) > EFUSE_MAX_MAP_LEN) { + DBG_8192C("%s: Invalid offset(%#x) with read bytes(%#x)!!\n", __func__, _offset, _size_byte); + return; + } + + efuseTbl = (u8 *)rtw_malloc(EFUSE_MAX_MAP_LEN); -+ if (efuseTbl == NULL) -+ { ++ if (efuseTbl == NULL) { + DBG_8192C("%s: alloc efuseTbl fail!\n", __func__); + return; + } @@ -67603,13 +65908,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + +#ifdef CONFIG_DEBUG -+if (0) -+{ -+ for (i = 0; i<256; i++) ++if (0) { ++ for (i = 0; i < 256; i++) + efuse_OneByteRead(padapter, i, &efuseTbl[i], false); + DBG_871X("Efuse Content:\n"); -+ for (i = 0; i<256; i++) -+ { ++ for (i = 0; i < 256; i++) { + if (i % 16 == 0) + printk("\n"); + printk("%02X ", efuseTbl[i]); @@ -67622,51 +65925,41 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* switch bank back to bank 0 for later BT and wifi use. */ + hal_EfuseSwitchToBank(padapter, 0, bPseudoTest); + -+ while (AVAILABLE_EFUSE_ADDR(eFuse_Addr)) -+ { ++ while (AVAILABLE_EFUSE_ADDR(eFuse_Addr)) { + efuse_OneByteRead(padapter, eFuse_Addr++, &efuseHeader, bPseudoTest); -+ if (efuseHeader == 0xFF) -+ { ++ if (efuseHeader == 0xFF) { + DBG_8192C("%s: data end at address =%#x\n", __func__, eFuse_Addr-1); + break; + } + /* DBG_8192C("%s: efuse[0x%X]= 0x%02X\n", __func__, eFuse_Addr-1, efuseHeader); */ + + /* Check PG header for section num. */ -+ if (EXT_HEADER(efuseHeader)) /* extended header */ -+ { ++ if (EXT_HEADER(efuseHeader)) { /* extended header */ + offset = GET_HDR_OFFSET_2_0(efuseHeader); + /* DBG_8192C("%s: extended header offset = 0x%X\n", __func__, offset); */ + + efuse_OneByteRead(padapter, eFuse_Addr++, &efuseExtHdr, bPseudoTest); + /* DBG_8192C("%s: efuse[0x%X]= 0x%02X\n", __func__, eFuse_Addr-1, efuseExtHdr); */ + if (ALL_WORDS_DISABLED(efuseExtHdr)) -+ { + continue; -+ } + + offset |= ((efuseExtHdr & 0xF0) >> 1); + wden = (efuseExtHdr & 0x0F); -+ } -+ else -+ { ++ } else { + offset = ((efuseHeader >> 4) & 0x0f); + wden = (efuseHeader & 0x0f); + } + /* DBG_8192C("%s: Offset =%d Worden = 0x%X\n", __func__, offset, wden); */ + -+ if (offset < EFUSE_MAX_SECTION_8723B) -+ { ++ if (offset < EFUSE_MAX_SECTION_8723B) { + u16 addr; + /* Get word enable value from PG header */ +/* DBG_8192C("%s: Offset =%d Worden = 0x%X\n", __func__, offset, wden); */ + + addr = offset * PGPKT_DATA_SIZE; -+ for (i = 0; ifakeEfuseUsedBytes = used; +#else + fakeEfuseUsedBytes = used; +#endif -+ } -+ else -+ { ++ } else { + rtw_hal_set_hwreg(padapter, HW_VAR_EFUSE_BYTES, (u8 *)&used); + rtw_hal_set_hwreg(padapter, HW_VAR_EFUSE_USAGE, (u8 *)&efuse_usage); + } @@ -67724,18 +66010,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + kfree(efuseTbl); +} + -+static void -+hal_ReadEFuse_BT( ++static void hal_ReadEFuse_BT( + struct adapter *padapter, -+ u16 _offset, -+ u16 _size_byte, -+ u8 *pbuf, -+ bool bPseudoTest -+ ) ++ u16 _offset, ++ u16 _size_byte, ++ u8 *pbuf, ++ bool bPseudoTest ++) +{ +#ifdef HAL_EFUSE_MEMORY + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal; ++ PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal; +#endif + u8 *efuseTbl; + u8 bank; @@ -67749,8 +66034,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* */ + /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ + /* */ -+ if ((_offset+_size_byte) > EFUSE_BT_MAP_LEN) -+ { ++ if ((_offset+_size_byte) > EFUSE_BT_MAP_LEN) { + DBG_8192C("%s: Invalid offset(%#x) with read bytes(%#x)!!\n", __func__, _offset, _size_byte); + return; + } @@ -67765,57 +66049,48 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_BANK, &total, bPseudoTest); + -+ for (bank = 1; bank<3; bank++) /* 8723b Max bake 0~2 */ -+ { -+ if (hal_EfuseSwitchToBank(padapter, bank, bPseudoTest) == false) -+ { ++ for (bank = 1; bank < 3; bank++) { /* 8723b Max bake 0~2 */ ++ if (hal_EfuseSwitchToBank(padapter, bank, bPseudoTest) == false) { + DBG_8192C("%s: hal_EfuseSwitchToBank Fail!!\n", __func__); + goto exit; + } + + eFuse_Addr = 0; + -+ while (AVAILABLE_EFUSE_ADDR(eFuse_Addr)) -+ { ++ while (AVAILABLE_EFUSE_ADDR(eFuse_Addr)) { + efuse_OneByteRead(padapter, eFuse_Addr++, &efuseHeader, bPseudoTest); -+ if (efuseHeader == 0xFF) break; ++ if (efuseHeader == 0xFF) ++ break; + DBG_8192C("%s: efuse[%#X]= 0x%02x (header)\n", __func__, (((bank-1)*EFUSE_REAL_CONTENT_LEN_8723B)+eFuse_Addr-1), efuseHeader); + + /* Check PG header for section num. */ -+ if (EXT_HEADER(efuseHeader)) /* extended header */ -+ { ++ if (EXT_HEADER(efuseHeader)) { /* extended header */ + offset = GET_HDR_OFFSET_2_0(efuseHeader); + DBG_8192C("%s: extended header offset_2_0 = 0x%X\n", __func__, offset); + + efuse_OneByteRead(padapter, eFuse_Addr++, &efuseExtHdr, bPseudoTest); + DBG_8192C("%s: efuse[%#X]= 0x%02x (ext header)\n", __func__, (((bank-1)*EFUSE_REAL_CONTENT_LEN_8723B)+eFuse_Addr-1), efuseExtHdr); + if (ALL_WORDS_DISABLED(efuseExtHdr)) -+ { + continue; -+ } ++ + + offset |= ((efuseExtHdr & 0xF0) >> 1); + wden = (efuseExtHdr & 0x0F); -+ } -+ else -+ { ++ } else { + offset = ((efuseHeader >> 4) & 0x0f); + wden = (efuseHeader & 0x0f); + } + -+ if (offset < EFUSE_BT_MAX_SECTION) -+ { ++ if (offset < EFUSE_BT_MAX_SECTION) { + u16 addr; + + /* Get word enable value from PG header */ + DBG_8192C("%s: Offset =%d Worden =%#X\n", __func__, offset, wden); + + addr = offset * PGPKT_DATA_SIZE; -+ for (i = 0; ifakeBTEfuseUsedBytes = used; +#else + fakeBTEfuseUsedBytes = used; +#endif -+ } -+ else -+ { ++ } else { + rtw_hal_set_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *)&used); + rtw_hal_set_hwreg(padapter, HW_VAR_EFUSE_BT_USAGE, (u8 *)&efuse_usage); + } @@ -67874,14 +66143,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + kfree(efuseTbl); +} + -+static void -+Hal_ReadEFuse( ++static void Hal_ReadEFuse( + struct adapter *padapter, -+ u8 efuseType, -+ u16 _offset, -+ u16 _size_byte, -+ u8 *pbuf, -+ bool bPseudoTest) ++ u8 efuseType, ++ u16 _offset, ++ u16 _size_byte, ++ u8 *pbuf, ++ bool bPseudoTest ++) +{ + if (efuseType == EFUSE_WIFI) + hal_ReadEFuse_WiFi(padapter, _offset, _size_byte, pbuf, bPseudoTest); @@ -67889,10 +66158,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + hal_ReadEFuse_BT(padapter, _offset, _size_byte, pbuf, bPseudoTest); +} + -+static u16 -+hal_EfuseGetCurrentSize_WiFi( -+ struct adapter *padapter, -+ bool bPseudoTest) ++static u16 hal_EfuseGetCurrentSize_WiFi( ++ struct adapter *padapter, bool bPseudoTest ++) +{ +#ifdef HAL_EFUSE_MEMORY + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); @@ -67905,18 +66173,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + u32 count = 0; /* for debug */ + + -+ if (bPseudoTest) -+ { ++ if (bPseudoTest) { +#ifdef HAL_EFUSE_MEMORY + efuse_addr = (u16)pEfuseHal->fakeEfuseUsedBytes; +#else + efuse_addr = (u16)fakeEfuseUsedBytes; +#endif -+ } -+ else -+ { ++ } else + rtw_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); -+ } ++ + start_addr = efuse_addr; + DBG_8192C("%s: start_efuse_addr = 0x%X\n", __func__, efuse_addr); + @@ -67924,29 +66189,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + hal_EfuseSwitchToBank(padapter, 0, bPseudoTest); + + count = 0; -+ while (AVAILABLE_EFUSE_ADDR(efuse_addr)) -+ { -+ if (efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest) == false) -+ { ++ while (AVAILABLE_EFUSE_ADDR(efuse_addr)) { ++ if (efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest) == false) { + DBG_8192C(KERN_ERR "%s: efuse_OneByteRead Fail! addr = 0x%X !!\n", __func__, efuse_addr); + goto error; + } + -+ if (efuse_data == 0xFF) break; ++ if (efuse_data == 0xFF) ++ break; + -+ if ((start_addr != 0) && (efuse_addr == start_addr)) -+ { ++ if ((start_addr != 0) && (efuse_addr == start_addr)) { + count++; + DBG_8192C(FUNC_ADPT_FMT ": [WARNING] efuse raw 0x%X = 0x%02X not 0xFF!!(%d times)\n", + FUNC_ADPT_ARG(padapter), efuse_addr, efuse_data, count); + + efuse_data = 0xFF; -+ if (count < 4) -+ { ++ if (count < 4) { + /* try again! */ + -+ if (count > 2) -+ { ++ if (count > 2) { + /* try again form address 0 */ + efuse_addr = 0; + start_addr = 0; @@ -67958,21 +66219,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + goto error; + } + -+ if (EXT_HEADER(efuse_data)) -+ { ++ if (EXT_HEADER(efuse_data)) { + hoffset = GET_HDR_OFFSET_2_0(efuse_data); + efuse_addr++; + efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest); + if (ALL_WORDS_DISABLED(efuse_data)) -+ { + continue; -+ } + + hoffset |= ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; -+ } -+ else -+ { ++ } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } @@ -67981,18 +66237,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + efuse_addr += (word_cnts*2)+1; + } + -+ if (bPseudoTest) -+ { ++ if (bPseudoTest) { +#ifdef HAL_EFUSE_MEMORY + pEfuseHal->fakeEfuseUsedBytes = efuse_addr; +#else + fakeEfuseUsedBytes = efuse_addr; +#endif -+ } -+ else -+ { ++ } else + rtw_hal_set_hwreg(padapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); -+ } + + goto exit; + @@ -68006,14 +66258,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return efuse_addr; +} + -+static u16 -+hal_EfuseGetCurrentSize_BT( -+ struct adapter *padapter, -+ u8 bPseudoTest) ++static u16 hal_EfuseGetCurrentSize_BT(struct adapter *padapter, u8 bPseudoTest) +{ +#ifdef HAL_EFUSE_MEMORY + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal; ++ PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal; +#endif + u16 btusedbytes; + u16 efuse_addr; @@ -68028,11 +66277,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +#else + btusedbytes = fakeBTEfuseUsedBytes; +#endif -+ } -+ else -+ { ++ } else + rtw_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *)&btusedbytes); -+ } ++ + efuse_addr = (u16)((btusedbytes%EFUSE_BT_REAL_BANK_CONTENT_LEN)); + startBank = (u8)(1+(btusedbytes/EFUSE_BT_REAL_BANK_CONTENT_LEN)); + @@ -68040,10 +66287,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_BANK, &retU2, bPseudoTest); + -+ for (bank =startBank; bank<3; bank++) -+ { -+ if (hal_EfuseSwitchToBank(padapter, bank, bPseudoTest) == false) -+ { ++ for (bank = startBank; bank < 3; bank++) { ++ if (hal_EfuseSwitchToBank(padapter, bank, bPseudoTest) == false) { + DBG_8192C(KERN_ERR "%s: switch bank(%d) Fail!!\n", __func__, bank); + /* bank = EFUSE_MAX_BANK; */ + break; @@ -68054,27 +66299,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + efuse_addr = 0; +#if 1 + -+ while (AVAILABLE_EFUSE_ADDR(efuse_addr)) -+ { -+ if (efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest) == false) -+ { ++ while (AVAILABLE_EFUSE_ADDR(efuse_addr)) { ++ if (efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest) == false) { + DBG_8192C(KERN_ERR "%s: efuse_OneByteRead Fail! addr = 0x%X !!\n", __func__, efuse_addr); + /* bank = EFUSE_MAX_BANK; */ + break; + } + DBG_8192C("%s: efuse_OneByteRead ! addr = 0x%X !efuse_data = 0x%X! bank =%d\n", __func__, efuse_addr, efuse_data, bank); + -+ if (efuse_data == 0xFF) break; ++ if (efuse_data == 0xFF) ++ break; + -+ if (EXT_HEADER(efuse_data)) -+ { ++ if (EXT_HEADER(efuse_data)) { + hoffset = GET_HDR_OFFSET_2_0(efuse_data); + efuse_addr++; + efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest); + DBG_8192C("%s: efuse_OneByteRead EXT_HEADER ! addr = 0x%X !efuse_data = 0x%X! bank =%d\n", __func__, efuse_addr, efuse_data, bank); + -+ if (ALL_WORDS_DISABLED(efuse_data)) -+ { ++ if (ALL_WORDS_DISABLED(efuse_data)) { + efuse_addr++; + continue; + } @@ -68082,9 +66324,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +/* hoffset = ((hoffset & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); */ + hoffset |= ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; -+ } -+ else -+ { ++ } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } @@ -68097,60 +66337,46 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + efuse_addr += (word_cnts*2)+1; + } +#else -+ while (bContinual && -+ efuse_OneByteRead(padapter, efuse_addr ,&efuse_data, bPseudoTest) && -+ AVAILABLE_EFUSE_ADDR(efuse_addr)) -+ { -+ if (efuse_data!= 0xFF) -+ { -+ if ((efuse_data&0x1F) == 0x0F) /* extended header */ -+ { ++ while ( ++ bContinual && ++ efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest) && ++ AVAILABLE_EFUSE_ADDR(efuse_addr) ++ ) { ++ if (efuse_data != 0xFF) { ++ if ((efuse_data&0x1F) == 0x0F) { /* extended header */ + hoffset = efuse_data; + efuse_addr++; -+ efuse_OneByteRead(padapter, efuse_addr ,&efuse_data, bPseudoTest); -+ if ((efuse_data & 0x0F) == 0x0F) -+ { ++ efuse_OneByteRead(padapter, efuse_addr, &efuse_data, bPseudoTest); ++ if ((efuse_data & 0x0F) == 0x0F) { + efuse_addr++; + continue; -+ } -+ else -+ { ++ } else { + hoffset = ((hoffset & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; + } -+ } -+ else -+ { ++ } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } + word_cnts = Efuse_CalculateWordCnts(hworden); + /* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; -+ } -+ else -+ { -+ bContinual = false ; -+ } ++ } else ++ bContinual = false; + } +#endif + + + /* Check if we need to check next bank efuse */ + if (efuse_addr < retU2) -+ { -+ break;/* don't need to check next bank. */ -+ } ++ break; /* don't need to check next bank. */ + } + + retU2 = ((bank-1)*EFUSE_BT_REAL_BANK_CONTENT_LEN)+efuse_addr; -+ if (bPseudoTest) -+ { ++ if (bPseudoTest) { + pEfuseHal->fakeBTEfuseUsedBytes = retU2; + /* RT_DISP(FEEPROM, EFUSE_PG, ("Hal_EfuseGetCurrentSize_BT92C(), already use %u bytes\n", pEfuseHal->fakeBTEfuseUsedBytes)); */ -+ } -+ else -+ { ++ } else { + pEfuseHal->BTEfuseUsedBytes = retU2; + /* RT_DISP(FEEPROM, EFUSE_PG, ("Hal_EfuseGetCurrentSize_BT92C(), already use %u bytes\n", pEfuseHal->BTEfuseUsedBytes)); */ + } @@ -68159,11 +66385,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return retU2; +} + -+static u16 -+Hal_EfuseGetCurrentSize( -+ struct adapter *padapter, -+ u8 efuseType, -+ bool bPseudoTest) ++static u16 Hal_EfuseGetCurrentSize( ++ struct adapter *padapter, u8 efuseType, bool bPseudoTest ++) +{ + u16 ret = 0; + @@ -68175,13 +66399,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return ret; +} + -+static u8 -+Hal_EfuseWordEnableDataWrite( ++static u8 Hal_EfuseWordEnableDataWrite( + struct adapter *padapter, -+ u16 efuse_addr, -+ u8 word_en, -+ u8 *data, -+ bool bPseudoTest) ++ u16 efuse_addr, ++ u8 word_en, ++ u8 *data, ++ bool bPseudoTest ++) +{ + u16 tmpaddr = 0; + u16 start_addr = efuse_addr; @@ -68192,51 +66416,49 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +/* DBG_8192C("%s: efuse_addr =%#x word_en =%#x\n", __func__, efuse_addr, word_en); */ + memset(tmpdata, 0xFF, PGPKT_DATA_SIZE); + -+ if (!(word_en & BIT(0))) -+ { ++ if (!(word_en & BIT(0))) { + tmpaddr = start_addr; + efuse_OneByteWrite(padapter, start_addr++, data[0], bPseudoTest); + efuse_OneByteWrite(padapter, start_addr++, data[1], bPseudoTest); + + efuse_OneByteRead(padapter, tmpaddr, &tmpdata[0], bPseudoTest); + efuse_OneByteRead(padapter, tmpaddr+1, &tmpdata[1], bPseudoTest); -+ if ((data[0]!=tmpdata[0]) || (data[1]!=tmpdata[1])) { ++ if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) { + badworden &= (~BIT(0)); + } + } -+ if (!(word_en & BIT(1))) -+ { ++ if (!(word_en & BIT(1))) { + tmpaddr = start_addr; + efuse_OneByteWrite(padapter, start_addr++, data[2], bPseudoTest); + efuse_OneByteWrite(padapter, start_addr++, data[3], bPseudoTest); + + efuse_OneByteRead(padapter, tmpaddr, &tmpdata[2], bPseudoTest); + efuse_OneByteRead(padapter, tmpaddr+1, &tmpdata[3], bPseudoTest); -+ if ((data[2]!=tmpdata[2]) || (data[3]!=tmpdata[3])) { ++ if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) { + badworden &= (~BIT(1)); + } + } -+ if (!(word_en & BIT(2))) -+ { ++ ++ if (!(word_en & BIT(2))) { + tmpaddr = start_addr; + efuse_OneByteWrite(padapter, start_addr++, data[4], bPseudoTest); + efuse_OneByteWrite(padapter, start_addr++, data[5], bPseudoTest); + + efuse_OneByteRead(padapter, tmpaddr, &tmpdata[4], bPseudoTest); + efuse_OneByteRead(padapter, tmpaddr+1, &tmpdata[5], bPseudoTest); -+ if ((data[4]!=tmpdata[4]) || (data[5]!=tmpdata[5])) { ++ if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) { + badworden &= (~BIT(2)); + } + } -+ if (!(word_en & BIT(3))) -+ { ++ ++ if (!(word_en & BIT(3))) { + tmpaddr = start_addr; + efuse_OneByteWrite(padapter, start_addr++, data[6], bPseudoTest); + efuse_OneByteWrite(padapter, start_addr++, data[7], bPseudoTest); + + efuse_OneByteRead(padapter, tmpaddr, &tmpdata[6], bPseudoTest); + efuse_OneByteRead(padapter, tmpaddr+1, &tmpdata[7], bPseudoTest); -+ if ((data[6]!=tmpdata[6]) || (data[7]!=tmpdata[7])) { ++ if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) { + badworden &= (~BIT(3)); + } + } @@ -68244,12 +66466,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return badworden; +} + -+static s32 -+Hal_EfusePgPacketRead( ++static s32 Hal_EfusePgPacketRead( + struct adapter *padapter, -+ u8 offset, -+ u8 *data, -+ bool bPseudoTest) ++ u8 offset, ++ u8 *data, ++ bool bPseudoTest ++) +{ + u8 efuse_data, word_cnts = 0; + u16 efuse_addr = 0; @@ -68263,8 +66485,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return false; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, &max_section, bPseudoTest); -+ if (offset > max_section) -+ { ++ if (offset > max_section) { + DBG_8192C("%s: Packet offset(%d) is illegal(>%d)!\n", __func__, offset, max_section); + return false; + } @@ -68277,42 +66498,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* Skip dummy parts to prevent unexpected data read from Efuse. */ + /* By pass right now. 2009.02.19. */ + /* */ -+ while (AVAILABLE_EFUSE_ADDR(efuse_addr)) -+ { -+ if (efuse_OneByteRead(padapter, efuse_addr++, &efuse_data, bPseudoTest) == false) -+ { ++ while (AVAILABLE_EFUSE_ADDR(efuse_addr)) { ++ if (efuse_OneByteRead(padapter, efuse_addr++, &efuse_data, bPseudoTest) == false) { + ret = false; + break; + } + -+ if (efuse_data == 0xFF) break; ++ if (efuse_data == 0xFF) ++ break; + -+ if (EXT_HEADER(efuse_data)) -+ { ++ if (EXT_HEADER(efuse_data)) { + hoffset = GET_HDR_OFFSET_2_0(efuse_data); + efuse_OneByteRead(padapter, efuse_addr++, &efuse_data, bPseudoTest); -+ if (ALL_WORDS_DISABLED(efuse_data)) -+ { ++ if (ALL_WORDS_DISABLED(efuse_data)) { + DBG_8192C("%s: Error!! All words disabled!\n", __func__); + continue; + } + + hoffset |= ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; -+ } -+ else -+ { ++ } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } + -+ if (hoffset == offset) -+ { -+ for (i = 0; i= max_available) -+ { ++ if (current_size >= max_available) { + DBG_8192C("%s: Error!! current_size(%d)>max_available(%d)\n", __func__, current_size, max_available); + return false; + } + return true; +} + -+static void -+hal_EfuseConstructPGPkt( -+ u8 offset, -+ u8 word_en, -+ u8 *pData, -+ PPGPKT_STRUCT pTargetPkt) ++static void hal_EfuseConstructPGPkt( ++ u8 offset, ++ u8 word_en, ++ u8 *pData, ++ PPGPKT_STRUCT pTargetPkt ++) +{ + memset(pTargetPkt->data, 0xFF, PGPKT_DATA_SIZE); + pTargetPkt->offset = offset; @@ -68369,93 +66577,72 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); +} + -+static u8 -+hal_EfusePartialWriteCheck( -+ struct adapter * padapter, -+ u8 efuseType, -+ u16 *pAddr, -+ PPGPKT_STRUCT pTargetPkt, -+ u8 bPseudoTest) ++static u8 hal_EfusePartialWriteCheck( ++ struct adapter *padapter, ++ u8 efuseType, ++ u16 *pAddr, ++ PPGPKT_STRUCT pTargetPkt, ++ u8 bPseudoTest ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal; -+ u8 bRet =false; ++ PEFUSE_HAL pEfuseHal = &pHalData->EfuseHal; ++ u8 bRet = false; + u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; + u8 efuse_data = 0; + + EFUSE_GetEfuseDefinition(padapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &efuse_max_available_len, bPseudoTest); + EFUSE_GetEfuseDefinition(padapter, efuseType, TYPE_EFUSE_CONTENT_LEN_BANK, &efuse_max, bPseudoTest); + -+ if (efuseType == EFUSE_WIFI) -+ { -+ if (bPseudoTest) -+ { ++ if (efuseType == EFUSE_WIFI) { ++ if (bPseudoTest) { +#ifdef HAL_EFUSE_MEMORY + startAddr = (u16)pEfuseHal->fakeEfuseUsedBytes; +#else + startAddr = (u16)fakeEfuseUsedBytes; +#endif -+ } -+ else -+ { ++ } else + rtw_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES, (u8 *)&startAddr); -+ } -+ } -+ else -+ { -+ if (bPseudoTest) -+ { ++ } else { ++ if (bPseudoTest) { +#ifdef HAL_EFUSE_MEMORY + startAddr = (u16)pEfuseHal->fakeBTEfuseUsedBytes; +#else + startAddr = (u16)fakeBTEfuseUsedBytes; +#endif -+ } -+ else -+ { ++ } else + rtw_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *)&startAddr); -+ } + } + startAddr %= efuse_max; + DBG_8192C("%s: startAddr =%#X\n", __func__, startAddr); + -+ while (1) -+ { -+ if (startAddr >= efuse_max_available_len) -+ { ++ while (1) { ++ if (startAddr >= efuse_max_available_len) { + bRet = false; -+ DBG_8192C("%s: startAddr(%d) >= efuse_max_available_len(%d)\n", -+ __func__, startAddr, efuse_max_available_len); ++ DBG_8192C("%s: startAddr(%d) >= efuse_max_available_len(%d)\n", __func__, startAddr, efuse_max_available_len); + break; + } + -+ if (efuse_OneByteRead(padapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data!= 0xFF)) -+ { ++ if (efuse_OneByteRead(padapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { +#if 1 + bRet = false; + DBG_8192C("%s: Something Wrong! last bytes(%#X = 0x%02X) is not 0xFF\n", + __func__, startAddr, efuse_data); + break; +#else -+ if (EXT_HEADER(efuse_data)) -+ { ++ if (EXT_HEADER(efuse_data)) { + cur_header = efuse_data; + startAddr++; + efuse_OneByteRead(padapter, startAddr, &efuse_data, bPseudoTest); -+ if (ALL_WORDS_DISABLED(efuse_data)) -+ { ++ if (ALL_WORDS_DISABLED(efuse_data)) { + DBG_8192C("%s: Error condition, all words disabled!", __func__); + bRet = false; + break; -+ } -+ else -+ { ++ } else { + curPkt.offset = ((cur_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + curPkt.word_en = efuse_data & 0x0F; + } -+ } -+ else -+ { ++ } else { + cur_header = efuse_data; + curPkt.offset = (cur_header>>4) & 0x0F; + curPkt.word_en = cur_header & 0x0F; @@ -68464,15 +66651,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + curPkt.word_cnts = Efuse_CalculateWordCnts(curPkt.word_en); + /* if same header is found but no data followed */ + /* write some part of data followed by the header. */ -+ if ((curPkt.offset == pTargetPkt->offset) && ++ if ( ++ (curPkt.offset == pTargetPkt->offset) && + (hal_EfuseCheckIfDatafollowed(padapter, curPkt.word_cnts, startAddr+1, bPseudoTest) == false) && -+ wordEnMatched(pTargetPkt, &curPkt, &matched_wden) == true) -+ { ++ wordEnMatched(pTargetPkt, &curPkt, &matched_wden) == true ++ ) { + DBG_8192C("%s: Need to partial write data by the previous wrote header\n", __func__); + /* Here to write partial data */ + badworden = Efuse_WordEnableDataWrite(padapter, startAddr+1, matched_wden, pTargetPkt->data, bPseudoTest); -+ if (badworden != 0x0F) -+ { ++ if (badworden != 0x0F) { + u32 PgWriteSuccess = 0; + /* if write fail on some words, write these bad words again */ + if (efuseType == EFUSE_WIFI) @@ -68480,17 +66667,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + else + PgWriteSuccess = Efuse_PgPacketWrite_BT(padapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); + -+ if (!PgWriteSuccess) -+ { ++ if (!PgWriteSuccess) { + bRet = false; /* write fail, return */ + break; + } + } + /* partial write ok, update the target packet for later use */ -+ for (i = 0; i<4; i++) -+ { -+ if ((matched_wden & (0x1<word_en |= (0x1< EFUSE_REPEAT_THRESHOLD_) -+ { ++ if (tmp_header != 0xFF) ++ break; ++ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { + DBG_8192C("%s: Repeat over limit for pg_header!!\n", __func__); + return false; + } + } while (1); + -+ if (tmp_header != pg_header) -+ { ++ if (tmp_header != pg_header) { + DBG_8192C(KERN_ERR "%s: PG Header Fail!!(pg = 0x%02X read = 0x%02X)\n", __func__, pg_header, tmp_header); + return false; + } @@ -68551,13 +66732,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return true; +} + -+static u8 -+hal_EfusePgPacketWrite2ByteHeader( -+ struct adapter * padapter, -+ u8 efuseType, -+ u16 *pAddr, -+ PPGPKT_STRUCT pTargetPkt, -+ u8 bPseudoTest) ++static u8 hal_EfusePgPacketWrite2ByteHeader( ++ struct adapter *padapter, ++ u8 efuseType, ++ u16 *pAddr, ++ PPGPKT_STRUCT pTargetPkt, ++ u8 bPseudoTest ++) +{ + u16 efuse_addr, efuse_max_available_len = 0; + u8 pg_header = 0, tmp_header = 0; @@ -68568,8 +66749,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + EFUSE_GetEfuseDefinition(padapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, &efuse_max_available_len, bPseudoTest); + + efuse_addr = *pAddr; -+ if (efuse_addr >= efuse_max_available_len) -+ { ++ if (efuse_addr >= efuse_max_available_len) { + DBG_8192C("%s: addr(%d) over avaliable(%d)!!\n", __func__, efuse_addr, efuse_max_available_len); + return false; + } @@ -68580,16 +66760,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + do { + efuse_OneByteWrite(padapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(padapter, efuse_addr, &tmp_header, bPseudoTest); -+ if (tmp_header != 0xFF) break; -+ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) -+ { ++ if (tmp_header != 0xFF) ++ break; ++ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { + DBG_8192C("%s: Repeat over limit for pg_header!!\n", __func__); + return false; + } + } while (1); + -+ if (tmp_header != pg_header) -+ { ++ if (tmp_header != pg_header) { + DBG_8192C(KERN_ERR "%s: PG Header Fail!!(pg = 0x%02X read = 0x%02X)\n", __func__, pg_header, tmp_header); + return false; + } @@ -68601,16 +66780,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + do { + efuse_OneByteWrite(padapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(padapter, efuse_addr, &tmp_header, bPseudoTest); -+ if (tmp_header != 0xFF) break; -+ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) -+ { ++ if (tmp_header != 0xFF) ++ break; ++ if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { + DBG_8192C("%s: Repeat over limit for ext_header!!\n", __func__); + return false; + } + } while (1); + -+ if (tmp_header != pg_header) /* offset PG fail */ -+ { ++ if (tmp_header != pg_header) { /* offset PG fail */ + DBG_8192C(KERN_ERR "%s: PG EXT Header Fail!!(pg = 0x%02X read = 0x%02X)\n", __func__, pg_header, tmp_header); + return false; + } @@ -68620,35 +66798,31 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return true; +} + -+static u8 -+hal_EfusePgPacketWriteHeader( -+ struct adapter * padapter, -+ u8 efuseType, -+ u16 *pAddr, -+ PPGPKT_STRUCT pTargetPkt, -+ u8 bPseudoTest) ++static u8 hal_EfusePgPacketWriteHeader( ++ struct adapter *padapter, ++ u8 efuseType, ++ u16 *pAddr, ++ PPGPKT_STRUCT pTargetPkt, ++ u8 bPseudoTest ++) +{ -+ u8 bRet =false; ++ u8 bRet = false; + + if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) -+ { + bRet = hal_EfusePgPacketWrite2ByteHeader(padapter, efuseType, pAddr, pTargetPkt, bPseudoTest); -+ } + else -+ { + bRet = hal_EfusePgPacketWrite1ByteHeader(padapter, efuseType, pAddr, pTargetPkt, bPseudoTest); -+ } + + return bRet; +} + -+static u8 -+hal_EfusePgPacketWriteData( -+ struct adapter * padapter, -+ u8 efuseType, -+ u16 *pAddr, -+ PPGPKT_STRUCT pTargetPkt, -+ u8 bPseudoTest) ++static u8 hal_EfusePgPacketWriteData( ++ struct adapter *padapter, ++ u8 efuseType, ++ u16 *pAddr, ++ PPGPKT_STRUCT pTargetPkt, ++ u8 bPseudoTest ++) +{ + u16 efuse_addr; + u8 badworden; @@ -68656,8 +66830,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + efuse_addr = *pAddr; + badworden = Efuse_WordEnableDataWrite(padapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest); -+ if (badworden != 0x0F) -+ { ++ if (badworden != 0x0F) { + DBG_8192C("%s: Fail!!\n", __func__); + return false; + } @@ -68666,17 +66839,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return true; +} + -+static s32 -+Hal_EfusePgPacketWrite( ++static s32 Hal_EfusePgPacketWrite( + struct adapter *padapter, -+ u8 offset, -+ u8 word_en, -+ u8 *pData, -+ bool bPseudoTest) ++ u8 offset, ++ u8 word_en, ++ u8 *pData, ++ bool bPseudoTest ++) +{ + PGPKT_STRUCT targetPkt; + u16 startAddr = 0; -+ u8 efuseType =EFUSE_WIFI; ++ u8 efuseType = EFUSE_WIFI; + + if (!hal_EfusePgCheckAvailableAddr(padapter, efuseType, bPseudoTest)) + return false; @@ -68695,17 +66868,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return true; +} + -+static bool -+Hal_EfusePgPacketWrite_BT( ++static bool Hal_EfusePgPacketWrite_BT( + struct adapter *padapter, -+ u8 offset, -+ u8 word_en, -+ u8 *pData, -+ bool bPseudoTest) ++ u8 offset, ++ u8 word_en, ++ u8 *pData, ++ bool bPseudoTest ++) +{ + PGPKT_STRUCT targetPkt; + u16 startAddr = 0; -+ u8 efuseType =EFUSE_BT; ++ u8 efuseType = EFUSE_BT; + + if (!hal_EfusePgCheckAvailableAddr(padapter, efuseType, bPseudoTest)) + return false; @@ -68724,14 +66897,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return true; +} + -+static HAL_VERSION -+ReadChipVersion8723B( -+struct adapter *padapter -+ ) ++static HAL_VERSION ReadChipVersion8723B(struct adapter *padapter) +{ -+ u32 value32; -+ HAL_VERSION ChipVersion; -+ struct hal_com_data *pHalData; ++ u32 value32; ++ HAL_VERSION ChipVersion; ++ struct hal_com_data *pHalData; + +/* YJ, TODO, move read chip type here */ + pHalData = GET_HAL_DATA(padapter); @@ -68739,7 +66909,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + value32 = rtw_read32(padapter, REG_SYS_CFG); + ChipVersion.ICType = CHIP_8723B; + ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); -+ ChipVersion.RFType = RF_TYPE_1T1R ; ++ ChipVersion.RFType = RF_TYPE_1T1R; + ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); + ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ + @@ -68811,9 +66981,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pHalData->RegCR_1 = rtw_read8(padapter, REG_CR+1); +} + -+void _InitBurstPktLen_8723BS(struct adapter * Adapter) ++void _InitBurstPktLen_8723BS(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + rtw_write8(Adapter, 0x4c7, rtw_read8(Adapter, 0x4c7)|BIT(7)); /* enable single pkt ampdu */ + rtw_write8(Adapter, REG_RX_PKT_LIMIT_8723B, 0x18); /* for VHT packet length 11K */ @@ -68821,9 +66991,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + rtw_write8(Adapter, REG_PIFS_8723B, 0x00); + rtw_write8(Adapter, REG_FWHW_TXQ_CTRL_8723B, rtw_read8(Adapter, REG_FWHW_TXQ_CTRL)&(~BIT(7))); + if (pHalData->AMPDUBurstMode) -+ { + rtw_write8(Adapter, REG_AMPDU_BURST_MODE_8723B, 0x5F); -+ } + rtw_write8(Adapter, REG_AMPDU_MAX_TIME_8723B, 0x70); + + /* ARFB table 9 for 11ac 5G 2SS */ @@ -68928,8 +67096,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + rtw_write32(padapter, REG_TCR, value32); + + /* NOTE: Fix test chip's bug (about contention windows's randomness) */ -+ if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE) == true) -+ { ++ if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE) == true) { + rtw_write8(padapter, REG_RXTSF_OFFSET_CCK, 0x50); + rtw_write8(padapter, REG_RXTSF_OFFSET_OFDM, 0x50); + } @@ -68943,19 +67110,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +} + +static void rtl8723b_GetHalODMVar( -+ struct adapter * Adapter, -+ enum HAL_ODM_VARIABLE eVariable, -+ void * pValue1, -+ void * pValue2) ++ struct adapter *Adapter, ++ enum HAL_ODM_VARIABLE eVariable, ++ void *pValue1, ++ void *pValue2 ++) +{ + GetHalODMVar(Adapter, eVariable, pValue1, pValue2); +} + +static void rtl8723b_SetHalODMVar( -+ struct adapter * Adapter, -+ enum HAL_ODM_VARIABLE eVariable, -+ void * pValue1, -+ bool bSet) ++ struct adapter *Adapter, ++ enum HAL_ODM_VARIABLE eVariable, ++ void *pValue1, ++ bool bSet ++) +{ + SetHalODMVar(Adapter, eVariable, pValue1, bSet); +} @@ -68984,15 +67153,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + DBG_871X("%s(): mac_id =%d rssi_level =%d\n", __func__, mac_id, rssi_level); + + if (mac_id >= NUM_STA) /* CAM_SIZE */ -+ { + return; -+ } + + psta = pmlmeinfo->FW_sta_info[mac_id].psta; + if (psta == NULL) -+ { + return; -+ } + + shortGIrate = query_ra_short_GI(psta); + @@ -69018,8 +67183,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } +#endif + -+ if (pHalData->fw_ractrl == true) -+ { ++ if (pHalData->fw_ractrl == true) { + rtl8723b_set_FwMacIdConfig_cmd(padapter, mac_id, psta->raid, psta->bw_mode, shortGIrate, mask); + } + @@ -69126,7 +67290,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +/* pdmpriv->initialize = 0; */ + + pdmpriv->ThermalValue_HP_index = 0; -+ for (i = 0; iThermalValue_HP[i] = 0; + + /* init Efuse variables */ @@ -69159,7 +67323,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* 6: EEPROM used is 93C46, 4: boot from E-Fuse. */ + size = (cr & BOOT_FROM_EEPROM) ? 6 : 4; + -+ MSG_8192C("EEPROM type is %s\n", size ==4 ? "E-FUSE" : "93C46"); ++ MSG_8192C("EEPROM type is %s\n", size == 4 ? "E-FUSE" : "93C46"); + + return size; +} @@ -69186,17 +67350,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + do { + val32 = rtw_read32(padapter, REG_AUTO_LLT); -+ if (!(val32 & BIT_AUTO_INIT_LLT)) -+ { ++ if (!(val32 & BIT_AUTO_INIT_LLT)) { + ret = _SUCCESS; + break; + } + + passing_time = jiffies_to_msecs(jiffies - start); -+ if (passing_time > 1000) -+ { -+ DBG_8192C("%s: FAIL!! REG_AUTO_LLT(0x%X) =%08x\n", -+ __func__, REG_AUTO_LLT, val32); ++ if (passing_time > 1000) { ++ DBG_8192C( ++ "%s: FAIL!! REG_AUTO_LLT(0x%X) =%08x\n", ++ __func__, ++ REG_AUTO_LLT, ++ val32 ++ ); + break; + } + @@ -69206,141 +67372,144 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return ret; +} + -+static bool -+Hal_GetChnlGroup8723B( -+u8 Channel, -+ u8 *pGroup -+ ) ++static bool Hal_GetChnlGroup8723B(u8 Channel, u8 *pGroup) +{ -+ bool bIn24G =true; ++ bool bIn24G = true; + -+ if (Channel <= 14) -+ { -+ bIn24G =true; ++ if (Channel <= 14) { ++ bIn24G = true; + -+ if (1 <= Channel && Channel <= 2) *pGroup = 0; -+ else if (3 <= Channel && Channel <= 5) *pGroup = 1; -+ else if (6 <= Channel && Channel <= 8) *pGroup = 2; -+ else if (9 <= Channel && Channel <= 11) *pGroup = 3; -+ else if (12 <= Channel && Channel <= 14) *pGroup = 4; -+ else -+ { ++ if (1 <= Channel && Channel <= 2) ++ *pGroup = 0; ++ else if (3 <= Channel && Channel <= 5) ++ *pGroup = 1; ++ else if (6 <= Channel && Channel <= 8) ++ *pGroup = 2; ++ else if (9 <= Channel && Channel <= 11) ++ *pGroup = 3; ++ else if (12 <= Channel && Channel <= 14) ++ *pGroup = 4; ++ else { + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("==>Hal_GetChnlGroup8723B in 2.4 G, but Channel %d in Group not found\n", Channel)); + } -+ } -+ else -+ { -+ bIn24G =false; ++ } else { ++ bIn24G = false; + -+ if (36 <= Channel && Channel <= 42) *pGroup = 0; -+ else if (44 <= Channel && Channel <= 48) *pGroup = 1; -+ else if (50 <= Channel && Channel <= 58) *pGroup = 2; -+ else if (60 <= Channel && Channel <= 64) *pGroup = 3; -+ else if (100 <= Channel && Channel <= 106) *pGroup = 4; -+ else if (108 <= Channel && Channel <= 114) *pGroup = 5; -+ else if (116 <= Channel && Channel <= 122) *pGroup = 6; -+ else if (124 <= Channel && Channel <= 130) *pGroup = 7; -+ else if (132 <= Channel && Channel <= 138) *pGroup = 8; -+ else if (140 <= Channel && Channel <= 144) *pGroup = 9; -+ else if (149 <= Channel && Channel <= 155) *pGroup = 10; -+ else if (157 <= Channel && Channel <= 161) *pGroup = 11; -+ else if (165 <= Channel && Channel <= 171) *pGroup = 12; -+ else if (173 <= Channel && Channel <= 177) *pGroup = 13; -+ else -+ { ++ if (36 <= Channel && Channel <= 42) ++ *pGroup = 0; ++ else if (44 <= Channel && Channel <= 48) ++ *pGroup = 1; ++ else if (50 <= Channel && Channel <= 58) ++ *pGroup = 2; ++ else if (60 <= Channel && Channel <= 64) ++ *pGroup = 3; ++ else if (100 <= Channel && Channel <= 106) ++ *pGroup = 4; ++ else if (108 <= Channel && Channel <= 114) ++ *pGroup = 5; ++ else if (116 <= Channel && Channel <= 122) ++ *pGroup = 6; ++ else if (124 <= Channel && Channel <= 130) ++ *pGroup = 7; ++ else if (132 <= Channel && Channel <= 138) ++ *pGroup = 8; ++ else if (140 <= Channel && Channel <= 144) ++ *pGroup = 9; ++ else if (149 <= Channel && Channel <= 155) ++ *pGroup = 10; ++ else if (157 <= Channel && Channel <= 161) ++ *pGroup = 11; ++ else if (165 <= Channel && Channel <= 171) ++ *pGroup = 12; ++ else if (173 <= Channel && Channel <= 177) ++ *pGroup = 13; ++ else { + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("==>Hal_GetChnlGroup8723B in 5G, but Channel %d in Group not found\n", Channel)); + } + + } -+ RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<==Hal_GetChnlGroup8723B, (%s) Channel = %d, Group =%d,\n", -+ (bIn24G) ? "2.4G" : "5G", Channel, *pGroup)); ++ RT_TRACE( ++ _module_hci_hal_init_c_, ++ _drv_info_, ++ ( ++ "<==Hal_GetChnlGroup8723B, (%s) Channel = %d, Group =%d,\n", ++ bIn24G ? "2.4G" : "5G", ++ Channel, ++ *pGroup ++ ) ++ ); + return bIn24G; +} + -+void -+Hal_InitPGData( -+ struct adapter *padapter, -+ u8 *PROMContent) ++void Hal_InitPGData(struct adapter *padapter, u8 *PROMContent) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + -+ if (false == pEEPROM->bautoload_fail_flag) -+ { /* autoload OK. */ ++ if (false == pEEPROM->bautoload_fail_flag) { /* autoload OK. */ + if (!pEEPROM->EepromOrEfuse) { + /* Read EFUSE real map to shadow. */ + EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); -+ memcpy((void*)PROMContent, (void*)pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE_8723B); ++ memcpy((void *)PROMContent, (void *)pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE_8723B); + } + } else {/* autoload fail */ + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n")); + if (false == pEEPROM->EepromOrEfuse) + EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); -+ memcpy((void*)PROMContent, (void*)pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE_8723B); ++ memcpy((void *)PROMContent, (void *)pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE_8723B); + } +} + -+void -+Hal_EfuseParseIDCode( -+struct adapter *padapter, -+u8 *hwinfo -+ ) ++void Hal_EfuseParseIDCode(struct adapter *padapter, u8 *hwinfo) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); +/* struct hal_com_data *pHalData = GET_HAL_DATA(padapter); */ -+ u16 EEPROMId; ++ u16 EEPROMId; + + + /* Checl 0x8129 again for making sure autoload status!! */ -+ EEPROMId = le16_to_cpu(*((__le16*)hwinfo)); -+ if (EEPROMId != RTL_EEPROM_ID) -+ { ++ EEPROMId = le16_to_cpu(*((__le16 *)hwinfo)); ++ if (EEPROMId != RTL_EEPROM_ID) { + DBG_8192C("EEPROM ID(%#x) is invalid!!\n", EEPROMId); + pEEPROM->bautoload_fail_flag = true; -+ } -+ else -+ { ++ } else + pEEPROM->bautoload_fail_flag = false; -+ } + + RT_TRACE(_module_hal_init_c_, _drv_notice_, ("EEPROM ID = 0x%04x\n", EEPROMId)); +} + -+static void Hal_ReadPowerValueFromPROM_8723B(struct adapter *Adapter, -+ struct TxPowerInfo24G *pwrInfo24G, -+ u8 *PROMContent, bool AutoLoadFail) ++static void Hal_ReadPowerValueFromPROM_8723B( ++ struct adapter *Adapter, ++ struct TxPowerInfo24G *pwrInfo24G, ++ u8 *PROMContent, ++ bool AutoLoadFail ++) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ u32 rfPath, eeAddr =EEPROM_TX_PWR_INX_8723B, group, TxCount = 0; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_8723B, group, TxCount = 0; + + memset(pwrInfo24G, 0, sizeof(struct TxPowerInfo24G)); + + if (0xFF == PROMContent[eeAddr+1]) + AutoLoadFail = true; + -+ if (AutoLoadFail) -+ { ++ if (AutoLoadFail) { + DBG_871X("%s(): Use Default value!\n", __func__); -+ for (rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) -+ { ++ for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { + /* 2.4G default value */ -+ for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) -+ { -+ pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; -+ pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; ++ for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { ++ pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; ++ pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + } -+ for (TxCount = 0;TxCountBW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF; -+ pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF; -+ } -+ else -+ { -+ pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; -+ pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; -+ pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; -+ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; ++ ++ for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { ++ if (TxCount == 0) { ++ pwrInfo24G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF; ++ pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF; ++ } else { ++ pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; ++ pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; ++ pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; ++ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } + } + } @@ -69350,83 +67519,70 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + pHalData->bTXPowerDataReadFromEEPORM = true; /* YJ, move, 120316 */ + -+ for (rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) -+ { ++ for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { + /* 2 2.4G default value */ -+ for (group = 0 ; group < MAX_CHNL_GROUP_24G; group++) -+ { ++ for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { + pwrInfo24G->IndexCCK_Base[rfPath][group] = PROMContent[eeAddr++]; + if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) -+ { + pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; -+ } + } -+ for (group = 0 ; group < MAX_CHNL_GROUP_24G-1; group++) -+ { ++ ++ for (group = 0; group < MAX_CHNL_GROUP_24G-1; group++) { + pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++]; + if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF) + pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + } -+ for (TxCount = 0;TxCountBW40_Diff[rfPath][TxCount] = 0; + if (PROMContent[eeAddr] == 0xFF) + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF; -+ else -+ { ++ else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) -+ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF; -+ else -+ { -+ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); ++ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF; ++ else { ++ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; + } + pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0; + eeAddr++; -+ } -+ else -+ { ++ } else { + if (PROMContent[eeAddr] == 0xFF) -+ pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; -+ else -+ { -+ pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; ++ pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; ++ else { ++ pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) -+ pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; -+ else -+ { -+ pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); ++ pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; ++ else { ++ pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; + } + eeAddr++; + + if (PROMContent[eeAddr] == 0xFF) -+ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; -+ else -+ { -+ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; ++ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; ++ else { ++ pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) -+ pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; -+ else -+ { -+ pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); ++ pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; ++ else { ++ pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0; + } @@ -69437,49 +67593,40 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +} + + -+void -+Hal_EfuseParseTxPowerInfo_8723B( -+struct adapter * padapter, -+u8* PROMContent, -+bool AutoLoadFail -+ ) ++void Hal_EfuseParseTxPowerInfo_8723B( ++ struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + struct TxPowerInfo24G pwrInfo24G; + u8 rfPath, ch, TxCount = 1; + + Hal_ReadPowerValueFromPROM_8723B(padapter, &pwrInfo24G, PROMContent, AutoLoadFail); -+ for (rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) -+ { -+ for (ch = 0 ; ch < CHANNEL_MAX_NUMBER; ch++) -+ { ++ for (rfPath = 0 ; rfPath < MAX_RF_PATH ; rfPath++) { ++ for (ch = 0 ; ch < CHANNEL_MAX_NUMBER; ch++) { + u8 group = 0; + + Hal_GetChnlGroup8723B(ch+1, &group); + -+ if (ch == 14-1) -+ { ++ if (ch == 14-1) { + pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][5]; + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group]; -+ } -+ else -+ { ++ } else { + pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group]; + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group]; + } +#ifdef CONFIG_DEBUG + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("======= Path %d, ChannelIndex %d, Group %d =======\n", rfPath, ch, group)); -+ RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_CCK_Base[rfPath][ch])); ++ RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_CCK_Base[rfPath][ch])); + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_BW40_Base[rfPath][ch])); +#endif + } + -+ for (TxCount = 0;TxCountCCK_24G_Diff[rfPath][TxCount]=pwrInfo24G.CCK_Diff[rfPath][TxCount]; -+ pHalData->OFDM_24G_Diff[rfPath][TxCount]=pwrInfo24G.OFDM_Diff[rfPath][TxCount]; -+ pHalData->BW20_24G_Diff[rfPath][TxCount]=pwrInfo24G.BW20_Diff[rfPath][TxCount]; -+ pHalData->BW40_24G_Diff[rfPath][TxCount]=pwrInfo24G.BW40_Diff[rfPath][TxCount]; ++ for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { ++ pHalData->CCK_24G_Diff[rfPath][TxCount] = pwrInfo24G.CCK_Diff[rfPath][TxCount]; ++ pHalData->OFDM_24G_Diff[rfPath][TxCount] = pwrInfo24G.OFDM_Diff[rfPath][TxCount]; ++ pHalData->BW20_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW20_Diff[rfPath][TxCount]; ++ pHalData->BW40_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW40_Diff[rfPath][TxCount]; + +#ifdef CONFIG_DEBUG + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("--------------------------------------- 2.4G ---------------------------------------\n")); @@ -69492,29 +67639,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } + + /* 2010/10/19 MH Add Regulator recognize for CU. */ -+ if (!AutoLoadFail) -+ { ++ if (!AutoLoadFail) { + pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_8723B]&0x7); /* bit0~2 */ + if (PROMContent[EEPROM_RF_BOARD_OPTION_8723B] == 0xFF) + pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION&0x7); /* bit0~2 */ -+ } -+ else -+ { ++ } else + pHalData->EEPROMRegulatory = 0; -+ } ++ + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROMRegulatory = 0x%x\n", pHalData->EEPROMRegulatory)); +} + -+void -+Hal_EfuseParseBTCoexistInfo_8723B( -+ struct adapter * padapter, -+ u8 *hwinfo, -+ bool AutoLoadFail -+ ) ++void Hal_EfuseParseBTCoexistInfo_8723B( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ u8 tempval; -+ u32 tmpu4; ++ u8 tempval; ++ u32 tmpu4; + + if (!AutoLoadFail) { + tmpu4 = rtw_read32(padapter, REG_MULTI_FUNC_CTRL); @@ -69531,14 +67672,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* EFUSE_0xC3[6] == 0, S1(Main)-ODM_RF_PATH_A; */ + /* EFUSE_0xC3[6] == 1, S0(Aux)-ODM_RF_PATH_B */ + pHalData->ant_path = (tempval & BIT(6))?ODM_RF_PATH_B:ODM_RF_PATH_A; -+ } -+ else { ++ } else { + pHalData->EEPROMBluetoothAntNum = Ant_x1; -+ pHalData->ant_path = ODM_RF_PATH_A; ++ if (pHalData->PackageType == PACKAGE_QFN68) ++ pHalData->ant_path = ODM_RF_PATH_B; ++ else ++ pHalData->ant_path = ODM_RF_PATH_A; + } -+ } -+ else -+ { ++ } else { + pHalData->EEPROMBluetoothCoexist = false; + pHalData->EEPROMBluetoothType = BT_RTL8723B; + pHalData->EEPROMBluetoothAntNum = Ant_x1; @@ -69546,10 +67687,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } + + if (padapter->registrypriv.ant_num > 0) { -+ DBG_8192C("%s: Apply driver defined antenna number(%d) to replace origin(%d)\n", ++ DBG_8192C( ++ "%s: Apply driver defined antenna number(%d) to replace origin(%d)\n", + __func__, + padapter->registrypriv.ant_num, -+ pHalData->EEPROMBluetoothAntNum ==Ant_x2?2:1); ++ pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1 ++ ); + + switch (padapter->registrypriv.ant_num) { + case 1: @@ -69559,32 +67702,32 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pHalData->EEPROMBluetoothAntNum = Ant_x2; + break; + default: -+ DBG_8192C("%s: Discard invalid driver defined antenna number(%d)!\n", -+ __func__, padapter->registrypriv.ant_num); ++ DBG_8192C( ++ "%s: Discard invalid driver defined antenna number(%d)!\n", ++ __func__, ++ padapter->registrypriv.ant_num ++ ); + break; + } + } + + rtw_btcoex_SetBTCoexist(padapter, pHalData->EEPROMBluetoothCoexist); + rtw_btcoex_SetChipType(padapter, pHalData->EEPROMBluetoothType); -+ rtw_btcoex_SetPGAntNum(padapter, pHalData->EEPROMBluetoothAntNum ==Ant_x2?2:1); ++ rtw_btcoex_SetPGAntNum(padapter, pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1); + if (pHalData->EEPROMBluetoothAntNum == Ant_x1) -+ { + rtw_btcoex_SetSingleAntPath(padapter, pHalData->ant_path); -+ } + -+ DBG_8192C("%s: %s BT-coex, ant_num =%d\n", ++ DBG_8192C( ++ "%s: %s BT-coex, ant_num =%d\n", + __func__, -+ pHalData->EEPROMBluetoothCoexist ==true?"Enable":"Disable", -+ pHalData->EEPROMBluetoothAntNum ==Ant_x2?2:1); ++ pHalData->EEPROMBluetoothCoexist == true ? "Enable" : "Disable", ++ pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1 ++ ); +} + -+void -+Hal_EfuseParseEEPROMVer_8723B( -+struct adapter * padapter, -+u8* hwinfo, -+bool AutoLoadFail -+ ) ++void Hal_EfuseParseEEPROMVer_8723B( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + @@ -69599,15 +67742,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + + -+void -+Hal_EfuseParsePackageType_8723B( -+struct adapter * padapter, -+u8* hwinfo, -+bool AutoLoadFail -+ ) ++void Hal_EfuseParsePackageType_8723B( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ u8 package; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ u8 package; + u8 efuseContent; + + Efuse_PowerSwitch(padapter, false, true); @@ -69616,58 +67756,51 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + Efuse_PowerSwitch(padapter, false, false); + + package = efuseContent & 0x7; -+ switch (package) -+ { -+ case 0x4: -+ pHalData->PackageType = PACKAGE_TFBGA79; -+ break; -+ case 0x5: -+ pHalData->PackageType = PACKAGE_TFBGA90; -+ break; -+ case 0x6: -+ pHalData->PackageType = PACKAGE_QFN68; -+ break; -+ case 0x7: -+ pHalData->PackageType = PACKAGE_TFBGA80; -+ break; ++ switch (package) { ++ case 0x4: ++ pHalData->PackageType = PACKAGE_TFBGA79; ++ break; ++ case 0x5: ++ pHalData->PackageType = PACKAGE_TFBGA90; ++ break; ++ case 0x6: ++ pHalData->PackageType = PACKAGE_QFN68; ++ break; ++ case 0x7: ++ pHalData->PackageType = PACKAGE_TFBGA80; ++ break; + -+ default: -+ pHalData->PackageType = PACKAGE_DEFAULT; -+ break; ++ default: ++ pHalData->PackageType = PACKAGE_DEFAULT; ++ break; + } + + DBG_871X("PackageType = 0x%X\n", pHalData->PackageType); +} + + -+void -+Hal_EfuseParseVoltage_8723B( -+struct adapter * padapter, -+u8* hwinfo, -+bool AutoLoadFail -+ ) ++void Hal_EfuseParseVoltage_8723B( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + + /* memcpy(pEEPROM->adjuseVoltageVal, &hwinfo[EEPROM_Voltage_ADDR_8723B], 1); */ + DBG_871X("%s hwinfo[EEPROM_Voltage_ADDR_8723B] =%02x\n", __func__, hwinfo[EEPROM_Voltage_ADDR_8723B]); -+ pEEPROM->adjuseVoltageVal = (hwinfo[EEPROM_Voltage_ADDR_8723B] & 0xf0) >> 4 ; ++ pEEPROM->adjuseVoltageVal = (hwinfo[EEPROM_Voltage_ADDR_8723B] & 0xf0) >> 4; + DBG_871X("%s pEEPROM->adjuseVoltageVal =%x\n", __func__, pEEPROM->adjuseVoltageVal); +} + -+void -+Hal_EfuseParseChnlPlan_8723B( -+struct adapter * padapter, -+u8* hwinfo, -+bool AutoLoadFail -+ ) ++void Hal_EfuseParseChnlPlan_8723B( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ + padapter->mlmepriv.ChannelPlan = hal_com_config_channel_plan( -+ padapter -+ , hwinfo?hwinfo[EEPROM_ChannelPlan_8723B]:0xFF -+ , padapter->registrypriv.channel_plan -+ , RT_CHANNEL_DOMAIN_WORLD_NULL -+ , AutoLoadFail ++ padapter, ++ hwinfo ? hwinfo[EEPROM_ChannelPlan_8723B] : 0xFF, ++ padapter->registrypriv.channel_plan, ++ RT_CHANNEL_DOMAIN_WORLD_NULL, ++ AutoLoadFail + ); + + Hal_ChannelPlanToRegulation(padapter, padapter->mlmepriv.ChannelPlan); @@ -69675,66 +67808,50 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROM ChannelPlan = 0x%02x\n", padapter->mlmepriv.ChannelPlan)); +} + -+void -+Hal_EfuseParseCustomerID_8723B( -+struct adapter * padapter, -+u8* hwinfo, -+bool AutoLoadFail -+ ) ++void Hal_EfuseParseCustomerID_8723B( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + +/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */ + if (!AutoLoadFail) -+ { + pHalData->EEPROMCustomerID = hwinfo[EEPROM_CustomID_8723B]; -+ } + else -+ { + pHalData->EEPROMCustomerID = 0; -+ } ++ + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROM Customer ID: 0x%2x\n", pHalData->EEPROMCustomerID)); +} + -+void -+Hal_EfuseParseAntennaDiversity_8723B( -+struct adapter * padapter, -+u8 * hwinfo, -+bool AutoLoadFail -+ ) ++void Hal_EfuseParseAntennaDiversity_8723B( ++ struct adapter *padapter, ++ u8 *hwinfo, ++ bool AutoLoadFail ++) +{ +} + -+void -+Hal_EfuseParseXtal_8723B( -+struct adapter * padapter, -+u8 * hwinfo, -+bool AutoLoadFail -+ ) ++void Hal_EfuseParseXtal_8723B( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + +/* RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("%s(): AutoLoadFail = %d\n", __func__, AutoLoadFail)); */ -+ if (!AutoLoadFail) -+ { ++ if (!AutoLoadFail) { + pHalData->CrystalCap = hwinfo[EEPROM_XTAL_8723B]; + if (pHalData->CrystalCap == 0xFF) + pHalData->CrystalCap = EEPROM_Default_CrystalCap_8723B; /* what value should 8812 set? */ -+ } -+ else -+ { ++ } else + pHalData->CrystalCap = EEPROM_Default_CrystalCap_8723B; -+ } ++ + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("EEPROM CrystalCap: 0x%2x\n", pHalData->CrystalCap)); +} + + -+void -+Hal_EfuseParseThermalMeter_8723B( -+ struct adapter *padapter, -+ u8 *PROMContent, -+ u8 AutoLoadFail -+ ) ++void Hal_EfuseParseThermalMeter_8723B( ++ struct adapter *padapter, u8 *PROMContent, u8 AutoLoadFail ++) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + @@ -69747,8 +67864,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + else + pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_8723B; + -+ if ((pHalData->EEPROMThermalMeter == 0xff) || (true == AutoLoadFail)) -+ { ++ if ((pHalData->EEPROMThermalMeter == 0xff) || (true == AutoLoadFail)) { + pHalData->bAPKThermalMeterIgnore = true; + pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_8723B; + } @@ -69758,21 +67874,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + +void Hal_ReadRFGainOffset( -+ struct adapter * Adapter, -+ u8* PROMContent, -+ bool AutoloadFail) ++ struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail ++) +{ + /* */ + /* BB_RF Gain Offset from EEPROM */ + /* */ + + if (!AutoloadFail) { -+ Adapter->eeprompriv.EEPROMRFGainOffset =PROMContent[EEPROM_RF_GAIN_OFFSET]; ++ Adapter->eeprompriv.EEPROMRFGainOffset = PROMContent[EEPROM_RF_GAIN_OFFSET]; + DBG_871X("AutoloadFail =%x,\n", AutoloadFail); -+ Adapter->eeprompriv.EEPROMRFGainVal =EFUSE_Read1Byte(Adapter, EEPROM_RF_GAIN_VAL); ++ Adapter->eeprompriv.EEPROMRFGainVal = EFUSE_Read1Byte(Adapter, EEPROM_RF_GAIN_VAL); + DBG_871X("Adapter->eeprompriv.EEPROMRFGainVal =%x\n", Adapter->eeprompriv.EEPROMRFGainVal); -+ } -+ else { ++ } else { + Adapter->eeprompriv.EEPROMRFGainOffset = 0; + Adapter->eeprompriv.EEPROMRFGainVal = 0xFF; + DBG_871X("else AutoloadFail =%x,\n", AutoloadFail); @@ -69780,34 +67894,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + DBG_871X("EEPRORFGainOffset = 0x%02x\n", Adapter->eeprompriv.EEPROMRFGainOffset); +} + -+u8 -+BWMapping_8723B( -+struct adapter * Adapter, -+struct pkt_attrib *pattrib -+) ++u8 BWMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib) +{ + u8 BWSettingOfDesc = 0; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + /* DBG_871X("BWMapping pHalData->CurrentChannelBW %d, pattrib->bwmode %d\n", pHalData->CurrentChannelBW, pattrib->bwmode); */ + -+ if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) -+ { ++ if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) { + if (pattrib->bwmode == CHANNEL_WIDTH_80) + BWSettingOfDesc = 2; + else if (pattrib->bwmode == CHANNEL_WIDTH_40) + BWSettingOfDesc = 1; + else + BWSettingOfDesc = 0; -+ } -+ else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) -+ { ++ } else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) { + if ((pattrib->bwmode == CHANNEL_WIDTH_40) || (pattrib->bwmode == CHANNEL_WIDTH_80)) + BWSettingOfDesc = 1; + else + BWSettingOfDesc = 0; -+ } -+ else ++ } else + BWSettingOfDesc = 0; + + /* if (pTcb->bBTTxPacket) */ @@ -69816,30 +67922,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + return BWSettingOfDesc; +} + -+u8 SCMapping_8723B(struct adapter * Adapter, struct pkt_attrib *pattrib) ++u8 SCMapping_8723B(struct adapter *Adapter, struct pkt_attrib *pattrib) +{ + u8 SCSettingOfDesc = 0; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + /* DBG_871X("SCMapping: pHalData->CurrentChannelBW %d, pHalData->nCur80MhzPrimeSC %d, pHalData->nCur40MhzPrimeSC %d\n", pHalData->CurrentChannelBW, pHalData->nCur80MhzPrimeSC, pHalData->nCur40MhzPrimeSC); */ + -+ if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) -+ { -+ if (pattrib->bwmode == CHANNEL_WIDTH_80) -+ { ++ if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) { ++ if (pattrib->bwmode == CHANNEL_WIDTH_80) { + SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE; -+ } -+ else if (pattrib->bwmode == CHANNEL_WIDTH_40) -+ { ++ } else if (pattrib->bwmode == CHANNEL_WIDTH_40) { + if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) + SCSettingOfDesc = VHT_DATA_SC_40_LOWER_OF_80MHZ; + else if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) + SCSettingOfDesc = VHT_DATA_SC_40_UPPER_OF_80MHZ; + else + DBG_871X("SCMapping: Not Correct Primary40MHz Setting\n"); -+ } -+ else -+ { ++ } else { + if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) + SCSettingOfDesc = VHT_DATA_SC_20_LOWEST_OF_80MHZ; + else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) @@ -69851,33 +67951,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + else + DBG_871X("SCMapping: Not Correct Primary40MHz Setting\n"); + } -+ } -+ else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) -+ { ++ } else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) { + /* DBG_871X("SCMapping: HT Case: pHalData->CurrentChannelBW %d, pHalData->nCur40MhzPrimeSC %d\n", pHalData->CurrentChannelBW, pHalData->nCur40MhzPrimeSC); */ + -+ if (pattrib->bwmode == CHANNEL_WIDTH_40) -+ { ++ if (pattrib->bwmode == CHANNEL_WIDTH_40) { + SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE; -+ } -+ else if (pattrib->bwmode == CHANNEL_WIDTH_20) -+ { -+ if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) -+ { ++ } else if (pattrib->bwmode == CHANNEL_WIDTH_20) { ++ if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) { + SCSettingOfDesc = VHT_DATA_SC_20_UPPER_OF_80MHZ; -+ } -+ else if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) -+ { ++ } else if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) { + SCSettingOfDesc = VHT_DATA_SC_20_LOWER_OF_80MHZ; -+ } -+ else -+ { ++ } else { + SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE; + } + } -+ } -+ else -+ { ++ } else { + SCSettingOfDesc = VHT_DATA_SC_DONOT_CARE; + } + @@ -69886,7 +67974,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + +static void rtl8723b_cal_txdesc_chksum(struct tx_desc *ptxdesc) +{ -+ u16 *usPtr = (u16*)ptxdesc; ++ u16 *usPtr = (u16 *)ptxdesc; + u32 count; + u32 index; + u16 checksum = 0; @@ -69910,25 +67998,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +static u8 fill_txdesc_sectype(struct pkt_attrib *pattrib) +{ + u8 sectype = 0; -+ if ((pattrib->encrypt > 0) && !pattrib->bswenc) -+ { -+ switch (pattrib->encrypt) -+ { -+ /* SEC_TYPE */ -+ case _WEP40_: -+ case _WEP104_: -+ case _TKIP_: -+ case _TKIP_WTMIC_: -+ sectype = 1; -+ break; ++ if ((pattrib->encrypt > 0) && !pattrib->bswenc) { ++ switch (pattrib->encrypt) { ++ /* SEC_TYPE */ ++ case _WEP40_: ++ case _WEP104_: ++ case _TKIP_: ++ case _TKIP_WTMIC_: ++ sectype = 1; ++ break; + -+ case _AES_: -+ sectype = 3; -+ break; ++ case _AES_: ++ sectype = 3; ++ break; + -+ case _NO_PRIVACY_: -+ default: -+ break; ++ case _NO_PRIVACY_: ++ default: ++ break; + } + } + return sectype; @@ -69938,23 +68024,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +{ + /* DBG_8192C("cvs_mode =%d\n", pattrib->vcs_mode); */ + -+ if (pattrib->vcs_mode) -+ { -+ switch (pattrib->vcs_mode) -+ { -+ case RTS_CTS: -+ ptxdesc->rtsen = 1; -+ /* ENABLE HW RTS */ -+ ptxdesc->hw_rts_en = 1; -+ break; ++ if (pattrib->vcs_mode) { ++ switch (pattrib->vcs_mode) { ++ case RTS_CTS: ++ ptxdesc->rtsen = 1; ++ /* ENABLE HW RTS */ ++ ptxdesc->hw_rts_en = 1; ++ break; + -+ case CTS_TO_SELF: -+ ptxdesc->cts2self = 1; -+ break; ++ case CTS_TO_SELF: ++ ptxdesc->cts2self = 1; ++ break; + -+ case NONE_VCS: -+ default: -+ break; ++ case NONE_VCS: ++ default: ++ break; + } + + ptxdesc->rtsrate = 8; /* RTS Rate =24M */ @@ -69965,9 +68049,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + /* Set RTS BW */ + if (pattrib->ht_en) -+ { + ptxdesc->rts_sc = SCMapping_8723B(padapter, pattrib); -+ } + } +} + @@ -69975,8 +68057,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +{ + /* DBG_8192C("bwmode =%d, ch_off =%d\n", pattrib->bwmode, pattrib->ch_offset); */ + -+ if (pattrib->ht_en) -+ { ++ if (pattrib->ht_en) { + ptxdesc->data_bw = BWMapping_8723B(padapter, pattrib); + + ptxdesc->data_sc = SCMapping_8723B(padapter, pattrib); @@ -69984,8 +68065,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +} + +static void rtl8723b_fill_default_txdesc( -+ struct xmit_frame *pxmitframe, -+ u8 *pbuf) ++ struct xmit_frame *pxmitframe, u8 *pbuf ++) +{ + struct adapter *padapter; + struct hal_com_data *pHalData; @@ -70009,8 +68090,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + ptxdesc = (PTXDESC_8723B)pbuf; + -+ if (pxmitframe->frame_tag == DATA_FRAMETAG) -+ { ++ if (pxmitframe->frame_tag == DATA_FRAMETAG) { + u8 drv_userate = 0; + + ptxdesc->macid = pattrib->mac_id; /* CAM_ID(MAC_ID) */ @@ -70024,33 +68104,30 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + if (pattrib->icmp_pkt == 1 && padapter->registrypriv.wifi_spec == 1) + drv_userate = 1; + -+ if ((pattrib->ether_type != 0x888e) && ++ if ( ++ (pattrib->ether_type != 0x888e) && + (pattrib->ether_type != 0x0806) && + (pattrib->ether_type != 0x88B4) && + (pattrib->dhcp_pkt != 1) && + (drv_userate != 1) +#ifdef CONFIG_AUTO_AP_MODE -+ && (pattrib->pctrl != true) ++ && (pattrib->pctrl != true) +#endif -+ ) -+ { ++ ) { + /* Non EAP & ARP & DHCP type data packet */ + -+ if (pattrib->ampdu_en == true) -+ { ++ if (pattrib->ampdu_en == true) { + ptxdesc->agg_en = 1; /* AGG EN */ + ptxdesc->max_agg_num = 0x1f; + ptxdesc->ampdu_density = pattrib->ampdu_spacing; -+ } -+ else ++ } else + ptxdesc->bk = 1; /* AGG BK */ + + fill_txdesc_phy_8723b(padapter, pattrib, ptxdesc); + + ptxdesc->data_ratefb_lmt = 0x1F; + -+ if (pHalData->fw_ractrl == false) -+ { ++ if (pHalData->fw_ractrl == false) { + ptxdesc->userate = 1; + + if (pHalData->dmpriv.INIDATA_RATE[pattrib->mac_id] & BIT(7)) @@ -70076,9 +68153,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +#ifdef CONFIG_CMCC_TEST + ptxdesc->data_short = 1; /* use cck short premble */ +#endif -+ } -+ else -+ { ++ } else { + /* EAP data packet and ARP packet. */ + /* Use the 1M data rate to send the EAP/ARP packet. */ + /* This will maybe make the handshake smooth. */ @@ -70092,9 +68167,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } + + ptxdesc->usb_txagg_num = pxmitframe->agg_num; -+ } -+ else if (pxmitframe->frame_tag == MGNT_FRAMETAG) -+ { ++ } else if (pxmitframe->frame_tag == MGNT_FRAMETAG) { +/* RT_TRACE(_module_hal_xmit_c_, _drv_notice_, ("%s: MGNT_FRAMETAG\n", __func__)); */ + + ptxdesc->macid = pattrib->mac_id; /* CAM_ID(MAC_ID) */ @@ -70122,13 +68195,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + ptxdesc->spe_rpt = 1; + ptxdesc->sw_define = (u8)(GET_PRIMARY_ADAPTER(padapter)->xmitpriv.seq_no); + } -+ } -+ else if (pxmitframe->frame_tag == TXAGG_FRAMETAG) -+ { ++ } else if (pxmitframe->frame_tag == TXAGG_FRAMETAG) { + RT_TRACE(_module_hal_xmit_c_, _drv_warning_, ("%s: TXAGG_FRAMETAG\n", __func__)); -+ } -+ else -+ { ++ } else { + RT_TRACE(_module_hal_xmit_c_, _drv_warning_, ("%s: frame_tag = 0x%x\n", __func__, pxmitframe->frame_tag)); + + ptxdesc->macid = pattrib->mac_id; /* CAM_ID(MAC_ID) */ @@ -70142,7 +68211,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + ptxdesc->pktlen = pattrib->last_txcmdsz; + ptxdesc->offset = TXDESC_SIZE + OFFSET_SZ; + -+ if (bmcst) ptxdesc->bmc = 1; ++ if (bmcst) ++ ptxdesc->bmc = 1; + + /* 2009.11.05. tynli_test. Suggested by SD4 Filen for FW LPS. */ + /* (1) The sequence number of each non-Qos frame / broadcast / multicast / */ @@ -70152,11 +68222,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* (2) Enable HW SEQ control for beacon packet, because we use Hw beacon. */ + /* (3) Use HW Qos SEQ to control the seq num of Ext port non-Qos packets. */ + /* 2010.06.23. Added by tynli. */ -+ if (!pattrib->qos_en) -+ { -+ /* Hw set sequence number */ ++ if (!pattrib->qos_en) /* Hw set sequence number */ + ptxdesc->en_hwseq = 1; /* HWSEQ_EN */ -+ } +} + +/* @@ -70172,7 +68239,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + rtl8723b_fill_default_txdesc(pxmitframe, pbuf); + -+ pdesc = (struct tx_desc*)pbuf; ++ pdesc = (struct tx_desc *)pbuf; + pdesc->txdw0 = pdesc->txdw0; + pdesc->txdw1 = pdesc->txdw1; + pdesc->txdw2 = pdesc->txdw2; @@ -70196,11 +68263,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +/* type1:pspoll, type2:null */ +void rtl8723b_fill_fake_txdesc( + struct adapter *padapter, -+ u8* pDesc, -+ u32 BufferLen, -+ u8 IsPsPoll, -+ u8 IsBTQosNull, -+ u8 bDataFrame) ++ u8 *pDesc, ++ u32 BufferLen, ++ u8 IsPsPoll, ++ u8 IsBTQosNull, ++ u8 bDataFrame ++) +{ + /* Clear all status */ + memset(pDesc, 0, TXDESC_SIZE); @@ -70214,18 +68282,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + SET_TX_DESC_QUEUE_SEL_8723B(pDesc, QSLT_MGNT); /* Fixed queue of Mgnt queue */ + + /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. */ -+ if (true == IsPsPoll) -+ { ++ if (true == IsPsPoll) { + SET_TX_DESC_NAV_USE_HDR_8723B(pDesc, 1); -+ } -+ else -+ { ++ } else { + SET_TX_DESC_HWSEQ_EN_8723B(pDesc, 1); /* Hw set sequence number */ + SET_TX_DESC_HWSEQ_SEL_8723B(pDesc, 0); + } + -+ if (true ==IsBTQosNull) -+ { ++ if (true == IsBTQosNull) { + SET_TX_DESC_BT_INT_8723B(pDesc, 1); + } + @@ -70237,36 +68301,34 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* */ + /* Encrypt the data frame if under security mode excepct null data. Suggested by CCW. */ + /* */ -+ if (true ==bDataFrame) -+ { ++ if (true == bDataFrame) { + u32 EncAlg; + + EncAlg = padapter->securitypriv.dot11PrivacyAlgrthm; -+ switch (EncAlg) -+ { -+ case _NO_PRIVACY_: -+ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x0); -+ break; -+ case _WEP40_: -+ case _WEP104_: -+ case _TKIP_: -+ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x1); -+ break; -+ case _SMS4_: -+ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x2); -+ break; -+ case _AES_: -+ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x3); -+ break; -+ default: -+ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x0); -+ break; ++ switch (EncAlg) { ++ case _NO_PRIVACY_: ++ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x0); ++ break; ++ case _WEP40_: ++ case _WEP104_: ++ case _TKIP_: ++ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x1); ++ break; ++ case _SMS4_: ++ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x2); ++ break; ++ case _AES_: ++ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x3); ++ break; ++ default: ++ SET_TX_DESC_SEC_TYPE_8723B(pDesc, 0x0); ++ break; + } + } + + /* USB interface drop packet if the checksum of descriptor isn't correct. */ + /* Using this checksum can let hardware recovery from packet bulk out error (e.g. Cancel URC, Bulk out error.). */ -+ rtl8723b_cal_txdesc_chksum((struct tx_desc*)pDesc); ++ rtl8723b_cal_txdesc_chksum((struct tx_desc *)pDesc); +} + +static void hw_var_set_opmode(struct adapter *padapter, u8 variable, u8 *val) @@ -70284,8 +68346,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + Set_MSR(padapter, mode); + DBG_871X("#### %s() -%d iface_type(0) mode = %d ####\n", __func__, __LINE__, mode); + -+ if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) -+ { ++ if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) { + { + StopTxBeacon(padapter); +#ifdef CONFIG_INTERRUPT_BASED_TXBCN @@ -70295,7 +68356,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +#endif /* CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT */ + +#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR -+ UpdateInterruptMask8812AU(padapter, true , 0, (IMR_TXBCN0ERR_8723B|IMR_TXBCN0OK_8723B)); ++ UpdateInterruptMask8812AU(padapter, true, 0, (IMR_TXBCN0ERR_8723B|IMR_TXBCN0OK_8723B)); +#endif /* CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR */ + +#endif /* CONFIG_INTERRUPT_BASED_TXBCN */ @@ -70304,21 +68365,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* disable atim wnd */ + rtw_write8(padapter, REG_BCN_CTRL, DIS_TSF_UDT|EN_BCN_FUNCTION|DIS_ATIM); + /* rtw_write8(padapter, REG_BCN_CTRL, 0x18); */ -+ } -+ else if ((mode == _HW_STATE_ADHOC_) /*|| (mode == _HW_STATE_AP_)*/) -+ { ++ } else if ((mode == _HW_STATE_ADHOC_) /*|| (mode == _HW_STATE_AP_)*/) { + ResumeTxBeacon(padapter); + rtw_write8(padapter, REG_BCN_CTRL, DIS_TSF_UDT|EN_BCN_FUNCTION|DIS_BCNQ_SUB); -+ } -+ else if (mode == _HW_STATE_AP_) -+ { ++ } else if (mode == _HW_STATE_AP_) { +#ifdef CONFIG_INTERRUPT_BASED_TXBCN +#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT -+ UpdateInterruptMask8723BU(padapter, true , IMR_BCNDMAINT0_8723B, 0); ++ UpdateInterruptMask8723BU(padapter, true, IMR_BCNDMAINT0_8723B, 0); +#endif /* CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT */ + +#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR -+ UpdateInterruptMask8723BU(padapter, true , (IMR_TXBCN0ERR_8723B|IMR_TXBCN0OK_8723B), 0); ++ UpdateInterruptMask8723BU(padapter, true, (IMR_TXBCN0ERR_8723B|IMR_TXBCN0OK_8723B), 0); +#endif /* CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR */ + +#endif /* CONFIG_INTERRUPT_BASED_TXBCN */ @@ -70355,8 +68412,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + rtw_hal_set_hwreg(padapter, HW_VAR_DL_BCN_SEL, NULL); + + /* select BCN on port 0 */ -+ rtw_write8(padapter, REG_CCK_CHECK_8723B, -+ (rtw_read8(padapter, REG_CCK_CHECK_8723B)& ~BIT_BCN_PORT_SEL)); ++ rtw_write8( ++ padapter, ++ REG_CCK_CHECK_8723B, ++ (rtw_read8(padapter, REG_CCK_CHECK_8723B)&~BIT_BCN_PORT_SEL) ++ ); + + /* dis BCN1 ATIM WND if if2 is station */ + val8 = rtw_read8(padapter, REG_BCN_CTRL_1); @@ -70374,9 +68434,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + reg_macid = REG_MACID; + + for (idx = 0 ; idx < 6; idx++) -+ { + rtw_write8(GET_PRIMARY_ADAPTER(padapter), (reg_macid+idx), val[idx]); -+ } +} + +static void hw_var_set_bssid(struct adapter *padapter, u8 variable, u8 *val) @@ -70387,9 +68445,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + reg_bssid = REG_BSSID; + + for (idx = 0 ; idx < 6; idx++) -+ { + rtw_write8(padapter, (reg_bssid+idx), val[idx]); -+ } +} + +static void hw_var_set_bcn_func(struct adapter *padapter, u8 variable, u8 *val) @@ -70399,11 +68455,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + bcn_ctrl_reg = REG_BCN_CTRL; + + if (*(u8 *)val) -+ { + rtw_write8(padapter, bcn_ctrl_reg, (EN_BCN_FUNCTION | EN_TXBCN_RPT)); -+ } -+ else -+ { ++ else { + u8 val8; + val8 = rtw_read8(padapter, bcn_ctrl_reg); + val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT); @@ -70419,7 +68472,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +static void hw_var_set_correct_tsf(struct adapter *padapter, u8 variable, u8 *val) +{ + u8 val8; -+ u64 tsf; ++ u64 tsf; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; + @@ -70427,13 +68480,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pmlmeext = &padapter->mlmeextpriv; + pmlmeinfo = &pmlmeext->mlmext_info; + -+ tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) -1024; /* us */ ++ tsf = pmlmeext->TSFValue-rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024))-1024; /* us */ + -+ if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || -+ ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) -+ { ++ if ( ++ ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ++ ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) ++ ) + StopTxBeacon(padapter); -+ } + + { + /* disable related TSF function */ @@ -70450,11 +68503,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + rtw_write8(padapter, REG_BCN_CTRL, val8); + } + -+ if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) -+ || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) -+ { ++ if ( ++ ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ++ ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) ++ ) + ResumeTxBeacon(padapter); -+ } +} + +static void hw_var_set_mlme_disconnect(struct adapter *padapter, u8 variable, u8 *val) @@ -70495,21 +68548,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + value_rxfltmap2 = 0; + + if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)) -+ { + rcr_clear_bit = RCR_CBSSID_BCN; -+ } ++ + value_rcr = rtw_read32(padapter, REG_RCR); + -+ if (*((u8 *)val)) -+ { ++ if (*((u8 *)val)) { + /* under sitesurvey */ + value_rcr &= ~(rcr_clear_bit); + rtw_write32(padapter, REG_RCR, value_rcr); + + rtw_write16(padapter, REG_RXFLTMAP2, value_rxfltmap2); + -+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { + /* disable update TSF */ + val8 = rtw_read8(padapter, reg_bcn_ctl); + val8 |= DIS_TSF_UDT; @@ -70518,18 +68568,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + /* Save orignal RRSR setting. */ + pHalData->RegRRSR = rtw_read16(padapter, REG_RRSR); -+ } -+ else -+ { ++ } else { + /* sitesurvey done */ + if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) -+ { + /* enable to rx data frame */ + rtw_write16(padapter, REG_RXFLTMAP2, 0xFFFF); -+ } + -+ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) -+ { ++ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { + /* enable update TSF */ + val8 = rtw_read8(padapter, reg_bcn_ctl); + val8 &= ~DIS_TSF_UDT; @@ -70562,8 +68607,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pmlmepriv = &padapter->mlmepriv; + pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + -+ if (type == 0) /* prepare to join */ -+ { ++ if (type == 0) { /* prepare to join */ + /* enable to rx data frame.Accept all data frame */ + /* rtw_write32(padapter, REG_RCR, rtw_read32(padapter, REG_RCR)|RCR_ADF); */ + rtw_write16(padapter, REG_RXFLTMAP2, 0xFFFF); @@ -70576,29 +68620,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + rtw_write32(padapter, REG_RCR, val32); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) -+ { + RetryLimit = (pEEPROM->CustomerID == RT_CID_CCX) ? 7 : 48; -+ } + else /* Ad-hoc Mode */ -+ { + RetryLimit = 0x7; -+ } -+ } -+ else if (type == 1) /* joinbss_event call back when join res < 0 */ -+ { ++ } else if (type == 1) /* joinbss_event call back when join res < 0 */ + rtw_write16(padapter, REG_RXFLTMAP2, 0x00); -+ } -+ else if (type == 2) /* sta add event call back */ -+ { ++ else if (type == 2) { /* sta add event call back */ + /* enable update TSF */ + val8 = rtw_read8(padapter, REG_BCN_CTRL); + val8 &= ~DIS_TSF_UDT; + rtw_write8(padapter, REG_BCN_CTRL, val8); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) -+ { + RetryLimit = 0x7; -+ } + } + + val16 = (RetryLimit << RETRY_LIMIT_SHORT_SHIFT) | (RetryLimit << RETRY_LIMIT_LONG_SHIFT); @@ -70626,9 +68660,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_CCX_PKT_FAIL); + } +*/ -+ else { ++ else + rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_SUCCESS); -+ } +} + +s32 c2h_id_filter_ccx_8723b(u8 *buf) @@ -70654,38 +68687,36 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + goto exit; + } + -+ switch (pC2hEvent->id) -+ { -+ case C2H_AP_RPT_RSP: -+ break; -+ case C2H_DBG: -+ { -+ RT_TRACE(_module_hal_init_c_, _drv_info_, ("c2h_handler_8723b: %s\n", pC2hEvent->payload)); -+ } -+ break; ++ switch (pC2hEvent->id) { ++ case C2H_AP_RPT_RSP: ++ break; ++ case C2H_DBG: ++ { ++ RT_TRACE(_module_hal_init_c_, _drv_info_, ("c2h_handler_8723b: %s\n", pC2hEvent->payload)); ++ } ++ break; + -+ case C2H_CCX_TX_RPT: ++ case C2H_CCX_TX_RPT: +/* CCX_FwC2HTxRpt(padapter, QueueID, pC2hEvent->payload); */ -+ break; ++ break; + -+ case C2H_EXT_RA_RPT: ++ case C2H_EXT_RA_RPT: +/* C2HExtRaRptHandler(padapter, pC2hEvent->payload, C2hEvent.CmdLen); */ -+ break; ++ break; + -+ case C2H_HW_INFO_EXCH: -+ RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], C2H_HW_INFO_EXCH\n")); -+ for (index = 0; index < pC2hEvent->plen; index++) -+ { -+ RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], tmpBuf[%d]= 0x%x\n", index, pC2hEvent->payload[index])); -+ } -+ break; ++ case C2H_HW_INFO_EXCH: ++ RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], C2H_HW_INFO_EXCH\n")); ++ for (index = 0; index < pC2hEvent->plen; index++) { ++ RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], tmpBuf[%d]= 0x%x\n", index, pC2hEvent->payload[index])); ++ } ++ break; + -+ case C2H_8723B_BT_INFO: -+ rtw_btcoex_BtInfoNotify(padapter, pC2hEvent->plen, pC2hEvent->payload); -+ break; ++ case C2H_8723B_BT_INFO: ++ rtw_btcoex_BtInfoNotify(padapter, pC2hEvent->plen, pC2hEvent->payload); ++ break; + -+ default: -+ break; ++ default: ++ break; + } + + /* Clear event to notify FW we have read the command. */ @@ -70698,45 +68729,43 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + +static void process_c2h_event(struct adapter *padapter, PC2H_EVT_HDR pC2hEvent, u8 *c2hBuf) +{ -+ u8 index = 0; ++ u8 index = 0; + + if (c2hBuf == NULL) { + DBG_8192C("%s c2hbuff is NULL\n", __func__); + return; + } + -+ switch (pC2hEvent->CmdID) -+ { -+ case C2H_AP_RPT_RSP: -+ break; -+ case C2H_DBG: -+ { -+ RT_TRACE(_module_hal_init_c_, _drv_info_, ("C2HCommandHandler: %s\n", c2hBuf)); -+ } -+ break; ++ switch (pC2hEvent->CmdID) { ++ case C2H_AP_RPT_RSP: ++ break; ++ case C2H_DBG: ++ { ++ RT_TRACE(_module_hal_init_c_, _drv_info_, ("C2HCommandHandler: %s\n", c2hBuf)); ++ } ++ break; + -+ case C2H_CCX_TX_RPT: ++ case C2H_CCX_TX_RPT: +/* CCX_FwC2HTxRpt(padapter, QueueID, tmpBuf); */ -+ break; ++ break; + -+ case C2H_EXT_RA_RPT: ++ case C2H_EXT_RA_RPT: +/* C2HExtRaRptHandler(padapter, tmpBuf, C2hEvent.CmdLen); */ -+ break; ++ break; + -+ case C2H_HW_INFO_EXCH: -+ RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], C2H_HW_INFO_EXCH\n")); -+ for (index = 0; index < pC2hEvent->CmdLen; index++) -+ { -+ RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], tmpBuf[%d]= 0x%x\n", index, c2hBuf[index])); -+ } -+ break; ++ case C2H_HW_INFO_EXCH: ++ RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], C2H_HW_INFO_EXCH\n")); ++ for (index = 0; index < pC2hEvent->CmdLen; index++) { ++ RT_TRACE(_module_hal_init_c_, _drv_info_, ("[BT], tmpBuf[%d]= 0x%x\n", index, c2hBuf[index])); ++ } ++ break; + -+ case C2H_8723B_BT_INFO: -+ rtw_btcoex_BtInfoNotify(padapter, pC2hEvent->CmdLen, c2hBuf); -+ break; ++ case C2H_8723B_BT_INFO: ++ rtw_btcoex_BtInfoNotify(padapter, pC2hEvent->CmdLen, c2hBuf); ++ break; + -+ default: -+ break; ++ default: ++ break; + } +} + @@ -70747,22 +68776,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 +#ifdef CONFIG_WOWLAN + struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); + -+ if (pwrpriv->wowlan_mode == true) -+ { ++ if (pwrpriv->wowlan_mode == true) { + DBG_871X("%s(): return because wowolan_mode ==true! CMDID =%d\n", __func__, pbuffer[0]); + return; + } +#endif + C2hEvent.CmdID = pbuffer[0]; + C2hEvent.CmdSeq = pbuffer[1]; -+ C2hEvent.CmdLen = length -2; ++ C2hEvent.CmdLen = length-2; + tmpBuf = pbuffer+2; + + /* DBG_871X("%s C2hEvent.CmdID:%x C2hEvent.CmdLen:%x C2hEvent.CmdSeq:%x\n", */ + /* __func__, C2hEvent.CmdID, C2hEvent.CmdLen, C2hEvent.CmdSeq); */ + RT_PRINT_DATA(_module_hal_init_c_, _drv_notice_, "C2HPacketHandler_8723B(): Command Content:\n", tmpBuf, C2hEvent.CmdLen); + -+ process_c2h_event(padapter,&C2hEvent, tmpBuf); ++ process_c2h_event(padapter, &C2hEvent, tmpBuf); + /* c2h_handler_8723b(padapter,&C2hEvent); */ + return; +} @@ -70873,20 +68901,19 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + case HW_VAR_MLME_JOIN: + hw_var_set_mlme_join(padapter, variable, val); + -+ switch (*val) -+ { -+ case 0: -+ /* prepare to join */ -+ rtw_btcoex_ConnectNotify(padapter, true); -+ break; -+ case 1: -+ /* joinbss_event callback when join res < 0 */ -+ rtw_btcoex_ConnectNotify(padapter, false); -+ break; -+ case 2: -+ /* sta add event callback */ ++ switch (*val) { ++ case 0: ++ /* prepare to join */ ++ rtw_btcoex_ConnectNotify(padapter, true); ++ break; ++ case 1: ++ /* joinbss_event callback when join res < 0 */ ++ rtw_btcoex_ConnectNotify(padapter, false); ++ break; ++ case 2: ++ /* sta add event callback */ +/* rtw_btcoex_MediaStatusNotify(padapter, RT_MEDIA_CONNECT); */ -+ break; ++ break; + } + break; + @@ -70905,7 +68932,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + break; + + case HW_VAR_BEACON_INTERVAL: -+ rtw_write16(padapter, REG_BCN_INTERVAL, *((u16*)val)); ++ rtw_write16(padapter, REG_BCN_INTERVAL, *((u16 *)val)); + break; + + case HW_VAR_SLOT_TIME: @@ -70930,7 +68957,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */ + /* regTmp = (pHalData->nCur40MhzPrimeSC)<<5; */ + regTmp = 0; -+ if (bShortPreamble) regTmp |= 0x80; ++ if (bShortPreamble) ++ regTmp |= 0x80; + rtw_write8(padapter, REG_RRSR+2, regTmp); + } + break; @@ -70943,18 +68971,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + u32 ulContent = 0; + u32 ulEncAlgo = CAM_AES; + -+ for (i = 0; iAcParam_BE = ((u32*)(val))[0]; -+ rtw_write32(padapter, REG_EDCA_BE_PARAM, *((u32*)val)); ++ pHalData->AcParam_BE = ((u32 *)(val))[0]; ++ rtw_write32(padapter, REG_EDCA_BE_PARAM, *((u32 *)val)); + break; + + case HW_VAR_AC_PARAM_BK: -+ rtw_write32(padapter, REG_EDCA_BK_PARAM, *((u32*)val)); ++ rtw_write32(padapter, REG_EDCA_BK_PARAM, *((u32 *)val)); + break; + + case HW_VAR_ACM_CTRL: @@ -71005,8 +69029,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + u8 ctrl = *((u8 *)val); + u8 hwctrl = 0; + -+ if (ctrl != 0) -+ { ++ if (ctrl != 0) { + hwctrl |= AcmHw_HwEn; + + if (ctrl & BIT(1)) /* BE */ @@ -71029,7 +69052,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + u32 AMPDULen = (*((u8 *)val)); + + if (AMPDULen < HT_AGG_SIZE_32K) -+ AMPDULen = (0x2000 << (*((u8 *)val))) -1; ++ AMPDULen = (0x2000 << (*((u8 *)val)))-1; + else + AMPDULen = 0x7fff; + @@ -71043,8 +69066,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + /* Forece leave RF low power mode for 1T1R to prevent conficting setting in Fw power */ + /* saving sequence. 2010.06.07. Added by tynli. Suggested by SD3 yschang. */ -+ if (psmode != PS_MODE_ACTIVE) -+ { ++ if (psmode != PS_MODE_ACTIVE) { + ODM_RF_Saving(&pHalData->odmpriv, true); + } + @@ -71067,7 +69089,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + case HW_VAR_INITIAL_GAIN: + { + DIG_T *pDigTable = &pHalData->odmpriv.DM_DigTable; -+ u32 rx_gain = *(u32*)val; ++ u32 rx_gain = *(u32 *)val; + + if (rx_gain == 0xff) {/* restore rx gain */ + ODM_Write_DIG(&pHalData->odmpriv, pDigTable->BackupIGValue); @@ -71083,7 +69105,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + break; + + case HW_VAR_EFUSE_BYTES: -+ pHalData->EfuseUsedBytes = *((u16*)val); ++ pHalData->EfuseUsedBytes = *((u16 *)val); + break; + + case HW_VAR_EFUSE_BT_USAGE: @@ -71094,9 +69116,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + case HW_VAR_EFUSE_BT_BYTES: +#ifdef HAL_EFUSE_MEMORY -+ pHalData->EfuseHal.BTEfuseUsedBytes = *((u16*)val); ++ pHalData->EfuseHal.BTEfuseUsedBytes = *((u16 *)val); +#else -+ BTEfuseUsedBytes = *((u16*)val); ++ BTEfuseUsedBytes = *((u16 *)val); +#endif + break; + @@ -71114,8 +69136,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* keep sn */ + padapter->xmitpriv.nqos_ssn = rtw_read16(padapter, REG_NQOS_SEQ); + -+ if (pwrpriv->bkeepfwalive != true) -+ { ++ if (pwrpriv->bkeepfwalive != true) { + /* RX DMA stop */ + val32 = rtw_read32(padapter, REG_RXPKT_NUM); + val32 |= RW_RELEASE_EN; @@ -71128,6 +69149,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + DBG_871X("%s: [HW_VAR_FIFO_CLEARN_UP] val =%x times:%d\n", __func__, val32, trycnt); + } while (--trycnt); ++ + if (trycnt == 0) { + DBG_8192C("[HW_VAR_FIFO_CLEARN_UP] Stop RX DMA failed......\n"); + } @@ -71147,10 +69169,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + case HW_VAR_NAV_UPPER: + { -+ u32 usNavUpper = *((u32*)val); ++ u32 usNavUpper = *((u32 *)val); + -+ if (usNavUpper > HAL_NAV_UPPER_UNIT_8723B * 0xFF) -+ { ++ if (usNavUpper > HAL_NAV_UPPER_UNIT_8723B * 0xFF) { + RT_TRACE(_module_hal_init_c_, _drv_notice_, ("The setting value (0x%08X us) of NAV_UPPER is larger than (%d * 0xFF)!!!\n", usNavUpper, HAL_NAV_UPPER_UNIT_8723B)); + break; + } @@ -71168,8 +69189,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + u8 mstatus, macId; + + mstatus = (u8) (mstatus_rpt & 0xFF); -+ macId = (u8)(mstatus_rpt >> 8) ; -+ rtl8723b_set_FwMediaStatusRpt_cmd(padapter , mstatus, macId); ++ macId = (u8)(mstatus_rpt >> 8); ++ rtl8723b_set_FwMediaStatusRpt_cmd(padapter, mstatus, macId); + } + break; + case HW_VAR_BCN_VALID: @@ -71196,18 +69217,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + case HW_VAR_DL_RSVD_PAGE: + if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true) -+ { + rtl8723b_download_BTCoex_AP_mode_rsvd_page(padapter); -+ } + else -+ { + rtl8723b_download_rsvd_page(padapter, RT_MEDIA_CONNECT); -+ } + break; + + case HW_VAR_MACID_SLEEP: + /* Input is MACID */ -+ val32 = *(u32*)val; ++ val32 = *(u32 *)val; + if (val32 > 31) { + DBG_8192C(FUNC_ADPT_FMT ": [HW_VAR_MACID_SLEEP] Invalid macid(%d)\n", + FUNC_ADPT_ARG(padapter), val32); @@ -71226,7 +69243,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + case HW_VAR_MACID_WAKEUP: + /* Input is MACID */ -+ val32 = *(u32*)val; ++ val32 = *(u32 *)val; + if (val32 > 31) { + DBG_8192C(FUNC_ADPT_FMT ": [HW_VAR_MACID_WAKEUP] Invalid macid(%d)\n", + FUNC_ADPT_ARG(padapter), val32); @@ -71264,7 +69281,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + { + /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ + val8 = rtw_read8(padapter, REG_TDECTRL+2); -+ *val = (BIT(0) & val8) ? true:false; ++ *val = (BIT(0) & val8) ? true : false; + } + break; + @@ -71273,15 +69290,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + /* When we halt NIC, we should check if FW LPS is leave. */ + u32 valRCR; + -+ if ((padapter->bSurpriseRemoved == true) || -+ (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off)) -+ { ++ if ( ++ (padapter->bSurpriseRemoved == true) || ++ (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off) ++ ) { + /* If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */ + /* because Fw is unload. */ + *val = true; -+ } -+ else -+ { ++ } else { + valRCR = rtw_read32(padapter, REG_RCR); + valRCR &= 0x00070000; + if (valRCR) @@ -71297,7 +69313,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + break; + + case HW_VAR_EFUSE_BYTES: -+ *((u16*)val) = pHalData->EfuseUsedBytes; ++ *((u16 *)val) = pHalData->EfuseUsedBytes; + break; + + case HW_VAR_EFUSE_BT_USAGE: @@ -71308,9 +69324,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + + case HW_VAR_EFUSE_BT_BYTES: +#ifdef HAL_EFUSE_MEMORY -+ *((u16*)val) = pHalData->EfuseHal.BTEfuseUsedBytes; ++ *((u16 *)val) = pHalData->EfuseHal.BTEfuseUsedBytes; +#else -+ *((u16*)val) = BTEfuseUsedBytes; ++ *((u16 *)val) = BTEfuseUsedBytes; +#endif + break; + @@ -71353,11 +69369,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pHalData = GET_HAL_DATA(padapter); + bResult = _SUCCESS; + -+ switch (variable) -+ { -+ default: -+ bResult = SetHalDefVar(padapter, variable, pval); -+ break; ++ switch (variable) { ++ default: ++ bResult = SetHalDefVar(padapter, variable, pval); ++ break; + } + + return bResult; @@ -71376,106 +69391,102 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + pHalData = GET_HAL_DATA(padapter); + bResult = _SUCCESS; + -+ switch (variable) -+ { -+ case HAL_DEF_MAX_RECVBUF_SZ: -+ *((u32*)pval) = MAX_RECVBUF_SZ; -+ break; ++ switch (variable) { ++ case HAL_DEF_MAX_RECVBUF_SZ: ++ *((u32 *)pval) = MAX_RECVBUF_SZ; ++ break; + -+ case HAL_DEF_RX_PACKET_OFFSET: -+ *((u32*)pval) = RXDESC_SIZE + DRVINFO_SZ*8; -+ break; ++ case HAL_DEF_RX_PACKET_OFFSET: ++ *((u32 *)pval) = RXDESC_SIZE + DRVINFO_SZ*8; ++ break; + -+ case HW_VAR_MAX_RX_AMPDU_FACTOR: -+ /* Stanley@BB.SD3 suggests 16K can get stable performance */ -+ /* The experiment was done on SDIO interface */ -+ /* coding by Lucas@20130730 */ -+ *(u32*)pval = MAX_AMPDU_FACTOR_16K; -+ break; -+ case HAL_DEF_TX_LDPC: -+ case HAL_DEF_RX_LDPC: -+ *((u8 *)pval) = false; -+ break; -+ case HAL_DEF_TX_STBC: -+ *((u8 *)pval) = 0; -+ break; -+ case HAL_DEF_RX_STBC: -+ *((u8 *)pval) = 1; -+ break; -+ case HAL_DEF_EXPLICIT_BEAMFORMER: -+ case HAL_DEF_EXPLICIT_BEAMFORMEE: -+ *((u8 *)pval) = false; -+ break; ++ case HW_VAR_MAX_RX_AMPDU_FACTOR: ++ /* Stanley@BB.SD3 suggests 16K can get stable performance */ ++ /* The experiment was done on SDIO interface */ ++ /* coding by Lucas@20130730 */ ++ *(u32 *)pval = MAX_AMPDU_FACTOR_16K; ++ break; ++ case HAL_DEF_TX_LDPC: ++ case HAL_DEF_RX_LDPC: ++ *((u8 *)pval) = false; ++ break; ++ case HAL_DEF_TX_STBC: ++ *((u8 *)pval) = 0; ++ break; ++ case HAL_DEF_RX_STBC: ++ *((u8 *)pval) = 1; ++ break; ++ case HAL_DEF_EXPLICIT_BEAMFORMER: ++ case HAL_DEF_EXPLICIT_BEAMFORMEE: ++ *((u8 *)pval) = false; ++ break; + -+ case HW_DEF_RA_INFO_DUMP: -+ { -+ u8 mac_id = *(u8 *)pval; -+ u32 cmd; -+ u32 ra_info1, ra_info2; -+ u32 rate_mask1, rate_mask2; -+ u8 curr_tx_rate, curr_tx_sgi, hight_rate, lowest_rate; ++ case HW_DEF_RA_INFO_DUMP: ++ { ++ u8 mac_id = *(u8 *)pval; ++ u32 cmd; ++ u32 ra_info1, ra_info2; ++ u32 rate_mask1, rate_mask2; ++ u8 curr_tx_rate, curr_tx_sgi, hight_rate, lowest_rate; + -+ DBG_8192C("============ RA status check Mac_id:%d ===================\n", mac_id); ++ DBG_8192C("============ RA status check Mac_id:%d ===================\n", mac_id); + -+ cmd = 0x40000100 | mac_id; -+ rtw_write32(padapter, REG_HMEBOX_DBG_2_8723B, cmd); -+ msleep(10); -+ ra_info1 = rtw_read32(padapter, 0x2F0); -+ curr_tx_rate = ra_info1&0x7F; -+ curr_tx_sgi = (ra_info1>>7)&0x01; -+ DBG_8192C("[ ra_info1:0x%08x ] =>cur_tx_rate = %s, cur_sgi:%d, PWRSTS = 0x%02x \n", -+ ra_info1, -+ HDATA_RATE(curr_tx_rate), -+ curr_tx_sgi, -+ (ra_info1>>8) & 0x07); ++ cmd = 0x40000100 | mac_id; ++ rtw_write32(padapter, REG_HMEBOX_DBG_2_8723B, cmd); ++ msleep(10); ++ ra_info1 = rtw_read32(padapter, 0x2F0); ++ curr_tx_rate = ra_info1&0x7F; ++ curr_tx_sgi = (ra_info1>>7)&0x01; ++ DBG_8192C("[ ra_info1:0x%08x ] =>cur_tx_rate = %s, cur_sgi:%d, PWRSTS = 0x%02x \n", ++ ra_info1, ++ HDATA_RATE(curr_tx_rate), ++ curr_tx_sgi, ++ (ra_info1>>8) & 0x07); + -+ cmd = 0x40000400 | mac_id; -+ rtw_write32(padapter, REG_HMEBOX_DBG_2_8723B, cmd); -+ msleep(10); -+ ra_info1 = rtw_read32(padapter, 0x2F0); -+ ra_info2 = rtw_read32(padapter, 0x2F4); -+ rate_mask1 = rtw_read32(padapter, 0x2F8); -+ rate_mask2 = rtw_read32(padapter, 0x2FC); -+ hight_rate = ra_info2&0xFF; -+ lowest_rate = (ra_info2>>8) & 0xFF; ++ cmd = 0x40000400 | mac_id; ++ rtw_write32(padapter, REG_HMEBOX_DBG_2_8723B, cmd); ++ msleep(10); ++ ra_info1 = rtw_read32(padapter, 0x2F0); ++ ra_info2 = rtw_read32(padapter, 0x2F4); ++ rate_mask1 = rtw_read32(padapter, 0x2F8); ++ rate_mask2 = rtw_read32(padapter, 0x2FC); ++ hight_rate = ra_info2&0xFF; ++ lowest_rate = (ra_info2>>8) & 0xFF; + -+ DBG_8192C("[ ra_info1:0x%08x ] =>RSSI =%d, BW_setting = 0x%02x, DISRA = 0x%02x, VHT_EN = 0x%02x\n", -+ ra_info1, -+ ra_info1&0xFF, -+ (ra_info1>>8) & 0xFF, -+ (ra_info1>>16) & 0xFF, -+ (ra_info1>>24) & 0xFF); ++ DBG_8192C("[ ra_info1:0x%08x ] =>RSSI =%d, BW_setting = 0x%02x, DISRA = 0x%02x, VHT_EN = 0x%02x\n", ++ ra_info1, ++ ra_info1&0xFF, ++ (ra_info1>>8) & 0xFF, ++ (ra_info1>>16) & 0xFF, ++ (ra_info1>>24) & 0xFF); + -+ DBG_8192C("[ ra_info2:0x%08x ] =>hight_rate =%s, lowest_rate =%s, SGI = 0x%02x, RateID =%d\n", -+ ra_info2, -+ HDATA_RATE(hight_rate), -+ HDATA_RATE(lowest_rate), -+ (ra_info2>>16) & 0xFF, -+ (ra_info2>>24) & 0xFF); ++ DBG_8192C("[ ra_info2:0x%08x ] =>hight_rate =%s, lowest_rate =%s, SGI = 0x%02x, RateID =%d\n", ++ ra_info2, ++ HDATA_RATE(hight_rate), ++ HDATA_RATE(lowest_rate), ++ (ra_info2>>16) & 0xFF, ++ (ra_info2>>24) & 0xFF); + -+ DBG_8192C("rate_mask2 = 0x%08x, rate_mask1 = 0x%08x\n", rate_mask2, rate_mask1); ++ DBG_8192C("rate_mask2 = 0x%08x, rate_mask1 = 0x%08x\n", rate_mask2, rate_mask1); + -+ } -+ break; ++ } ++ break; + -+ case HAL_DEF_TX_PAGE_BOUNDARY: -+ if (!padapter->registrypriv.wifi_spec) -+ { -+ *(u8 *)pval = TX_PAGE_BOUNDARY_8723B; -+ } -+ else -+ { -+ *(u8 *)pval = WMM_NORMAL_TX_PAGE_BOUNDARY_8723B; -+ } -+ break; ++ case HAL_DEF_TX_PAGE_BOUNDARY: ++ if (!padapter->registrypriv.wifi_spec) { ++ *(u8 *)pval = TX_PAGE_BOUNDARY_8723B; ++ } else { ++ *(u8 *)pval = WMM_NORMAL_TX_PAGE_BOUNDARY_8723B; ++ } ++ break; + -+ case HAL_DEF_MACID_SLEEP: -+ *(u8 *)pval = true; /* support macid sleep */ -+ break; ++ case HAL_DEF_MACID_SLEEP: ++ *(u8 *)pval = true; /* support macid sleep */ ++ break; + -+ default: -+ bResult = GetHalDefVar(padapter, variable, pval); -+ break; ++ default: ++ bResult = GetHalDefVar(padapter, variable, pval); ++ break; + } + + return bResult; @@ -71495,8 +69506,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + struct xmit_priv *xmitpriv = &padapter->xmitpriv; + + xmitpriv->SdioXmitThread = kthread_run(rtl8723bs_xmit_thread, padapter, "RTWHALXT"); -+ if (IS_ERR(xmitpriv->SdioXmitThread)) -+ { ++ if (IS_ERR(xmitpriv->SdioXmitThread)) { + RT_TRACE(_module_hal_xmit_c_, _drv_err_, ("%s: start rtl8723bs_xmit_thread FAIL!!\n", __func__)); + } +#endif @@ -71518,13 +69528,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + +#if defined(CONFIG_CHECK_BT_HANG) +extern void check_bt_status_work(void *data); -+void rtl8723bs_init_checkbthang_workqueue(struct adapter * adapter) ++void rtl8723bs_init_checkbthang_workqueue(struct adapter *adapter) +{ + adapter->priv_checkbt_wq = alloc_workqueue("sdio_wq", 0, 0); -+ INIT_DELAYED_WORK(&adapter->checkbt_work, (void*)check_bt_status_work); ++ INIT_DELAYED_WORK(&adapter->checkbt_work, (void *)check_bt_status_work); +} + -+void rtl8723bs_free_checkbthang_workqueue(struct adapter * adapter) ++void rtl8723bs_free_checkbthang_workqueue(struct adapter *adapter) +{ + if (adapter->priv_checkbt_wq) { + cancel_delayed_work_sync(&adapter->checkbt_work); @@ -71534,23 +69544,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_hal_init.c linux-4.3-rtl872 + } +} + -+void rtl8723bs_cancle_checkbthang_workqueue(struct adapter * adapter) ++void rtl8723bs_cancle_checkbthang_workqueue(struct adapter *adapter) +{ -+ if (adapter->priv_checkbt_wq) { ++ if (adapter->priv_checkbt_wq) + cancel_delayed_work_sync(&adapter->checkbt_work); -+ } +} + -+void rtl8723bs_hal_check_bt_hang(struct adapter * adapter) ++void rtl8723bs_hal_check_bt_hang(struct adapter *adapter) +{ + if (adapter->priv_checkbt_wq) + queue_delayed_work(adapter->priv_checkbt_wq, &(adapter->checkbt_work), 0); +} +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c ---- linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1070 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c +--- linux.old/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1060 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -71595,7 +69604,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b +{ + u32 i; + -+ for (i = 0; i <=31; i++) { ++ for (i = 0; i <= 31; i++) { + if (((BitMask>>i) & 0x1) == 1) + break; + } @@ -71617,12 +69626,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b +* Return: u32 Data The readback register value +* Note: This function is equal to "GetRegSetting" in PHY programming guide +*/ -+u32 -+PHY_QueryBBReg_8723B( -+struct adapter *Adapter, -+u32 RegAddr, -+u32 BitMask -+ ) ++u32 PHY_QueryBBReg_8723B(struct adapter *Adapter, u32 RegAddr, u32 BitMask) +{ + u32 ReturnValue = 0, OriginalValue, BitShift; + @@ -71636,7 +69640,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + BitShift = phy_CalculateBitShift(BitMask); + ReturnValue = (OriginalValue & BitMask) >> BitShift; + -+ return (ReturnValue); ++ return ReturnValue; + +} + @@ -71659,16 +69663,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b +* Note: This function is equal to "PutRegSetting" in PHY programming guide +*/ + -+void -+PHY_SetBBReg_8723B( -+struct adapter *Adapter, -+u32 RegAddr, -+u32 BitMask, -+u32 Data -+ ) ++void PHY_SetBBReg_8723B( ++ struct adapter *Adapter, ++ u32 RegAddr, ++ u32 BitMask, ++ u32 Data ++) +{ -+ /* u16 BBWaitCounter = 0; */ -+ u32 OriginalValue, BitShift; ++ /* u16 BBWaitCounter = 0; */ ++ u32 OriginalValue, BitShift; + +#if (DISABLE_BB_RF == 1) + return; @@ -71676,7 +69679,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + + /* RT_TRACE(COMP_RF, DBG_TRACE, ("--->PHY_SetBBReg(): RegAddr(%#lx), BitMask(%#lx), Data(%#lx)\n", RegAddr, BitMask, Data)); */ + -+ if (BitMask!= bMaskDWord) {/* if not "double word" write */ ++ if (BitMask != bMaskDWord) { /* if not "double word" write */ + OriginalValue = rtw_read32(Adapter, RegAddr); + BitShift = phy_CalculateBitShift(BitMask); + Data = ((OriginalValue & (~BitMask)) | ((Data << BitShift) & BitMask)); @@ -71691,20 +69694,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b +/* 2. RF register R/W API */ +/* */ + -+static u32 -+phy_RFSerialRead_8723B( -+struct adapter * Adapter, -+enum RF_PATH eRFPath, -+u32 Offset -+ ) ++static u32 phy_RFSerialRead_8723B( ++ struct adapter *Adapter, enum RF_PATH eRFPath, u32 Offset ++) +{ + u32 retValue = 0; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + struct bb_register_def *pPhyReg = &pHalData->PHYRegDef[eRFPath]; -+ u32 NewOffset; ++ u32 NewOffset; + u32 tmplong2; -+ u8 RfPiEnable = 0; -+ u32 MaskforPhySet = 0; ++ u8 RfPiEnable = 0; ++ u32 MaskforPhySet = 0; + int i = 0; + + /* */ @@ -71714,14 +69714,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + + NewOffset = Offset; + -+ if (eRFPath == RF_PATH_A) -+ { ++ if (eRFPath == RF_PATH_A) { + tmplong2 = PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter2|MaskforPhySet, bMaskDWord);; + tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset<<23) | bLSSIReadEdge; /* T65 RF */ + PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2|MaskforPhySet, bMaskDWord, tmplong2&(~bLSSIReadEdge)); -+ } -+ else -+ { ++ } else { + tmplong2 = PHY_QueryBBReg(Adapter, rFPGA0_XB_HSSIParameter2|MaskforPhySet, bMaskDWord); + tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset<<23) | bLSSIReadEdge; /* T65 RF */ + PHY_SetBBReg(Adapter, rFPGA0_XB_HSSIParameter2|MaskforPhySet, bMaskDWord, tmplong2&(~bLSSIReadEdge)); @@ -71733,7 +69730,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + + udelay(10); + -+ for (i = 0;i<2;i++) ++ for (i = 0; i < 2; i++) + udelay(MAX_STALL_TIME); + udelay(10); + @@ -71742,14 +69739,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + else if (eRFPath == RF_PATH_B) + RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XB_HSSIParameter1|MaskforPhySet, BIT8); + -+ if (RfPiEnable) -+ { /* Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF */ ++ if (RfPiEnable) { ++ /* Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF */ + retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBackPi|MaskforPhySet, bLSSIReadBackData); + + /* RT_DISP(FINIT, INIT_RF, ("Readback from RF-PI : 0x%x\n", retValue)); */ -+ } -+ else -+ { /* Read from BBreg8a0, 12 bits for 8190, 20 bits for T65 RF */ ++ } else { ++ /* Read from BBreg8a0, 12 bits for 8190, 20 bits for T65 RF */ + retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBack|MaskforPhySet, bLSSIReadBackData); + + /* RT_DISP(FINIT, INIT_RF, ("Readback from RF-SI : 0x%x\n", retValue)); */ @@ -71801,18 +69797,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + * + * +*/ -+static void -+phy_RFSerialWrite_8723B( -+struct adapter * Adapter, -+enum RF_PATH eRFPath, -+u32 Offset, -+u32 Data -+ ) ++static void phy_RFSerialWrite_8723B( ++ struct adapter *Adapter, ++ enum RF_PATH eRFPath, ++ u32 Offset, ++ u32 Data ++) +{ -+ u32 DataAndAddr = 0; -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ u32 DataAndAddr = 0; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + struct bb_register_def *pPhyReg = &pHalData->PHYRegDef[eRFPath]; -+ u32 NewOffset; ++ u32 NewOffset; + + Offset &= 0xff; + @@ -71852,13 +69847,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b +* Return: u32 Readback value +* Note: This function is equal to "GetRFRegSetting" in PHY programming guide +*/ -+u32 -+PHY_QueryRFReg_8723B( -+struct adapter * Adapter, -+u8 eRFPath, -+u32 RegAddr, -+u32 BitMask -+ ) ++u32 PHY_QueryRFReg_8723B( ++ struct adapter *Adapter, ++ u8 eRFPath, ++ u32 RegAddr, ++ u32 BitMask ++) +{ + u32 Original_Value, Readback_Value, BitShift; + @@ -71871,7 +69865,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + BitShift = phy_CalculateBitShift(BitMask); + Readback_Value = (Original_Value & BitMask) >> BitShift; + -+ return (Readback_Value); ++ return Readback_Value; +} + +/** @@ -71892,27 +69886,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b +* Return: None +* Note: This function is equal to "PutRFRegSetting" in PHY programming guide +*/ -+void -+PHY_SetRFReg_8723B( -+struct adapter * Adapter, -+u8 eRFPath, -+u32 RegAddr, -+u32 BitMask, -+u32 Data -+ ) ++void PHY_SetRFReg_8723B( ++ struct adapter *Adapter, ++ u8 eRFPath, ++ u32 RegAddr, ++ u32 BitMask, ++ u32 Data ++) +{ -+ u32 Original_Value, BitShift; ++ u32 Original_Value, BitShift; + +#if (DISABLE_BB_RF == 1) + return; +#endif + + /* RF data is 12 bits only */ -+ if (BitMask != bRFRegOffsetMask) -+ { ++ if (BitMask != bRFRegOffsetMask) { + Original_Value = phy_RFSerialRead_8723B(Adapter, eRFPath, RegAddr); + BitShift = phy_CalculateBitShift(BitMask); -+ Data = ((Original_Value & (~BitMask)) | (Data<< BitShift)); ++ Data = ((Original_Value & (~BitMask)) | (Data<PHYRegDef[ODM_RF_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; /* wire control parameter2 */ + pHalData->PHYRegDef[ODM_RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; /* wire control parameter2 */ + -+ /* Tranceiver Readback LSSI/HSPI mode */ ++ /* Tranceiver Readback LSSI/HSPI mode */ + pHalData->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; + pHalData->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; + pHalData->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback; @@ -72010,13 +70000,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + +} + -+static int -+phy_BB8723b_Config_ParaFile( -+struct adapter *Adapter -+ ) ++static int phy_BB8723b_Config_ParaFile(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ int rtStatus = _SUCCESS; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ int rtStatus = _SUCCESS; + u8 sz8723BBRegFile[] = RTL8723B_PHY_REG; + u8 sz8723AGCTableFile[] = RTL8723B_AGC_TAB; + u8 sz8723BBBRegPgFile[] = RTL8723B_PHY_REG_PG; @@ -72024,7 +70011,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + u8 sz8723BRFTxPwrLmtFile[] = RTL8723B_TXPWR_LMT; + u8 *pszBBRegFile = NULL, *pszAGCTableFile = NULL, *pszBBRegPgFile = NULL, *pszBBRegMpFile = NULL, *pszRFTxPwrLmtFile = NULL; + -+ pszBBRegFile = sz8723BBRegFile ; ++ pszBBRegFile = sz8723BBRegFile; + pszAGCTableFile = sz8723AGCTableFile; + pszBBRegPgFile = sz8723BBBRegPgFile; + pszBBRegMpFile = sz8723BBRegMpFile; @@ -72032,9 +70019,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + + /* Read Tx Power Limit File */ + PHY_InitTxPowerLimit(Adapter); -+ if (Adapter->registrypriv.RegEnableTxPowerLimit == 1 || -+ (Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory == 1)) -+ { ++ if ( ++ Adapter->registrypriv.RegEnableTxPowerLimit == 1 || ++ (Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory == 1) ++ ) { +#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE + if (PHY_ConfigRFWithPowerLimitTableParaFile(Adapter, pszRFTxPwrLmtFile) == _FAIL) +#endif @@ -72067,9 +70055,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + + /* If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ + PHY_InitTxPowerByRate(Adapter); -+ if (Adapter->registrypriv.RegEnableTxPowerByRate == 1 || -+ (Adapter->registrypriv.RegEnableTxPowerByRate == 2 && pHalData->EEPROMRegulatory != 2)) -+ { ++ if ( ++ Adapter->registrypriv.RegEnableTxPowerByRate == 1 || ++ (Adapter->registrypriv.RegEnableTxPowerByRate == 2 && pHalData->EEPROMRegulatory != 2) ++ ) { +#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE + if (phy_ConfigBBWithPgParaFile(Adapter, pszBBRegPgFile) == _FAIL) +#endif @@ -72081,8 +70070,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) + PHY_TxPowerByRateConfiguration(Adapter); + -+ if (Adapter->registrypriv.RegEnableTxPowerLimit == 1 || -+ (Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory == 1)) ++ if ( ++ Adapter->registrypriv.RegEnableTxPowerLimit == 1 || ++ (Adapter->registrypriv.RegEnableTxPowerLimit == 2 && pHalData->EEPROMRegulatory == 1) ++ ) + PHY_ConvertTxPowerLimitToPowerIndex(Adapter); + + if (rtStatus != _SUCCESS) { @@ -72112,10 +70103,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b +} + + -+int -+PHY_BBConfig8723B( -+struct adapter *Adapter -+ ) ++int PHY_BBConfig8723B(struct adapter *Adapter) +{ + int rtStatus = _SUCCESS; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); @@ -72152,9 +70140,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + return rtStatus; +} + -+static void phy_LCK_8723B( -+struct adapter *Adapter -+ ) ++static void phy_LCK_8723B(struct adapter *Adapter) +{ + PHY_SetRFReg(Adapter, RF_PATH_A, 0xB0, bRFRegOffsetMask, 0xDFBE0); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, 0x8C01); @@ -72162,12 +70148,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + PHY_SetRFReg(Adapter, RF_PATH_A, 0xB0, bRFRegOffsetMask, 0xDFFE0); +} + -+int -+PHY_RFConfig8723B( -+struct adapter *Adapter -+ ) ++int PHY_RFConfig8723B(struct adapter *Adapter) +{ -+ int rtStatus = _SUCCESS; ++ int rtStatus = _SUCCESS; + + /* */ + /* RF config */ @@ -72187,73 +70170,115 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + * <20120830, Kordan> + **************************************************************************************************************/ + -+void -+PHY_SetTxPowerIndex_8723B( -+struct adapter * Adapter, -+u32 PowerIndex, -+u8 RFPath, -+u8 Rate -+ ) ++void PHY_SetTxPowerIndex_8723B( ++ struct adapter *Adapter, ++ u32 PowerIndex, ++ u8 RFPath, ++ u8 Rate ++) +{ -+ if (RFPath == ODM_RF_PATH_A || RFPath == ODM_RF_PATH_B) -+ { -+ switch (Rate) -+ { -+ case MGN_1M: PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, PowerIndex); break; -+ case MGN_2M: PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte1, PowerIndex); break; -+ case MGN_5_5M: PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte2, PowerIndex); break; -+ case MGN_11M: PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte3, PowerIndex); break; ++ if (RFPath == ODM_RF_PATH_A || RFPath == ODM_RF_PATH_B) { ++ switch (Rate) { ++ case MGN_1M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, PowerIndex); ++ break; ++ case MGN_2M: ++ PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte1, PowerIndex); ++ break; ++ case MGN_5_5M: ++ PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte2, PowerIndex); ++ break; ++ case MGN_11M: ++ PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte3, PowerIndex); ++ break; + -+ case MGN_6M: PHY_SetBBReg(Adapter, rTxAGC_A_Rate18_06, bMaskByte0, PowerIndex); break; -+ case MGN_9M: PHY_SetBBReg(Adapter, rTxAGC_A_Rate18_06, bMaskByte1, PowerIndex); break; -+ case MGN_12M: PHY_SetBBReg(Adapter, rTxAGC_A_Rate18_06, bMaskByte2, PowerIndex); break; -+ case MGN_18M: PHY_SetBBReg(Adapter, rTxAGC_A_Rate18_06, bMaskByte3, PowerIndex); break; ++ case MGN_6M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Rate18_06, bMaskByte0, PowerIndex); ++ break; ++ case MGN_9M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Rate18_06, bMaskByte1, PowerIndex); ++ break; ++ case MGN_12M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Rate18_06, bMaskByte2, PowerIndex); ++ break; ++ case MGN_18M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Rate18_06, bMaskByte3, PowerIndex); ++ break; + -+ case MGN_24M: PHY_SetBBReg(Adapter, rTxAGC_A_Rate54_24, bMaskByte0, PowerIndex); break; -+ case MGN_36M: PHY_SetBBReg(Adapter, rTxAGC_A_Rate54_24, bMaskByte1, PowerIndex); break; -+ case MGN_48M: PHY_SetBBReg(Adapter, rTxAGC_A_Rate54_24, bMaskByte2, PowerIndex); break; -+ case MGN_54M: PHY_SetBBReg(Adapter, rTxAGC_A_Rate54_24, bMaskByte3, PowerIndex); break; ++ case MGN_24M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Rate54_24, bMaskByte0, PowerIndex); ++ break; ++ case MGN_36M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Rate54_24, bMaskByte1, PowerIndex); ++ break; ++ case MGN_48M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Rate54_24, bMaskByte2, PowerIndex); ++ break; ++ case MGN_54M: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Rate54_24, bMaskByte3, PowerIndex); ++ break; + -+ case MGN_MCS0: PHY_SetBBReg(Adapter, rTxAGC_A_Mcs03_Mcs00, bMaskByte0, PowerIndex); break; -+ case MGN_MCS1: PHY_SetBBReg(Adapter, rTxAGC_A_Mcs03_Mcs00, bMaskByte1, PowerIndex); break; -+ case MGN_MCS2: PHY_SetBBReg(Adapter, rTxAGC_A_Mcs03_Mcs00, bMaskByte2, PowerIndex); break; -+ case MGN_MCS3: PHY_SetBBReg(Adapter, rTxAGC_A_Mcs03_Mcs00, bMaskByte3, PowerIndex); break; ++ case MGN_MCS0: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Mcs03_Mcs00, bMaskByte0, PowerIndex); ++ break; ++ case MGN_MCS1: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Mcs03_Mcs00, bMaskByte1, PowerIndex); ++ break; ++ case MGN_MCS2: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Mcs03_Mcs00, bMaskByte2, PowerIndex); ++ break; ++ case MGN_MCS3: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Mcs03_Mcs00, bMaskByte3, PowerIndex); ++ break; + -+ case MGN_MCS4: PHY_SetBBReg(Adapter, rTxAGC_A_Mcs07_Mcs04, bMaskByte0, PowerIndex); break; -+ case MGN_MCS5: PHY_SetBBReg(Adapter, rTxAGC_A_Mcs07_Mcs04, bMaskByte1, PowerIndex); break; -+ case MGN_MCS6: PHY_SetBBReg(Adapter, rTxAGC_A_Mcs07_Mcs04, bMaskByte2, PowerIndex); break; -+ case MGN_MCS7: PHY_SetBBReg(Adapter, rTxAGC_A_Mcs07_Mcs04, bMaskByte3, PowerIndex); break; ++ case MGN_MCS4: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Mcs07_Mcs04, bMaskByte0, PowerIndex); ++ break; ++ case MGN_MCS5: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Mcs07_Mcs04, bMaskByte1, PowerIndex); ++ break; ++ case MGN_MCS6: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Mcs07_Mcs04, bMaskByte2, PowerIndex); ++ break; ++ case MGN_MCS7: ++ PHY_SetBBReg(Adapter, rTxAGC_A_Mcs07_Mcs04, bMaskByte3, PowerIndex); ++ break; + -+ default: -+ DBG_871X("Invalid Rate!!\n"); -+ break; ++ default: ++ DBG_871X("Invalid Rate!!\n"); ++ break; + } -+ } -+ else -+ { ++ } else { + RT_TRACE(_module_hal_init_c_, _drv_err_, ("Invalid RFPath!!\n")); + } +} + -+u8 -+PHY_GetTxPowerIndex_8723B( -+struct adapter * padapter, -+u8 RFPath, -+u8 Rate, -+enum CHANNEL_WIDTH BandWidth, -+u8 Channel -+ ) ++u8 PHY_GetTxPowerIndex_8723B( ++ struct adapter *padapter, ++ u8 RFPath, ++ u8 Rate, ++ enum CHANNEL_WIDTH BandWidth, ++ u8 Channel ++) +{ -+ struct hal_com_data * pHalData = GET_HAL_DATA(padapter); -+ s8 txPower = 0, powerDiffByRate = 0, limit = 0; -+ bool bIn24G = false; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ s8 txPower = 0, powerDiffByRate = 0, limit = 0; ++ bool bIn24G = false; + + /* DBG_871X("===>%s\n", __func__); */ + + txPower = (s8) PHY_GetTxPowerIndexBase(padapter, RFPath, Rate, BandWidth, Channel, &bIn24G); + powerDiffByRate = PHY_GetTxPowerByRate(padapter, BAND_ON_2_4G, ODM_RF_PATH_A, RF_1TX, Rate); + -+ limit = PHY_GetTxPowerLimit(padapter, padapter->registrypriv.RegPwrTblSel, (u8)(!bIn24G), pHalData->CurrentChannelBW, RFPath, Rate, pHalData->CurrentChannel); ++ limit = PHY_GetTxPowerLimit( ++ padapter, ++ padapter->registrypriv.RegPwrTblSel, ++ (u8)(!bIn24G), ++ pHalData->CurrentChannelBW, ++ RFPath, ++ Rate, ++ pHalData->CurrentChannel ++ ); + + powerDiffByRate = powerDiffByRate > limit ? limit : powerDiffByRate; + txPower += powerDiffByRate; @@ -72267,21 +70292,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + return (u8) txPower; +} + -+void -+PHY_SetTxPowerLevel8723B( -+struct adapter * Adapter, -+u8 Channel -+ ) ++void PHY_SetTxPowerLevel8723B(struct adapter *Adapter, u8 Channel) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; -+ pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable; -+ u8 RFPath = ODM_RF_PATH_A; ++ PDM_ODM_T pDM_Odm = &pHalData->odmpriv; ++ pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable; ++ u8 RFPath = ODM_RF_PATH_A; + + if (pHalData->AntDivCfg) {/* antenna diversity Enable */ + RFPath = ((pDM_FatTable->RxIdleAnt == MAIN_ANT) ? ODM_RF_PATH_A : ODM_RF_PATH_B); -+ } -+ else { /* antenna diversity disable */ ++ } else { /* antenna diversity disable */ + RFPath = pHalData->ant_path; + } + @@ -72292,56 +70312,54 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + RT_TRACE(_module_hal_init_c_, _drv_info_, ("<==PHY_SetTxPowerLevel8723B()\n")); +} + -+void -+PHY_GetTxPowerLevel8723B( -+struct adapter * Adapter, -+ s32* powerlevel -+ ) ++void PHY_GetTxPowerLevel8723B(struct adapter *Adapter, s32 *powerlevel) +{ +} + -+static void -+phy_SetRegBW_8723B( -+struct adapter * Adapter, -+ enum CHANNEL_WIDTH CurrentBW ++static void phy_SetRegBW_8723B( ++ struct adapter *Adapter, enum CHANNEL_WIDTH CurrentBW +) +{ + u16 RegRfMod_BW, u2tmp = 0; + RegRfMod_BW = rtw_read16(Adapter, REG_TRXPTCL_CTL_8723B); + -+ switch (CurrentBW) -+ { -+ case CHANNEL_WIDTH_20: -+ rtw_write16(Adapter, REG_TRXPTCL_CTL_8723B, (RegRfMod_BW & 0xFE7F)); /* BIT 7 = 0, BIT 8 = 0 */ -+ break; ++ switch (CurrentBW) { ++ case CHANNEL_WIDTH_20: ++ rtw_write16(Adapter, REG_TRXPTCL_CTL_8723B, (RegRfMod_BW & 0xFE7F)); /* BIT 7 = 0, BIT 8 = 0 */ ++ break; + -+ case CHANNEL_WIDTH_40: -+ u2tmp = RegRfMod_BW | BIT7; -+ rtw_write16(Adapter, REG_TRXPTCL_CTL_8723B, (u2tmp & 0xFEFF)); /* BIT 7 = 1, BIT 8 = 0 */ -+ break; ++ case CHANNEL_WIDTH_40: ++ u2tmp = RegRfMod_BW | BIT7; ++ rtw_write16(Adapter, REG_TRXPTCL_CTL_8723B, (u2tmp & 0xFEFF)); /* BIT 7 = 1, BIT 8 = 0 */ ++ break; + -+ case CHANNEL_WIDTH_80: -+ u2tmp = RegRfMod_BW | BIT8; -+ rtw_write16(Adapter, REG_TRXPTCL_CTL_8723B, (u2tmp & 0xFF7F)); /* BIT 7 = 0, BIT 8 = 1 */ -+ break; ++ case CHANNEL_WIDTH_80: ++ u2tmp = RegRfMod_BW | BIT8; ++ rtw_write16(Adapter, REG_TRXPTCL_CTL_8723B, (u2tmp & 0xFF7F)); /* BIT 7 = 0, BIT 8 = 1 */ ++ break; + -+ default: -+ DBG_871X("phy_PostSetBWMode8723B(): unknown Bandwidth: %#X\n", CurrentBW); -+ break; ++ default: ++ DBG_871X("phy_PostSetBWMode8723B(): unknown Bandwidth: %#X\n", CurrentBW); ++ break; + } +} + -+static u8 -+phy_GetSecondaryChnl_8723B( -+struct adapter *Adapter -+) ++static u8 phy_GetSecondaryChnl_8723B(struct adapter *Adapter) +{ + u8 SCSettingOf40 = 0, SCSettingOf20 = 0; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + -+ RT_TRACE(_module_hal_init_c_, _drv_info_, ("SCMapping: VHT Case: pHalData->CurrentChannelBW %d, pHalData->nCur80MhzPrimeSC %d, pHalData->nCur40MhzPrimeSC %d\n", pHalData->CurrentChannelBW, pHalData->nCur80MhzPrimeSC, pHalData->nCur40MhzPrimeSC)); -+ if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) -+ { ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_info_, ++ ( ++ "SCMapping: VHT Case: pHalData->CurrentChannelBW %d, pHalData->nCur80MhzPrimeSC %d, pHalData->nCur40MhzPrimeSC %d\n", ++ pHalData->CurrentChannelBW, ++ pHalData->nCur80MhzPrimeSC, ++ pHalData->nCur40MhzPrimeSC ++ ) ++ ); ++ if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_80) { + if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) + SCSettingOf40 = VHT_DATA_SC_40_LOWER_OF_80MHZ; + else if (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) @@ -72349,20 +70367,38 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + else + RT_TRACE(_module_hal_init_c_, _drv_err_, ("SCMapping: Not Correct Primary40MHz Setting\n")); + -+ if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) ++ if ( ++ (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && ++ (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ++ ) + SCSettingOf20 = VHT_DATA_SC_20_LOWEST_OF_80MHZ; -+ else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER)) ++ else if ( ++ (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && ++ (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ++ ) + SCSettingOf20 = VHT_DATA_SC_20_LOWER_OF_80MHZ; -+ else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) ++ else if ( ++ (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) && ++ (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) ++ ) + SCSettingOf20 = VHT_DATA_SC_20_UPPER_OF_80MHZ; -+ else if ((pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER)) ++ else if ( ++ (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) && ++ (pHalData->nCur80MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) ++ ) + SCSettingOf20 = VHT_DATA_SC_20_UPPERST_OF_80MHZ; + else + RT_TRACE(_module_hal_init_c_, _drv_err_, ("SCMapping: Not Correct Primary40MHz Setting\n")); -+ } -+ else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) -+ { -+ RT_TRACE(_module_hal_init_c_, _drv_info_, ("SCMapping: VHT Case: pHalData->CurrentChannelBW %d, pHalData->nCur40MhzPrimeSC %d\n", pHalData->CurrentChannelBW, pHalData->nCur40MhzPrimeSC)); ++ } else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) { ++ RT_TRACE( ++ _module_hal_init_c_, ++ _drv_info_, ++ ( ++ "SCMapping: VHT Case: pHalData->CurrentChannelBW %d, pHalData->nCur40MhzPrimeSC %d\n", ++ pHalData->CurrentChannelBW, ++ pHalData->nCur40MhzPrimeSC ++ ) ++ ); + + if (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_UPPER) + SCSettingOf20 = VHT_DATA_SC_20_UPPER_OF_80MHZ; @@ -72376,13 +70412,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + return ((SCSettingOf40 << 4) | SCSettingOf20); +} + -+static void -+phy_PostSetBwMode8723B( -+struct adapter *Adapter -+) ++static void phy_PostSetBwMode8723B(struct adapter *Adapter) +{ -+ u8 SubChnlNum = 0; -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ u8 SubChnlNum = 0; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + + /* 3 Set Reg668 Reg440 BW */ @@ -72395,80 +70428,67 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + /* 3 */ + /* 3<2>Set PHY related register */ + /* 3 */ -+ switch (pHalData->CurrentChannelBW) -+ { -+ /* 20 MHz channel*/ -+ case CHANNEL_WIDTH_20: -+ PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x0); ++ switch (pHalData->CurrentChannelBW) { ++ /* 20 MHz channel*/ ++ case CHANNEL_WIDTH_20: ++ PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x0); + -+ PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x0); ++ PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x0); + +/* PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT10, 1); */ + -+ PHY_SetBBReg(Adapter, rOFDM0_TxPseudoNoiseWgt, (BIT31|BIT30), 0x0); -+ break; ++ PHY_SetBBReg(Adapter, rOFDM0_TxPseudoNoiseWgt, (BIT31|BIT30), 0x0); ++ break; + ++ /* 40 MHz channel*/ ++ case CHANNEL_WIDTH_40: ++ PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x1); + -+ /* 40 MHz channel*/ -+ case CHANNEL_WIDTH_40: -+ PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x1); ++ PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x1); + -+ PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x1); ++ /* Set Control channel to upper or lower. These settings are required only for 40MHz */ ++ PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC>>1)); + -+ /* Set Control channel to upper or lower. These settings are required only for 40MHz */ -+ PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC>>1)); ++ PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); + -+ PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); ++/* PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT10, 0); */ + -+/* PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT10, 0); */ ++ PHY_SetBBReg(Adapter, 0x818, (BIT26|BIT27), (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); + -+ PHY_SetBBReg(Adapter, 0x818, (BIT26|BIT27), (pHalData->nCur40MhzPrimeSC ==HAL_PRIME_CHNL_OFFSET_LOWER)?2:1); -+ -+ break; -+ -+ -+ -+ default: -+ /*RT_TRACE(COMP_DBG, DBG_LOUD, ("phy_SetBWMode8723B(): unknown Bandwidth: %#X\n"\ -+ , pHalData->CurrentChannelBW));*/ -+ break; ++ break; + ++ default: ++ /*RT_TRACE(COMP_DBG, DBG_LOUD, ("phy_SetBWMode8723B(): unknown Bandwidth: %#X\n"\ ++ , pHalData->CurrentChannelBW));*/ ++ break; + } + + /* 3<3>Set RF related register */ + PHY_RF6052SetBandwidth8723B(Adapter, pHalData->CurrentChannelBW); +} + -+static void -+phy_SwChnl8723B( -+struct adapter * padapter -+ ) ++static void phy_SwChnl8723B(struct adapter *padapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ u8 channelToSW = pHalData->CurrentChannel; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ u8 channelToSW = pHalData->CurrentChannel; + -+ if (pHalData->rf_chip == RF_PSEUDO_11N) -+ { ++ if (pHalData->rf_chip == RF_PSEUDO_11N) { + /* RT_TRACE(COMP_MLME, DBG_LOUD, ("phy_SwChnl8723B: return for PSEUDO\n")); */ + return; + } -+ pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff00) | channelToSW ); ++ pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff00) | channelToSW); + PHY_SetRFReg(padapter, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, pHalData->RfRegChnlVal[0]); + PHY_SetRFReg(padapter, ODM_RF_PATH_B, RF_CHNLBW, 0x3FF, pHalData->RfRegChnlVal[0]); + + DBG_8192C("===>phy_SwChnl8723B: Channel = %d\n", channelToSW); +} + -+static void -+phy_SwChnlAndSetBwMode8723B( -+ struct adapter * Adapter -+) ++static void phy_SwChnlAndSetBwMode8723B(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + /* RT_TRACE(COMP_SCAN, DBG_LOUD, ("phy_SwChnlAndSetBwMode8723B(): bSwChnl %d, bSetChnlBW %d\n", pHalData->bSwChnl, pHalData->bSetChnlBW)); */ -+ if (Adapter->bNotifyChannelChange) -+ { ++ if (Adapter->bNotifyChannelChange) { + DBG_871X("[%s] bSwChnl =%d, ch =%d, bSetChnlBW =%d, bw =%d\n", + __func__, + pHalData->bSwChnl, @@ -72477,19 +70497,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + pHalData->CurrentChannelBW); + } + -+ if ((Adapter->bDriverStopped) || (Adapter->bSurpriseRemoved)) -+ { ++ if (Adapter->bDriverStopped || Adapter->bSurpriseRemoved) + return; -+ } + -+ if (pHalData->bSwChnl) -+ { ++ if (pHalData->bSwChnl) { + phy_SwChnl8723B(Adapter); + pHalData->bSwChnl = false; + } + -+ if (pHalData->bSetChnlBW) -+ { ++ if (pHalData->bSetChnlBW) { + phy_PostSetBwMode8723B(Adapter); + pHalData->bSetChnlBW = false; + } @@ -72497,38 +70513,35 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + PHY_SetTxPowerLevel8723B(Adapter, pHalData->CurrentChannel); +} + -+static void -+PHY_HandleSwChnlAndSetBW8723B( -+struct adapter * Adapter, -+bool bSwitchChannel, -+bool bSetBandWidth, -+u8 ChannelNum, -+enum CHANNEL_WIDTH ChnlWidth, -+enum EXTCHNL_OFFSET ExtChnlOffsetOf40MHz, -+enum EXTCHNL_OFFSET ExtChnlOffsetOf80MHz, -+u8 CenterFrequencyIndex1 ++static void PHY_HandleSwChnlAndSetBW8723B( ++ struct adapter *Adapter, ++ bool bSwitchChannel, ++ bool bSetBandWidth, ++ u8 ChannelNum, ++ enum CHANNEL_WIDTH ChnlWidth, ++ enum EXTCHNL_OFFSET ExtChnlOffsetOf40MHz, ++ enum EXTCHNL_OFFSET ExtChnlOffsetOf80MHz, ++ u8 CenterFrequencyIndex1 +) +{ + /* static bool bInitialzed = false; */ -+ struct hal_com_data * pHalData = GET_HAL_DATA(Adapter); -+ u8 tmpChannel = pHalData->CurrentChannel; -+ enum CHANNEL_WIDTH tmpBW = pHalData->CurrentChannelBW; -+ u8 tmpnCur40MhzPrimeSC = pHalData->nCur40MhzPrimeSC; -+ u8 tmpnCur80MhzPrimeSC = pHalData->nCur80MhzPrimeSC; -+ u8 tmpCenterFrequencyIndex1 =pHalData->CurrentCenterFrequencyIndex1; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ u8 tmpChannel = pHalData->CurrentChannel; ++ enum CHANNEL_WIDTH tmpBW = pHalData->CurrentChannelBW; ++ u8 tmpnCur40MhzPrimeSC = pHalData->nCur40MhzPrimeSC; ++ u8 tmpnCur80MhzPrimeSC = pHalData->nCur80MhzPrimeSC; ++ u8 tmpCenterFrequencyIndex1 = pHalData->CurrentCenterFrequencyIndex1; + + /* DBG_871X("=> PHY_HandleSwChnlAndSetBW8812: bSwitchChannel %d, bSetBandWidth %d\n", bSwitchChannel, bSetBandWidth); */ + + /* check is swchnl or setbw */ -+ if (!bSwitchChannel && !bSetBandWidth) -+ { ++ if (!bSwitchChannel && !bSetBandWidth) { + DBG_871X("PHY_HandleSwChnlAndSetBW8812: not switch channel and not set bandwidth\n"); + return; + } + + /* skip change for channel or bandwidth is the same */ -+ if (bSwitchChannel) -+ { ++ if (bSwitchChannel) { + /* if (pHalData->CurrentChannel != ChannelNum) */ + { + if (HAL_IsLegalChannel(Adapter, ChannelNum)) @@ -72537,26 +70550,21 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + } + + if (bSetBandWidth) -+ { + pHalData->bSetChnlBW = true; -+ } + -+ if (!pHalData->bSetChnlBW && !pHalData->bSwChnl) -+ { ++ if (!pHalData->bSetChnlBW && !pHalData->bSwChnl) { + /* DBG_871X("<= PHY_HandleSwChnlAndSetBW8812: bSwChnl %d, bSetChnlBW %d\n", pHalData->bSwChnl, pHalData->bSetChnlBW); */ + return; + } + + -+ if (pHalData->bSwChnl) -+ { -+ pHalData->CurrentChannel =ChannelNum; ++ if (pHalData->bSwChnl) { ++ pHalData->CurrentChannel = ChannelNum; + pHalData->CurrentCenterFrequencyIndex1 = ChannelNum; + } + + -+ if (pHalData->bSetChnlBW) -+ { ++ if (pHalData->bSetChnlBW) { + pHalData->CurrentChannelBW = ChnlWidth; + pHalData->nCur40MhzPrimeSC = ExtChnlOffsetOf40MHz; + pHalData->nCur80MhzPrimeSC = ExtChnlOffsetOf80MHz; @@ -72564,19 +70572,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + } + + /* Switch workitem or set timer to do switch channel or setbandwidth operation */ -+ if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) -+ { ++ if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) { + phy_SwChnlAndSetBwMode8723B(Adapter); -+ } -+ else -+ { -+ if (pHalData->bSwChnl) -+ { ++ } else { ++ if (pHalData->bSwChnl) { + pHalData->CurrentChannel = tmpChannel; + pHalData->CurrentCenterFrequencyIndex1 = tmpChannel; + } -+ if (pHalData->bSetChnlBW) -+ { ++ ++ if (pHalData->bSetChnlBW) { + pHalData->CurrentChannelBW = tmpBW; + pHalData->nCur40MhzPrimeSC = tmpnCur40MhzPrimeSC; + pHalData->nCur80MhzPrimeSC = tmpnCur80MhzPrimeSC; @@ -72585,34 +70589,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + } +} + -+void -+PHY_SetBWMode8723B( -+struct adapter * Adapter, -+enum CHANNEL_WIDTH Bandwidth, /* 20M or 40M */ -+unsigned char Offset /* Upper, Lower, or Don't care */ ++void PHY_SetBWMode8723B( ++ struct adapter *Adapter, ++ enum CHANNEL_WIDTH Bandwidth, /* 20M or 40M */ ++ unsigned char Offset /* Upper, Lower, or Don't care */ +) +{ -+ struct hal_com_data * pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + PHY_HandleSwChnlAndSetBW8723B(Adapter, false, true, pHalData->CurrentChannel, Bandwidth, Offset, Offset, pHalData->CurrentChannel); +} + -+void -+PHY_SwChnl8723B(/* Call after initialization */ -+struct adapter *Adapter, -+u8 channel -+ ) ++/* Call after initialization */ ++void PHY_SwChnl8723B(struct adapter *Adapter, u8 channel) +{ + PHY_HandleSwChnlAndSetBW8723B(Adapter, true, false, channel, 0, 0, 0, channel); +} + -+void -+PHY_SetSwChnlBWMode8723B( -+struct adapter * Adapter, -+u8 channel, -+enum CHANNEL_WIDTH Bandwidth, -+u8 Offset40, -+u8 Offset80 ++void PHY_SetSwChnlBWMode8723B( ++ struct adapter *Adapter, ++ u8 channel, ++ enum CHANNEL_WIDTH Bandwidth, ++ u8 Offset40, ++ u8 Offset80 +) +{ + /* DBG_871X("%s() ===>\n", __func__); */ @@ -72621,10 +70620,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_phycfg.c linux-4.3-rtl8723b + + /* DBG_871X("<==%s()\n", __func__); */ +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c ---- linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,241 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c +--- linux.old/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,230 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -72689,50 +70688,45 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux-4.3-rtl8723b + * + * Note: For RF type 0222D + *---------------------------------------------------------------------------*/ -+void -+PHY_RF6052SetBandwidth8723B( -+struct adapter * Adapter, -+enum CHANNEL_WIDTH Bandwidth) /* 20M or 40M */ ++void PHY_RF6052SetBandwidth8723B( ++ struct adapter *Adapter, enum CHANNEL_WIDTH Bandwidth ++) /* 20M or 40M */ +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + -+ switch (Bandwidth) -+ { -+ case CHANNEL_WIDTH_20: -+ pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10 | BIT11); -+ PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); -+ PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); -+ break; ++ switch (Bandwidth) { ++ case CHANNEL_WIDTH_20: ++ pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10 | BIT11); ++ PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); ++ PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); ++ break; + -+ case CHANNEL_WIDTH_40: -+ pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10); -+ PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); -+ PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); -+ break; ++ case CHANNEL_WIDTH_40: ++ pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10); ++ PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); ++ PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); ++ break; + -+ default: -+ /* RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n", Bandwidth)); */ -+ break; ++ default: ++ /* RT_TRACE(COMP_DBG, DBG_LOUD, ("PHY_SetRF8225Bandwidth(): unknown Bandwidth: %#X\n", Bandwidth)); */ ++ break; + } + +} + -+static int -+phy_RF6052_Config_ParaFile( -+struct adapter * Adapter -+ ) ++static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) +{ -+ u32 u4RegValue = 0; -+ u8 eRFPath; ++ u32 u4RegValue = 0; ++ u8 eRFPath; + struct bb_register_def *pPhyReg; + -+ int rtStatus = _SUCCESS; -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ int rtStatus = _SUCCESS; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + -+ static char sz8723RadioAFile[] = RTL8723B_PHY_RADIO_A; -+ static char sz8723RadioBFile[] = RTL8723B_PHY_RADIO_B; -+ static s8 sz8723BTxPwrTrackFile[] = RTL8723B_TXPWR_TRACK; -+ char *pszRadioAFile, *pszRadioBFile, *pszTxPwrTrackFile; ++ static char sz8723RadioAFile[] = RTL8723B_PHY_RADIO_A; ++ static char sz8723RadioBFile[] = RTL8723B_PHY_RADIO_B; ++ static s8 sz8723BTxPwrTrackFile[] = RTL8723B_TXPWR_TRACK; ++ char *pszRadioAFile, *pszRadioBFile, *pszTxPwrTrackFile; + + pszRadioAFile = sz8723RadioAFile; + pszRadioBFile = sz8723RadioBFile; @@ -72742,19 +70736,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux-4.3-rtl8723b + /* 3 <2> Initialize RF */ + /* 3----------------------------------------------------------------- */ + /* for (eRFPath = RF_PATH_A; eRFPath NumTotalRFPath; eRFPath++) */ -+ for (eRFPath = 0; eRFPath NumTotalRFPath; eRFPath++) -+ { ++ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { + + pPhyReg = &pHalData->PHYRegDef[eRFPath]; + + /*----Store original RFENV control type----*/ -+ switch (eRFPath) -+ { ++ switch (eRFPath) { + case RF_PATH_A: + case RF_PATH_C: + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); + break; -+ case RF_PATH_B : ++ case RF_PATH_B: + case RF_PATH_D: + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); + break; @@ -72776,14 +70768,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux-4.3-rtl8723b + udelay(1);/* PlatformStallExecution(1); */ + + /*----Initialize RF fom connfiguration file----*/ -+ switch (eRFPath) -+ { ++ switch (eRFPath) { + case RF_PATH_A: +#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE + if (PHY_ConfigRFWithParaFile(Adapter, pszRadioAFile, eRFPath) == _FAIL) +#endif + { -+ if (HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) ++ if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) + rtStatus = _FAIL; + } + break; @@ -72792,7 +70783,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux-4.3-rtl8723b + if (PHY_ConfigRFWithParaFile(Adapter, pszRadioBFile, eRFPath) == _FAIL) +#endif + { -+ if (HAL_STATUS_FAILURE ==ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) ++ if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) + rtStatus = _FAIL; + } + break; @@ -72803,13 +70794,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux-4.3-rtl8723b + } + + /*----Restore RFENV control type----*/; -+ switch (eRFPath) -+ { ++ switch (eRFPath) { + case RF_PATH_A: + case RF_PATH_C: + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); + break; -+ case RF_PATH_B : ++ case RF_PATH_B: + case RF_PATH_D: + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + break; @@ -72841,12 +70831,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux-4.3-rtl8723b +} + + -+int -+PHY_RF6052_Config8723B( -+struct adapter * Adapter) ++int PHY_RF6052_Config8723B(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); -+ int rtStatus = _SUCCESS; ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ int rtStatus = _SUCCESS; + + /* */ + /* Initialize general global value */ @@ -72866,10 +70854,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rf6052.c linux-4.3-rtl8723b +} + +/* End of HalRf6052.c */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c ---- linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,87 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c linux/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c +--- linux.old/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,86 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. @@ -72891,7 +70879,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c linux-4.3-rtl8723b +static void process_rssi(struct adapter *padapter, union recv_frame *prframe) +{ + struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; -+ struct signal_stat * signal_stat = &padapter->recvpriv.signal_strength_data; ++ struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data; + + /* DBG_8192C("process_rssi => pattrib->rssil(%d) signal_strength(%d)\n ", pattrib->RecvSignalPower, pattrib->signal_strength); */ + /* if (pRfd->Status.bPacketToSelf || pRfd->Status.bPacketBeacon) */ @@ -72907,16 +70895,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c linux-4.3-rtl8723b + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; + } + -+}/* Process_UI_RSSI_8192C */ ++} /* Process_UI_RSSI_8192C */ + +static void process_link_qual(struct adapter *padapter, union recv_frame *prframe) +{ + struct rx_pkt_attrib *pattrib; -+ struct signal_stat * signal_stat; ++ struct signal_stat *signal_stat; + -+ if (prframe == NULL || padapter == NULL) { ++ if (prframe == NULL || padapter == NULL) + return; -+ } + + pattrib = &prframe->u.hdr.attrib; + signal_stat = &padapter->recvpriv.signal_qual_data; @@ -72932,7 +70919,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c linux-4.3-rtl8723b + signal_stat->total_num++; + signal_stat->total_val += pattrib->phy_info.SignalQuality; + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; -+}/* Process_UiLinkQuality8192S */ ++} /* Process_UiLinkQuality8192S */ + + +void rtl8723b_process_phy_info(struct adapter *padapter, void *prframe) @@ -72957,10 +70944,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723b_rxdesc.c linux-4.3-rtl8723b + #endif + +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c ---- linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,528 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c +--- linux.old/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,490 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -72993,12 +70980,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs +} + +static void update_recvframe_attrib( -+ struct adapter *padapter, -+ union recv_frame *precvframe, -+ struct recv_stat *prxstat) ++ struct adapter *padapter, union recv_frame *precvframe, struct recv_stat *prxstat ++) +{ -+ struct rx_pkt_attrib *pattrib; -+ struct recv_stat report; ++ struct rx_pkt_attrib *pattrib; ++ struct recv_stat report; + PRXREPORT prxreport = (PRXREPORT)&report; + + report.rxdw0 = prxstat->rxdw0; @@ -73015,8 +71001,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + pattrib->pkt_rpt_type = prxreport->c2h_ind?C2H_PACKET:NORMAL_RX; +/* DBG_871X("%s: pkt_rpt_type =%d\n", __func__, pattrib->pkt_rpt_type); */ + -+ if (pattrib->pkt_rpt_type == NORMAL_RX) -+ { ++ if (pattrib->pkt_rpt_type == NORMAL_RX) { + /* Normal rx packet */ + /* update rx report to recv_frame attribute */ + pattrib->pkt_len = (u16)prxreport->pktlen; @@ -73040,11 +71025,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + pattrib->mdata = (u8)prxreport->md; + + pattrib->data_rate = (u8)prxreport->rx_rate; -+ } -+ else -+ { ++ } else + pattrib->pkt_len = (u16)prxreport->pktlen; -+ } +} + +/* @@ -73053,22 +71035,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + *precvframe->u.hdr.rx_data should be ready! + */ +static void update_recvframe_phyinfo( -+ union recv_frame *precvframe, -+ struct phy_stat *pphy_status) ++ union recv_frame *precvframe, struct phy_stat *pphy_status ++) +{ -+ struct adapter * padapter = precvframe->u.hdr.adapter; -+ struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ PODM_PHY_INFO_T pPHYInfo = (PODM_PHY_INFO_T)(&pattrib->phy_info); ++ struct adapter *padapter = precvframe->u.hdr.adapter; ++ struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ PODM_PHY_INFO_T pPHYInfo = (PODM_PHY_INFO_T)(&pattrib->phy_info); + -+ u8 *wlanhdr; -+ ODM_PACKET_INFO_T pkt_info; ++ u8 *wlanhdr; ++ ODM_PACKET_INFO_T pkt_info; + u8 *sa = NULL; + /* _irqL irqL; */ + struct sta_priv *pstapriv; + struct sta_info *psta; + -+ pkt_info.bPacketMatchBSSID =false; ++ pkt_info.bPacketMatchBSSID = false; + pkt_info.bPacketToSelf = false; + pkt_info.bPacketBeacon = false; + @@ -73089,8 +71071,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + + pstapriv = &padapter->stapriv; + psta = rtw_get_stainfo(pstapriv, sa); -+ if (psta) -+ { ++ if (psta) { + pkt_info.StationID = psta->mac_id; + /* DBG_8192C("%s ==> StationID(%d)\n", __func__, pkt_info.StationID); */ + } @@ -73098,28 +71079,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + + /* rtl8723b_query_rx_phy_status(precvframe, pphy_status); */ + /* spin_lock_bh(&pHalData->odm_stainfo_lock); */ -+ ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status,&(pkt_info)); -+ if (psta) psta->rssi = pattrib->phy_info.RecvSignalPower; ++ ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info)); ++ if (psta) ++ psta->rssi = pattrib->phy_info.RecvSignalPower; + /* spin_unlock_bh(&pHalData->odm_stainfo_lock); */ + precvframe->u.hdr.psta = NULL; -+ if (pkt_info.bPacketMatchBSSID && -+ (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true)) -+ { -+ if (psta) -+ { ++ if ( ++ pkt_info.bPacketMatchBSSID && ++ (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true) ++ ) { ++ if (psta) { + precvframe->u.hdr.psta = psta; + rtl8723b_process_phy_info(padapter, precvframe); -+ } -+ } -+ else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) -+ { -+ if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true) -+ { -+ if (psta) -+ { -+ precvframe->u.hdr.psta = psta; -+ } + } ++ } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { ++ if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true) ++ if (psta) ++ precvframe->u.hdr.psta = psta; + rtl8723b_process_phy_info(padapter, precvframe); + } +} @@ -73152,15 +71128,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + +static void rtl8723bs_recv_tasklet(void *priv) +{ -+ struct adapter * padapter; -+ struct hal_com_data * pHalData; -+ struct recv_priv *precvpriv; -+ struct recv_buf *precvbuf; -+ union recv_frame *precvframe; -+ struct rx_pkt_attrib *pattrib; ++ struct adapter *padapter; ++ struct hal_com_data *pHalData; ++ struct recv_priv *precvpriv; ++ struct recv_buf *precvbuf; ++ union recv_frame *precvframe; ++ struct rx_pkt_attrib *pattrib; + u8 *ptr; + u32 pkt_offset, skb_len, alloc_sz; -+ _pkt *pkt_copy = NULL; ++ _pkt *pkt_copy = NULL; + u8 shift_sz = 0, rx_report_sz = 0; + + @@ -73170,15 +71146,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + + do { + precvbuf = rtw_dequeue_recvbuf(&precvpriv->recv_buf_pending_queue); -+ if (NULL == precvbuf) break; ++ if (NULL == precvbuf) ++ break; + + ptr = precvbuf->pdata; + -+ while (ptr < precvbuf->ptail) -+ { ++ while (ptr < precvbuf->ptail) { + precvframe = rtw_alloc_recvframe(&precvpriv->free_recv_queue); -+ if (precvframe == NULL) -+ { ++ if (precvframe == NULL) { + DBG_8192C("%s: no enough recv frame!\n", __func__); + rtw_enqueue_recvbuf_to_head(precvbuf, &precvpriv->recv_buf_pending_queue); + @@ -73189,13 +71164,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + } + + /* rx desc parsing */ -+ update_recvframe_attrib(padapter, precvframe, (struct recv_stat*)ptr); ++ update_recvframe_attrib(padapter, precvframe, (struct recv_stat *)ptr); + + pattrib = &precvframe->u.hdr.attrib; + + /* fix Hardware RX data error, drop whole recv_buffer */ -+ if ((!(pHalData->ReceiveConfig & RCR_ACRC32)) && pattrib->crc_err) -+ { ++ if ((!(pHalData->ReceiveConfig & RCR_ACRC32)) && pattrib->crc_err) { + DBG_8192C("%s()-%d: RX Warning! rx CRC ERROR !!\n", __func__, __LINE__); + rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); + break; @@ -73210,25 +71184,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + break; + } + -+ if ((pattrib->crc_err) || (pattrib->icv_err)) -+ { ++ if ((pattrib->crc_err) || (pattrib->icv_err)) { + { + DBG_8192C("%s: crc_err =%d icv_err =%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); + } + rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); -+ } -+ else -+ { ++ } else { + /* Modified by Albert 20101213 */ + /* For 8 bytes IP header alignment. */ + if (pattrib->qos) /* Qos data, wireless lan header length is 26 */ -+ { + shift_sz = 6; -+ } + else -+ { + shift_sz = 0; -+ } + + skb_len = pattrib->pkt_len; + @@ -73239,8 +71206,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + alloc_sz = 1664; + else + alloc_sz = skb_len + 14; -+ } -+ else { ++ } else { + alloc_sz = skb_len; + /* 6 is for IP header 8 bytes alignment in QoS packet case. */ + /* 8 is for skb->data 4 bytes alignment. */ @@ -73249,8 +71215,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + + pkt_copy = rtw_skb_alloc(alloc_sz); + -+ if (pkt_copy) -+ { ++ if (pkt_copy) { + pkt_copy->dev = padapter->pnetdev; + precvframe->u.hdr.pkt = pkt_copy; + skb_reserve(pkt_copy, 8 - ((SIZE_PTR)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ @@ -73259,29 +71224,23 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + precvframe->u.hdr.rx_head = pkt_copy->head; + precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail = pkt_copy->data; + precvframe->u.hdr.rx_end = skb_end_pointer(pkt_copy); -+ } -+ else -+ { -+ if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) -+ { ++ } else { ++ if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + DBG_8192C("%s: alloc_skb fail, drop frag frame\n", __func__); + rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); + break; + } + + precvframe->u.hdr.pkt = rtw_skb_clone(precvbuf->pskb); -+ if (precvframe->u.hdr.pkt) -+ { -+ _pkt *pkt_clone = precvframe->u.hdr.pkt; ++ if (precvframe->u.hdr.pkt) { ++ _pkt *pkt_clone = precvframe->u.hdr.pkt; + + pkt_clone->data = ptr + rx_report_sz + pattrib->shift_sz; + skb_reset_tail_pointer(pkt_clone); + precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail + = pkt_clone->data; + precvframe->u.hdr.rx_end = pkt_clone->data + skb_len; -+ } -+ else -+ { ++ } else { + DBG_8192C("%s: rtw_skb_clone fail\n", __func__); + rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); + break; @@ -73303,18 +71262,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + ptr += 4; + } + -+ if (pattrib->pkt_rpt_type == NORMAL_RX)/* Normal rx packet */ -+ { ++ if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ + if (pattrib->physt) -+ update_recvframe_phyinfo(precvframe, (struct phy_stat*)ptr); ++ update_recvframe_phyinfo(precvframe, (struct phy_stat *)ptr); + -+ if (rtw_recv_entry(precvframe) != _SUCCESS) -+ { ++ if (rtw_recv_entry(precvframe) != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_dump_, ("%s: rtw_recv_entry(precvframe) != _SUCCESS\n", __func__)); + } -+ } -+ else if (pattrib->pkt_rpt_type == C2H_PACKET) -+ { ++ } else if (pattrib->pkt_rpt_type == C2H_PACKET) { + C2H_EVT_HDR C2hEvent; + + u16 len_c2h = pattrib->pkt_len; @@ -73323,17 +71278,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + + C2hEvent.CmdID = pbuf_c2h[0]; + C2hEvent.CmdSeq = pbuf_c2h[1]; -+ C2hEvent.CmdLen = (len_c2h -2); ++ C2hEvent.CmdLen = (len_c2h-2); + pdata_c2h = pbuf_c2h+2; + + if (C2hEvent.CmdID == C2H_CCX_TX_RPT) -+ { + CCX_FwC2HTxRpt_8723b(padapter, pdata_c2h, C2hEvent.CmdLen); -+ } + else -+ { + rtl8723bs_c2h_packet_handler(padapter, precvframe->u.hdr.rx_data, pattrib->pkt_len); -+ } + + rtw_free_recvframe(precvframe, &precvpriv->free_recv_queue); + @@ -73360,10 +71311,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + */ +s32 rtl8723bs_init_recv_priv(struct adapter *padapter) +{ -+ s32 res; -+ u32 i, n; ++ s32 res; ++ u32 i, n; + struct recv_priv *precvpriv; -+ struct recv_buf *precvbuf; ++ struct recv_buf *precvbuf; + + + res = _SUCCESS; @@ -73384,9 +71335,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4); + + /* init each recv buffer */ -+ precvbuf = (struct recv_buf*)precvpriv->precv_buf; -+ for (i = 0; i < NR_RECVBUFF; i++) -+ { ++ precvbuf = (struct recv_buf *)precvpriv->precv_buf; ++ for (i = 0; i < NR_RECVBUFF; i++) { + res = initrecvbuf(precvbuf, padapter); + if (res == _FAIL) + break; @@ -73397,8 +71347,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + + precvbuf->pskb = rtw_skb_alloc(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); + -+ if (precvbuf->pskb) -+ { ++ if (precvbuf->pskb) { + precvbuf->pskb->dev = padapter->pnetdev; + + tmpaddr = (SIZE_PTR)precvbuf->pskb->data; @@ -73421,19 +71370,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + goto initbuferror; + + /* 3 2. init tasklet */ -+ tasklet_init(&precvpriv->recv_tasklet, -+ (void(*)(unsigned long))rtl8723bs_recv_tasklet, -+ (unsigned long)padapter); ++ tasklet_init( ++ &precvpriv->recv_tasklet, ++ (void(*)(unsigned long))rtl8723bs_recv_tasklet, ++ (unsigned long)padapter ++ ); + + goto exit; + +initbuferror: -+ precvbuf = (struct recv_buf*)precvpriv->precv_buf; ++ precvbuf = (struct recv_buf *)precvpriv->precv_buf; + if (precvbuf) { + n = precvpriv->free_recv_buf_queue_cnt; + precvpriv->free_recv_buf_queue_cnt = 0; -+ for (i = 0; i < n ; i++) -+ { ++ for (i = 0; i < n ; i++) { + list_del_init(&precvbuf->list); + rtw_os_recvbuf_resource_free(padapter, precvbuf); + precvbuf++; @@ -73459,9 +71409,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + */ +void rtl8723bs_free_recv_priv(struct adapter *padapter) +{ -+ u32 i, n; ++ u32 i, n; + struct recv_priv *precvpriv; -+ struct recv_buf *precvbuf; ++ struct recv_buf *precvbuf; + + + precvpriv = &padapter->recvpriv; @@ -73470,12 +71420,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + tasklet_kill(&precvpriv->recv_tasklet); + + /* 3 2. free all recv buffers */ -+ precvbuf = (struct recv_buf*)precvpriv->precv_buf; ++ precvbuf = (struct recv_buf *)precvpriv->precv_buf; + if (precvbuf) { + n = NR_RECVBUFF; + precvpriv->free_recv_buf_queue_cnt = 0; -+ for (i = 0; i < n ; i++) -+ { ++ for (i = 0; i < n ; i++) { + list_del_init(&precvbuf->list); + rtw_os_recvbuf_resource_free(padapter, precvbuf); + precvbuf++; @@ -73489,10 +71438,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_recv.c linux-4.3-rtl8723bs + precvpriv->pallocated_recv_buf = NULL; + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c ---- linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,652 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c +--- linux.old/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,686 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -73520,8 +71469,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + + while (pHalData->SdioTxOQTFreeSpace < agg_num) + { -+ if ((padapter->bSurpriseRemoved == true) -+ || (padapter->bDriverStopped == true)) { ++ if ( ++ (padapter->bSurpriseRemoved == true) || ++ (padapter->bDriverStopped == true) ++ ) { + DBG_871X("%s: bSurpriseRemoved or bDriverStopped (wait TxOQT)\n", __func__); + return false; + } @@ -73572,23 +71523,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + + /* translate fifo addr to queue index */ + switch (deviceId) { -+ case WLAN_TX_HIQ_DEVICE_ID: -+ PageIdx = HI_QUEUE_IDX; -+ break; ++ case WLAN_TX_HIQ_DEVICE_ID: ++ PageIdx = HI_QUEUE_IDX; ++ break; + -+ case WLAN_TX_MIQ_DEVICE_ID: -+ PageIdx = MID_QUEUE_IDX; -+ break; ++ case WLAN_TX_MIQ_DEVICE_ID: ++ PageIdx = MID_QUEUE_IDX; ++ break; + -+ case WLAN_TX_LOQ_DEVICE_ID: -+ PageIdx = LOW_QUEUE_IDX; -+ break; ++ case WLAN_TX_LOQ_DEVICE_ID: ++ PageIdx = LOW_QUEUE_IDX; ++ break; + } + +query_free_page: + /* check if hardware tx fifo page is enough */ -+ if (false == rtw_hal_sdio_query_tx_freepage(pri_padapter, PageIdx, pxmitbuf->pg_num)) -+ { ++ if (false == rtw_hal_sdio_query_tx_freepage(pri_padapter, PageIdx, pxmitbuf->pg_num)) { + if (!bUpdatePageNum) { + /* Total number of page is NOT available, so update current FIFO status */ + HalQueryTxBufferStatus8723BSdio(padapter); @@ -73601,17 +71551,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + } + } + -+ if ((padapter->bSurpriseRemoved == true) -+ || (padapter->bDriverStopped == true)) { -+ RT_TRACE(_module_hal_xmit_c_, _drv_notice_, -+ ("%s: bSurpriseRemoved(wirte port)\n", __func__)); ++ if ( ++ (padapter->bSurpriseRemoved == true) || ++ (padapter->bDriverStopped == true) ++ ) { ++ RT_TRACE( ++ _module_hal_xmit_c_, ++ _drv_notice_, ++ ("%s: bSurpriseRemoved(wirte port)\n", __func__) ++ ); + goto free_xmitbuf; + } + + if (rtw_sdio_wait_enough_TxOQT_space(padapter, pxmitbuf->agg_num) == false) -+ { + goto free_xmitbuf; -+ } + + traffic_check_for_leave_lps(padapter, true, pxmitbuf->agg_num); + @@ -73643,7 +71596,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs +{ + struct xmit_priv *pxmitpriv; + u8 queue_empty, queue_pending; -+ s32 ret; ++ s32 ret; + + + pxmitpriv = &padapter->xmitpriv; @@ -73655,9 +71608,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + + ret = (padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true); + if (ret) { -+ RT_TRACE(_module_hal_xmit_c_, _drv_err_, -+ ("%s: bDriverStopped(%d) bSurpriseRemoved(%d)!\n", -+ __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved)); ++ RT_TRACE( ++ _module_hal_xmit_c_, ++ _drv_err_, ++ ( ++ "%s: bDriverStopped(%d) bSurpriseRemoved(%d)!\n", ++ __func__, ++ padapter->bDriverStopped, ++ padapter->bSurpriseRemoved ++ ) ++ ); + return _FAIL; + } + @@ -73718,15 +71678,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + for (idx = 0; idx<4; idx++) + inx[idx] = pxmitpriv->wmm_para_seq[idx]; + } else { -+ inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; ++ inx[0] = 0; ++ inx[1] = 1; ++ inx[2] = 2; ++ inx[3] = 3; + } + + /* 0(VO), 1(VI), 2(BE), 3(BK) */ -+ for (idx = 0; idx < hwentry; idx++) -+ { ++ for (idx = 0; idx < hwentry; idx++) { + phwxmit = hwxmits + inx[idx]; + -+ if ((check_pending_xmitbuf(pxmitpriv) == true) && (padapter->mlmepriv.LinkDetectInfo.bHigherBusyTxTraffic == true)) { ++ if ( ++ (check_pending_xmitbuf(pxmitpriv) == true) && ++ (padapter->mlmepriv.LinkDetectInfo.bHigherBusyTxTraffic == true) ++ ) { + if ((phwxmit->accnt > 0) && (phwxmit->accnt < 5)) { + err = -2; + break; @@ -73741,38 +71706,44 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + sta_plist = get_next(sta_phead); + /* because stop_sta_xmit may delete sta_plist at any time */ + /* so we should add lock here, or while loop can not exit */ -+ while (sta_phead != sta_plist) -+ { ++ while (sta_phead != sta_plist) { + ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq, tx_pending); + sta_plist = get_next(sta_plist); + +#ifdef DBG_XMIT_BUF -+ DBG_871X("%s idx:%d hwxmit_pkt_num:%d ptxservq_pkt_num:%d\n", __func__, idx, phwxmit->accnt, ptxservq->qcnt); -+ DBG_871X("%s free_xmit_extbuf_cnt =%d free_xmitbuf_cnt =%d free_xmitframe_cnt =%d\n", -+ __func__, pxmitpriv->free_xmit_extbuf_cnt, pxmitpriv->free_xmitbuf_cnt, -+ pxmitpriv->free_xmitframe_cnt); ++ DBG_871X( ++ "%s idx:%d hwxmit_pkt_num:%d ptxservq_pkt_num:%d\n", ++ __func__, ++ idx, ++ phwxmit->accnt, ++ ptxservq->qcnt ++ ); ++ DBG_871X( ++ "%s free_xmit_extbuf_cnt =%d free_xmitbuf_cnt =%d free_xmitframe_cnt =%d\n", ++ __func__, ++ pxmitpriv->free_xmit_extbuf_cnt, ++ pxmitpriv->free_xmitbuf_cnt, ++ pxmitpriv->free_xmitframe_cnt ++ ); +#endif + pframe_queue = &ptxservq->sta_pending; + + frame_phead = get_list_head(pframe_queue); + -+ while (list_empty(frame_phead) == false) -+ { ++ while (list_empty(frame_phead) == false) { + frame_plist = get_next(frame_phead); + pxmitframe = LIST_CONTAINOR(frame_plist, struct xmit_frame, list); + + /* check xmit_buf size enough or not */ + txlen = txdesc_size + rtw_wlan_pkt_size(pxmitframe); -+ if ((NULL == pxmitbuf) || -+ ((_RND(pxmitbuf->len, 8) + txlen) > max_xmit_len) -+ || (k >= (rtw_hal_sdio_max_txoqt_free_space(padapter)-1)) -+ ) -+ { -+ if (pxmitbuf) -+ { ++ if ( ++ (NULL == pxmitbuf) || ++ ((_RND(pxmitbuf->len, 8) + txlen) > max_xmit_len) || ++ (k >= (rtw_hal_sdio_max_txoqt_free_space(padapter)-1)) ++ ) { ++ if (pxmitbuf) { + /* pxmitbuf->priv_data will be NULL, and will crash here */ -+ if (pxmitbuf->len > 0 && pxmitbuf->priv_data) -+ { ++ if (pxmitbuf->len > 0 && pxmitbuf->priv_data) { + struct xmit_frame *pframe; + pframe = (struct xmit_frame*)pxmitbuf->priv_data; + pframe->agg_num = k; @@ -73783,9 +71754,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + enqueue_pending_xmitbuf(pxmitpriv, pxmitbuf); + /* can not yield under lock */ + /* yield(); */ -+ } else { ++ } else + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); -+ } + } + + pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); @@ -73802,10 +71772,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + + /* ok to send, remove frame from queue */ + if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == true) { -+ if ((pxmitframe->attrib.psta->state & WIFI_SLEEP_STATE) && -+ (pxmitframe->attrib.triggered == 0)) { -+ DBG_871X("%s: one not triggered pkt in queue when this STA sleep," -+ " break and goto next sta\n", __func__); ++ if ( ++ (pxmitframe->attrib.psta->state & WIFI_SLEEP_STATE) && ++ (pxmitframe->attrib.triggered == 0) ++ ) { ++ DBG_871X( ++ "%s: one not triggered pkt in queue when this STA sleep," ++ " break and goto next sta\n", ++ __func__ ++ ); + break; + } + } @@ -73850,13 +71825,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + if (list_empty(&pframe_queue->queue)) + list_del_init(&ptxservq->tx_pending); + -+ if (err) break; ++ if (err) ++ break; + } + spin_unlock_bh(&pxmitpriv->lock); + + /* dump xmit_buf to hw tx fifo */ -+ if (pxmitbuf) -+ { ++ if (pxmitbuf) { + RT_TRACE(_module_hal_xmit_c_, _drv_info_, ("pxmitbuf->len =%d enqueue\n", pxmitbuf->len)); + + if (pxmitbuf->len > 0) { @@ -73875,7 +71850,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + pxmitbuf = NULL; + } + -+ if (err) break; ++ if (err) ++ break; + } + + return err; @@ -73903,11 +71879,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + } + +next: -+ if ((padapter->bDriverStopped == true) || -+ (padapter->bSurpriseRemoved == true)) { -+ RT_TRACE(_module_hal_xmit_c_, _drv_notice_, -+ ("%s: bDriverStopped(%d) bSurpriseRemoved(%d)\n", -+ __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved)); ++ if ( ++ (padapter->bDriverStopped == true) || ++ (padapter->bSurpriseRemoved == true) ++ ) { ++ RT_TRACE( ++ _module_hal_xmit_c_, ++ _drv_notice_, ++ ( ++ "%s: bDriverStopped(%d) bSurpriseRemoved(%d)\n", ++ __func__, ++ padapter->bDriverStopped, ++ padapter->bSurpriseRemoved ++ ) ++ ); + return _FAIL; + } + @@ -73976,7 +71961,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + thread_exit(); +} + -+s32 rtl8723bs_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe) ++s32 rtl8723bs_mgnt_xmit( ++ struct adapter *padapter, struct xmit_frame *pmgntframe ++) +{ + s32 ret = _SUCCESS; + struct pkt_attrib *pattrib; @@ -74004,18 +71991,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + + pxmitbuf->priv_data = NULL; + -+ if (GetFrameSubType(pframe) ==WIFI_BEACON) /* dump beacon directly */ -+ { ++ if (GetFrameSubType(pframe) == WIFI_BEACON) { /* dump beacon directly */ + ret = rtw_write_port(padapter, pdvobjpriv->Queue2Pipe[pxmitbuf->ff_hwaddr], pxmitbuf->len, (u8 *)pxmitbuf); + if (ret != _SUCCESS) + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); + + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); -+ } -+ else -+ { ++ } else + enqueue_pending_xmitbuf(pxmitpriv, pxmitbuf); -+ } + + return ret; +} @@ -74028,7 +72011,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + *true dump packet directly ok + *false enqueue, temporary can't transmit packets to hardware + */ -+s32 rtl8723bs_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe) ++s32 rtl8723bs_hal_xmit( ++ struct adapter *padapter, struct xmit_frame *pxmitframe ++) +{ + struct xmit_priv *pxmitpriv; + s32 err; @@ -74037,11 +72022,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + pxmitframe->attrib.qsel = pxmitframe->attrib.priority; + pxmitpriv = &padapter->xmitpriv; + -+ if ((pxmitframe->frame_tag == DATA_FRAMETAG) && ++ if ( ++ (pxmitframe->frame_tag == DATA_FRAMETAG) && + (pxmitframe->attrib.ether_type != 0x0806) && + (pxmitframe->attrib.ether_type != 0x888e) && -+ (pxmitframe->attrib.dhcp_pkt != 1)) -+ { ++ (pxmitframe->attrib.dhcp_pkt != 1) ++ ) { + if (padapter->mlmepriv.LinkDetectInfo.bBusyTraffic == true) + rtw_issue_addbareq_cmd(padapter, pxmitframe); + } @@ -74062,19 +72048,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + return false; +} + -+s32 rtl8723bs_hal_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) ++s32 rtl8723bs_hal_xmitframe_enqueue( ++ struct adapter *padapter, struct xmit_frame *pxmitframe ++) +{ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + s32 err; + -+ if ((err =rtw_xmitframe_enqueue(padapter, pxmitframe)) != _SUCCESS) -+ { ++ if ((err = rtw_xmitframe_enqueue(padapter, pxmitframe)) != _SUCCESS) { + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + pxmitpriv->tx_drop++; -+ } -+ else -+ { ++ } else { +#ifdef CONFIG_SDIO_TX_TASKLET + tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); +#else @@ -74124,8 +72109,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + INIT_LIST_HEAD(&tmplist); + + spin_lock_bh(&pqueue->lock); -+ if (!list_empty(&pqueue->queue)) -+ { ++ if (!list_empty(&pqueue->queue)) { + /* Insert tmplist to end of queue, and delete phead */ + /* then tmplist become head of queue. */ + list_add_tail(&tmplist, phead); @@ -74134,21 +72118,20 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/rtl8723bs_xmit.c linux-4.3-rtl8723bs + spin_unlock_bh(&pqueue->lock); + + phead = &tmplist; -+ while (list_empty(phead) == false) -+ { ++ while (list_empty(phead) == false) { + plist = get_next(phead); + list_del_init(plist); + + pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); -+ rtw_free_xmitframe(pxmitpriv, (struct xmit_frame*)pxmitbuf->priv_data); ++ rtw_free_xmitframe(pxmitpriv, (struct xmit_frame *)pxmitbuf->priv_data); + pxmitbuf->priv_data = NULL; + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); + } +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/sdio_halinit.c ---- linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/sdio_halinit.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1959 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/sdio_halinit.c linux/3rdparty/rtl8723bs/hal/sdio_halinit.c +--- linux.old/3rdparty/rtl8723bs/hal/sdio_halinit.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/sdio_halinit.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1928 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -74185,8 +72168,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + + + rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); -+ if (bMacPwrCtrlOn == false) -+ { ++ if (bMacPwrCtrlOn == false) { + /* RSV_CTRL 0x1C[7:0] = 0x00 */ + /* unlock ISO/CLK/Power control register */ + rtw_write8(padapter, REG_RSV_CTRL, 0x0); @@ -74205,7 +72187,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 +#ifdef CONFIG_GPIO_WAKEUP +/* we set it high under init and fw will */ +/* give us Low Pulse when host wake up */ -+void HostWakeUpGpioClear(struct adapter * Adapter) ++void HostWakeUpGpioClear(struct adapter *Adapter) +{ + u32 value32; + @@ -74231,11 +72213,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + rtw_write8(padapter, REG_GPIO_PIN_CTRL + 2, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 2) | BIT(index)); + + /* set output value */ -+ if (OutPutValue) { ++ if (OutPutValue) + rtw_write8(padapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 1) | BIT(index)); -+ } else { ++ else + rtw_write8(padapter, REG_GPIO_PIN_CTRL + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL + 1) & ~BIT(index)); -+ } + } else { + /* 88C Series: */ + /* index: 11~8 transform to 3~0 */ @@ -74252,11 +72233,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 2, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 2) | BIT(index)); + + /* set output value */ -+ if (OutPutValue) { ++ if (OutPutValue) + rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 1) | BIT(index)); -+ } else { ++ else + rtw_write8(padapter, REG_GPIO_PIN_CTRL_2 + 1, rtw_read8(padapter, REG_GPIO_PIN_CTRL_2 + 1) & ~BIT(index)); -+ } + } +} +#endif @@ -74290,8 +72270,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + /* only cmd52 can be used before power on(card enable) */ + ret = CardEnable(padapter); + if (ret == false) { -+ RT_TRACE(_module_hci_hal_init_c_, _drv_emerg_, -+ ("%s: run power on flow fail\n", __func__)); ++ RT_TRACE( ++ _module_hci_hal_init_c_, ++ _drv_emerg_, ++ ("%s: run power on flow fail\n", __func__) ++ ); + return _FAIL; + } + @@ -74315,8 +72298,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + rtw_write8(padapter, REG_CR, 0x00); + /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ + value16 = rtw_read16(padapter, REG_CR); -+ value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN -+ | PROTOCOL_EN | SCHEDULE_EN | ENSEC | CALTMR_EN); ++ value16 |= ( ++ HCI_TXDMA_EN | ++ HCI_RXDMA_EN | ++ TXDMA_EN | ++ RXDMA_EN | ++ PROTOCOL_EN | ++ SCHEDULE_EN | ++ ENSEC | ++ CALTMR_EN ++ ); + rtw_write16(padapter, REG_CR, value16); + + rtw_btcoex_PowerOnSetting(padapter); @@ -74370,30 +72361,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + +static void _InitQueueReservedPage(struct adapter *padapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + struct registry_priv *pregistrypriv = &padapter->registrypriv; -+ u32 numHQ = 0; -+ u32 numLQ = 0; -+ u32 numNQ = 0; -+ u32 numPubQ; -+ u32 value32; -+ u8 value8; -+ bool bWiFiConfig = pregistrypriv->wifi_spec; ++ u32 numHQ = 0; ++ u32 numLQ = 0; ++ u32 numNQ = 0; ++ u32 numPubQ; ++ u32 value32; ++ u8 value8; ++ bool bWiFiConfig = pregistrypriv->wifi_spec; + + if (pHalData->OutEpQueueSel & TX_SELE_HQ) -+ { + numHQ = bWiFiConfig ? WMM_NORMAL_PAGE_NUM_HPQ_8723B : NORMAL_PAGE_NUM_HPQ_8723B; -+ } + + if (pHalData->OutEpQueueSel & TX_SELE_LQ) -+ { + numLQ = bWiFiConfig ? WMM_NORMAL_PAGE_NUM_LPQ_8723B : NORMAL_PAGE_NUM_LPQ_8723B; -+ } + + /* NOTE: This step shall be proceed before writting REG_RQPN. */ -+ if (pHalData->OutEpQueueSel & TX_SELE_NQ) { ++ if (pHalData->OutEpQueueSel & TX_SELE_NQ) + numNQ = bWiFiConfig ? WMM_NORMAL_PAGE_NUM_NPQ_8723B : NORMAL_PAGE_NUM_NPQ_8723B; -+ } + + numPubQ = TX_TOTAL_PAGE_NUMBER_8723B - numHQ - numLQ - numNQ; + @@ -74430,162 +72416,146 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); +} + -+static void -+_InitNormalChipRegPriority( -+struct adapter *Adapter, -+u16 beQ, -+u16 bkQ, -+u16 viQ, -+u16 voQ, -+u16 mgtQ, -+u16 hiQ -+ ) ++static void _InitNormalChipRegPriority( ++ struct adapter *Adapter, ++ u16 beQ, ++ u16 bkQ, ++ u16 viQ, ++ u16 voQ, ++ u16 mgtQ, ++ u16 hiQ ++) +{ -+ u16 value16 = (rtw_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); ++ u16 value16 = (rtw_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); + -+ value16 |= _TXDMA_BEQ_MAP(beQ) | _TXDMA_BKQ_MAP(bkQ) | -+ _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | -+ _TXDMA_MGQ_MAP(mgtQ)| _TXDMA_HIQ_MAP(hiQ); ++ value16 |= ++ _TXDMA_BEQ_MAP(beQ) | ++ _TXDMA_BKQ_MAP(bkQ) | ++ _TXDMA_VIQ_MAP(viQ) | ++ _TXDMA_VOQ_MAP(voQ) | ++ _TXDMA_MGQ_MAP(mgtQ) | ++ _TXDMA_HIQ_MAP(hiQ); + + rtw_write16(Adapter, REG_TRXDMA_CTRL, value16); +} + -+static void -+_InitNormalChipOneOutEpPriority( -+struct adapter * Adapter -+ ) ++static void _InitNormalChipOneOutEpPriority(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + + u16 value = 0; -+ switch (pHalData->OutEpQueueSel) -+ { -+ case TX_SELE_HQ: -+ value = QUEUE_HIGH; -+ break; -+ case TX_SELE_LQ: -+ value = QUEUE_LOW; -+ break; -+ case TX_SELE_NQ: -+ value = QUEUE_NORMAL; -+ break; -+ default: -+ /* RT_ASSERT(false, ("Shall not reach here!\n")); */ -+ break; ++ switch (pHalData->OutEpQueueSel) { ++ case TX_SELE_HQ: ++ value = QUEUE_HIGH; ++ break; ++ case TX_SELE_LQ: ++ value = QUEUE_LOW; ++ break; ++ case TX_SELE_NQ: ++ value = QUEUE_NORMAL; ++ break; ++ default: ++ /* RT_ASSERT(false, ("Shall not reach here!\n")); */ ++ break; + } + -+ _InitNormalChipRegPriority(Adapter, -+ value, -+ value, -+ value, -+ value, -+ value, -+ value -+ ); ++ _InitNormalChipRegPriority( ++ Adapter, value, value, value, value, value, value ++ ); + +} + -+static void -+_InitNormalChipTwoOutEpPriority( -+struct adapter * Adapter -+ ) ++static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + struct registry_priv *pregistrypriv = &Adapter->registrypriv; -+ u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; ++ u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; + + + u16 valueHi = 0; + u16 valueLow = 0; + -+ switch (pHalData->OutEpQueueSel) -+ { -+ case (TX_SELE_HQ | TX_SELE_LQ): -+ valueHi = QUEUE_HIGH; -+ valueLow = QUEUE_LOW; -+ break; -+ case (TX_SELE_NQ | TX_SELE_LQ): -+ valueHi = QUEUE_NORMAL; -+ valueLow = QUEUE_LOW; -+ break; -+ case (TX_SELE_HQ | TX_SELE_NQ): -+ valueHi = QUEUE_HIGH; -+ valueLow = QUEUE_NORMAL; -+ break; -+ default: -+ /* RT_ASSERT(false, ("Shall not reach here!\n")); */ -+ break; ++ switch (pHalData->OutEpQueueSel) { ++ case (TX_SELE_HQ | TX_SELE_LQ): ++ valueHi = QUEUE_HIGH; ++ valueLow = QUEUE_LOW; ++ break; ++ case (TX_SELE_NQ | TX_SELE_LQ): ++ valueHi = QUEUE_NORMAL; ++ valueLow = QUEUE_LOW; ++ break; ++ case (TX_SELE_HQ | TX_SELE_NQ): ++ valueHi = QUEUE_HIGH; ++ valueLow = QUEUE_NORMAL; ++ break; ++ default: ++ /* RT_ASSERT(false, ("Shall not reach here!\n")); */ ++ break; + } + + if (!pregistrypriv->wifi_spec) { -+ beQ = valueLow; -+ bkQ = valueLow; -+ viQ = valueHi; -+ voQ = valueHi; -+ mgtQ = valueHi; -+ hiQ = valueHi; -+ } -+ else {/* for WMM , CONFIG_OUT_EP_WIFI_MODE */ -+ beQ = valueLow; -+ bkQ = valueHi; -+ viQ = valueHi; -+ voQ = valueLow; -+ mgtQ = valueHi; -+ hiQ = valueHi; ++ beQ = valueLow; ++ bkQ = valueLow; ++ viQ = valueHi; ++ voQ = valueHi; ++ mgtQ = valueHi; ++ hiQ = valueHi; ++ } else { ++ /* for WMM , CONFIG_OUT_EP_WIFI_MODE */ ++ beQ = valueLow; ++ bkQ = valueHi; ++ viQ = valueHi; ++ voQ = valueLow; ++ mgtQ = valueHi; ++ hiQ = valueHi; + } + + _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); + +} + -+static void -+_InitNormalChipThreeOutEpPriority( -+struct adapter *padapter -+ ) ++static void _InitNormalChipThreeOutEpPriority(struct adapter *padapter) +{ + struct registry_priv *pregistrypriv = &padapter->registrypriv; -+ u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; ++ u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; + -+ if (!pregistrypriv->wifi_spec) {/* typical setting */ -+ beQ = QUEUE_LOW; -+ bkQ = QUEUE_LOW; -+ viQ = QUEUE_NORMAL; -+ voQ = QUEUE_HIGH; -+ mgtQ = QUEUE_HIGH; -+ hiQ = QUEUE_HIGH; -+ } -+ else {/* for WMM */ -+ beQ = QUEUE_LOW; -+ bkQ = QUEUE_NORMAL; -+ viQ = QUEUE_NORMAL; -+ voQ = QUEUE_HIGH; -+ mgtQ = QUEUE_HIGH; -+ hiQ = QUEUE_HIGH; ++ if (!pregistrypriv->wifi_spec) { ++ /* typical setting */ ++ beQ = QUEUE_LOW; ++ bkQ = QUEUE_LOW; ++ viQ = QUEUE_NORMAL; ++ voQ = QUEUE_HIGH; ++ mgtQ = QUEUE_HIGH; ++ hiQ = QUEUE_HIGH; ++ } else { ++ /* for WMM */ ++ beQ = QUEUE_LOW; ++ bkQ = QUEUE_NORMAL; ++ viQ = QUEUE_NORMAL; ++ voQ = QUEUE_HIGH; ++ mgtQ = QUEUE_HIGH; ++ hiQ = QUEUE_HIGH; + } + _InitNormalChipRegPriority(padapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); +} + -+static void -+_InitNormalChipQueuePriority( -+struct adapter * Adapter -+ ) ++static void _InitNormalChipQueuePriority(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + -+ switch (pHalData->OutEpNumber) -+ { -+ case 1: -+ _InitNormalChipOneOutEpPriority(Adapter); -+ break; -+ case 2: -+ _InitNormalChipTwoOutEpPriority(Adapter); -+ break; -+ case 3: -+ _InitNormalChipThreeOutEpPriority(Adapter); -+ break; -+ default: -+ /* RT_ASSERT(false, ("Shall not reach here!\n")); */ -+ break; ++ switch (pHalData->OutEpNumber) { ++ case 1: ++ _InitNormalChipOneOutEpPriority(Adapter); ++ break; ++ case 2: ++ _InitNormalChipTwoOutEpPriority(Adapter); ++ break; ++ case 3: ++ _InitNormalChipThreeOutEpPriority(Adapter); ++ break; ++ default: ++ /* RT_ASSERT(false, ("Shall not reach here!\n")); */ ++ break; + } + + @@ -74728,16 +72698,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + + pregistrypriv = &padapter->registrypriv; + -+ if (pregistrypriv->wifi_spec) -+ { ++ if (pregistrypriv->wifi_spec) { + /* 2010.04.27 hpfan */ + /* Adjust RxAggrTimeout to close to zero disable RxAggr, suggested by designer */ + /* Timeout value is calculated by 34 / (2^n) */ + valueDMATimeout = 0x06; + valueDMAPageCount = 0x06; -+ } -+ else -+ { ++ } else { + /* 20130530, Isaac@SD1 suggest 3 kinds of parameter */ + /* TX/RX Balance */ + valueDMATimeout = 0x06; @@ -74788,8 +72755,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 +{ + struct hal_com_data *pHalData; + struct mlme_ext_priv *pmlmeext; -+ u8 regBwOpMode = 0; -+ u32 regRATR = 0, regRRSR = 0; ++ u8 regBwOpMode = 0; ++ u32 regRATR = 0, regRRSR = 0; + + pHalData = GET_HAL_DATA(padapter); + pmlmeext = &padapter->mlmeextpriv; @@ -74798,42 +72765,41 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + /* */ + /* Set RRSR, RATR, and REG_BWOPMODE registers */ + /* */ -+ switch (pmlmeext->cur_wireless_mode) -+ { -+ case WIRELESS_MODE_B: -+ regBwOpMode = BW_OPMODE_20MHZ; -+ regRATR = RATE_ALL_CCK; -+ regRRSR = RATE_ALL_CCK; -+ break; -+ case WIRELESS_MODE_A: ++ switch (pmlmeext->cur_wireless_mode) { ++ case WIRELESS_MODE_B: ++ regBwOpMode = BW_OPMODE_20MHZ; ++ regRATR = RATE_ALL_CCK; ++ regRRSR = RATE_ALL_CCK; ++ break; ++ case WIRELESS_MODE_A: +/* RT_ASSERT(false, ("Error wireless a mode\n")); */ -+ break; -+ case WIRELESS_MODE_G: -+ regBwOpMode = BW_OPMODE_20MHZ; -+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; -+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; -+ break; -+ case WIRELESS_MODE_AUTO: -+ regBwOpMode = BW_OPMODE_20MHZ; -+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; -+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; -+ break; -+ case WIRELESS_MODE_N_24G: -+ /* It support CCK rate by default. */ -+ /* CCK rate will be filtered out only when associated AP does not support it. */ -+ regBwOpMode = BW_OPMODE_20MHZ; -+ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; -+ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; -+ break; -+ case WIRELESS_MODE_N_5G: ++ break; ++ case WIRELESS_MODE_G: ++ regBwOpMode = BW_OPMODE_20MHZ; ++ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; ++ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; ++ break; ++ case WIRELESS_MODE_AUTO: ++ regBwOpMode = BW_OPMODE_20MHZ; ++ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; ++ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; ++ break; ++ case WIRELESS_MODE_N_24G: ++ /* It support CCK rate by default. */ ++ /* CCK rate will be filtered out only when associated AP does not support it. */ ++ regBwOpMode = BW_OPMODE_20MHZ; ++ regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; ++ regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; ++ break; ++ case WIRELESS_MODE_N_5G: +/* RT_ASSERT(false, ("Error wireless mode")); */ -+ regBwOpMode = BW_OPMODE_5G; -+ regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; -+ regRRSR = RATE_ALL_OFDM_AG; -+ break; ++ regBwOpMode = BW_OPMODE_5G; ++ regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; ++ regRRSR = RATE_ALL_OFDM_AG; ++ break; + -+ default: /* for MacOSX compiler warning. */ -+ break; ++ default: /* for MacOSX compiler warning. */ ++ break; + } + + rtw_write8(padapter, REG_BWOPMODE, regBwOpMode); @@ -74882,7 +72848,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 +/* */ +/* 2010/08/09 MH Add for power down check. */ +/* */ -+static bool HalDetectPwrDownMode(struct adapter * Adapter) ++static bool HalDetectPwrDownMode(struct adapter *Adapter) +{ + u8 tmpvalue; + struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); @@ -74893,13 +72859,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + + /* 2010/08/25 MH INF priority > PDN Efuse value. */ + if (tmpvalue & BIT4 && pwrctrlpriv->reg_pdnmode) -+ { + pHalData->pwrdown = true; -+ } + else -+ { + pHalData->pwrdown = false; -+ } + + DBG_8192C("HalDetectPwrDownMode(): PDN =%d\n", pHalData->pwrdown); + @@ -74919,9 +72881,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + pwrctrlpriv = adapter_to_pwrctl(padapter); + pregistrypriv = &padapter->registrypriv; + -+ if (adapter_to_pwrctl(padapter)->bips_processing == true -+ && adapter_to_pwrctl(padapter)->pre_ips_type == 0) -+ { ++ if ( ++ adapter_to_pwrctl(padapter)->bips_processing == true && ++ adapter_to_pwrctl(padapter)->pre_ips_type == 0 ++ ) { + unsigned long start_time; + u8 cpwm_orig, cpwm_now; + u8 val8, bMacPwrCtrlOn = true; @@ -74949,12 +72912,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + + rtw_hal_get_hwreg(padapter, HW_VAR_CPWM, &cpwm_now); + if ((cpwm_orig ^ cpwm_now) & 0x80) -+ { + break; -+ } + -+ if (jiffies_to_msecs(jiffies - start_time) > 100) -+ { ++ if (jiffies_to_msecs(jiffies - start_time) > 100) { + DBG_871X("%s: polling cpwm timeout when leaving IPS in FWLPS state\n", __func__); + break; + } @@ -75020,9 +72980,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + +/* SIC_Init(padapter); */ + -+ if (pwrctrlpriv->reg_rfoff == true) { ++ if (pwrctrlpriv->reg_rfoff == true) + pwrctrlpriv->rf_pwrstate = rf_off; -+ } + + /* 2010/08/09 MH We need to check if we need to turnon or off RF after detecting */ + /* HW GPIO pin. Before PHY_RFConfig8192C. */ @@ -75069,8 +73028,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + /* */ + /* Joseph Note: Keep RfRegChnlVal for later use. */ + /* */ -+ pHalData->RfRegChnlVal[0] = PHY_QueryRFReg(padapter, (enum RF_PATH)0, RF_CHNLBW, bRFRegOffsetMask); -+ pHalData->RfRegChnlVal[1] = PHY_QueryRFReg(padapter, (enum RF_PATH)1, RF_CHNLBW, bRFRegOffsetMask); ++ pHalData->RfRegChnlVal[0] = ++ PHY_QueryRFReg(padapter, (enum RF_PATH)0, RF_CHNLBW, bRFRegOffsetMask); ++ pHalData->RfRegChnlVal[1] = ++ PHY_QueryRFReg(padapter, (enum RF_PATH)1, RF_CHNLBW, bRFRegOffsetMask); + + + /* if (!pHalData->bMACFuncEnable) { */ @@ -75167,8 +73128,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + { + pwrctrlpriv->rf_pwrstate = rf_on; + -+ if (pwrctrlpriv->rf_pwrstate == rf_on) -+ { ++ if (pwrctrlpriv->rf_pwrstate == rf_on) { + struct pwrctrl_priv *pwrpriv; + unsigned long start_time; + u8 restore_iqk_rst; @@ -75193,8 +73153,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + + rtw_btcoex_IQKNotify(padapter, true); + -+ restore_iqk_rst = (pwrpriv->bips_processing ==true)?true:false; -+ b2Ant = pHalData->EEPROMBluetoothAntNum ==Ant_x2?true:false; ++ restore_iqk_rst = (pwrpriv->bips_processing == true) ? true : false; ++ b2Ant = pHalData->EEPROMBluetoothAntNum == Ant_x2 ? true : false; + PHY_IQCalibrate_8723B(padapter, false, restore_iqk_rst, b2Ant, pHalData->ant_path); + pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized = true; + @@ -75270,15 +73230,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + +static u32 rtl8723bs_hal_deinit(struct adapter *padapter) +{ -+ struct dvobj_priv *psdpriv = padapter->dvobj; ++ struct dvobj_priv *psdpriv = padapter->dvobj; + struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; + -+ if (padapter->hw_init_completed == true) -+ { -+ if (adapter_to_pwrctl(padapter)->bips_processing == true) -+ { -+ if (padapter->netif_up == true) -+ { ++ if (padapter->hw_init_completed == true) { ++ if (adapter_to_pwrctl(padapter)->bips_processing == true) { ++ if (padapter->netif_up == true) { + int cnt = 0; + u8 val8 = 0; + @@ -75286,15 +73243,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + + rtl8723b_set_FwPwrModeInIPS_cmd(padapter, 0x3); + /* poll 0x1cc to make sure H2C command already finished by FW; MAC_0x1cc = 0 means H2C done by FW. */ -+ do{ ++ do { + val8 = rtw_read8(padapter, REG_HMETFR); + cnt++; + DBG_871X("%s polling REG_HMETFR = 0x%x, cnt =%d\n", __func__, val8, cnt); + mdelay(10); -+ }while (cnt<100 && (val8!= 0)); ++ } while (cnt < 100 && (val8 != 0)); + /* H2C done, enter 32k */ -+ if (val8 == 0) -+ { ++ if (val8 == 0) { + /* ser rpwm to enter 32k */ + val8 = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1); + val8 += 0x80; @@ -75303,44 +73259,44 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + DBG_871X("%s: write rpwm =%02x\n", __func__, val8); + adapter_to_pwrctl(padapter)->tog = (val8 + 0x80) & 0x80; + cnt = val8 = 0; -+ do{ ++ do { + val8 = rtw_read8(padapter, REG_CR); + cnt++; + DBG_871X("%s polling 0x100 = 0x%x, cnt =%d\n", __func__, val8, cnt); + mdelay(10); -+ }while (cnt<100 && (val8!= 0xEA)); -+ } -+ else -+ { -+ DBG_871X("MAC_1C0 =%08x, MAC_1C4 =%08x, MAC_1C8 =%08x, MAC_1CC =%08x\n", rtw_read32(padapter, 0x1c0), rtw_read32(padapter, 0x1c4) -+ , rtw_read32(padapter, 0x1c8), rtw_read32(padapter, 0x1cc)); ++ } while (cnt < 100 && (val8 != 0xEA)); ++ } else { ++ DBG_871X( ++ "MAC_1C0 =%08x, MAC_1C4 =%08x, MAC_1C8 =%08x, MAC_1CC =%08x\n", ++ rtw_read32(padapter, 0x1c0), ++ rtw_read32(padapter, 0x1c4), ++ rtw_read32(padapter, 0x1c8), ++ rtw_read32(padapter, 0x1cc) ++ ); + } + -+ DBG_871X("polling done when entering IPS, check result : 0x100 = 0x%x, cnt =%d, MAC_1cc = 0x%02x\n" -+ , rtw_read8(padapter, REG_CR), cnt, rtw_read8(padapter, REG_HMETFR)); ++ DBG_871X( ++ "polling done when entering IPS, check result : 0x100 = 0x%x, cnt =%d, MAC_1cc = 0x%02x\n", ++ rtw_read8(padapter, REG_CR), ++ cnt, ++ rtw_read8(padapter, REG_HMETFR) ++ ); + + adapter_to_pwrctl(padapter)->pre_ips_type = 0; + -+ } -+ else -+ { ++ } else { + pdbgpriv->dbg_carddisable_cnt++; + CardDisableRTL8723BSdio(padapter); + + adapter_to_pwrctl(padapter)->pre_ips_type = 1; + } + -+ } -+ else -+ { ++ } else { + pdbgpriv->dbg_carddisable_cnt++; + CardDisableRTL8723BSdio(padapter); + } -+ } -+ else -+ { ++ } else + pdbgpriv->dbg_deinit_fail_cnt++; -+ } + + return _SUCCESS; +} @@ -75374,10 +73330,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + +static void rtl8723bs_interface_configure(struct adapter *padapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); -+ struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + struct registry_priv *pregistrypriv = &padapter->registrypriv; -+ bool bWiFiConfig = pregistrypriv->wifi_spec; ++ bool bWiFiConfig = pregistrypriv->wifi_spec; + + + pdvobjpriv->RtOutPipe[0] = WLAN_TX_HIQ_DEVICE_ID; @@ -75390,17 +73346,17 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + pHalData->OutEpNumber = SDIO_MAX_TX_QUEUE; + + switch (pHalData->OutEpNumber) { -+ case 3: -+ pHalData->OutEpQueueSel =TX_SELE_HQ| TX_SELE_LQ|TX_SELE_NQ; -+ break; -+ case 2: -+ pHalData->OutEpQueueSel =TX_SELE_HQ| TX_SELE_NQ; -+ break; -+ case 1: -+ pHalData->OutEpQueueSel =TX_SELE_HQ; -+ break; -+ default: -+ break; ++ case 3: ++ pHalData->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ|TX_SELE_NQ; ++ break; ++ case 2: ++ pHalData->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ; ++ break; ++ case 1: ++ pHalData->OutEpQueueSel = TX_SELE_HQ; ++ break; ++ default: ++ break; + } + + Hal_MappingOutPipe(padapter, pHalData->OutEpNumber); @@ -75415,24 +73371,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 +/* */ +/* Added by Roger, 2010.11.23. */ +/* */ -+static void -+_EfuseCellSel( -+struct adapter *padapter -+ ) ++static void _EfuseCellSel(struct adapter *padapter) +{ -+ u32 value32; ++ u32 value32; + + value32 = rtw_read32(padapter, EFUSE_TEST); + value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0); + rtw_write32(padapter, EFUSE_TEST, value32); +} + -+static void -+_ReadRFType( -+struct adapter *Adapter -+ ) ++static void _ReadRFType(struct adapter *Adapter) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); + +#if DISABLE_BB_RF + pHalData->rf_chip = RF_PSEUDO_11N; @@ -75442,64 +73392,58 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 +} + + -+static void -+Hal_EfuseParseMACAddr_8723BS( -+struct adapter * padapter, -+u8* hwinfo, -+bool AutoLoadFail -+ ) ++static void Hal_EfuseParseMACAddr_8723BS( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ -+ u16 i; -+ u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0xb7, 0x23, 0x00}; ++ u16 i; ++ u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0xb7, 0x23, 0x00}; + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + -+ if (AutoLoadFail) -+ { ++ if (AutoLoadFail) { +/* sMacAddr[5] = (u8)GetRandomNumber(1, 254); */ -+ for (i = 0; i<6; i++) ++ for (i = 0; i < 6; i++) + pEEPROM->mac_addr[i] = sMacAddr[i]; -+ } -+ else -+ { ++ } else { + /* Read Permanent MAC address */ + memcpy(pEEPROM->mac_addr, &hwinfo[EEPROM_MAC_ADDR_8723BS], ETH_ALEN); + } +/* NicIFSetMacAddress(padapter, padapter->PermanentAddress); */ + -+ RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, -+ ("Hal_EfuseParseMACAddr_8723BS: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", -+ pEEPROM->mac_addr[0], pEEPROM->mac_addr[1], -+ pEEPROM->mac_addr[2], pEEPROM->mac_addr[3], -+ pEEPROM->mac_addr[4], pEEPROM->mac_addr[5])); ++ RT_TRACE( ++ _module_hci_hal_init_c_, ++ _drv_notice_, ++ ( ++ "Hal_EfuseParseMACAddr_8723BS: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", ++ pEEPROM->mac_addr[0], ++ pEEPROM->mac_addr[1], ++ pEEPROM->mac_addr[2], ++ pEEPROM->mac_addr[3], ++ pEEPROM->mac_addr[4], ++ pEEPROM->mac_addr[5] ++ ) ++ ); +} + -+static void -+Hal_EfuseParseBoardType_8723BS( -+struct adapter * padapter, -+u8* hwinfo, -+bool AutoLoadFail -+ ) ++static void Hal_EfuseParseBoardType_8723BS( ++ struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail ++) +{ -+ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ struct hal_com_data *pHalData = GET_HAL_DATA(padapter); + -+ if (!AutoLoadFail) -+ { ++ if (!AutoLoadFail) { + pHalData->BoardType = (hwinfo[EEPROM_RF_BOARD_OPTION_8723B] & 0xE0) >> 5; + if (pHalData->BoardType == 0xFF) + pHalData->BoardType = (EEPROM_DEFAULT_BOARD_OPTION&0xE0)>>5; -+ } -+ else ++ } else + pHalData->BoardType = 0; + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Board Type: 0x%2x\n", pHalData->BoardType)); +} + -+static void -+_ReadEfuseInfo8723BS( -+ struct adapter * padapter -+ ) ++static void _ReadEfuseInfo8723BS(struct adapter *padapter) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); -+ u8* hwinfo = NULL; ++ u8 *hwinfo = NULL; + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("====>_ReadEfuseInfo8723BS()\n")); + @@ -75525,10 +73469,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + /* */ + /* Read Bluetooth co-exist and initialize */ + /* */ ++ Hal_EfuseParsePackageType_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag); + Hal_EfuseParseBTCoexistInfo_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag); + Hal_EfuseParseChnlPlan_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag); + Hal_EfuseParseXtal_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag); -+ Hal_EfuseParsePackageType_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag); + Hal_EfuseParseThermalMeter_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag); + Hal_EfuseParseAntennaDiversity_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag); + Hal_EfuseParseCustomerID_8723B(padapter, hwinfo, pEEPROM->bautoload_fail_flag); @@ -75544,9 +73488,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<==== _ReadEfuseInfo8723BS()\n")); +} + -+static void _ReadPROMContent( -+ struct adapter * padapter -+ ) ++static void _ReadPROMContent(struct adapter *padapter) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + u8 eeValue; @@ -75567,10 +73509,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + _ReadEfuseInfo8723BS(padapter); +} + -+static void -+_InitOtherVariable( -+ struct adapter * Adapter -+ ) ++static void _InitOtherVariable(struct adapter *Adapter) +{ +} + @@ -75607,8 +73546,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + _ReadPROMContent(padapter); + _InitOtherVariable(padapter); + -+ if (padapter->hw_init_completed == false) -+ { ++ if (padapter->hw_init_completed == false) { + rtw_write8(padapter, 0x67, 0x00); /* for BT, Switch Ant control to BT */ + CardDisableRTL8723BSdio(padapter);/* for the power consumption issue, wifi ko module is loaded during booting, but wifi GUI is off */ + } @@ -75655,228 +73593,246 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + + pHalData = GET_HAL_DATA(padapter); + -+ switch (variable) -+ { -+ case HW_VAR_SET_RPWM: -+ /* rpwm value only use BIT0(clock bit) , BIT6(Ack bit), and BIT7(Toggle bit) */ -+ /* BIT0 value - 1: 32k, 0:40MHz. */ -+ /* BIT6 value - 1: report cpwm value after success set, 0:do not report. */ -+ /* BIT7 value - Toggle bit change. */ -+ { -+ val8 = *val; -+ val8 &= 0xC1; -+ rtw_write8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1, val8); -+ } -+ break; -+ case HW_VAR_SET_REQ_FW_PS: -+ { -+ u8 req_fw_ps = 0; -+ req_fw_ps = rtw_read8(padapter, 0x8f); -+ req_fw_ps |= 0x10; -+ rtw_write8(padapter, 0x8f, req_fw_ps); -+ } -+ break; -+ case HW_VAR_RXDMA_AGG_PG_TH: -+ val8 = *val; -+ break; -+ -+#ifdef CONFIG_WOWLAN -+ case HW_VAR_WOWLAN: ++ switch (variable) { ++ case HW_VAR_SET_RPWM: ++ /* rpwm value only use BIT0(clock bit) , BIT6(Ack bit), and BIT7(Toggle bit) */ ++ /* BIT0 value - 1: 32k, 0:40MHz. */ ++ /* BIT6 value - 1: report cpwm value after success set, 0:do not report. */ ++ /* BIT7 value - Toggle bit change. */ + { -+ poidparam = (struct wowlan_ioctl_param *)val; -+ switch (poidparam->subcode) { -+ case WOWLAN_ENABLE: -+ DBG_871X_LEVEL(_drv_always_, "WOWLAN_ENABLE\n"); -+ -+ /* backup data rate to register 0x8b for wowlan FW */ -+ rtw_write8(padapter, 0x8d, 1); -+ rtw_write8(padapter, 0x8c, 0); -+ rtw_write8(padapter, 0x8f, 0x40); -+ rtw_write8(padapter, 0x8b, -+ rtw_read8(padapter, 0x2f0)); -+ -+ /* 1. Download WOWLAN FW */ -+ DBG_871X_LEVEL(_drv_always_, "Re-download WoWlan FW!\n"); -+ SetFwRelatedForWoWLAN8723b(padapter, true); -+ -+ /* 2. RX DMA stop */ -+ DBG_871X_LEVEL(_drv_always_, "Pause DMA\n"); -+ rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); -+ do{ -+ if ((rtw_read32(padapter, REG_RXPKT_NUM)&RXDMA_IDLE)) { -+ DBG_871X_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n"); -+ break; -+ } else { -+ /* If RX_DMA is not idle, receive one pkt from DMA */ -+ res = sdio_local_read(padapter, SDIO_REG_RX0_REQ_LEN, 4, (u8 *)&tmp); -+ len = le16_to_cpu(tmp); -+ DBG_871X_LEVEL(_drv_always_, "RX len:%d\n", len); -+ if (len > 0) -+ res = RecvOnePkt(padapter, len); -+ else -+ DBG_871X_LEVEL(_drv_always_, "read length fail %d\n", len); -+ -+ DBG_871X_LEVEL(_drv_always_, "RecvOnePkt Result: %d\n", res); -+ } -+ }while (trycnt--); -+ if (trycnt == 0) -+ DBG_871X_LEVEL(_drv_always_, "Stop RX DMA failed......\n"); -+ -+ /* 3. Clear IMR and ISR */ -+ DBG_871X_LEVEL(_drv_always_, "Clear IMR and ISR\n"); -+ tmp = 0; -+ sdio_local_write(padapter, SDIO_REG_HIMR_ON, 4, (u8 *)&tmp); -+ sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); -+ sdio_local_read(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp); -+ sdio_local_write(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp); -+ -+ /* 4. Enable CPWM2 only */ -+ DBG_871X_LEVEL(_drv_always_, "Enable only CPWM2\n"); -+ sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); -+ DBG_871X("DisableInterruptButCpwm28723BSdio(): Read SDIO_REG_HIMR: 0x%08x\n", tmp); -+ -+ himr = cpu_to_le32(SDIO_HIMR_DISABLED)|SDIO_HIMR_CPWM2_MSK; -+ sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr); -+ -+ sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); -+ DBG_871X("DisableInterruptButCpwm28723BSdio(): Read again SDIO_REG_HIMR: 0x%08x\n", tmp); -+ -+ /* 5. Set Enable WOWLAN H2C command. */ -+ DBG_871X_LEVEL(_drv_always_, "Set Enable WOWLan cmd\n"); -+ rtl8723b_set_wowlan_cmd(padapter, 1); -+ -+ /* 6. Check EnableWoWlan CMD is ready */ -+ if (!pwrctl->wowlan_pno_enable) { -+ DBG_871X_LEVEL(_drv_always_, "Check EnableWoWlan CMD is ready\n"); -+ mstatus = rtw_read8(padapter, REG_WOW_CTRL); -+ trycnt = 10; -+ while (!(mstatus&BIT1) && trycnt>1) { -+ mstatus = rtw_read8(padapter, REG_WOW_CTRL); -+ DBG_871X("Loop index: %d :0x%02x\n", trycnt, mstatus); -+ trycnt --; -+ msleep(2); -+ } -+ } -+ break; -+ -+ case WOWLAN_DISABLE: -+ DBG_871X_LEVEL(_drv_always_, "WOWLAN_DISABLE\n"); -+ -+ psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv)); -+ if (psta != NULL) -+ rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_DISCONNECT, psta->mac_id); -+ else -+ DBG_871X("psta is null\n"); -+ -+ /* 1. Read wakeup reason */ -+ pwrctl->wowlan_wake_reason = rtw_read8(padapter, REG_WOWLAN_WAKE_REASON); -+ DBG_871X_LEVEL(_drv_always_, "wakeup_reason: 0x%02x, mac_630 = 0x%08x, mac_634 = 0x%08x, mac_1c0 = 0x%08x, mac_1c4 = 0x%08x" -+ ", mac_494 = 0x%08x, , mac_498 = 0x%08x, mac_49c = 0x%08x, mac_608 = 0x%08x, mac_4a0 = 0x%08x, mac_4a4 = 0x%08x\n" -+ ", mac_1cc = 0x%08x, mac_2f0 = 0x%08x, mac_2f4 = 0x%08x, mac_2f8 = 0x%08x, mac_2fc = 0x%08x, mac_8c = 0x%08x" -+ , pwrctl->wowlan_wake_reason, rtw_read32(padapter, REG_WOWLAN_GTK_DBG1), rtw_read32(padapter, REG_WOWLAN_GTK_DBG2) -+ , rtw_read32(padapter, 0x1c0), rtw_read32(padapter, 0x1c4) -+ , rtw_read32(padapter, 0x494), rtw_read32(padapter, 0x498), rtw_read32(padapter, 0x49c), rtw_read32(padapter, 0x608) -+ , rtw_read32(padapter, 0x4a0), rtw_read32(padapter, 0x4a4) -+ , rtw_read32(padapter, 0x1cc), rtw_read32(padapter, 0x2f0), rtw_read32(padapter, 0x2f4), rtw_read32(padapter, 0x2f8) -+ , rtw_read32(padapter, 0x2fc), rtw_read32(padapter, 0x8c)); -+#ifdef CONFIG_PNO_SET_DEBUG -+ DBG_871X("0x1b9: 0x%02x, 0x632: 0x%02x\n", rtw_read8(padapter, 0x1b9), rtw_read8(padapter, 0x632)); -+ DBG_871X("0x4fc: 0x%02x, 0x4fd: 0x%02x\n", rtw_read8(padapter, 0x4fc), rtw_read8(padapter, 0x4fd)); -+ DBG_871X("TXDMA STATUS: 0x%08x\n", rtw_read32(padapter, REG_TXDMA_STATUS)); -+#endif -+ -+ { -+ /* 2. Set Disable WOWLAN H2C command. */ -+ DBG_871X_LEVEL(_drv_always_, "Set Disable WOWLan cmd\n"); -+ rtl8723b_set_wowlan_cmd(padapter, 0); -+ -+ /* 3. Check Disable WoWlan CMD ready. */ -+ DBG_871X_LEVEL(_drv_always_, "Check DisableWoWlan CMD is ready\n"); -+ mstatus = rtw_read8(padapter, REG_WOW_CTRL); -+ trycnt = 50; -+ while (mstatus&BIT1 && trycnt>1) { -+ mstatus = rtw_read8(padapter, REG_WOW_CTRL); -+ DBG_871X_LEVEL(_drv_always_, "Loop index: %d :0x%02x\n", trycnt, mstatus); -+ trycnt --; -+ msleep(10); -+ } -+ -+ if (mstatus & BIT1) { -+ DBG_871X_LEVEL(_drv_always_, "Disable WOW mode fail!!\n"); -+ DBG_871X("Set 0x690 = 0x00\n"); -+ rtw_write8(padapter, REG_WOW_CTRL, (rtw_read8(padapter, REG_WOW_CTRL)&0xf0)); -+ DBG_871X_LEVEL(_drv_always_, "Release RXDMA\n"); -+ rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM)&(~RW_RELEASE_EN))); -+ } -+ -+ /* 3.1 read fw iv */ -+ iv_low = rtw_read32(padapter, REG_TXPKTBUF_IV_LOW); -+ /* only low two bytes is PN, check AES_IV macro for detail */ -+ iv_low &= 0xffff; -+ iv_high = rtw_read32(padapter, REG_TXPKTBUF_IV_HIGH); -+ /* get the real packet number */ -+ pwrctl->wowlan_fw_iv = iv_high << 16 | iv_low; -+ DBG_871X_LEVEL(_drv_always_, "fw_iv: 0x%016llx\n", pwrctl->wowlan_fw_iv); -+ /* Update TX iv data. */ -+ rtw_set_sec_pn(padapter); -+ -+ /* 3.2 read GTK index and key */ -+ if (psecuritypriv->binstallKCK_KEK == true && psecuritypriv->dot11PrivacyAlgrthm == _AES_) -+ { -+ u8 gtk_keyindex = 0; -+ u8 get_key[16]; -+ /* read gtk key index */ -+ gtk_keyindex = rtw_read8(padapter, 0x48c); -+ -+ if (gtk_keyindex < 4) -+ { -+ psecuritypriv->dot118021XGrpKeyid = gtk_keyindex; -+ read_cam(padapter , gtk_keyindex, get_key); -+ memcpy(psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, get_key, 16); -+ DBG_871X_LEVEL(_drv_always_, "GTK (%d) = 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", gtk_keyindex, -+ psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[0], -+ psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[1], -+ psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[2], -+ psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[3]); -+ } -+ else -+ DBG_871X_LEVEL(_drv_always_, "GTK index =%d\n", gtk_keyindex); -+ } -+ -+ /* 4. Re-download Normal FW. */ -+ DBG_871X_LEVEL(_drv_always_, "Re-download Normal FW!\n"); -+ SetFwRelatedForWoWLAN8723b(padapter, false); -+ } -+#ifdef CONFIG_GPIO_WAKEUP -+ DBG_871X_LEVEL(_drv_always_, "Set Wake GPIO to high for default.\n"); -+ HalSetOutPutGPIO(padapter, WAKEUP_GPIO_IDX, 1); -+#endif -+ -+ /* 5. Download reserved pages and report media status if needed. */ -+ if ((pwrctl->wowlan_wake_reason != FWDecisionDisconnect) && -+ (pwrctl->wowlan_wake_reason != Rx_Pairwisekey) && -+ (pwrctl->wowlan_wake_reason != Rx_DisAssoc) && -+ (pwrctl->wowlan_wake_reason != Rx_DeAuth)) -+ { -+ rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT); -+ if (psta != NULL) -+ rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id); -+ } -+#ifdef CONFIG_PNO_SUPPORT -+ rtw_write8(padapter, 0x1b8, 0); -+ DBG_871X("reset 0x1b8: %d\n", rtw_read8(padapter, 0x1b8)); -+ rtw_write8(padapter, 0x1b9, 0); -+ DBG_871X("reset 0x1b9: %d\n", rtw_read8(padapter, 0x1b9)); -+ rtw_write8(padapter, REG_PNO_STATUS, 0); -+ DBG_871X("reset REG_PNO_STATUS: %d\n", rtw_read8(padapter, REG_PNO_STATUS)); -+#endif -+ break; -+ -+ default: -+ break; -+ } ++ val8 = *val; ++ val8 &= 0xC1; ++ rtw_write8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1, val8); + } + break; ++ case HW_VAR_SET_REQ_FW_PS: ++ { ++ u8 req_fw_ps = 0; ++ req_fw_ps = rtw_read8(padapter, 0x8f); ++ req_fw_ps |= 0x10; ++ rtw_write8(padapter, 0x8f, req_fw_ps); ++ } ++ break; ++ case HW_VAR_RXDMA_AGG_PG_TH: ++ val8 = *val; ++ break; ++ ++#ifdef CONFIG_WOWLAN ++ case HW_VAR_WOWLAN: ++ { ++ poidparam = (struct wowlan_ioctl_param *)val; ++ switch (poidparam->subcode) { ++ case WOWLAN_ENABLE: ++ DBG_871X_LEVEL(_drv_always_, "WOWLAN_ENABLE\n"); ++ ++ /* backup data rate to register 0x8b for wowlan FW */ ++ rtw_write8(padapter, 0x8d, 1); ++ rtw_write8(padapter, 0x8c, 0); ++ rtw_write8(padapter, 0x8f, 0x40); ++ rtw_write8(padapter, 0x8b, ++ rtw_read8(padapter, 0x2f0)); ++ ++ /* 1. Download WOWLAN FW */ ++ DBG_871X_LEVEL(_drv_always_, "Re-download WoWlan FW!\n"); ++ SetFwRelatedForWoWLAN8723b(padapter, true); ++ ++ /* 2. RX DMA stop */ ++ DBG_871X_LEVEL(_drv_always_, "Pause DMA\n"); ++ rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); ++ do { ++ if ((rtw_read32(padapter, REG_RXPKT_NUM)&RXDMA_IDLE)) { ++ DBG_871X_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n"); ++ break; ++ } else { ++ /* If RX_DMA is not idle, receive one pkt from DMA */ ++ res = sdio_local_read(padapter, SDIO_REG_RX0_REQ_LEN, 4, (u8 *)&tmp); ++ len = le16_to_cpu(tmp); ++ DBG_871X_LEVEL(_drv_always_, "RX len:%d\n", len); ++ if (len > 0) ++ res = RecvOnePkt(padapter, len); ++ else ++ DBG_871X_LEVEL(_drv_always_, "read length fail %d\n", len); ++ ++ DBG_871X_LEVEL(_drv_always_, "RecvOnePkt Result: %d\n", res); ++ } ++ } while (trycnt--); ++ if (trycnt == 0) ++ DBG_871X_LEVEL(_drv_always_, "Stop RX DMA failed......\n"); ++ ++ /* 3. Clear IMR and ISR */ ++ DBG_871X_LEVEL(_drv_always_, "Clear IMR and ISR\n"); ++ tmp = 0; ++ sdio_local_write(padapter, SDIO_REG_HIMR_ON, 4, (u8 *)&tmp); ++ sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); ++ sdio_local_read(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp); ++ sdio_local_write(padapter, SDIO_REG_HISR, 4, (u8 *)&tmp); ++ ++ /* 4. Enable CPWM2 only */ ++ DBG_871X_LEVEL(_drv_always_, "Enable only CPWM2\n"); ++ sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); ++ DBG_871X("DisableInterruptButCpwm28723BSdio(): Read SDIO_REG_HIMR: 0x%08x\n", tmp); ++ ++ himr = cpu_to_le32(SDIO_HIMR_DISABLED)|SDIO_HIMR_CPWM2_MSK; ++ sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr); ++ ++ sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); ++ DBG_871X("DisableInterruptButCpwm28723BSdio(): Read again SDIO_REG_HIMR: 0x%08x\n", tmp); ++ ++ /* 5. Set Enable WOWLAN H2C command. */ ++ DBG_871X_LEVEL(_drv_always_, "Set Enable WOWLan cmd\n"); ++ rtl8723b_set_wowlan_cmd(padapter, 1); ++ ++ /* 6. Check EnableWoWlan CMD is ready */ ++ if (!pwrctl->wowlan_pno_enable) { ++ DBG_871X_LEVEL(_drv_always_, "Check EnableWoWlan CMD is ready\n"); ++ mstatus = rtw_read8(padapter, REG_WOW_CTRL); ++ trycnt = 10; ++ while (!(mstatus&BIT1) && trycnt > 1) { ++ mstatus = rtw_read8(padapter, REG_WOW_CTRL); ++ DBG_871X("Loop index: %d :0x%02x\n", trycnt, mstatus); ++ trycnt--; ++ msleep(2); ++ } ++ } ++ break; ++ ++ case WOWLAN_DISABLE: ++ DBG_871X_LEVEL(_drv_always_, "WOWLAN_DISABLE\n"); ++ ++ psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv)); ++ if (psta != NULL) ++ rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_DISCONNECT, psta->mac_id); ++ else ++ DBG_871X("psta is null\n"); ++ ++ /* 1. Read wakeup reason */ ++ pwrctl->wowlan_wake_reason = rtw_read8(padapter, REG_WOWLAN_WAKE_REASON); ++ DBG_871X_LEVEL( ++ _drv_always_, ++ "wakeup_reason: 0x%02x, mac_630 = 0x%08x, mac_634 = 0x%08x, mac_1c0 = 0x%08x, mac_1c4 = 0x%08x" ++ ", mac_494 = 0x%08x, , mac_498 = 0x%08x, mac_49c = 0x%08x, mac_608 = 0x%08x, mac_4a0 = 0x%08x, mac_4a4 = 0x%08x\n" ++ ", mac_1cc = 0x%08x, mac_2f0 = 0x%08x, mac_2f4 = 0x%08x, mac_2f8 = 0x%08x, mac_2fc = 0x%08x, mac_8c = 0x%08x", ++ pwrctl->wowlan_wake_reason, ++ rtw_read32(padapter, REG_WOWLAN_GTK_DBG1), ++ rtw_read32(padapter, REG_WOWLAN_GTK_DBG2), ++ rtw_read32(padapter, 0x1c0), ++ rtw_read32(padapter, 0x1c4), ++ rtw_read32(padapter, 0x494), ++ rtw_read32(padapter, 0x498), ++ rtw_read32(padapter, 0x49c), ++ rtw_read32(padapter, 0x608), ++ rtw_read32(padapter, 0x4a0), ++ rtw_read32(padapter, 0x4a4), ++ rtw_read32(padapter, 0x1cc), ++ rtw_read32(padapter, 0x2f0), ++ rtw_read32(padapter, 0x2f4), ++ rtw_read32(padapter, 0x2f8), ++ rtw_read32(padapter, 0x2fc), ++ rtw_read32(padapter, 0x8c) ++ ); ++#ifdef CONFIG_PNO_SET_DEBUG ++ DBG_871X("0x1b9: 0x%02x, 0x632: 0x%02x\n", rtw_read8(padapter, 0x1b9), rtw_read8(padapter, 0x632)); ++ DBG_871X("0x4fc: 0x%02x, 0x4fd: 0x%02x\n", rtw_read8(padapter, 0x4fc), rtw_read8(padapter, 0x4fd)); ++ DBG_871X("TXDMA STATUS: 0x%08x\n", rtw_read32(padapter, REG_TXDMA_STATUS)); ++#endif ++ ++ { ++ /* 2. Set Disable WOWLAN H2C command. */ ++ DBG_871X_LEVEL(_drv_always_, "Set Disable WOWLan cmd\n"); ++ rtl8723b_set_wowlan_cmd(padapter, 0); ++ ++ /* 3. Check Disable WoWlan CMD ready. */ ++ DBG_871X_LEVEL(_drv_always_, "Check DisableWoWlan CMD is ready\n"); ++ mstatus = rtw_read8(padapter, REG_WOW_CTRL); ++ trycnt = 50; ++ while (mstatus&BIT1 && trycnt > 1) { ++ mstatus = rtw_read8(padapter, REG_WOW_CTRL); ++ DBG_871X_LEVEL(_drv_always_, "Loop index: %d :0x%02x\n", trycnt, mstatus); ++ trycnt--; ++ msleep(10); ++ } ++ ++ if (mstatus & BIT1) { ++ DBG_871X_LEVEL(_drv_always_, "Disable WOW mode fail!!\n"); ++ DBG_871X("Set 0x690 = 0x00\n"); ++ rtw_write8(padapter, REG_WOW_CTRL, (rtw_read8(padapter, REG_WOW_CTRL)&0xf0)); ++ DBG_871X_LEVEL(_drv_always_, "Release RXDMA\n"); ++ rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM)&(~RW_RELEASE_EN))); ++ } ++ ++ /* 3.1 read fw iv */ ++ iv_low = rtw_read32(padapter, REG_TXPKTBUF_IV_LOW); ++ /* only low two bytes is PN, check AES_IV macro for detail */ ++ iv_low &= 0xffff; ++ iv_high = rtw_read32(padapter, REG_TXPKTBUF_IV_HIGH); ++ /* get the real packet number */ ++ pwrctl->wowlan_fw_iv = iv_high << 16 | iv_low; ++ DBG_871X_LEVEL(_drv_always_, "fw_iv: 0x%016llx\n", pwrctl->wowlan_fw_iv); ++ /* Update TX iv data. */ ++ rtw_set_sec_pn(padapter); ++ ++ /* 3.2 read GTK index and key */ ++ if ( ++ psecuritypriv->binstallKCK_KEK == true && ++ psecuritypriv->dot11PrivacyAlgrthm == _AES_ ++ ) { ++ u8 gtk_keyindex = 0; ++ u8 get_key[16]; ++ /* read gtk key index */ ++ gtk_keyindex = rtw_read8(padapter, 0x48c); ++ ++ if (gtk_keyindex < 4) { ++ psecuritypriv->dot118021XGrpKeyid = gtk_keyindex; ++ read_cam(padapter, gtk_keyindex, get_key); ++ memcpy(psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, get_key, 16); ++ DBG_871X_LEVEL( ++ _drv_always_, ++ "GTK (%d) = 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", ++ gtk_keyindex, ++ psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[0], ++ psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[1], ++ psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[2], ++ psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].lkey[3] ++ ); ++ } else ++ DBG_871X_LEVEL(_drv_always_, "GTK index =%d\n", gtk_keyindex); ++ } ++ ++ /* 4. Re-download Normal FW. */ ++ DBG_871X_LEVEL(_drv_always_, "Re-download Normal FW!\n"); ++ SetFwRelatedForWoWLAN8723b(padapter, false); ++ } ++#ifdef CONFIG_GPIO_WAKEUP ++ DBG_871X_LEVEL(_drv_always_, "Set Wake GPIO to high for default.\n"); ++ HalSetOutPutGPIO(padapter, WAKEUP_GPIO_IDX, 1); ++#endif ++ ++ /* 5. Download reserved pages and report media status if needed. */ ++ if ( ++ (pwrctl->wowlan_wake_reason != FWDecisionDisconnect) && ++ (pwrctl->wowlan_wake_reason != Rx_Pairwisekey) && ++ (pwrctl->wowlan_wake_reason != Rx_DisAssoc) && ++ (pwrctl->wowlan_wake_reason != Rx_DeAuth) ++ ) { ++ rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT); ++ if (psta != NULL) ++ rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id); ++ } ++#ifdef CONFIG_PNO_SUPPORT ++ rtw_write8(padapter, 0x1b8, 0); ++ DBG_871X("reset 0x1b8: %d\n", rtw_read8(padapter, 0x1b8)); ++ rtw_write8(padapter, 0x1b9, 0); ++ DBG_871X("reset 0x1b9: %d\n", rtw_read8(padapter, 0x1b9)); ++ rtw_write8(padapter, REG_PNO_STATUS, 0); ++ DBG_871X("reset REG_PNO_STATUS: %d\n", rtw_read8(padapter, REG_PNO_STATUS)); ++#endif ++ break; ++ ++ default: ++ break; ++ } ++ } ++ break; +#endif /* CONFIG_WOWLAN */ +#ifdef CONFIG_AP_WOWLAN + case HW_VAR_AP_WOWLAN: @@ -75965,26 +73921,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + SetFwRelatedForWoWLAN8723b(padapter, false); + +#ifdef CONFIG_GPIO_WAKEUP -+ DBG_871X_LEVEL(_drv_always_, "Set Wake GPIO to high for default.\n"); -+ HalSetOutPutGPIO(padapter, WAKEUP_GPIO_IDX, 1); ++ DBG_871X_LEVEL(_drv_always_, "Set Wake GPIO to high for default.\n"); ++ HalSetOutPutGPIO(padapter, WAKEUP_GPIO_IDX, 1); +#endif /* CONFIG_GPIO_WAKEUP */ -+ rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT); -+ issue_beacon(padapter, 0); -+ break; -+ default: -+ break; -+ } -+ } ++ rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT); ++ issue_beacon(padapter, 0); + break; -+#endif /* CONFIG_AP_WOWLAN */ -+ case HW_VAR_DM_IN_LPS: -+ rtl8723b_hal_dm_in_lps(padapter); -+ break; + default: -+ SetHwReg8723B(padapter, variable, val); + break; + } +} ++ break; ++#endif /* CONFIG_AP_WOWLAN */ ++ case HW_VAR_DM_IN_LPS: ++ rtl8723b_hal_dm_in_lps(padapter); ++ break; ++ default: ++ SetHwReg8723B(padapter, variable, val); ++ break; ++ } ++} + +/* + * If variable not handled here, @@ -76000,7 +73956,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + case HW_VAR_FW_PS_STATE: + { + /* 3. read dword 0x88 driver read fw ps state */ -+ *((u16*)val) = rtw_read16(padapter, 0x88); ++ *((u16 *)val) = rtw_read16(padapter, 0x88); + } + break; + default: @@ -76025,29 +73981,25 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 +/* Description: */ +/* Query setting of specified variable. */ +/* */ -+static u8 -+GetHalDefVar8723BSDIO( -+struct adapter * Adapter, -+enum HAL_DEF_VARIABLE eVariable, -+void * pValue -+ ) ++static u8 GetHalDefVar8723BSDIO( ++ struct adapter *Adapter, enum HAL_DEF_VARIABLE eVariable, void *pValue ++) +{ + u8 bResult = _SUCCESS; + -+ switch (eVariable) -+ { -+ case HAL_DEF_IS_SUPPORT_ANT_DIV: -+ break; -+ case HAL_DEF_CURRENT_ANTENNA: -+ break; -+ case HW_VAR_MAX_RX_AMPDU_FACTOR: -+ /* Stanley@BB.SD3 suggests 16K can get stable performance */ -+ /* coding by Lucas@20130730 */ -+ *(u32*)pValue = MAX_AMPDU_FACTOR_16K; -+ break; -+ default: -+ bResult = GetHalDefVar8723B(Adapter, eVariable, pValue); -+ break; ++ switch (eVariable) { ++ case HAL_DEF_IS_SUPPORT_ANT_DIV: ++ break; ++ case HAL_DEF_CURRENT_ANTENNA: ++ break; ++ case HW_VAR_MAX_RX_AMPDU_FACTOR: ++ /* Stanley@BB.SD3 suggests 16K can get stable performance */ ++ /* coding by Lucas@20130730 */ ++ *(u32 *)pValue = MAX_AMPDU_FACTOR_16K; ++ break; ++ default: ++ bResult = GetHalDefVar8723B(Adapter, eVariable, pValue); ++ break; + } + + return bResult; @@ -76108,10 +74060,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_halinit.c linux-4.3-rtl8723bs/3 + pHalFunc->hal_checke_bt_hang = &rtl8723bs_hal_check_bt_hang; +#endif +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/sdio_ops.c ---- linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/hal/sdio_ops.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,1262 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/hal/sdio_ops.c linux/3rdparty/rtl8723bs/hal/sdio_ops.c +--- linux.old/3rdparty/rtl8723bs/hal/sdio_ops.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/hal/sdio_ops.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,1296 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -76142,40 +74094,39 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa +/* Creadted by Roger, 2011.01.31. */ +/* */ +static void HalSdioGetCmdAddr8723BSdio( -+struct adapter * padapter, -+u8 DeviceID, -+u32 Addr, -+ u32* pCmdAddr -+ ) ++ struct adapter *padapter, ++ u8 DeviceID, ++ u32 Addr, ++ u32 *pCmdAddr ++) +{ -+ switch (DeviceID) -+ { -+ case SDIO_LOCAL_DEVICE_ID: -+ *pCmdAddr = ((SDIO_LOCAL_DEVICE_ID << 13) | (Addr & SDIO_LOCAL_MSK)); -+ break; ++ switch (DeviceID) { ++ case SDIO_LOCAL_DEVICE_ID: ++ *pCmdAddr = ((SDIO_LOCAL_DEVICE_ID << 13) | (Addr & SDIO_LOCAL_MSK)); ++ break; + -+ case WLAN_IOREG_DEVICE_ID: -+ *pCmdAddr = ((WLAN_IOREG_DEVICE_ID << 13) | (Addr & WLAN_IOREG_MSK)); -+ break; ++ case WLAN_IOREG_DEVICE_ID: ++ *pCmdAddr = ((WLAN_IOREG_DEVICE_ID << 13) | (Addr & WLAN_IOREG_MSK)); ++ break; + -+ case WLAN_TX_HIQ_DEVICE_ID: -+ *pCmdAddr = ((WLAN_TX_HIQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); -+ break; ++ case WLAN_TX_HIQ_DEVICE_ID: ++ *pCmdAddr = ((WLAN_TX_HIQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); ++ break; + -+ case WLAN_TX_MIQ_DEVICE_ID: -+ *pCmdAddr = ((WLAN_TX_MIQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); -+ break; ++ case WLAN_TX_MIQ_DEVICE_ID: ++ *pCmdAddr = ((WLAN_TX_MIQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); ++ break; + -+ case WLAN_TX_LOQ_DEVICE_ID: -+ *pCmdAddr = ((WLAN_TX_LOQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); -+ break; ++ case WLAN_TX_LOQ_DEVICE_ID: ++ *pCmdAddr = ((WLAN_TX_LOQ_DEVICE_ID << 13) | (Addr & WLAN_FIFO_MSK)); ++ break; + -+ case WLAN_RX0FF_DEVICE_ID: -+ *pCmdAddr = ((WLAN_RX0FF_DEVICE_ID << 13) | (Addr & WLAN_RX0FF_MSK)); -+ break; ++ case WLAN_RX0FF_DEVICE_ID: ++ *pCmdAddr = ((WLAN_RX0FF_DEVICE_ID << 13) | (Addr & WLAN_RX0FF_MSK)); ++ break; + -+ default: -+ break; ++ default: ++ break; + } +} + @@ -76186,40 +74137,39 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + + + pseudoId = (u16)(addr >> 16); -+ switch (pseudoId) -+ { -+ case 0x1025: -+ devideId = SDIO_LOCAL_DEVICE_ID; -+ break; ++ switch (pseudoId) { ++ case 0x1025: ++ devideId = SDIO_LOCAL_DEVICE_ID; ++ break; + -+ case 0x1026: -+ devideId = WLAN_IOREG_DEVICE_ID; -+ break; ++ case 0x1026: ++ devideId = WLAN_IOREG_DEVICE_ID; ++ break; + +/* case 0x1027: */ +/* devideId = SDIO_FIRMWARE_FIFO; */ +/* break; */ + -+ case 0x1031: -+ devideId = WLAN_TX_HIQ_DEVICE_ID; -+ break; ++ case 0x1031: ++ devideId = WLAN_TX_HIQ_DEVICE_ID; ++ break; + -+ case 0x1032: -+ devideId = WLAN_TX_MIQ_DEVICE_ID; -+ break; ++ case 0x1032: ++ devideId = WLAN_TX_MIQ_DEVICE_ID; ++ break; + -+ case 0x1033: -+ devideId = WLAN_TX_LOQ_DEVICE_ID; -+ break; ++ case 0x1033: ++ devideId = WLAN_TX_LOQ_DEVICE_ID; ++ break; + -+ case 0x1034: -+ devideId = WLAN_RX0FF_DEVICE_ID; -+ break; ++ case 0x1034: ++ devideId = WLAN_RX0FF_DEVICE_ID; ++ break; + -+ default: ++ default: +/* devideId = (u8)((addr >> 13) & 0xF); */ -+ devideId = WLAN_IOREG_DEVICE_ID; -+ break; ++ devideId = WLAN_IOREG_DEVICE_ID; ++ break; + } + + return devideId; @@ -76239,32 +74189,33 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + deviceId = get_deviceid(addr); + offset = 0; + -+ switch (deviceId) -+ { -+ case SDIO_LOCAL_DEVICE_ID: -+ offset = addr & SDIO_LOCAL_MSK; -+ break; ++ switch (deviceId) { ++ case SDIO_LOCAL_DEVICE_ID: ++ offset = addr & SDIO_LOCAL_MSK; ++ break; + -+ case WLAN_TX_HIQ_DEVICE_ID: -+ case WLAN_TX_MIQ_DEVICE_ID: -+ case WLAN_TX_LOQ_DEVICE_ID: -+ offset = addr & WLAN_FIFO_MSK; -+ break; ++ case WLAN_TX_HIQ_DEVICE_ID: ++ case WLAN_TX_MIQ_DEVICE_ID: ++ case WLAN_TX_LOQ_DEVICE_ID: ++ offset = addr & WLAN_FIFO_MSK; ++ break; + -+ case WLAN_RX0FF_DEVICE_ID: -+ offset = addr & WLAN_RX0FF_MSK; -+ break; ++ case WLAN_RX0FF_DEVICE_ID: ++ offset = addr & WLAN_RX0FF_MSK; ++ break; + -+ case WLAN_IOREG_DEVICE_ID: -+ default: -+ deviceId = WLAN_IOREG_DEVICE_ID; -+ offset = addr & WLAN_IOREG_MSK; -+ break; ++ case WLAN_IOREG_DEVICE_ID: ++ default: ++ deviceId = WLAN_IOREG_DEVICE_ID; ++ offset = addr & WLAN_IOREG_MSK; ++ break; + } + ftaddr = (deviceId << 13) | offset; + -+ if (pdeviceId) *pdeviceId = deviceId; -+ if (poffset) *poffset = offset; ++ if (pdeviceId) ++ *pdeviceId = deviceId; ++ if (poffset) ++ *poffset = offset; + + return ftaddr; +} @@ -76307,10 +74258,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + ftaddr = _cvrt2ftaddr(addr, &deviceId, &offset); + + rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); -+ if (((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) -+ || (false == bMacPwrCtrlOn) -+ || (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)) -+ { ++ if ( ++ ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || ++ (false == bMacPwrCtrlOn) || ++ (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ++ ) { + err = sd_cmd52_read(pintfhdl, ftaddr, 4, (u8 *)&le_tmp); +#ifdef SDIO_DEBUG_IO + if (!err) { @@ -76364,10 +74316,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + ftaddr = _cvrt2ftaddr(addr, &deviceId, &offset); + + rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); -+ if (((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) -+ || (false == bMacPwrCtrlOn) -+ || (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)) -+ { ++ if ( ++ ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || ++ (false == bMacPwrCtrlOn) || ++ (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ++ ) { + err = sd_cmd52_read(pintfhdl, ftaddr, cnt, pbuf); + return err; + } @@ -76383,7 +74336,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + ftaddr &= ~(u16)0x3; + n = cnt + shift; + ptmpbuf = rtw_malloc(n); -+ if (NULL == ptmpbuf) return -1; ++ if (NULL == ptmpbuf) ++ return -1; ++ + err = sd_read(pintfhdl, ftaddr, n, ptmpbuf); + if (!err) + memcpy(pbuf, ptmpbuf+shift, cnt); @@ -76433,8 +74388,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + ftaddr = _cvrt2ftaddr(addr, &deviceId, &offset); + + rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); -+ if (((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || -+ (!bMacPwrCtrlOn) || (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)) { ++ if ( ++ ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || ++ (!bMacPwrCtrlOn) || ++ (adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ++ ) { + le_tmp = cpu_to_le32(val); + err = sd_cmd52_write(pintfhdl, ftaddr, 4, (u8 *)&le_tmp); + return err; @@ -76442,8 +74400,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + + /* 4 bytes alignment */ + shift = ftaddr & 0x3; -+ if (shift == 0) -+ { ++ if (shift == 0) { + sd_write32(pintfhdl, ftaddr, val, &err); + } else { + le_tmp = cpu_to_le32(val); @@ -76468,10 +74425,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + ftaddr = _cvrt2ftaddr(addr, &deviceId, &offset); + + rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); -+ if (((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) -+ || (false == bMacPwrCtrlOn) -+ || (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)) -+ { ++ if ( ++ ((deviceId == WLAN_IOREG_DEVICE_ID) && (offset < 0x100)) || ++ (false == bMacPwrCtrlOn) || ++ (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ++ ) { + err = sd_cmd52_write(pintfhdl, ftaddr, cnt, pbuf); + return err; + } @@ -76486,7 +74444,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + ftaddr &= ~(u16)0x3; + n = cnt + shift; + ptmpbuf = rtw_malloc(n); -+ if (NULL == ptmpbuf) return -1; ++ if (NULL == ptmpbuf) ++ return -1; + err = sd_read(pintfhdl, ftaddr, 4, ptmpbuf); + if (err) { + kfree(ptmpbuf); @@ -76504,7 +74463,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + return sd_f0_read8(pintfhdl, addr, NULL); +} + -+static void sdio_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) ++static void sdio_read_mem( ++ struct intf_hdl *pintfhdl, ++ u32 addr, ++ u32 cnt, ++ u8 *rmem ++) +{ + s32 err; + @@ -76512,7 +74476,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + /* TODO: Report error is err not zero */ +} + -+static void sdio_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) ++static void sdio_write_mem( ++ struct intf_hdl *pintfhdl, ++ u32 addr, ++ u32 cnt, ++ u8 *wmem ++) +{ + sdio_writeN(pintfhdl, addr, cnt, wmem); +} @@ -76537,7 +74506,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + struct intf_hdl *pintfhdl, + u32 addr, + u32 cnt, -+ u8 *mem) ++ u8 *mem ++) +{ + struct adapter *padapter; + PSDIO_DATA psdio; @@ -76584,7 +74554,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + } +#endif + -+ if (err) return _FAIL; ++ if (err) ++ return _FAIL; + return _SUCCESS; +} + @@ -76608,7 +74579,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + struct intf_hdl *pintfhdl, + u32 addr, + u32 cnt, -+ u8 *mem) ++ u8 *mem ++) +{ + struct adapter *padapter; + PSDIO_DATA psdio; @@ -76632,10 +74604,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + + err = sd_write(pintfhdl, addr, cnt, xmitbuf->pdata); + -+ rtw_sctx_done_err(&xmitbuf->sctx, -+ err ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS); ++ rtw_sctx_done_err( ++ &xmitbuf->sctx, ++ err ? RTW_SCTX_DONE_WRITE_PORT_ERR : RTW_SCTX_DONE_SUCCESS ++ ); + -+ if (err) return _FAIL; ++ if (err) ++ return _FAIL; + return _SUCCESS; +} + @@ -76662,24 +74637,24 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + */ +static s32 _sdio_local_read( + struct adapter *padapter, -+ u32 addr, -+ u32 cnt, -+ u8 *pbuf) ++ u32 addr, ++ u32 cnt, ++ u8 *pbuf ++) +{ -+ struct intf_hdl * pintfhdl; ++ struct intf_hdl *pintfhdl; + u8 bMacPwrCtrlOn; + s32 err; + u8 *ptmpbuf; + u32 n; + + -+ pintfhdl =&padapter->iopriv.intf; ++ pintfhdl = &padapter->iopriv.intf; + + HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); + + rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); -+ if (false == bMacPwrCtrlOn) -+ { ++ if (false == bMacPwrCtrlOn) { + err = _sd_cmd52_read(pintfhdl, addr, cnt, pbuf); + return err; + } @@ -76704,24 +74679,26 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + */ +s32 sdio_local_read( + struct adapter *padapter, -+ u32 addr, -+ u32 cnt, -+ u8 *pbuf) ++ u32 addr, ++ u32 cnt, ++ u8 *pbuf ++) +{ -+ struct intf_hdl * pintfhdl; ++ struct intf_hdl *pintfhdl; + u8 bMacPwrCtrlOn; + s32 err; + u8 *ptmpbuf; + u32 n; + -+ pintfhdl =&padapter->iopriv.intf; ++ pintfhdl = &padapter->iopriv.intf; + + HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); + + rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); -+ if ((false == bMacPwrCtrlOn) -+ || (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)) -+ { ++ if ( ++ (false == bMacPwrCtrlOn) || ++ (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ++ ) { + err = sd_cmd52_read(pintfhdl, addr, cnt, pbuf); + return err; + } @@ -76746,11 +74723,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + */ +s32 sdio_local_write( + struct adapter *padapter, -+ u32 addr, -+ u32 cnt, -+ u8 *pbuf) ++ u32 addr, ++ u32 cnt, ++ u8 *pbuf ++) +{ -+ struct intf_hdl * pintfhdl; ++ struct intf_hdl *pintfhdl; + u8 bMacPwrCtrlOn; + s32 err; + u8 *ptmpbuf; @@ -76761,14 +74739,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + if (cnt & 0x3) + DBG_8192C("%s, size must be the multiple of 4\n", __func__); + -+ pintfhdl =&padapter->iopriv.intf; ++ pintfhdl = &padapter->iopriv.intf; + + HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); + + rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); -+ if ((false == bMacPwrCtrlOn) -+ || (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode)) -+ { ++ if ( ++ (false == bMacPwrCtrlOn) || ++ (true == adapter_to_pwrctl(padapter)->bFwCurrentInPSMode) ++ ) { + err = sd_cmd52_write(pintfhdl, addr, cnt, pbuf); + return err; + } @@ -76789,7 +74768,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa +u8 SdioLocalCmd52Read1Byte(struct adapter *padapter, u32 addr) +{ + u8 val = 0; -+ struct intf_hdl * pintfhdl =&padapter->iopriv.intf; ++ struct intf_hdl *pintfhdl = &padapter->iopriv.intf; + + HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); + sd_cmd52_read(pintfhdl, addr, 1, &val); @@ -76800,7 +74779,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa +static u16 SdioLocalCmd52Read2Byte(struct adapter *padapter, u32 addr) +{ + __le16 val = 0; -+ struct intf_hdl * pintfhdl =&padapter->iopriv.intf; ++ struct intf_hdl *pintfhdl = &padapter->iopriv.intf; + + HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); + sd_cmd52_read(pintfhdl, addr, 2, (u8 *)&val); @@ -76813,7 +74792,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + + u8 bMacPwrCtrlOn; + u32 val = 0; -+ struct intf_hdl * pintfhdl =&padapter->iopriv.intf; ++ struct intf_hdl *pintfhdl = &padapter->iopriv.intf; + __le32 le_tmp; + + HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); @@ -76829,7 +74808,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + +void SdioLocalCmd52Write1Byte(struct adapter *padapter, u32 addr, u8 v) +{ -+ struct intf_hdl * pintfhdl =&padapter->iopriv.intf; ++ struct intf_hdl *pintfhdl = &padapter->iopriv.intf; + + HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); + sd_cmd52_write(pintfhdl, addr, 1, &v); @@ -76837,7 +74816,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + +static void SdioLocalCmd52Write4Byte(struct adapter *padapter, u32 addr, u32 v) +{ -+ struct intf_hdl * pintfhdl =&padapter->iopriv.intf; ++ struct intf_hdl *pintfhdl = &padapter->iopriv.intf; + __le32 le_tmp; + + HalSdioGetCmdAddr8723BSdio(padapter, SDIO_LOCAL_DEVICE_ID, addr, &addr); @@ -76858,15 +74837,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + + /* decide how many bytes need to be read */ + hisr_len = 0; -+ while (himr) -+ { ++ while (himr) { + hisr_len++; + himr >>= 8; + } + + hisr = 0; -+ while (hisr_len != 0) -+ { ++ while (hisr_len != 0) { + hisr_len--; + val8 = SdioLocalCmd52Read1Byte(padapter, SDIO_REG_HISR+hisr_len); + hisr |= (val8 << (8*hisr_len)); @@ -76959,8 +74936,8 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + clear = rtw_zmalloc(4); + + /* Clear corresponding HISR Content if needed */ -+ *(__le32*)clear = cpu_to_le32(pHalData->sdio_hisr & MASK_SDIO_HISR_CLEAR); -+ if (*(__le32*)clear) { ++ *(__le32 *)clear = cpu_to_le32(pHalData->sdio_hisr & MASK_SDIO_HISR_CLEAR); ++ if (*(__le32 *)clear) { + /* Perform write one clear operation */ + sdio_local_write(padapter, SDIO_REG_HISR, 4, clear); + } @@ -76990,15 +74967,29 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + himr = cpu_to_le32(pHalData->sdio_himr); + sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr); + -+ RT_TRACE(_module_hci_ops_c_, _drv_notice_, -+ ("%s: enable SDIO HIMR = 0x%08X\n", __func__, pHalData->sdio_himr)); ++ RT_TRACE( ++ _module_hci_ops_c_, ++ _drv_notice_, ++ ( ++ "%s: enable SDIO HIMR = 0x%08X\n", ++ __func__, ++ pHalData->sdio_himr ++ ) ++ ); + + /* Update current system IMR settings */ + tmp = rtw_read32(padapter, REG_HSIMR); + rtw_write32(padapter, REG_HSIMR, tmp | pHalData->SysIntrMask); + -+ RT_TRACE(_module_hci_ops_c_, _drv_notice_, -+ ("%s: enable HSIMR = 0x%08X\n", __func__, pHalData->SysIntrMask)); ++ RT_TRACE( ++ _module_hci_ops_c_, ++ _drv_notice_, ++ ( ++ "%s: enable HSIMR = 0x%08X\n", ++ __func__, ++ pHalData->SysIntrMask ++ ) ++ ); + + /* */ + /* There are some C2H CMDs have been sent before system interrupt is enabled, e.g., C2H, CPWM. */ @@ -77036,8 +75027,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa +/* */ +u8 CheckIPSStatus(struct adapter *padapter) +{ -+ DBG_871X("%s(): Read 0x100 = 0x%02x 0x86 = 0x%02x\n", __func__, -+ rtw_read8(padapter, 0x100), rtw_read8(padapter, 0x86)); ++ DBG_871X( ++ "%s(): Read 0x100 = 0x%02x 0x86 = 0x%02x\n", ++ __func__, ++ rtw_read8(padapter, 0x100), ++ rtw_read8(padapter, 0x86) ++ ); + + if (rtw_read8(padapter, 0x100) == 0xEA) + return true; @@ -77045,7 +75040,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + return false; +} + -+static struct recv_buf* sd_recv_rxfifo(struct adapter *padapter, u32 size) ++static struct recv_buf *sd_recv_rxfifo(struct adapter *padapter, u32 size) +{ + u32 readsize, ret; + u8 *preadbuf; @@ -77072,8 +75067,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + + precvbuf->pskb = rtw_skb_alloc(MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); + -+ if (precvbuf->pskb) -+ { ++ if (precvbuf->pskb) { + precvbuf->pskb->dev = padapter->pnetdev; + + tmpaddr = (SIZE_PTR)precvbuf->pskb->data; @@ -77126,7 +75120,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa +{ + struct hal_com_data *phal; + struct dvobj_priv *dvobj; -+ struct intf_hdl * pintfhdl =&padapter->iopriv.intf; ++ struct intf_hdl *pintfhdl = &padapter->iopriv.intf; + struct pwrctrl_priv *pwrctl; + + @@ -77134,15 +75128,14 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + dvobj = adapter_to_dvobj(padapter); + pwrctl = dvobj_to_pwrctl(dvobj); + -+ if (phal->sdio_hisr & SDIO_HISR_AVAL) -+ { ++ if (phal->sdio_hisr & SDIO_HISR_AVAL) { + u8 freepage[4]; + + _sdio_local_read(padapter, SDIO_REG_FREE_TXPG, 4, freepage); + up(&(padapter->xmitpriv.xmit_sema)); + } -+ if (phal->sdio_hisr & SDIO_HISR_CPWM1) -+ { ++ ++ if (phal->sdio_hisr & SDIO_HISR_CPWM1) { + struct reportpwrstate_parm report; + + u8 bcancelled; @@ -77154,41 +75147,37 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + _set_workitem(&(pwrctl->cpwm_event)); + } + -+ if (phal->sdio_hisr & SDIO_HISR_TXERR) -+ { ++ if (phal->sdio_hisr & SDIO_HISR_TXERR) { + u8 *status; + u32 addr; + + status = rtw_malloc(4); -+ if (status) -+ { ++ if (status) { + addr = REG_TXDMA_STATUS; + HalSdioGetCmdAddr8723BSdio(padapter, WLAN_IOREG_DEVICE_ID, addr, &addr); + _sd_read(pintfhdl, addr, 4, status); + _sd_write(pintfhdl, addr, 4, status); -+ DBG_8192C("%s: SDIO_HISR_TXERR (0x%08x)\n", __func__, le32_to_cpu(*(u32*)status)); ++ DBG_8192C("%s: SDIO_HISR_TXERR (0x%08x)\n", __func__, le32_to_cpu(*(u32 *)status)); + kfree(status); + } else { + DBG_8192C("%s: SDIO_HISR_TXERR, but can't allocate memory to read status!\n", __func__); + } + } + -+ if (phal->sdio_hisr & SDIO_HISR_TXBCNOK) -+ { ++ if (phal->sdio_hisr & SDIO_HISR_TXBCNOK) { + DBG_8192C("%s: SDIO_HISR_TXBCNOK\n", __func__); + } + -+ if (phal->sdio_hisr & SDIO_HISR_TXBCNERR) -+ { ++ if (phal->sdio_hisr & SDIO_HISR_TXBCNERR) { + DBG_8192C("%s: SDIO_HISR_TXBCNERR\n", __func__); + } +#ifndef CONFIG_C2H_PACKET_EN -+ if (phal->sdio_hisr & SDIO_HISR_C2HCMD) -+ { ++ if (phal->sdio_hisr & SDIO_HISR_C2HCMD) { + struct c2h_evt_hdr_88xx *c2h_evt; + + DBG_8192C("%s: C2H Command\n", __func__); -+ if ((c2h_evt = (struct c2h_evt_hdr_88xx*)rtw_zmalloc(16)) != NULL) { ++ c2h_evt = (struct c2h_evt_hdr_88xx *)rtw_zmalloc(16); ++ if (c2h_evt != NULL) { + if (rtw_hal_c2h_evt_read(padapter, (u8 *)c2h_evt) == _SUCCESS) { + if (c2h_id_filter_ccx_8723b((u8 *)c2h_evt)) { + /* Handle CCX report here */ @@ -77200,24 +75189,22 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + } + } else { + /* Error handling for malloc fail */ -+ if (rtw_cbuf_push(padapter->evtpriv.c2h_queue, (void*)NULL) != _SUCCESS) ++ if (rtw_cbuf_push(padapter->evtpriv.c2h_queue, (void *)NULL) != _SUCCESS) + DBG_871X("%s rtw_cbuf_push fail\n", __func__); + _set_workitem(&padapter->evtpriv.c2h_wk); + } + } +#endif + -+ if (phal->sdio_hisr & SDIO_HISR_RXFOVW) -+ { ++ if (phal->sdio_hisr & SDIO_HISR_RXFOVW) { + DBG_8192C("%s: Rx Overflow\n", __func__); + } -+ if (phal->sdio_hisr & SDIO_HISR_RXERR) -+ { ++ ++ if (phal->sdio_hisr & SDIO_HISR_RXERR) { + DBG_8192C("%s: Rx Error\n", __func__); + } + -+ if (phal->sdio_hisr & SDIO_HISR_RX_REQUEST) -+ { ++ if (phal->sdio_hisr & SDIO_HISR_RX_REQUEST) { + struct recv_buf *precvbuf; + int alloc_fail_time = 0; + u32 hisr; @@ -77226,21 +75213,18 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + phal->sdio_hisr ^= SDIO_HISR_RX_REQUEST; + do { + phal->SdioRxFIFOSize = SdioLocalCmd52Read2Byte(padapter, SDIO_REG_RX0_REQ_LEN); -+ if (phal->SdioRxFIFOSize != 0) -+ { ++ if (phal->SdioRxFIFOSize != 0) { + precvbuf = sd_recv_rxfifo(padapter, phal->SdioRxFIFOSize); + if (precvbuf) + sd_rxhandler(padapter, precvbuf); -+ else -+ { ++ else { + alloc_fail_time++; + DBG_871X("precvbuf is Null for %d times because alloc memory failed\n", alloc_fail_time); + if (alloc_fail_time >= 10) + break; + } + phal->SdioRxFIFOSize = 0; -+ } -+ else ++ } else + break; + + hisr = 0; @@ -77261,8 +75245,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + struct hal_com_data *phal; + + -+ if ((padapter->bDriverStopped == true) || -+ (padapter->bSurpriseRemoved == true)) ++ if ( ++ (padapter->bDriverStopped == true) || ++ (padapter->bSurpriseRemoved == true) ++ ) + return; + + phal = GET_HAL_DATA(padapter); @@ -77270,8 +75256,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + phal->sdio_hisr = 0; + ReadInterrupt8723BSdio(padapter, &phal->sdio_hisr); + -+ if (phal->sdio_hisr & phal->sdio_himr) -+ { ++ if (phal->sdio_hisr & phal->sdio_himr) { + u32 v32; + + phal->sdio_hisr &= phal->sdio_himr; @@ -77332,6 +75317,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa +u8 HalQueryTxOQTBufferStatus8723BSdio(struct adapter *padapter) +{ + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); ++ + pHalData->SdioTxOQTFreeSpace = SdioLocalCmd52Read1Byte(padapter, SDIO_REG_OQT_FREE_PG); + return true; +} @@ -77374,10 +75360,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/hal/sdio_ops.c linux-4.3-rtl8723bs/3rdpa + return res; +} +#endif /* CONFIG_WOWLAN */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/autoconf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/autoconf.h ---- linux-4.3/3rdparty/rtl8723bs/include/autoconf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/autoconf.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,67 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/include/autoconf.h linux/3rdparty/rtl8723bs/include/autoconf.h +--- linux.old/3rdparty/rtl8723bs/include/autoconf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/autoconf.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,71 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -77403,6 +75389,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/autoconf.h linux-4.3-rtl8723bs/3 + */ +/* define CONFIG_DEBUG_CFG80211 */ + ++#ifndef CONFIG_WIRELESS_EXT ++#error CONFIG_WIRELESS_EXT needs to be enabled for this driver to work ++#endif ++ +/* + * Auto Config Section + */ @@ -77445,9 +75435,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/autoconf.h linux-4.3-rtl8723bs/3 + +/* define DBG_XMIT_BUF */ +/* define DBG_XMIT_BUF_EXT */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/basic_types.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/basic_types.h ---- linux-4.3/3rdparty/rtl8723bs/include/basic_types.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/basic_types.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/basic_types.h linux/3rdparty/rtl8723bs/include/basic_types.h +--- linux.old/3rdparty/rtl8723bs/include/basic_types.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/basic_types.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,209 @@ +/****************************************************************************** + * @@ -77658,9 +75648,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/basic_types.h linux-4.3-rtl8723b +#define TEST_FLAGS(__Flag, __testFlags) (((__Flag) & (__testFlags)) == (__testFlags)) + +#endif /* __BASIC_TYPES_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/cmd_osdep.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/cmd_osdep.h ---- linux-4.3/3rdparty/rtl8723bs/include/cmd_osdep.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/cmd_osdep.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/cmd_osdep.h linux/3rdparty/rtl8723bs/include/cmd_osdep.h +--- linux.old/3rdparty/rtl8723bs/include/cmd_osdep.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/cmd_osdep.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,26 @@ +/****************************************************************************** + * @@ -77688,9 +75678,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/cmd_osdep.h linux-4.3-rtl8723bs/ +extern struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/drv_conf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/drv_conf.h ---- linux-4.3/3rdparty/rtl8723bs/include/drv_conf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/drv_conf.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/drv_conf.h linux/3rdparty/rtl8723bs/include/drv_conf.h +--- linux.old/3rdparty/rtl8723bs/include/drv_conf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/drv_conf.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,37 @@ +/****************************************************************************** + * @@ -77729,9 +75719,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/drv_conf.h linux-4.3-rtl8723bs/3 +//#include + +#endif // __DRV_CONF_H__ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/drv_types.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/drv_types.h ---- linux-4.3/3rdparty/rtl8723bs/include/drv_types.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/drv_types.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/drv_types.h linux/3rdparty/rtl8723bs/include/drv_types.h +--- linux.old/3rdparty/rtl8723bs/include/drv_types.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/drv_types.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,720 @@ +/****************************************************************************** + * @@ -78453,9 +76443,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/drv_types.h linux-4.3-rtl8723bs/ +extern u8 g_fwdl_chksum_fail; + +#endif /* __DRV_TYPES_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/drv_types_sdio.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/drv_types_sdio.h ---- linux-4.3/3rdparty/rtl8723bs/include/drv_types_sdio.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/drv_types_sdio.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/drv_types_sdio.h linux/3rdparty/rtl8723bs/include/drv_types_sdio.h +--- linux.old/3rdparty/rtl8723bs/include/drv_types_sdio.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/drv_types_sdio.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,39 @@ +/****************************************************************************** + * @@ -78496,9 +76486,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/drv_types_sdio.h linux-4.3-rtl87 +} SDIO_DATA, *PSDIO_DATA; + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/ethernet.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/ethernet.h ---- linux-4.3/3rdparty/rtl8723bs/include/ethernet.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/ethernet.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/ethernet.h linux/3rdparty/rtl8723bs/include/ethernet.h +--- linux.old/3rdparty/rtl8723bs/include/ethernet.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/ethernet.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,22 @@ +/****************************************************************************** + * @@ -78522,9 +76512,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/ethernet.h linux-4.3-rtl8723bs/3 +#define LLC_HEADER_SIZE 6 /* LLC Header Length */ + +#endif /* #ifndef __INC_ETHERNET_H */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h ---- linux-4.3/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h linux/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h +--- linux.old/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,1126 @@ +/****************************************************************************** + * @@ -79652,9 +77642,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/Hal8192CPhyReg.h linux-4.3-rtl87 + + +#endif /* __INC_HAL8192SPHYREG_H */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h ---- linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h linux/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h +--- linux.old/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,128 @@ +/****************************************************************************** + * @@ -79784,9 +77774,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPhyCfg.h linux-4.3-rtl87 +/*--------------------------Exported Function prototype End---------------------*/ + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h ---- linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h linux/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h +--- linux.old/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,77 @@ +/****************************************************************************** + * @@ -79865,9 +77855,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPhyReg.h linux-4.3-rtl87 +#define rPm_Rx3_AntB 0xbf8 + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h ---- linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h linux/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h +--- linux.old/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,232 @@ +#ifndef REALTEK_POWER_SEQUENCE_8723B +#define REALTEK_POWER_SEQUENCE_8723B @@ -80101,9 +78091,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/Hal8723BPwrSeq.h linux-4.3-rtl87 +extern WLAN_PWR_CFG rtl8723B_enter_swlps_flow[RTL8723B_TRANS_ACT_TO_SWLPS_STEPS+RTL8723B_TRANS_END_STEPS]; +extern WLAN_PWR_CFG rtl8723B_leave_swlps_flow[RTL8723B_TRANS_SWLPS_TO_ACT_STEPS+RTL8723B_TRANS_END_STEPS]; +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_btcoex.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_btcoex.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_btcoex.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_btcoex.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_btcoex.h linux/3rdparty/rtl8723bs/include/hal_btcoex.h +--- linux.old/3rdparty/rtl8723bs/include/hal_btcoex.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_btcoex.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,68 @@ +/****************************************************************************** + * @@ -80173,9 +78163,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_btcoex.h linux-4.3-rtl8723bs +u32 hal_btcoex_GetDBG(struct adapter *, u8 *pStrBuf, u32 bufSize); + +#endif /* !__HAL_BTCOEX_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_com.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_com.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_com.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_com.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_com.h linux/3rdparty/rtl8723bs/include/hal_com.h +--- linux.old/3rdparty/rtl8723bs/include/hal_com.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_com.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,309 @@ +/****************************************************************************** + * @@ -80486,9 +78476,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_com.h linux-4.3-rtl8723bs/3r +#endif + +#endif /* __HAL_COMMON_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_com_h2c.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_com_h2c.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_com_h2c.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_com_h2c.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_com_h2c.h linux/3rdparty/rtl8723bs/include/hal_com_h2c.h +--- linux.old/3rdparty/rtl8723bs/include/hal_com_h2c.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_com_h2c.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,293 @@ +/****************************************************************************** + * @@ -80783,9 +78773,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_com_h2c.h linux-4.3-rtl8723b +void rtw_get_sec_iv(struct adapter *padapter, u8*pcur_dot11txpn, u8 *StaAddr); +void rtw_set_sec_pn(struct adapter *padapter); +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_com_phycfg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_com_phycfg.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_com_phycfg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_com_phycfg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_com_phycfg.h linux/3rdparty/rtl8723bs/include/hal_com_phycfg.h +--- linux.old/3rdparty/rtl8723bs/include/hal_com_phycfg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_com_phycfg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,275 @@ +/****************************************************************************** + * @@ -81062,9 +79052,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_com_phycfg.h linux-4.3-rtl87 +#endif /* CONFIG_LOAD_PHY_PARA_FROM_FILE */ + +#endif /* __HAL_COMMON_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_com_reg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_com_reg.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_com_reg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_com_reg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_com_reg.h linux/3rdparty/rtl8723bs/include/hal_com_reg.h +--- linux.old/3rdparty/rtl8723bs/include/hal_com_reg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_com_reg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,1725 @@ +/****************************************************************************** + * @@ -82791,9 +80781,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_com_reg.h linux-4.3-rtl8723b +#define HAL_8188E_HW_GPIO_WPS_BIT BIT7 + +#endif /* __HAL_COMMON_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_data.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_data.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_data.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_data.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_data.h linux/3rdparty/rtl8723bs/include/hal_data.h +--- linux.old/3rdparty/rtl8723bs/include/hal_data.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_data.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,485 @@ +/****************************************************************************** + * @@ -83280,9 +81270,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_data.h linux-4.3-rtl8723bs/3 +#define GET_RF_TYPE(__padapter) (GET_HAL_DATA(__padapter)->rf_type) + +#endif /* __HAL_DATA_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_intf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_intf.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_intf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_intf.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_intf.h linux/3rdparty/rtl8723bs/include/hal_intf.h +--- linux.old/3rdparty/rtl8723bs/include/hal_intf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_intf.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,410 @@ +/****************************************************************************** + * @@ -83694,9 +81684,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_intf.h linux-4.3-rtl8723bs/3 +s32 rtw_hal_fill_h2c_cmd(struct adapter *, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer); + +#endif /* __HAL_INTF_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_pg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_pg.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_pg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_pg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_pg.h linux/3rdparty/rtl8723bs/include/hal_pg.h +--- linux.old/3rdparty/rtl8723bs/include/hal_pg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_pg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,81 @@ +/****************************************************************************** + * @@ -83779,9 +81769,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_pg.h linux-4.3-rtl8723bs/3rd +}; + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_phy.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_phy.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_phy.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_phy.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_phy.h linux/3rdparty/rtl8723bs/include/hal_phy.h +--- linux.old/3rdparty/rtl8723bs/include/hal_phy.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_phy.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,183 @@ +/****************************************************************************** + * @@ -83966,9 +81956,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_phy.h linux-4.3-rtl8723bs/3r +/*--------------------------Exported Function prototype---------------------*/ + +#endif /* __HAL_COMMON_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_phy_reg.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_phy_reg.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_phy_reg.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_phy_reg.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_phy_reg.h linux/3rdparty/rtl8723bs/include/hal_phy_reg.h +--- linux.old/3rdparty/rtl8723bs/include/hal_phy_reg.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_phy_reg.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,25 @@ +/****************************************************************************** + * @@ -83995,9 +81985,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_phy_reg.h linux-4.3-rtl8723b +/* endif */ + +#endif /* __HAL_PHY_REG_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h ---- linux-4.3/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h linux/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h +--- linux.old/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,132 @@ +/****************************************************************************** + * @@ -84131,9 +82121,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/HalPwrSeqCmd.h linux-4.3-rtl8723 + WLAN_PWR_CFG PwrCfgCmd[]); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_sdio.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_sdio.h ---- linux-4.3/3rdparty/rtl8723bs/include/hal_sdio.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/hal_sdio.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/hal_sdio.h linux/3rdparty/rtl8723bs/include/hal_sdio.h +--- linux.old/3rdparty/rtl8723bs/include/hal_sdio.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/hal_sdio.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,26 @@ +/****************************************************************************** + * @@ -84161,9 +82151,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/hal_sdio.h linux-4.3-rtl8723bs/3 +u32 rtw_hal_get_sdio_tx_max_length(struct adapter *padapter, u8 queue_idx); + +#endif /* __RTW_LED_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/HalVerDef.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/HalVerDef.h ---- linux-4.3/3rdparty/rtl8723bs/include/HalVerDef.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/HalVerDef.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/HalVerDef.h linux/3rdparty/rtl8723bs/include/HalVerDef.h +--- linux.old/3rdparty/rtl8723bs/include/HalVerDef.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/HalVerDef.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,127 @@ +/****************************************************************************** + * @@ -84292,9 +82282,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/HalVerDef.h linux-4.3-rtl8723bs/ +#define IS_2T2R(version) ((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R)? true : false) + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/ieee80211.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/ieee80211.h ---- linux-4.3/3rdparty/rtl8723bs/include/ieee80211.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/ieee80211.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/ieee80211.h linux/3rdparty/rtl8723bs/include/ieee80211.h +--- linux.old/3rdparty/rtl8723bs/include/ieee80211.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/ieee80211.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,1345 @@ +/****************************************************************************** + * @@ -85633,7 +83623,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/ieee80211.h linux-4.3-rtl8723bs/ + +void rtw_get_bcn_info(struct wlan_network *pnetwork); + -+void rtw_macaddr_cfg(u8 *mac_addr); ++void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr); + +u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char * MCS_rate); + @@ -85641,9 +83631,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/ieee80211.h linux-4.3-rtl8723bs/ +const char *action_public_str(u8 action); + +#endif /* IEEE80211_H */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/ioctl_cfg80211.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/ioctl_cfg80211.h ---- linux-4.3/3rdparty/rtl8723bs/include/ioctl_cfg80211.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/ioctl_cfg80211.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/ioctl_cfg80211.h linux/3rdparty/rtl8723bs/include/ioctl_cfg80211.h +--- linux.old/3rdparty/rtl8723bs/include/ioctl_cfg80211.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/ioctl_cfg80211.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,132 @@ +/****************************************************************************** + * @@ -85777,9 +83767,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/ioctl_cfg80211.h linux-4.3-rtl87 +#define rtw_cfg80211_remain_on_channel_expired(adapter, cookie, chan, chan_type, gfp) cfg80211_remain_on_channel_expired((adapter)->rtw_wdev, cookie, chan, gfp) + +#endif /* __IOCTL_CFG80211_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/mlme_osdep.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/mlme_osdep.h ---- linux-4.3/3rdparty/rtl8723bs/include/mlme_osdep.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/mlme_osdep.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/mlme_osdep.h linux/3rdparty/rtl8723bs/include/mlme_osdep.h +--- linux.old/3rdparty/rtl8723bs/include/mlme_osdep.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/mlme_osdep.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,27 @@ +/****************************************************************************** + * @@ -85808,9 +83798,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/mlme_osdep.h linux-4.3-rtl8723bs +void rtw_reset_securitypriv(struct adapter *adapter); + +#endif /* _MLME_OSDEP_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/osdep_intf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/osdep_intf.h ---- linux-4.3/3rdparty/rtl8723bs/include/osdep_intf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/osdep_intf.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/osdep_intf.h linux/3rdparty/rtl8723bs/include/osdep_intf.h +--- linux.old/3rdparty/rtl8723bs/include/osdep_intf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/osdep_intf.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,88 @@ +/****************************************************************************** + * @@ -85900,9 +83890,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/osdep_intf.h linux-4.3-rtl8723bs +int rtw_resume_common(struct adapter *padapter); + +#endif /* _OSDEP_INTF_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/osdep_service.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/osdep_service.h ---- linux-4.3/3rdparty/rtl8723bs/include/osdep_service.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/osdep_service.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/osdep_service.h linux/3rdparty/rtl8723bs/include/osdep_service.h +--- linux.old/3rdparty/rtl8723bs/include/osdep_service.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/osdep_service.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,281 @@ +/****************************************************************************** + * @@ -86185,9 +84175,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/osdep_service.h linux-4.3-rtl872 +#define rtw_sprintf(buf, size, format, arg...) snprintf(buf, size, format, ##arg) + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/osdep_service_linux.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/osdep_service_linux.h ---- linux-4.3/3rdparty/rtl8723bs/include/osdep_service_linux.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/osdep_service_linux.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/osdep_service_linux.h linux/3rdparty/rtl8723bs/include/osdep_service_linux.h +--- linux.old/3rdparty/rtl8723bs/include/osdep_service_linux.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/osdep_service_linux.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,178 @@ +/****************************************************************************** + * @@ -86367,9 +84357,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/osdep_service_linux.h linux-4.3- +extern struct net_device * rtw_alloc_etherdev(int sizeof_priv); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/recv_osdep.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/recv_osdep.h ---- linux-4.3/3rdparty/rtl8723bs/include/recv_osdep.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/recv_osdep.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/recv_osdep.h linux/3rdparty/rtl8723bs/include/recv_osdep.h +--- linux.old/3rdparty/rtl8723bs/include/recv_osdep.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/recv_osdep.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,48 @@ +/****************************************************************************** + * @@ -86419,9 +84409,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/recv_osdep.h linux-4.3-rtl8723bs + + +#endif /* */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8192c_recv.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8192c_recv.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8192c_recv.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8192c_recv.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8192c_recv.h linux/3rdparty/rtl8723bs/include/rtl8192c_recv.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8192c_recv.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8192c_recv.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,50 @@ +/****************************************************************************** + * @@ -86473,9 +84463,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8192c_recv.h linux-4.3-rtl872 +void rtl8192c_query_rx_desc_status(union recv_frame *precvframe, struct recv_stat *pdesc); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8192c_rf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8192c_rf.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8192c_rf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8192c_rf.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8192c_rf.h linux/3rdparty/rtl8723bs/include/rtl8192c_rf.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8192c_rf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8192c_rf.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,39 @@ +/****************************************************************************** + * @@ -86516,9 +84506,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8192c_rf.h linux-4.3-rtl8723b + + +#endif/* End of HalRf.h */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_cmd.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_cmd.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_cmd.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_cmd.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8723b_cmd.h linux/3rdparty/rtl8723bs/include/rtl8723b_cmd.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8723b_cmd.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8723b_cmd.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,199 @@ +/****************************************************************************** + * @@ -86719,9 +84709,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_cmd.h linux-4.3-rtl8723 + +#define FillH2CCmd FillH2CCmd8723B +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_dm.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_dm.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_dm.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_dm.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8723b_dm.h linux/3rdparty/rtl8723bs/include/rtl8723b_dm.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8723b_dm.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8723b_dm.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,41 @@ +/****************************************************************************** + * @@ -86764,9 +84754,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_dm.h linux-4.3-rtl8723b + + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_hal.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_hal.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_hal.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_hal.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8723b_hal.h linux/3rdparty/rtl8723bs/include/rtl8723b_hal.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8723b_hal.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8723b_hal.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,279 @@ +/****************************************************************************** + * @@ -87047,9 +85037,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_hal.h linux-4.3-rtl8723 +void Hal_ReadRFGainOffset(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_recv.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_recv.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_recv.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_recv.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8723b_recv.h linux/3rdparty/rtl8723bs/include/rtl8723b_recv.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8723b_recv.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8723b_recv.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,144 @@ +/****************************************************************************** + * @@ -87195,9 +85185,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_recv.h linux-4.3-rtl872 +void rtl8723b_process_phy_info(struct adapter *padapter, void *prframe); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_rf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_rf.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_rf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_rf.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8723b_rf.h linux/3rdparty/rtl8723bs/include/rtl8723b_rf.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8723b_rf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8723b_rf.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,26 @@ +/****************************************************************************** + * @@ -87225,9 +85215,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_rf.h linux-4.3-rtl8723b + enum CHANNEL_WIDTH Bandwidth); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_spec.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_spec.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_spec.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_spec.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8723b_spec.h linux/3rdparty/rtl8723bs/include/rtl8723b_spec.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8723b_spec.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8723b_spec.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,262 @@ +/****************************************************************************** + * @@ -87491,9 +85481,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_spec.h linux-4.3-rtl872 +#define IMR_RXFOVW_8723B BIT8 /* Receive FIFO Overflow */ + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_xmit.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_xmit.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_xmit.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtl8723b_xmit.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtl8723b_xmit.h linux/3rdparty/rtl8723bs/include/rtl8723b_xmit.h +--- linux.old/3rdparty/rtl8723bs/include/rtl8723b_xmit.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtl8723b_xmit.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,458 @@ +/****************************************************************************** + * @@ -87953,9 +85943,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtl8723b_xmit.h linux-4.3-rtl872 +u8 SCMapping_8723B(struct adapter * Adapter, struct pkt_attrib *pattrib); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_ap.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_ap.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_ap.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_ap.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_ap.h linux/3rdparty/rtl8723bs/include/rtw_ap.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_ap.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_ap.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,47 @@ +/****************************************************************************** + * @@ -88004,9 +85994,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_ap.h linux-4.3-rtl8723bs/3rd + +#endif +void update_bmc_sta(struct adapter *padapter); -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_beamforming.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_beamforming.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_beamforming.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_beamforming.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_beamforming.h linux/3rdparty/rtl8723bs/include/rtw_beamforming.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_beamforming.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_beamforming.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,135 @@ +/****************************************************************************** + * @@ -88143,9 +86133,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_beamforming.h linux-4.3-rtl8 +u8 beamforming_wk_cmd(struct adapter *padapter, s32 type, u8 *pbuf, s32 size, u8 enqueue); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_br_ext.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_br_ext.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_br_ext.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_br_ext.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_br_ext.h linux/3rdparty/rtl8723bs/include/rtw_br_ext.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_br_ext.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_br_ext.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,63 @@ +/****************************************************************************** + * @@ -88210,9 +86200,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_br_ext.h linux-4.3-rtl8723bs +void nat25_db_cleanup(struct adapter *priv); + +#endif /* _RTW_BR_EXT_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_btcoex.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_btcoex.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_btcoex.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_btcoex.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_btcoex.h linux/3rdparty/rtl8723bs/include/rtw_btcoex.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_btcoex.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_btcoex.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,64 @@ +/****************************************************************************** + * @@ -88278,9 +86268,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_btcoex.h linux-4.3-rtl8723bs +void rtw_btcoex_LPS_Leave(struct adapter *); + +#endif /* __RTW_BTCOEX_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_byteorder.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_byteorder.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_byteorder.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_byteorder.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_byteorder.h linux/3rdparty/rtl8723bs/include/rtw_byteorder.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_byteorder.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_byteorder.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,24 @@ +/****************************************************************************** + * @@ -88306,9 +86296,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_byteorder.h linux-4.3-rtl872 +#endif + +#endif /* _RTL871X_BYTEORDER_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_cmd.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_cmd.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_cmd.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_cmd.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_cmd.h linux/3rdparty/rtl8723bs/include/rtw_cmd.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_cmd.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_cmd.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,980 @@ +/****************************************************************************** + * @@ -89290,9 +87280,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_cmd.h linux-4.3-rtl8723bs/3r +#define _SetRFReg_CMD_ _Write_RFREG_CMD_ + +#endif /* _CMD_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_debug.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_debug.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_debug.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_debug.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_debug.h linux/3rdparty/rtl8723bs/include/rtw_debug.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_debug.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_debug.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,355 @@ +/****************************************************************************** + * @@ -89649,9 +87639,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_debug.h linux-4.3-rtl8723bs/ +#endif /* CONFIG_PROC_DEBUG */ + +#endif /* __RTW_DEBUG_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_eeprom.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_eeprom.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_eeprom.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_eeprom.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_eeprom.h linux/3rdparty/rtl8723bs/include/rtw_eeprom.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_eeprom.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_eeprom.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,128 @@ +/****************************************************************************** + * @@ -89781,9 +87771,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_eeprom.h linux-4.3-rtl8723bs +}; + +#endif /* __RTL871X_EEPROM_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_efuse.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_efuse.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_efuse.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_efuse.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_efuse.h linux/3rdparty/rtl8723bs/include/rtw_efuse.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_efuse.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_efuse.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,132 @@ +/****************************************************************************** + * @@ -89917,9 +87907,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_efuse.h linux-4.3-rtl8723bs/ +u32 Rtw_Hal_readPGDataFromConfigFile(struct adapter *padapter); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_event.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_event.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_event.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_event.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_event.h linux/3rdparty/rtl8723bs/include/rtw_event.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_event.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_event.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,117 @@ +/****************************************************************************** + * @@ -90038,9 +88028,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_event.h linux-4.3-rtl8723bs/ + + +#endif /* _WLANEVENT_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_ht.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_ht.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_ht.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_ht.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_ht.h linux/3rdparty/rtl8723bs/include/rtw_ht.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_ht.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_ht.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,118 @@ +/****************************************************************************** + * @@ -90160,9 +88150,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_ht.h linux-4.3-rtl8723bs/3rd +#define GET_HT_CAP_TXBF_EXPLICIT_COMP_FEEDBACK_CAP(_pEleStart) LE_BITS_TO_4BYTE((_pEleStart)+21, 15, 2) + +#endif /* _RTL871X_HT_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_ioctl.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_ioctl.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_ioctl.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_ioctl.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_ioctl.h linux/3rdparty/rtl8723bs/include/rtw_ioctl.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_ioctl.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_ioctl.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,80 @@ +/****************************************************************************** + * @@ -90244,9 +88234,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_ioctl.h linux-4.3-rtl8723bs/ +extern struct iw_handler_def rtw_handlers_def; + +#endif /* #ifndef __INC_CEINFO_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_ioctl_set.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_ioctl_set.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_ioctl_set.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_ioctl_set.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_ioctl_set.h linux/3rdparty/rtl8723bs/include/rtw_ioctl_set.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_ioctl_set.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_ioctl_set.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,41 @@ +/****************************************************************************** + * @@ -90289,9 +88279,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_ioctl_set.h linux-4.3-rtl872 +u16 rtw_get_cur_max_rate(struct adapter *adapter); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_io.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_io.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_io.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_io.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_io.h linux/3rdparty/rtl8723bs/include/rtw_io.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_io.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_io.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,373 @@ +/****************************************************************************** + * @@ -90666,9 +88656,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_io.h linux-4.3-rtl8723bs/3rd + rtw_read32(_a, _b) + +#endif /* _RTL8711_IO_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_mlme_ext.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_mlme_ext.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_mlme_ext.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_mlme_ext.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_mlme_ext.h linux/3rdparty/rtl8723bs/include/rtw_mlme_ext.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_mlme_ext.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_mlme_ext.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,888 @@ +/****************************************************************************** + * @@ -91558,9 +89548,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_mlme_ext.h linux-4.3-rtl8723 +#endif/* _RTL8192C_CMD_C_ */ + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_mlme.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_mlme.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_mlme.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_mlme.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_mlme.h linux/3rdparty/rtl8723bs/include/rtw_mlme.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_mlme.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_mlme.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,695 @@ +/****************************************************************************** + * @@ -92257,9 +90247,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_mlme.h linux-4.3-rtl8723bs/3 +void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, u32 mstatus); + +#endif /* __RTL871X_MLME_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_mp.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_mp.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_mp.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_mp.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_mp.h linux/3rdparty/rtl8723bs/include/rtw_mp.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_mp.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_mp.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,512 @@ +/****************************************************************************** + * @@ -92773,9 +90763,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_mp.h linux-4.3-rtl8723bs/3rd +u8 MptToMgntRate(u32 MptRateIdx); + +#endif /* _RTW_MP_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_odm.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_odm.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_odm.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_odm.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_odm.h linux/3rdparty/rtl8723bs/include/rtw_odm.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_odm.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_odm.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,36 @@ +/****************************************************************************** + * @@ -92813,9 +90803,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_odm.h linux-4.3-rtl8723bs/3r + s8 IGI_Base, bool ForceEDCCA, u8 AdapEn_RSSI, u8 IGI_LowerBound); +void rtw_odm_get_perpkt_rssi(void *sel, struct adapter *adapter); +#endif /* __RTW_ODM_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_pwrctrl.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_pwrctrl.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_pwrctrl.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_pwrctrl.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_pwrctrl.h linux/3rdparty/rtl8723bs/include/rtw_pwrctrl.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_pwrctrl.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_pwrctrl.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,375 @@ +/****************************************************************************** + * @@ -93192,9 +91182,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_pwrctrl.h linux-4.3-rtl8723b +u32 rtw_ps_deny_get(struct adapter *padapter); + +#endif /* __RTL871X_PWRCTRL_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_qos.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_qos.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_qos.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_qos.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_qos.h linux/3rdparty/rtl8723bs/include/rtw_qos.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_qos.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_qos.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,27 @@ +/****************************************************************************** + * @@ -93223,9 +91213,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_qos.h linux-4.3-rtl8723bs/3r + + +#endif /* _RTL871X_QOS_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_recv.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_recv.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_recv.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_recv.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_recv.h linux/3rdparty/rtl8723bs/include/rtw_recv.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_recv.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_recv.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,553 @@ +/****************************************************************************** + * @@ -93780,9 +91770,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_recv.h linux-4.3-rtl8723bs/3 +extern void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_rf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_rf.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_rf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_rf.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_rf.h linux/3rdparty/rtl8723bs/include/rtw_rf.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_rf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_rf.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,159 @@ +/****************************************************************************** + * @@ -93943,9 +91933,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_rf.h linux-4.3-rtl8723bs/3rd +u32 rtw_ch2freq(u32 ch); + +#endif /* _RTL8711_RF_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_security.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_security.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_security.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_security.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_security.h linux/3rdparty/rtl8723bs/include/rtw_security.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_security.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_security.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,440 @@ +/****************************************************************************** + * @@ -94387,16 +92377,16 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_security.h linux-4.3-rtl8723 +u8 rtw_handle_tkip_countermeasure(struct adapter * adapter, const char *caller); + +#endif /* __RTL871X_SECURITY_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_version.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_version.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_version.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_version.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_version.h linux/3rdparty/rtl8723bs/include/rtw_version.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_version.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_version.h 2016-04-29 18:14:02.000000000 +0300 @@ -0,0 +1,2 @@ +#define DRIVERVERSION "v4.3.5.5_12290.20140916_BTCOEX20140507-4E40" +#define BTCOEXVERSION "BTCOEX20140507-4E40" -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_wifi_regd.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_wifi_regd.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_wifi_regd.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_wifi_regd.h 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,28 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_wifi_regd.h linux/3rdparty/rtl8723bs/include/rtw_wifi_regd.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_wifi_regd.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_wifi_regd.h 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,35 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. @@ -94406,6 +92396,13 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_wifi_regd.h linux-4.3-rtl872 +#ifndef __RTW_WIFI_REGD_H__ +#define __RTW_WIFI_REGD_H__ + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) ++#define ieee80211_band nl80211_band ++#define IEEE80211_BAND_2GHZ NL80211_BAND_2GHZ ++#define IEEE80211_BAND_5GHZ NL80211_BAND_5GHZ ++#define IEEE80211_NUM_BANDS NUM_NL80211_BANDS ++#endif ++ +struct country_code_to_enum_rd { + u16 countrycode; + const char *iso_name; @@ -94425,9 +92422,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_wifi_regd.h linux-4.3-rtl872 + + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_xmit.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_xmit.h ---- linux-4.3/3rdparty/rtl8723bs/include/rtw_xmit.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/rtw_xmit.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/rtw_xmit.h linux/3rdparty/rtl8723bs/include/rtw_xmit.h +--- linux.old/3rdparty/rtl8723bs/include/rtw_xmit.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/rtw_xmit.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,528 @@ +/****************************************************************************** + * @@ -94957,9 +92954,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/rtw_xmit.h linux-4.3-rtl8723bs/3 +#include + +#endif /* _RTL871X_XMIT_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sdio_hal.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sdio_hal.h ---- linux-4.3/3rdparty/rtl8723bs/include/sdio_hal.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sdio_hal.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/sdio_hal.h linux/3rdparty/rtl8723bs/include/sdio_hal.h +--- linux.old/3rdparty/rtl8723bs/include/sdio_hal.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/sdio_hal.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,28 @@ +/****************************************************************************** + * @@ -94989,9 +92986,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sdio_hal.h linux-4.3-rtl8723bs/3 +void rtl8723bs_set_hal_ops(struct adapter *padapter); + +#endif /* __SDIO_HAL_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sdio_ops.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sdio_ops.h ---- linux-4.3/3rdparty/rtl8723bs/include/sdio_ops.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sdio_ops.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/sdio_ops.h linux/3rdparty/rtl8723bs/include/sdio_ops.h +--- linux.old/3rdparty/rtl8723bs/include/sdio_ops.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/sdio_ops.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,49 @@ +/****************************************************************************** + * @@ -95042,9 +93039,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sdio_ops.h linux-4.3-rtl8723bs/3 +#endif /* CONFIG_WOWLAN */ + +#endif /* !__SDIO_OPS_H__ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sdio_ops_linux.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sdio_ops_linux.h ---- linux-4.3/3rdparty/rtl8723bs/include/sdio_ops_linux.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sdio_ops_linux.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/sdio_ops_linux.h linux/3rdparty/rtl8723bs/include/sdio_ops_linux.h +--- linux.old/3rdparty/rtl8723bs/include/sdio_ops_linux.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/sdio_ops_linux.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,40 @@ +/****************************************************************************** + * @@ -95086,9 +93083,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sdio_ops_linux.h linux-4.3-rtl87 + +void rtw_sdio_set_irq_thd(struct dvobj_priv *dvobj, void *thd_hdl); +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sdio_osintf.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sdio_osintf.h ---- linux-4.3/3rdparty/rtl8723bs/include/sdio_osintf.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sdio_osintf.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/sdio_osintf.h linux/3rdparty/rtl8723bs/include/sdio_osintf.h +--- linux.old/3rdparty/rtl8723bs/include/sdio_osintf.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/sdio_osintf.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,24 @@ +/****************************************************************************** + * @@ -95114,9 +93111,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sdio_osintf.h linux-4.3-rtl8723b +void sd_c2h_hdl(struct adapter *padapter); + +#endif -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sta_info.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sta_info.h ---- linux-4.3/3rdparty/rtl8723bs/include/sta_info.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/sta_info.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/sta_info.h linux/3rdparty/rtl8723bs/include/sta_info.h +--- linux.old/3rdparty/rtl8723bs/include/sta_info.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/sta_info.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,392 @@ +/****************************************************************************** + * @@ -95510,9 +93507,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/sta_info.h linux-4.3-rtl8723bs/3 +extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr); + +#endif /* _STA_INFO_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/wifi.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/wifi.h ---- linux-4.3/3rdparty/rtl8723bs/include/wifi.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/wifi.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/wifi.h linux/3rdparty/rtl8723bs/include/wifi.h +--- linux.old/3rdparty/rtl8723bs/include/wifi.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/wifi.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,1158 @@ +/****************************************************************************** + * @@ -96672,9 +94669,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/wifi.h linux-4.3-rtl8723bs/3rdpa +}; + +#endif /* _WIFI_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/wlan_bssdef.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/wlan_bssdef.h ---- linux-4.3/3rdparty/rtl8723bs/include/wlan_bssdef.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/wlan_bssdef.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/wlan_bssdef.h linux/3rdparty/rtl8723bs/include/wlan_bssdef.h +--- linux.old/3rdparty/rtl8723bs/include/wlan_bssdef.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/wlan_bssdef.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,278 @@ +/****************************************************************************** + * @@ -96954,9 +94951,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/wlan_bssdef.h linux-4.3-rtl8723b +#define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY + +#endif /* ifndef WLAN_BSSDEF_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/xmit_osdep.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/xmit_osdep.h ---- linux-4.3/3rdparty/rtl8723bs/include/xmit_osdep.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/include/xmit_osdep.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/include/xmit_osdep.h linux/3rdparty/rtl8723bs/include/xmit_osdep.h +--- linux.old/3rdparty/rtl8723bs/include/xmit_osdep.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/include/xmit_osdep.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,54 @@ +/****************************************************************************** + * @@ -97012,9 +95009,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/include/xmit_osdep.h linux-4.3-rtl8723bs +extern void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe); + +#endif /* __XMIT_OSDEP_H_ */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/Kconfig linux-4.3-rtl8723bs/3rdparty/rtl8723bs/Kconfig ---- linux-4.3/3rdparty/rtl8723bs/Kconfig 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/Kconfig 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/Kconfig linux/3rdparty/rtl8723bs/Kconfig +--- linux.old/3rdparty/rtl8723bs/Kconfig 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/Kconfig 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,11 @@ +config RTL8723BS + tristate "Realtek 8723B SDIO or SPI WiFi" @@ -97027,10 +95024,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/Kconfig linux-4.3-rtl8723bs/3rdparty/rtl + default n + ---help--- + Use memory preallocated in platform -diff -Nurp linux-4.3/3rdparty/rtl8723bs/Makefile linux-4.3-rtl8723bs/3rdparty/rtl8723bs/Makefile ---- linux-4.3/3rdparty/rtl8723bs/Makefile 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/Makefile 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,250 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/Makefile linux/3rdparty/rtl8723bs/Makefile +--- linux.old/3rdparty/rtl8723bs/Makefile 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/Makefile 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,251 @@ +EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS) +EXTRA_CFLAGS += -O1 +#EXTRA_CFLAGS += -O3 @@ -97198,7 +95195,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/Makefile linux-4.3-rtl8723bs/3rdparty/rt +endif + +ifeq ($(CONFIG_PLATFORM_I386_PC), y) -+SUBARCH := $(shell uname -m | sed -e s/i.86/i386/) ++SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ | sed -e s/armv7l/arm/) +ARCH ?= $(SUBARCH) +CROSS_COMPILE ?= +KVER := $(shell uname -r) @@ -97253,6 +95250,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/Makefile linux-4.3-rtl8723bs/3rdparty/rt + +install: + install -p -m 644 $(MODULE_NAME).ko $(MODDESTDIR) ++ @mkdir -p /lib/firmware/rtlwifi/ + @cp -n rtl8723bs_nic.bin /lib/firmware/rtlwifi/rtl8723bs_nic.bin + @cp -n rtl8723bs_wowlan.bin /lib/firmware/rtlwifi/rtl8723bs_wowlan.bin + /sbin/depmod -a ${KVER} @@ -97276,15 +95274,15 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/Makefile linux-4.3-rtl8723bs/3rdparty/rt +clean: + @rm -fr hal/*/*.mod.c hal/*/*.mod hal/*/*.o hal/*/.*.cmd hal/*/*.ko \ + hal/*.mod.c hal/*.mod hal/*.o hal/.*.cmd hal/*.ko \ -+ core/*.mod.c core/*.mod *.o core/.*.cmd core/*.ko \ ++ core/*.mod.c core/*.mod core/*.o core/.*.cmd core/*.ko \ + os_dep/*.mod.c os_dep/*.mod os_dep/*.o os_dep/.*.cmd *.ko \ + platform/*.mod.c platform/*.mod platform/*.o platform/.*.cmd platform/*.ko \ + Module.symvers Module.markers modules.order *.mod.c *.mod *.o .*.cmd *.ko *~ .tmp_versions \ + cppcheck.log -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,3599 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c linux/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c +--- linux.old/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,3608 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -98686,6 +96684,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c linux-4.3-rtl872 +void rtw_cfg80211_indicate_scan_done(struct adapter *adapter, bool aborted) +{ + struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(adapter); ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) ++ struct cfg80211_scan_info info = { ++ .aborted = aborted ++ }; ++#endif + + spin_lock_bh(&pwdev_priv->scan_req_lock); + if (pwdev_priv->scan_request != NULL) { @@ -98700,7 +96703,11 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c linux-4.3-rtl872 + } + else + { ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) ++ cfg80211_scan_done(pwdev_priv->scan_request, &info); ++#else + cfg80211_scan_done(pwdev_priv->scan_request, aborted); ++#endif + } + + pwdev_priv->scan_request = NULL; @@ -100884,9 +98891,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/ioctl_cfg80211.c linux-4.3-rtl872 + + wiphy_unregister(wdev->wiphy); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/ioctl_linux.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/ioctl_linux.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/ioctl_linux.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/ioctl_linux.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/ioctl_linux.c linux/3rdparty/rtl8723bs/os_dep/ioctl_linux.c +--- linux.old/3rdparty/rtl8723bs/os_dep/ioctl_linux.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/ioctl_linux.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,5820 @@ +/****************************************************************************** + * @@ -106708,9 +104715,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/ioctl_linux.c linux-4.3-rtl8723bs + + return ret; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/mlme_linux.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/mlme_linux.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/mlme_linux.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/mlme_linux.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/mlme_linux.c linux/3rdparty/rtl8723bs/os_dep/mlme_linux.c +--- linux.old/3rdparty/rtl8723bs/os_dep/mlme_linux.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/mlme_linux.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,206 @@ +/****************************************************************************** + * @@ -106918,9 +104925,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/mlme_linux.c linux-4.3-rtl8723bs/ + _init_timer(&pmlmeext->link_timer, padapter->pnetdev, link_timer_hdl, padapter); + _init_timer(&pmlmeext->sa_query_timer, padapter->pnetdev, sa_query_timer_hdl, padapter); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/osdep_service.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/osdep_service.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/osdep_service.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/osdep_service.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/osdep_service.c linux/3rdparty/rtl8723bs/os_dep/osdep_service.c +--- linux.old/3rdparty/rtl8723bs/os_dep/osdep_service.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/osdep_service.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,481 @@ +/****************************************************************************** + * @@ -107403,9 +105410,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/osdep_service.c linux-4.3-rtl8723 + + return cbuf; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/os_intfs.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/os_intfs.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/os_intfs.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/os_intfs.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/os_intfs.c linux/3rdparty/rtl8723bs/os_dep/os_intfs.c +--- linux.old/3rdparty/rtl8723bs/os_dep/os_intfs.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/os_intfs.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,1916 @@ +/****************************************************************************** + * @@ -109323,9 +107330,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/os_intfs.c linux-4.3-rtl8723bs/3r + + return ret; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/recv_linux.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/recv_linux.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/recv_linux.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/recv_linux.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/recv_linux.c linux/3rdparty/rtl8723bs/os_dep/recv_linux.c +--- linux.old/3rdparty/rtl8723bs/os_dep/recv_linux.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/recv_linux.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,366 @@ +/****************************************************************************** + * @@ -109693,9 +107700,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/recv_linux.c linux-4.3-rtl8723bs/ + _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, rtw_reordering_ctrl_timeout_handler, preorder_ctrl); + +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/rtw_proc.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/rtw_proc.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/rtw_proc.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/rtw_proc.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/rtw_proc.c linux/3rdparty/rtl8723bs/os_dep/rtw_proc.c +--- linux.old/3rdparty/rtl8723bs/os_dep/rtw_proc.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/rtw_proc.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,786 @@ +/****************************************************************************** + * @@ -110483,9 +108490,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/rtw_proc.c linux-4.3-rtl8723bs/3r +} + +#endif /* CONFIG_PROC_DEBUG */ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/rtw_proc.h linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/rtw_proc.h ---- linux-4.3/3rdparty/rtl8723bs/os_dep/rtw_proc.h 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/rtw_proc.h 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/rtw_proc.h linux/3rdparty/rtl8723bs/os_dep/rtw_proc.h +--- linux.old/3rdparty/rtl8723bs/os_dep/rtw_proc.h 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/rtw_proc.h 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,45 @@ +/****************************************************************************** + * @@ -110532,10 +108539,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/rtw_proc.h linux-4.3-rtl8723bs/3r +#endif //!CONFIG_PROC_DEBUG + +#endif //__RTW_PROC_H__ -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_intf.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/sdio_intf.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_intf.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/sdio_intf.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,725 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/sdio_intf.c linux/3rdparty/rtl8723bs/os_dep/sdio_intf.c +--- linux.old/3rdparty/rtl8723bs/os_dep/sdio_intf.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/sdio_intf.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,727 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. @@ -110867,6 +108874,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_intf.c linux-4.3-rtl8723bs/3 + int status = _FAIL; + struct net_device *pnetdev; + struct adapter *padapter = NULL; ++ PSDIO_DATA psdio = &dvobj->intf_data; + + if ((padapter = (struct adapter *)vzalloc(sizeof(*padapter))) == NULL) { + goto exit; @@ -110931,7 +108939,7 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_intf.c linux-4.3-rtl8723bs/3 + + /* 3 8. get WLan MAC address */ + /* set mac addr */ -+ rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); ++ rtw_macaddr_cfg(&psdio->func->dev, padapter->eeprompriv.mac_addr); + + rtw_hal_disable_interrupt(padapter); + @@ -111018,11 +109026,12 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_intf.c linux-4.3-rtl8723bs/3 + switch (func->device) { + case 0x0523: + case 0x0623: ++ case 0x0626: + case 0xb723: + break; + default: -+ pr_info("RTL8723BS: Found unrecognized vendor 0x%x, device 0x%x\n", -+ func->vendor, func->device); ++ pr_info("RTL8723BS: Found unrecognized device 0x%x for vendor 0x%x\n", ++ func->device, func->vendor); + goto exit; + } + break; @@ -111261,9 +109270,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_intf.c linux-4.3-rtl8723bs/3 + +module_init(rtw_drv_entry); +module_exit(rtw_drv_halt); -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c linux/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c +--- linux.old/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,599 @@ +/****************************************************************************** + * @@ -111864,10 +109873,10 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/sdio_ops_linux.c linux-4.3-rtl872 + sdio_release_host(func); + return err; +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/wifi_regd.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/wifi_regd.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/wifi_regd.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/wifi_regd.c 2015-11-21 19:42:45.000000000 +0200 -@@ -0,0 +1,218 @@ +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/wifi_regd.c linux/3rdparty/rtl8723bs/os_dep/wifi_regd.c +--- linux.old/3rdparty/rtl8723bs/os_dep/wifi_regd.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/wifi_regd.c 2017-01-20 22:14:45.000000000 +0200 +@@ -0,0 +1,164 @@ +/****************************************************************************** + * + * Copyright(c) 2009-2010 Realtek Corporation. @@ -111916,60 +109925,6 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/wifi_regd.c linux-4.3-rtl8723bs/3 + } +}; + -+static const struct ieee80211_regdomain rtw_regdom_11 = { -+ .n_reg_rules = 1, -+ .alpha2 = "99", -+ .reg_rules = { -+ RTW_2GHZ_CH01_11, -+ } -+}; -+ -+static const struct ieee80211_regdomain rtw_regdom_12_13 = { -+ .n_reg_rules = 2, -+ .alpha2 = "99", -+ .reg_rules = { -+ RTW_2GHZ_CH01_11, -+ RTW_2GHZ_CH12_13, -+ } -+}; -+ -+static const struct ieee80211_regdomain rtw_regdom_no_midband = { -+ .n_reg_rules = 3, -+ .alpha2 = "99", -+ .reg_rules = { -+ RTW_2GHZ_CH01_11, -+ } -+}; -+ -+static const struct ieee80211_regdomain rtw_regdom_60_64 = { -+ .n_reg_rules = 3, -+ .alpha2 = "99", -+ .reg_rules = { -+ RTW_2GHZ_CH01_11, -+ RTW_2GHZ_CH12_13, -+ } -+}; -+ -+static const struct ieee80211_regdomain rtw_regdom_14_60_64 = { -+ .n_reg_rules = 4, -+ .alpha2 = "99", -+ .reg_rules = { -+ RTW_2GHZ_CH01_11, -+ RTW_2GHZ_CH12_13, -+ RTW_2GHZ_CH14, -+ } -+}; -+ -+static const struct ieee80211_regdomain rtw_regdom_14 = { -+ .n_reg_rules = 3, -+ .alpha2 = "99", -+ .reg_rules = { -+ RTW_2GHZ_CH01_11, -+ RTW_2GHZ_CH12_13, -+ RTW_2GHZ_CH14, -+ } -+}; -+ +static int rtw_ieee80211_channel_to_frequency(int chan, int band) +{ + /* see 802.11 17.3.8.3.2 and Annex J @@ -112086,9 +110041,9 @@ diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/wifi_regd.c linux-4.3-rtl8723bs/3 + + _rtw_reg_notifier_apply(wiphy, request, reg); +} -diff -Nurp linux-4.3/3rdparty/rtl8723bs/os_dep/xmit_linux.c linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/xmit_linux.c ---- linux-4.3/3rdparty/rtl8723bs/os_dep/xmit_linux.c 1970-01-01 02:00:00.000000000 +0200 -+++ linux-4.3-rtl8723bs/3rdparty/rtl8723bs/os_dep/xmit_linux.c 2015-11-21 19:42:45.000000000 +0200 +diff -Nurp linux.old/3rdparty/rtl8723bs/os_dep/xmit_linux.c linux/3rdparty/rtl8723bs/os_dep/xmit_linux.c +--- linux.old/3rdparty/rtl8723bs/os_dep/xmit_linux.c 1970-01-01 02:00:00.000000000 +0200 ++++ linux/3rdparty/rtl8723bs/os_dep/xmit_linux.c 2017-01-20 22:14:45.000000000 +0200 @@ -0,0 +1,298 @@ +/****************************************************************************** + * diff --git a/kernel/kernel/files/patches/mageia/acpi-do-not-warn-if-_BQC-does-not-exist.patch b/kernel/kernel/files/patches/mageia/acpi-do-not-warn-if-_BQC-does-not-exist.patch new file mode 100644 index 00000000..4078a1ec --- /dev/null +++ b/kernel/kernel/files/patches/mageia/acpi-do-not-warn-if-_BQC-does-not-exist.patch @@ -0,0 +1,39 @@ +From 7020bcb82838006e23d058ff07b063b393ed3f10 Mon Sep 17 00:00:00 2001 +From: Zhang Rui +Date: Tue, 29 Nov 2016 23:19:46 +0100 +Subject: [PATCH] ACPI: do not warn if _BQC does not exist + +Starting from ACPI spec 3.0, it's only clarified that _BCM control +method is required if _BCL is implemented. There is no word +saying _BQC is required. + +And in ACPI spec 6.1 B.5.4, for _BQC, it is explicitly stated that +"This optional method returns the current brightness level of a +built-in display output device. If present, it must be set by +the platform for initial brightness." + +Thus remove the obsolete warning message. + +Signed-off-by: Zhang Rui +Signed-off-by: Rafael J. Wysocki +--- + drivers/acpi/scan.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c +index 3d1856f..07aa2e6 100644 +--- a/drivers/acpi/scan.c ++++ b/drivers/acpi/scan.c +@@ -1119,9 +1119,6 @@ acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context, + ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found generic backlight " + "support\n")); + *cap |= ACPI_VIDEO_BACKLIGHT; +- if (!acpi_has_method(handle, "_BQC")) +- printk(KERN_WARNING FW_BUG PREFIX "No _BQC method, " +- "cannot determine initial brightness\n"); + /* We have backlight support, no need to scan further */ + return AE_CTRL_TERMINATE; + } +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/block-Turn-into-BFQ-v8r6-for-4.9.0.patch b/kernel/kernel/files/patches/mageia/block-Turn-into-BFQ-v8r6-for-4.9.0.patch new file mode 100644 index 00000000..bd1279b5 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/block-Turn-into-BFQ-v8r6-for-4.9.0.patch @@ -0,0 +1,9106 @@ +From 3e3791c0b4ef3b2067f8454e58001af8e3da3840 Mon Sep 17 00:00:00 2001 +From: Paolo Valente +Date: Tue, 17 May 2016 08:28:04 +0200 +Subject: [PATCH 4/4] Turn into BFQ-v8r6 for 4.9.0 + +CHANGELOG from v8r4 to v8r6 + +BFQ v8r6 + +BUGFIX Removed the check that, when the new queue to set in service +must be selected, the cached next_in_service entities coincide with +the entities chosen by __bfq_lookup_next_entity. This check, +issuing a warning on failure, was wrong, because the cached and the +newly chosen entity could differ in case of a CLASS_IDLE timeout. + +EFFICIENCY IMPROVEMENT (this improvement is related to the above +BUGFIX) The cached next_in_service entities are now really used to +select the next queue to serve when the in-service queue +expires. Before this change, the cached values were used only for +extra (and in general wrong) consistency checks. This caused +additional overhead instead of reducing it. + +EFFICIENCY IMPROVEMENT The next entity to serve, for each level of the +hierarchy, is now updated on every event that may change it, i.e., on +every activation or deactivation of any entity. This finer granularity +is not strictly needed for corectness, because it is only on queue +expirations that BFQ needs to know what are the next entities to +serve. Yet this change makes it possible to implement optimizations in +which it is necessary to know the next queue to serve before the +in-service queue expires. + +SERVICE-ACCURACY IMPROVEMENT The per-device CLASS_IDLE service timeout +has been turned into a much more accurate per-group timeout. + +CODE-QUALITY IMPROVEMENT The non-trivial parts touched by the above +improvements have been partially rewritten, and enriched of comments, +so as to improve their transparency and understandability. + +IMPROVEMENT Ported and improved CFQ commit 41647e7a +Before this improvememtn, BFQ used the same logic for detecting +seeky queues for rotational disks and SSDs. This logic is appropriate +for the former, as it takes into account only inter-request distance, +and the latter is the dominant latency factor on a rotational device. +Yet things change with flash-based devices, where serving a large +request still yields a high throughput, even the request is far +from the previous request served. This commits extends seeky +detection to take into accoutn also this fact with flash-based +devices. In particular, this commit is an improved port of the +original commit 41647e7a for CFQ. + +CODE IMPROVEMENT Remove useless parameter from bfq_del_bfqq_busy + +OPTIMIZATION Optimize the update of next_in_service entity. +If the update of the next_in_service candidate entity is triggered by +the activation of an entity, then it is not necessary to perform full +lookups in the active trees to update next_in_service. In fact, it is +enough to check whether the just-activated entity has a higher +priority than next_in_service, or, even if it has the same priority as +next_in_service, is eligible and has a lower virtual finish time than +next_in_service. If this compound condition holds, then the new entity +can be set as the new next_in_service. Otherwise no change is needed. +This commit implements this optimization. + +BUGFIX Fix bug causing occasional loss of weight raising. +When a bfq_queue, say bfqq, is split after a merging with another +bfq_queue, BFQ checks whether it has to restore for bfqq the +weight-raising state that bfqq had before being merged. In +particular, the weight-raising is restored only if, according to the +weight-raising duration decided for bfqq when it started to be +weight-raised (before being merged), bfqq would not have already +finished its weight-raising period. +Yet, by mistake, such a duration was not saved when bfqq is merged. So, +if bfqq was freed and reallocated when it was split, then this duration +was wrongly set to zero on the split. As a consequence, the +weight-raising state of bfqq was wrongly not restored, which caused BFQ +to fail in guaranteeing a low latency to bfqq. +This commit fixes this bug by saving weight-raising duration when bfqq +is merged, and correctly restoring it when bfqq is split. + +BUGFIX Fix wrong reset of in-service entities +In-service entities were reset with an indirect logic, which +happened to be even buggy for some cases. This commit fixes +this bug in two important steps. First, by replacing this +indirect logic with a direct logic, in which all involved +entities are immediately reset, with a bubble-up loop, when +the in-service queue is reset. Second, by restructuring the +code related to this change, so as to become not only correct +with respect to this change, but also cleaner and hopefully +clearer. + +CODE IMPROVEMENT Add code to be able to redirect trace log to +console. + +BUGFIX Fixed bug in optimized update of next_in_service entity. +There was a case where bfq_update_next_in_service did not update +next_in_service, even if it might need to be changed: in case of +requeueing or repositioning of the entity that happened to be +pointed exactly by next_in_service. This could result in violation +of service guarantees, because, after a change of timestamps for +such an entity, it might be the case that next_in_service had to +point to a different entity. This commit fixes this bug. + +OPTIMIZATION Stop bubble-up of next_in_service update if possible. + +BUGFIX Fixed a false-positive warning for uninitialized var + +BFQ-v8r5 + +DOCUMENTATION IMPROVEMENT Added documentation of BFQ +benefits, inner workings, interface and tunables. + +BUGFIX: Replaced max wrongly used for modulo numbers. + +DOCUMENTATION IMPROVEMENT Improved help message in +Kconfig.iosched. + +BUGFIX: Removed wrong conversion in use of bfq_fifo_expire. + +CODE IMPROVEMENT Added parentheses to complex macros. + +Signed-off-by: Paolo Valente +--- + Documentation/block/00-INDEX | 2 + + Documentation/block/bfq-iosched.txt | 530 ++++++ + block/Kconfig.iosched | 18 +- + block/bfq-cgroup.c | 501 +++--- + block/bfq-iosched.c | 3278 ++++++++++++++++++++++------------- + block/bfq-sched.c | 1270 +++++++++++--- + block/bfq.h | 800 +++++---- + 7 files changed, 4310 insertions(+), 2089 deletions(-) + create mode 100644 Documentation/block/bfq-iosched.txt + +diff --git a/Documentation/block/00-INDEX b/Documentation/block/00-INDEX +index e55103a..8d55b4b 100644 +--- a/Documentation/block/00-INDEX ++++ b/Documentation/block/00-INDEX +@@ -1,5 +1,7 @@ + 00-INDEX + - This file ++bfq-iosched.txt ++ - BFQ IO scheduler and its tunables + biodoc.txt + - Notes on the Generic Block Layer Rewrite in Linux 2.5 + biovecs.txt +diff --git a/Documentation/block/bfq-iosched.txt b/Documentation/block/bfq-iosched.txt +new file mode 100644 +index 0000000..13b5248 +--- /dev/null ++++ b/Documentation/block/bfq-iosched.txt +@@ -0,0 +1,530 @@ ++BFQ (Budget Fair Queueing) ++========================== ++ ++BFQ is a proportional-share I/O scheduler, with some extra ++low-latency capabilities. In addition to cgroups support (blkio or io ++controllers), BFQ's main features are: ++- BFQ guarantees a high system and application responsiveness, and a ++ low latency for time-sensitive applications, such as audio or video ++ players; ++- BFQ distributes bandwidth, and not just time, among processes or ++ groups (switching back to time distribution when needed to keep ++ throughput high). ++ ++On average CPUs, the current version of BFQ can handle devices ++performing at most ~30K IOPS; at most ~50 KIOPS on faster CPUs. As a ++reference, 30-50 KIOPS correspond to very high bandwidths with ++sequential I/O (e.g., 8-12 GB/s if I/O requests are 256 KB large), and ++to 120-200 MB/s with 4KB random I/O. ++ ++The table of contents follow. Impatients can just jump to Section 3. ++ ++CONTENTS ++ ++1. When may BFQ be useful? ++ 1-1 Personal systems ++ 1-2 Server systems ++2. How does BFQ work? ++3. What are BFQ's tunable? ++4. BFQ group scheduling ++ 4-1 Service guarantees provided ++ 4-2 Interface ++ ++1. When may BFQ be useful? ++========================== ++ ++BFQ provides the following benefits on personal and server systems. ++ ++1-1 Personal systems ++-------------------- ++ ++Low latency for interactive applications ++ ++Regardless of the actual background workload, BFQ guarantees that, for ++interactive tasks, the storage device is virtually as responsive as if ++it was idle. For example, even if one or more of the following ++background workloads are being executed: ++- one or more large files are being read, written or copied, ++- a tree of source files is being compiled, ++- one or more virtual machines are performing I/O, ++- a software update is in progress, ++- indexing daemons are scanning filesystems and updating their ++ databases, ++starting an application or loading a file from within an application ++takes about the same time as if the storage device was idle. As a ++comparison, with CFQ, NOOP or DEADLINE, and in the same conditions, ++applications experience high latencies, or even become unresponsive ++until the background workload terminates (also on SSDs). ++ ++Low latency for soft real-time applications ++ ++Also soft real-time applications, such as audio and video ++players/streamers, enjoy a low latency and a low drop rate, regardless ++of the background I/O workload. As a consequence, these applications ++do not suffer from almost any glitch due to the background workload. ++ ++Higher speed for code-development tasks ++ ++If some additional workload happens to be executed in parallel, then ++BFQ executes the I/O-related components of typical code-development ++tasks (compilation, checkout, merge, ...) much more quickly than CFQ, ++NOOP or DEADLINE. ++ ++High throughput ++ ++On hard disks, BFQ achieves up to 30% higher throughput than CFQ, and ++up to 150% higher throughput than DEADLINE and NOOP, with all the ++sequential workloads considered in our tests. With random workloads, ++and with all the workloads on flash-based devices, BFQ achieves, ++instead, about the same throughput as the other schedulers. ++ ++Strong fairness, bandwidth and delay guarantees ++ ++BFQ distributes the device throughput, and not just the device time, ++among I/O-bound applications in proportion their weights, with any ++workload and regardless of the device parameters. From these bandwidth ++guarantees, it is possible to compute tight per-I/O-request delay ++guarantees by a simple formula. If not configured for strict service ++guarantees, BFQ switches to time-based resource sharing (only) for ++applications that would otherwise cause a throughput loss. ++ ++1-2 Server systems ++------------------ ++ ++Most benefits for server systems follow from the same service ++properties as above. In particular, regardless of whether additional, ++possibly heavy workloads are being served, BFQ guarantees: ++ ++. audio and video-streaming with zero or very low jitter and drop ++ rate; ++ ++. fast retrieval of WEB pages and embedded objects; ++ ++. real-time recording of data in live-dumping applications (e.g., ++ packet logging); ++ ++. responsiveness in local and remote access to a server. ++ ++ ++2. How does BFQ work? ++===================== ++ ++BFQ is a proportional-share I/O scheduler, whose general structure, ++plus a lot of code, are borrowed from CFQ. ++ ++- Each process doing I/O on a device is associated with a weight and a ++ (bfq_)queue. ++ ++- BFQ grants exclusive access to the device, for a while, to one queue ++ (process) at a time, and implements this service model by ++ associating every queue with a budget, measured in number of ++ sectors. ++ ++ - After a queue is granted access to the device, the budget of the ++ queue is decremented, on each request dispatch, by the size of the ++ request. ++ ++ - The in-service queue is expired, i.e., its service is suspended, ++ only if one of the following events occurs: 1) the queue finishes ++ its budget, 2) the queue empties, 3) a "budget timeout" fires. ++ ++ - The budget timeout prevents processes doing random I/O from ++ holding the device for too long and dramatically reducing ++ throughput. ++ ++ - Actually, as in CFQ, a queue associated with a process issuing ++ sync requests may not be expired immediately when it empties. In ++ contrast, BFQ may idle the device for a short time interval, ++ giving the process the chance to go on being served if it issues ++ a new request in time. Device idling typically boosts the ++ throughput on rotational devices, if processes do synchronous ++ and sequential I/O. In addition, under BFQ, device idling is ++ also instrumental in guaranteeing the desired throughput ++ fraction to processes issuing sync requests (see the description ++ of the slice_idle tunable in this document, or [1, 2], for more ++ details). ++ ++ - With respect to idling for service guarantees, if several ++ processes are competing for the device at the same time, but ++ all processes (and groups, after the following commit) have ++ the same weight, then BFQ guarantees the expected throughput ++ distribution without ever idling the device. Throughput is ++ thus as high as possible in this common scenario. ++ ++ - If low-latency mode is enabled (default configuration), BFQ ++ executes some special heuristics to detect interactive and soft ++ real-time applications (e.g., video or audio players/streamers), ++ and to reduce their latency. The most important action taken to ++ achieve this goal is to give to the queues associated with these ++ applications more than their fair share of the device ++ throughput. For brevity, we call just "weight-raising" the whole ++ sets of actions taken by BFQ to privilege these queues. In ++ particular, BFQ provides a milder form of weight-raising for ++ interactive applications, and a stronger form for soft real-time ++ applications. ++ ++ - BFQ automatically deactivates idling for queues born in a burst of ++ queue creations. In fact, these queues are usually associated with ++ the processes of applications and services that benefit mostly ++ from a high throughput. Examples are systemd during boot, or git ++ grep. ++ ++ - As CFQ, BFQ merges queues performing interleaved I/O, i.e., ++ performing random I/O that becomes mostly sequential if ++ merged. Differently from CFQ, BFQ achieves this goal with a more ++ reactive mechanism, called Early Queue Merge (EQM). EQM is so ++ responsive in detecting interleaved I/O (cooperating processes), ++ that it enables BFQ to achieve a high throughput, by queue ++ merging, even for queues for which CFQ needs a different ++ mechanism, preemption, to get a high throughput. As such EQM is a ++ unified mechanism to achieve a high throughput with interleaved ++ I/O. ++ ++ - Queues are scheduled according to a variant of WF2Q+, named ++ B-WF2Q+, and implemented using an augmented rb-tree to preserve an ++ O(log N) overall complexity. See [2] for more details. B-WF2Q+ is ++ also ready for hierarchical scheduling. However, for a cleaner ++ logical breakdown, the code that enables and completes ++ hierarchical support is provided in the next commit, which focuses ++ exactly on this feature. ++ ++ - B-WF2Q+ guarantees a tight deviation with respect to an ideal, ++ perfectly fair, and smooth service. In particular, B-WF2Q+ ++ guarantees that each queue receives a fraction of the device ++ throughput proportional to its weight, even if the throughput ++ fluctuates, and regardless of: the device parameters, the current ++ workload and the budgets assigned to the queue. ++ ++ - The last, budget-independence, property (although probably ++ counterintuitive in the first place) is definitely beneficial, for ++ the following reasons: ++ ++ - First, with any proportional-share scheduler, the maximum ++ deviation with respect to an ideal service is proportional to ++ the maximum budget (slice) assigned to queues. As a consequence, ++ BFQ can keep this deviation tight not only because of the ++ accurate service of B-WF2Q+, but also because BFQ *does not* ++ need to assign a larger budget to a queue to let the queue ++ receive a higher fraction of the device throughput. ++ ++ - Second, BFQ is free to choose, for every process (queue), the ++ budget that best fits the needs of the process, or best ++ leverages the I/O pattern of the process. In particular, BFQ ++ updates queue budgets with a simple feedback-loop algorithm that ++ allows a high throughput to be achieved, while still providing ++ tight latency guarantees to time-sensitive applications. When ++ the in-service queue expires, this algorithm computes the next ++ budget of the queue so as to: ++ ++ - Let large budgets be eventually assigned to the queues ++ associated with I/O-bound applications performing sequential ++ I/O: in fact, the longer these applications are served once ++ got access to the device, the higher the throughput is. ++ ++ - Let small budgets be eventually assigned to the queues ++ associated with time-sensitive applications (which typically ++ perform sporadic and short I/O), because, the smaller the ++ budget assigned to a queue waiting for service is, the sooner ++ B-WF2Q+ will serve that queue (Subsec 3.3 in [2]). ++ ++- If several processes are competing for the device at the same time, ++ but all processes and groups have the same weight, then BFQ ++ guarantees the expected throughput distribution without ever idling ++ the device. It uses preemption instead. Throughput is then much ++ higher in this common scenario. ++ ++- ioprio classes are served in strict priority order, i.e., ++ lower-priority queues are not served as long as there are ++ higher-priority queues. Among queues in the same class, the ++ bandwidth is distributed in proportion to the weight of each ++ queue. A very thin extra bandwidth is however guaranteed to ++ the Idle class, to prevent it from starving. ++ ++ ++3. What are BFQ's tunable? ++========================== ++ ++The tunables back_seek-max, back_seek_penalty, fifo_expire_async and ++fifo_expire_sync below are the same as in CFQ. Their description is ++just copied from that for CFQ. Some considerations in the description ++of slice_idle are copied from CFQ too. ++ ++per-process ioprio and weight ++----------------------------- ++ ++Unless the cgroups interface is used (see "4. BFQ group scheduling"), ++weights can be assigned to processes only indirectly, through I/O ++priorities, and according to the relation: ++weight = (IOPRIO_BE_NR - ioprio) * 10. ++ ++Beware that, if low-latency is set, then BFQ automatically raises the ++weight of the queues associated with interactive and soft real-time ++applications. Unset this tunable if you need/want to control weights. ++ ++slice_idle ++---------- ++ ++This parameter specifies how long BFQ should idle for next I/O ++request, when certain sync BFQ queues become empty. By default ++slice_idle is a non-zero value. Idling has a double purpose: boosting ++throughput and making sure that the desired throughput distribution is ++respected (see the description of how BFQ works, and, if needed, the ++papers referred there). ++ ++As for throughput, idling can be very helpful on highly seeky media ++like single spindle SATA/SAS disks where we can cut down on overall ++number of seeks and see improved throughput. ++ ++Setting slice_idle to 0 will remove all the idling on queues and one ++should see an overall improved throughput on faster storage devices ++like multiple SATA/SAS disks in hardware RAID configuration. ++ ++So depending on storage and workload, it might be useful to set ++slice_idle=0. In general for SATA/SAS disks and software RAID of ++SATA/SAS disks keeping slice_idle enabled should be useful. For any ++configurations where there are multiple spindles behind single LUN ++(Host based hardware RAID controller or for storage arrays), setting ++slice_idle=0 might end up in better throughput and acceptable ++latencies. ++ ++Idling is however necessary to have service guarantees enforced in ++case of differentiated weights or differentiated I/O-request lengths. ++To see why, suppose that a given BFQ queue A must get several I/O ++requests served for each request served for another queue B. Idling ++ensures that, if A makes a new I/O request slightly after becoming ++empty, then no request of B is dispatched in the middle, and thus A ++does not lose the possibility to get more than one request dispatched ++before the next request of B is dispatched. Note that idling ++guarantees the desired differentiated treatment of queues only in ++terms of I/O-request dispatches. To guarantee that the actual service ++order then corresponds to the dispatch order, the strict_guarantees ++tunable must be set too. ++ ++There is an important flipside for idling: apart from the above cases ++where it is beneficial also for throughput, idling can severely impact ++throughput. One important case is random workload. Because of this ++issue, BFQ tends to avoid idling as much as possible, when it is not ++beneficial also for throughput. As a consequence of this behavior, and ++of further issues described for the strict_guarantees tunable, ++short-term service guarantees may be occasionally violated. And, in ++some cases, these guarantees may be more important than guaranteeing ++maximum throughput. For example, in video playing/streaming, a very ++low drop rate may be more important than maximum throughput. In these ++cases, consider setting the strict_guarantees parameter. ++ ++strict_guarantees ++----------------- ++ ++If this parameter is set (default: unset), then BFQ ++ ++- always performs idling when the in-service queue becomes empty; ++ ++- forces the device to serve one I/O request at a time, by dispatching a ++ new request only if there is no outstanding request. ++ ++In the presence of differentiated weights or I/O-request sizes, both ++the above conditions are needed to guarantee that every BFQ queue ++receives its allotted share of the bandwidth. The first condition is ++needed for the reasons explained in the description of the slice_idle ++tunable. The second condition is needed because all modern storage ++devices reorder internally-queued requests, which may trivially break ++the service guarantees enforced by the I/O scheduler. ++ ++Setting strict_guarantees may evidently affect throughput. ++ ++back_seek_max ++------------- ++ ++This specifies, given in Kbytes, the maximum "distance" for backward seeking. ++The distance is the amount of space from the current head location to the ++sectors that are backward in terms of distance. ++ ++This parameter allows the scheduler to anticipate requests in the "backward" ++direction and consider them as being the "next" if they are within this ++distance from the current head location. ++ ++back_seek_penalty ++----------------- ++ ++This parameter is used to compute the cost of backward seeking. If the ++backward distance of request is just 1/back_seek_penalty from a "front" ++request, then the seeking cost of two requests is considered equivalent. ++ ++So scheduler will not bias toward one or the other request (otherwise scheduler ++will bias toward front request). Default value of back_seek_penalty is 2. ++ ++fifo_expire_async ++----------------- ++ ++This parameter is used to set the timeout of asynchronous requests. Default ++value of this is 248ms. ++ ++fifo_expire_sync ++---------------- ++ ++This parameter is used to set the timeout of synchronous requests. Default ++value of this is 124ms. In case to favor synchronous requests over asynchronous ++one, this value should be decreased relative to fifo_expire_async. ++ ++low_latency ++----------- ++ ++This parameter is used to enable/disable BFQ's low latency mode. By ++default, low latency mode is enabled. If enabled, interactive and soft ++real-time applications are privileged and experience a lower latency, ++as explained in more detail in the description of how BFQ works. ++ ++DO NOT enable this mode if you need full control on bandwidth ++distribution. In fact, if it is enabled, then BFQ automatically ++increases the bandwidth share of privileged applications, as the main ++means to guarantee a lower latency to them. ++ ++timeout_sync ++------------ ++ ++Maximum amount of device time that can be given to a task (queue) once ++it has been selected for service. On devices with costly seeks, ++increasing this time usually increases maximum throughput. On the ++opposite end, increasing this time coarsens the granularity of the ++short-term bandwidth and latency guarantees, especially if the ++following parameter is set to zero. ++ ++max_budget ++---------- ++ ++Maximum amount of service, measured in sectors, that can be provided ++to a BFQ queue once it is set in service (of course within the limits ++of the above timeout). According to what said in the description of ++the algorithm, larger values increase the throughput in proportion to ++the percentage of sequential I/O requests issued. The price of larger ++values is that they coarsen the granularity of short-term bandwidth ++and latency guarantees. ++ ++The default value is 0, which enables auto-tuning: BFQ sets max_budget ++to the maximum number of sectors that can be served during ++timeout_sync, according to the estimated peak rate. ++ ++weights ++------- ++ ++Read-only parameter, used to show the weights of the currently active ++BFQ queues. ++ ++ ++wr_ tunables ++------------ ++ ++BFQ exports a few parameters to control/tune the behavior of ++low-latency heuristics. ++ ++wr_coeff ++ ++Factor by which the weight of a weight-raised queue is multiplied. If ++the queue is deemed soft real-time, then the weight is further ++multiplied by an additional, constant factor. ++ ++wr_max_time ++ ++Maximum duration of a weight-raising period for an interactive task ++(ms). If set to zero (default value), then this value is computed ++automatically, as a function of the peak rate of the device. In any ++case, when the value of this parameter is read, it always reports the ++current duration, regardless of whether it has been set manually or ++computed automatically. ++ ++wr_max_softrt_rate ++ ++Maximum service rate below which a queue is deemed to be associated ++with a soft real-time application, and is then weight-raised ++accordingly (sectors/sec). ++ ++wr_min_idle_time ++ ++Minimum idle period after which interactive weight-raising may be ++reactivated for a queue (in ms). ++ ++wr_rt_max_time ++ ++Maximum weight-raising duration for soft real-time queues (in ms). The ++start time from which this duration is considered is automatically ++moved forward if the queue is detected to be still soft real-time ++before the current soft real-time weight-raising period finishes. ++ ++wr_min_inter_arr_async ++ ++Minimum period between I/O request arrivals after which weight-raising ++may be reactivated for an already busy async queue (in ms). ++ ++ ++4. Group scheduling with BFQ ++============================ ++ ++BFQ supports both cgroups-v1 and cgroups-v2 io controllers, namely ++blkio and io. In particular, BFQ supports weight-based proportional ++share. To activate cgroups support, set BFQ_GROUP_IOSCHED. ++ ++4-1 Service guarantees provided ++------------------------------- ++ ++With BFQ, proportional share means true proportional share of the ++device bandwidth, according to group weights. For example, a group ++with weight 200 gets twice the bandwidth, and not just twice the time, ++of a group with weight 100. ++ ++BFQ supports hierarchies (group trees) of any depth. Bandwidth is ++distributed among groups and processes in the expected way: for each ++group, the children of the group share the whole bandwidth of the ++group in proportion to their weights. In particular, this implies ++that, for each leaf group, every process of the group receives the ++same share of the whole group bandwidth, unless the ioprio of the ++process is modified. ++ ++The resource-sharing guarantee for a group may partially or totally ++switch from bandwidth to time, if providing bandwidth guarantees to ++the group lowers the throughput too much. This switch occurs on a ++per-process basis: if a process of a leaf group causes throughput loss ++if served in such a way to receive its share of the bandwidth, then ++BFQ switches back to just time-based proportional share for that ++process. ++ ++4-2 Interface ++------------- ++ ++To get proportional sharing of bandwidth with BFQ for a given device, ++BFQ must of course be the active scheduler for that device. ++ ++Within each group directory, the names of the files associated with ++BFQ-specific cgroup parameters and stats begin with the "bfq." ++prefix. So, with cgroups-v1 or cgroups-v2, the full prefix for ++BFQ-specific files is "blkio.bfq." or "io.bfq." For example, the group ++parameter to set the weight of a group with BFQ is blkio.bfq.weight ++or io.bfq.weight. ++ ++Parameters to set ++----------------- ++ ++For each group, there is only the following parameter to set. ++ ++weight (namely blkio.bfq.weight or io.bfq-weight): the weight of the ++group inside its parent. Available values: 1..10000 (default 100). The ++linear mapping between ioprio and weights, described at the beginning ++of the tunable section, is still valid, but all weights higher than ++IOPRIO_BE_NR*10 are mapped to ioprio 0. ++ ++Recall that, if low-latency is set, then BFQ automatically raises the ++weight of the queues associated with interactive and soft real-time ++applications. Unset this tunable if you need/want to control weights. ++ ++ ++[1] P. Valente, A. Avanzini, "Evolution of the BFQ Storage I/O ++ Scheduler", Proceedings of the First Workshop on Mobile System ++ Technologies (MST-2015), May 2015. ++ http://algogroup.unimore.it/people/paolo/disk_sched/mst-2015.pdf ++ ++[2] P. Valente and M. Andreolini, "Improving Application ++ Responsiveness with the BFQ Disk I/O Scheduler", Proceedings of ++ the 5th Annual International Systems and Storage Conference ++ (SYSTOR '12), June 2012. ++ Slightly extended version: ++ http://algogroup.unimore.it/people/paolo/disk_sched/bfq-v1-suite- ++ results.pdf +diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched +index f78cd1a..f2cd945 100644 +--- a/block/Kconfig.iosched ++++ b/block/Kconfig.iosched +@@ -43,20 +43,20 @@ config IOSCHED_BFQ + tristate "BFQ I/O scheduler" + default n + ---help--- +- The BFQ I/O scheduler tries to distribute bandwidth among +- all processes according to their weights. +- It aims at distributing the bandwidth as desired, independently of +- the disk parameters and with any workload. It also tries to +- guarantee low latency to interactive and soft real-time +- applications. If compiled built-in (saying Y here), BFQ can +- be configured to support hierarchical scheduling. ++ The BFQ I/O scheduler distributes bandwidth among all ++ processes according to their weights, regardless of the ++ device parameters and with any workload. It also guarantees ++ a low latency to interactive and soft real-time applications. ++ Details in Documentation/block/bfq-iosched.txt + + config BFQ_GROUP_IOSCHED + bool "BFQ hierarchical scheduling support" +- depends on CGROUPS && IOSCHED_BFQ=y ++ depends on IOSCHED_BFQ && BLK_CGROUP + default n + ---help--- +- Enable hierarchical scheduling in BFQ, using the blkio controller. ++ ++ Enable hierarchical scheduling in BFQ, using the blkio ++ (cgroups-v1) or io (cgroups-v2) controller. + + choice + prompt "Default I/O scheduler" +diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c +index 0367996..bbaecd0 100644 +--- a/block/bfq-cgroup.c ++++ b/block/bfq-cgroup.c +@@ -7,7 +7,9 @@ + * Copyright (C) 2008 Fabio Checconi + * Paolo Valente + * +- * Copyright (C) 2010 Paolo Valente ++ * Copyright (C) 2015 Paolo Valente ++ * ++ * Copyright (C) 2016 Paolo Valente + * + * Licensed under the GPL-2 as detailed in the accompanying COPYING.BFQ + * file. +@@ -163,8 +165,6 @@ static struct bfq_group *blkg_to_bfqg(struct blkcg_gq *blkg) + { + struct blkg_policy_data *pd = blkg_to_pd(blkg, &blkcg_policy_bfq); + +- BUG_ON(!pd); +- + return pd_to_bfqg(pd); + } + +@@ -208,59 +208,49 @@ static void bfqg_put(struct bfq_group *bfqg) + + static void bfqg_stats_update_io_add(struct bfq_group *bfqg, + struct bfq_queue *bfqq, +- int rw) ++ int op, int op_flags) + { +- blkg_rwstat_add(&bfqg->stats.queued, rw, 1); ++ blkg_rwstat_add(&bfqg->stats.queued, op, op_flags, 1); + bfqg_stats_end_empty_time(&bfqg->stats); + if (!(bfqq == ((struct bfq_data *)bfqg->bfqd)->in_service_queue)) + bfqg_stats_set_start_group_wait_time(bfqg, bfqq_group(bfqq)); + } + +-static void bfqg_stats_update_io_remove(struct bfq_group *bfqg, int rw) +-{ +- blkg_rwstat_add(&bfqg->stats.queued, rw, -1); +-} +- +-static void bfqg_stats_update_io_merged(struct bfq_group *bfqg, int rw) ++static void bfqg_stats_update_io_remove(struct bfq_group *bfqg, int op, ++ int op_flags) + { +- blkg_rwstat_add(&bfqg->stats.merged, rw, 1); ++ blkg_rwstat_add(&bfqg->stats.queued, op, op_flags, -1); + } + +-static void bfqg_stats_update_dispatch(struct bfq_group *bfqg, +- uint64_t bytes, int rw) ++static void bfqg_stats_update_io_merged(struct bfq_group *bfqg, int op, ++ int op_flags) + { +- blkg_stat_add(&bfqg->stats.sectors, bytes >> 9); +- blkg_rwstat_add(&bfqg->stats.serviced, rw, 1); +- blkg_rwstat_add(&bfqg->stats.service_bytes, rw, bytes); ++ blkg_rwstat_add(&bfqg->stats.merged, op, op_flags, 1); + } + + static void bfqg_stats_update_completion(struct bfq_group *bfqg, +- uint64_t start_time, uint64_t io_start_time, int rw) ++ uint64_t start_time, uint64_t io_start_time, int op, ++ int op_flags) + { + struct bfqg_stats *stats = &bfqg->stats; + unsigned long long now = sched_clock(); + + if (time_after64(now, io_start_time)) +- blkg_rwstat_add(&stats->service_time, rw, now - io_start_time); ++ blkg_rwstat_add(&stats->service_time, op, op_flags, ++ now - io_start_time); + if (time_after64(io_start_time, start_time)) +- blkg_rwstat_add(&stats->wait_time, rw, ++ blkg_rwstat_add(&stats->wait_time, op, op_flags, + io_start_time - start_time); + } + + /* @stats = 0 */ + static void bfqg_stats_reset(struct bfqg_stats *stats) + { +- if (!stats) +- return; +- + /* queued stats shouldn't be cleared */ +- blkg_rwstat_reset(&stats->service_bytes); +- blkg_rwstat_reset(&stats->serviced); + blkg_rwstat_reset(&stats->merged); + blkg_rwstat_reset(&stats->service_time); + blkg_rwstat_reset(&stats->wait_time); + blkg_stat_reset(&stats->time); +- blkg_stat_reset(&stats->unaccounted_time); + blkg_stat_reset(&stats->avg_queue_size_sum); + blkg_stat_reset(&stats->avg_queue_size_samples); + blkg_stat_reset(&stats->dequeue); +@@ -270,19 +260,16 @@ static void bfqg_stats_reset(struct bfqg_stats *stats) + } + + /* @to += @from */ +-static void bfqg_stats_merge(struct bfqg_stats *to, struct bfqg_stats *from) ++static void bfqg_stats_add_aux(struct bfqg_stats *to, struct bfqg_stats *from) + { + if (!to || !from) + return; + + /* queued stats shouldn't be cleared */ +- blkg_rwstat_add_aux(&to->service_bytes, &from->service_bytes); +- blkg_rwstat_add_aux(&to->serviced, &from->serviced); + blkg_rwstat_add_aux(&to->merged, &from->merged); + blkg_rwstat_add_aux(&to->service_time, &from->service_time); + blkg_rwstat_add_aux(&to->wait_time, &from->wait_time); + blkg_stat_add_aux(&from->time, &from->time); +- blkg_stat_add_aux(&to->unaccounted_time, &from->unaccounted_time); + blkg_stat_add_aux(&to->avg_queue_size_sum, &from->avg_queue_size_sum); + blkg_stat_add_aux(&to->avg_queue_size_samples, + &from->avg_queue_size_samples); +@@ -311,10 +298,8 @@ static void bfqg_stats_xfer_dead(struct bfq_group *bfqg) + if (unlikely(!parent)) + return; + +- bfqg_stats_merge(&parent->dead_stats, &bfqg->stats); +- bfqg_stats_merge(&parent->dead_stats, &bfqg->dead_stats); ++ bfqg_stats_add_aux(&parent->stats, &bfqg->stats); + bfqg_stats_reset(&bfqg->stats); +- bfqg_stats_reset(&bfqg->dead_stats); + } + + static void bfq_init_entity(struct bfq_entity *entity, +@@ -329,21 +314,17 @@ static void bfq_init_entity(struct bfq_entity *entity, + bfqq->ioprio_class = bfqq->new_ioprio_class; + bfqg_get(bfqg); + } +- entity->parent = bfqg->my_entity; ++ entity->parent = bfqg->my_entity; /* NULL for root group */ + entity->sched_data = &bfqg->sched_data; + } + + static void bfqg_stats_exit(struct bfqg_stats *stats) + { +- blkg_rwstat_exit(&stats->service_bytes); +- blkg_rwstat_exit(&stats->serviced); + blkg_rwstat_exit(&stats->merged); + blkg_rwstat_exit(&stats->service_time); + blkg_rwstat_exit(&stats->wait_time); + blkg_rwstat_exit(&stats->queued); +- blkg_stat_exit(&stats->sectors); + blkg_stat_exit(&stats->time); +- blkg_stat_exit(&stats->unaccounted_time); + blkg_stat_exit(&stats->avg_queue_size_sum); + blkg_stat_exit(&stats->avg_queue_size_samples); + blkg_stat_exit(&stats->dequeue); +@@ -354,15 +335,11 @@ static void bfqg_stats_exit(struct bfqg_stats *stats) + + static int bfqg_stats_init(struct bfqg_stats *stats, gfp_t gfp) + { +- if (blkg_rwstat_init(&stats->service_bytes, gfp) || +- blkg_rwstat_init(&stats->serviced, gfp) || +- blkg_rwstat_init(&stats->merged, gfp) || ++ if (blkg_rwstat_init(&stats->merged, gfp) || + blkg_rwstat_init(&stats->service_time, gfp) || + blkg_rwstat_init(&stats->wait_time, gfp) || + blkg_rwstat_init(&stats->queued, gfp) || +- blkg_stat_init(&stats->sectors, gfp) || + blkg_stat_init(&stats->time, gfp) || +- blkg_stat_init(&stats->unaccounted_time, gfp) || + blkg_stat_init(&stats->avg_queue_size_sum, gfp) || + blkg_stat_init(&stats->avg_queue_size_samples, gfp) || + blkg_stat_init(&stats->dequeue, gfp) || +@@ -386,11 +363,27 @@ static struct bfq_group_data *blkcg_to_bfqgd(struct blkcg *blkcg) + return cpd_to_bfqgd(blkcg_to_cpd(blkcg, &blkcg_policy_bfq)); + } + ++static struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp) ++{ ++ struct bfq_group_data *bgd; ++ ++ bgd = kzalloc(sizeof(*bgd), GFP_KERNEL); ++ if (!bgd) ++ return NULL; ++ return &bgd->pd; ++} ++ + static void bfq_cpd_init(struct blkcg_policy_data *cpd) + { + struct bfq_group_data *d = cpd_to_bfqgd(cpd); + +- d->weight = BFQ_DEFAULT_GRP_WEIGHT; ++ d->weight = cgroup_subsys_on_dfl(io_cgrp_subsys) ? ++ CGROUP_WEIGHT_DFL : BFQ_WEIGHT_LEGACY_DFL; ++} ++ ++static void bfq_cpd_free(struct blkcg_policy_data *cpd) ++{ ++ kfree(cpd_to_bfqgd(cpd)); + } + + static struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node) +@@ -401,8 +394,7 @@ static struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node) + if (!bfqg) + return NULL; + +- if (bfqg_stats_init(&bfqg->stats, gfp) || +- bfqg_stats_init(&bfqg->dead_stats, gfp)) { ++ if (bfqg_stats_init(&bfqg->stats, gfp)) { + kfree(bfqg); + return NULL; + } +@@ -410,27 +402,20 @@ static struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node) + return &bfqg->pd; + } + +-static void bfq_group_set_parent(struct bfq_group *bfqg, +- struct bfq_group *parent) ++static void bfq_pd_init(struct blkg_policy_data *pd) + { ++ struct blkcg_gq *blkg; ++ struct bfq_group *bfqg; ++ struct bfq_data *bfqd; + struct bfq_entity *entity; ++ struct bfq_group_data *d; + +- BUG_ON(!parent); +- BUG_ON(!bfqg); +- BUG_ON(bfqg == parent); +- ++ blkg = pd_to_blkg(pd); ++ BUG_ON(!blkg); ++ bfqg = blkg_to_bfqg(blkg); ++ bfqd = blkg->q->elevator->elevator_data; + entity = &bfqg->entity; +- entity->parent = parent->my_entity; +- entity->sched_data = &parent->sched_data; +-} +- +-static void bfq_pd_init(struct blkg_policy_data *pd) +-{ +- struct blkcg_gq *blkg = pd_to_blkg(pd); +- struct bfq_group *bfqg = blkg_to_bfqg(blkg); +- struct bfq_data *bfqd = blkg->q->elevator->elevator_data; +- struct bfq_entity *entity = &bfqg->entity; +- struct bfq_group_data *d = blkcg_to_bfqgd(blkg->blkcg); ++ d = blkcg_to_bfqgd(blkg->blkcg); + + entity->orig_weight = entity->weight = entity->new_weight = d->weight; + entity->my_sched_data = &bfqg->sched_data; +@@ -448,70 +433,53 @@ static void bfq_pd_free(struct blkg_policy_data *pd) + struct bfq_group *bfqg = pd_to_bfqg(pd); + + bfqg_stats_exit(&bfqg->stats); +- bfqg_stats_exit(&bfqg->dead_stats); +- + return kfree(bfqg); + } + +-/* offset delta from bfqg->stats to bfqg->dead_stats */ +-static const int dead_stats_off_delta = offsetof(struct bfq_group, dead_stats) - +- offsetof(struct bfq_group, stats); +- +-/* to be used by recursive prfill, sums live and dead stats recursively */ +-static u64 bfqg_stat_pd_recursive_sum(struct blkg_policy_data *pd, int off) ++static void bfq_pd_reset_stats(struct blkg_policy_data *pd) + { +- u64 sum = 0; ++ struct bfq_group *bfqg = pd_to_bfqg(pd); + +- sum += blkg_stat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, off); +- sum += blkg_stat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, +- off + dead_stats_off_delta); +- return sum; ++ bfqg_stats_reset(&bfqg->stats); + } + +-/* to be used by recursive prfill, sums live and dead rwstats recursively */ +-static struct blkg_rwstat +-bfqg_rwstat_pd_recursive_sum(struct blkg_policy_data *pd, int off) ++static void bfq_group_set_parent(struct bfq_group *bfqg, ++ struct bfq_group *parent) + { +- struct blkg_rwstat a, b; ++ struct bfq_entity *entity; ++ ++ BUG_ON(!parent); ++ BUG_ON(!bfqg); ++ BUG_ON(bfqg == parent); + +- a = blkg_rwstat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, off); +- b = blkg_rwstat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, +- off + dead_stats_off_delta); +- blkg_rwstat_add_aux(&a, &b); +- return a; ++ entity = &bfqg->entity; ++ entity->parent = parent->my_entity; ++ entity->sched_data = &parent->sched_data; + } + +-static void bfq_pd_reset_stats(struct blkg_policy_data *pd) ++static struct bfq_group *bfq_lookup_bfqg(struct bfq_data *bfqd, ++ struct blkcg *blkcg) + { +- struct bfq_group *bfqg = pd_to_bfqg(pd); ++ struct blkcg_gq *blkg; + +- bfqg_stats_reset(&bfqg->stats); +- bfqg_stats_reset(&bfqg->dead_stats); ++ blkg = blkg_lookup(blkcg, bfqd->queue); ++ if (likely(blkg)) ++ return blkg_to_bfqg(blkg); ++ return NULL; + } + +-static struct bfq_group *bfq_find_alloc_group(struct bfq_data *bfqd, +- struct blkcg *blkcg) ++static struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd, ++ struct blkcg *blkcg) + { +- struct request_queue *q = bfqd->queue; +- struct bfq_group *bfqg = NULL, *parent; +- struct bfq_entity *entity = NULL; ++ struct bfq_group *bfqg, *parent; ++ struct bfq_entity *entity; + + assert_spin_locked(bfqd->queue->queue_lock); + +- /* avoid lookup for the common case where there's no blkcg */ +- if (blkcg == &blkcg_root) { +- bfqg = bfqd->root_group; +- } else { +- struct blkcg_gq *blkg; +- +- blkg = blkg_lookup_create(blkcg, q); +- if (!IS_ERR(blkg)) +- bfqg = blkg_to_bfqg(blkg); +- else /* fallback to root_group */ +- bfqg = bfqd->root_group; +- } ++ bfqg = bfq_lookup_bfqg(bfqd, blkcg); + +- BUG_ON(!bfqg); ++ if (unlikely(!bfqg)) ++ return NULL; + + /* + * Update chain of bfq_groups as we might be handling a leaf group +@@ -537,11 +505,15 @@ static struct bfq_group *bfq_find_alloc_group(struct bfq_data *bfqd, + static void bfq_pos_tree_add_move(struct bfq_data *bfqd, + struct bfq_queue *bfqq); + ++static void bfq_bfqq_expire(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq, ++ bool compensate, ++ enum bfqq_expiration reason); ++ + /** + * bfq_bfqq_move - migrate @bfqq to @bfqg. + * @bfqd: queue descriptor. + * @bfqq: the queue to move. +- * @entity: @bfqq's entity. + * @bfqg: the group to move to. + * + * Move @bfqq to @bfqg, deactivating it from its old group and reactivating +@@ -552,26 +524,40 @@ static void bfq_pos_tree_add_move(struct bfq_data *bfqd, + * rcu_read_lock()). + */ + static void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq, +- struct bfq_entity *entity, struct bfq_group *bfqg) ++ struct bfq_group *bfqg) + { +- int busy, resume; ++ struct bfq_entity *entity = &bfqq->entity; + +- busy = bfq_bfqq_busy(bfqq); +- resume = !RB_EMPTY_ROOT(&bfqq->sort_list); +- +- BUG_ON(resume && !entity->on_st); +- BUG_ON(busy && !resume && entity->on_st && ++ BUG_ON(!bfq_bfqq_busy(bfqq) && !RB_EMPTY_ROOT(&bfqq->sort_list)); ++ BUG_ON(!RB_EMPTY_ROOT(&bfqq->sort_list) && !entity->on_st); ++ BUG_ON(bfq_bfqq_busy(bfqq) && RB_EMPTY_ROOT(&bfqq->sort_list) ++ && entity->on_st && + bfqq != bfqd->in_service_queue); ++ BUG_ON(!bfq_bfqq_busy(bfqq) && bfqq == bfqd->in_service_queue); ++ ++ /* If bfqq is empty, then bfq_bfqq_expire also invokes ++ * bfq_del_bfqq_busy, thereby removing bfqq and its entity ++ * from data structures related to current group. Otherwise we ++ * need to remove bfqq explicitly with bfq_deactivate_bfqq, as ++ * we do below. ++ */ ++ if (bfqq == bfqd->in_service_queue) ++ bfq_bfqq_expire(bfqd, bfqd->in_service_queue, ++ false, BFQ_BFQQ_PREEMPTED); + +- if (busy) { +- BUG_ON(atomic_read(&bfqq->ref) < 2); ++ BUG_ON(entity->on_st && !bfq_bfqq_busy(bfqq) ++ && &bfq_entity_service_tree(entity)->idle != ++ entity->tree); + +- if (!resume) +- bfq_del_bfqq_busy(bfqd, bfqq, 0); +- else +- bfq_deactivate_bfqq(bfqd, bfqq, 0); +- } else if (entity->on_st) ++ BUG_ON(RB_EMPTY_ROOT(&bfqq->sort_list) && bfq_bfqq_busy(bfqq)); ++ ++ if (bfq_bfqq_busy(bfqq)) ++ bfq_deactivate_bfqq(bfqd, bfqq, false, false); ++ else if (entity->on_st) { ++ BUG_ON(&bfq_entity_service_tree(entity)->idle != ++ entity->tree); + bfq_put_idle_entity(bfq_entity_service_tree(entity), entity); ++ } + bfqg_put(bfqq_group(bfqq)); + + /* +@@ -583,14 +569,17 @@ static void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq, + entity->sched_data = &bfqg->sched_data; + bfqg_get(bfqg); + +- if (busy) { ++ BUG_ON(RB_EMPTY_ROOT(&bfqq->sort_list) && bfq_bfqq_busy(bfqq)); ++ if (bfq_bfqq_busy(bfqq)) { + bfq_pos_tree_add_move(bfqd, bfqq); +- if (resume) +- bfq_activate_bfqq(bfqd, bfqq); ++ bfq_activate_bfqq(bfqd, bfqq); + } + + if (!bfqd->in_service_queue && !bfqd->rq_in_driver) + bfq_schedule_dispatch(bfqd); ++ BUG_ON(entity->on_st && !bfq_bfqq_busy(bfqq) ++ && &bfq_entity_service_tree(entity)->idle != ++ entity->tree); + } + + /** +@@ -617,7 +606,11 @@ static struct bfq_group *__bfq_bic_change_cgroup(struct bfq_data *bfqd, + + lockdep_assert_held(bfqd->queue->queue_lock); + +- bfqg = bfq_find_alloc_group(bfqd, blkcg); ++ bfqg = bfq_find_set_group(bfqd, blkcg); ++ ++ if (unlikely(!bfqg)) ++ bfqg = bfqd->root_group; ++ + if (async_bfqq) { + entity = &async_bfqq->entity; + +@@ -625,7 +618,8 @@ static struct bfq_group *__bfq_bic_change_cgroup(struct bfq_data *bfqd, + bic_set_bfqq(bic, NULL, 0); + bfq_log_bfqq(bfqd, async_bfqq, + "bic_change_group: %p %d", +- async_bfqq, atomic_read(&async_bfqq->ref)); ++ async_bfqq, ++ async_bfqq->ref); + bfq_put_queue(async_bfqq); + } + } +@@ -633,7 +627,7 @@ static struct bfq_group *__bfq_bic_change_cgroup(struct bfq_data *bfqd, + if (sync_bfqq) { + entity = &sync_bfqq->entity; + if (entity->sched_data != &bfqg->sched_data) +- bfq_bfqq_move(bfqd, sync_bfqq, entity, bfqg); ++ bfq_bfqq_move(bfqd, sync_bfqq, bfqg); + } + + return bfqg; +@@ -642,25 +636,23 @@ static struct bfq_group *__bfq_bic_change_cgroup(struct bfq_data *bfqd, + static void bfq_bic_update_cgroup(struct bfq_io_cq *bic, struct bio *bio) + { + struct bfq_data *bfqd = bic_to_bfqd(bic); +- struct blkcg *blkcg; + struct bfq_group *bfqg = NULL; +- uint64_t id; ++ uint64_t serial_nr; + + rcu_read_lock(); +- blkcg = bio_blkcg(bio); +- id = blkcg->css.serial_nr; +- rcu_read_unlock(); ++ serial_nr = bio_blkcg(bio)->css.serial_nr; + + /* + * Check whether blkcg has changed. The condition may trigger + * spuriously on a newly created cic but there's no harm. + */ +- if (unlikely(!bfqd) || likely(bic->blkcg_id == id)) +- return; ++ if (unlikely(!bfqd) || likely(bic->blkcg_serial_nr == serial_nr)) ++ goto out; + +- bfqg = __bfq_bic_change_cgroup(bfqd, bic, blkcg); +- BUG_ON(!bfqg); +- bic->blkcg_id = id; ++ bfqg = __bfq_bic_change_cgroup(bfqd, bic, bio_blkcg(bio)); ++ bic->blkcg_serial_nr = serial_nr; ++out: ++ rcu_read_unlock(); + } + + /** +@@ -672,7 +664,7 @@ static void bfq_flush_idle_tree(struct bfq_service_tree *st) + struct bfq_entity *entity = st->first_idle; + + for (; entity ; entity = st->first_idle) +- __bfq_deactivate_entity(entity, 0); ++ __bfq_deactivate_entity(entity, false); + } + + /** +@@ -686,7 +678,7 @@ static void bfq_reparent_leaf_entity(struct bfq_data *bfqd, + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); + + BUG_ON(!bfqq); +- bfq_bfqq_move(bfqd, bfqq, entity, bfqd->root_group); ++ bfq_bfqq_move(bfqd, bfqq, bfqd->root_group); + } + + /** +@@ -717,11 +709,12 @@ static void bfq_reparent_active_entities(struct bfq_data *bfqd, + } + + /** +- * bfq_destroy_group - destroy @bfqg. +- * @bfqg: the group being destroyed. ++ * bfq_pd_offline - deactivate the entity associated with @pd, ++ * and reparent its children entities. ++ * @pd: descriptor of the policy going offline. + * +- * Destroy @bfqg, making sure that it is not referenced from its parent. +- * blkio already grabs the queue_lock for us, so no need to use RCU-based magic ++ * blkio already grabs the queue_lock for us, so no need to use ++ * RCU-based magic + */ + static void bfq_pd_offline(struct blkg_policy_data *pd) + { +@@ -776,10 +769,16 @@ static void bfq_pd_offline(struct blkg_policy_data *pd) + BUG_ON(bfqg->sched_data.next_in_service); + BUG_ON(bfqg->sched_data.in_service_entity); + +- __bfq_deactivate_entity(entity, 0); ++ __bfq_deactivate_entity(entity, false); + bfq_put_async_queues(bfqd, bfqg); + BUG_ON(entity->tree); + ++ /* ++ * @blkg is going offline and will be ignored by ++ * blkg_[rw]stat_recursive_sum(). Transfer stats to the parent so ++ * that they don't get lost. If IOs complete after this point, the ++ * stats for them will be lost. Oh well... ++ */ + bfqg_stats_xfer_dead(bfqg); + } + +@@ -789,46 +788,35 @@ static void bfq_end_wr_async(struct bfq_data *bfqd) + + list_for_each_entry(blkg, &bfqd->queue->blkg_list, q_node) { + struct bfq_group *bfqg = blkg_to_bfqg(blkg); ++ BUG_ON(!bfqg); + + bfq_end_wr_async_queues(bfqd, bfqg); + } + bfq_end_wr_async_queues(bfqd, bfqd->root_group); + } + +-static u64 bfqio_cgroup_weight_read(struct cgroup_subsys_state *css, +- struct cftype *cftype) +-{ +- struct blkcg *blkcg = css_to_blkcg(css); +- struct bfq_group_data *bfqgd = blkcg_to_bfqgd(blkcg); +- int ret = -EINVAL; +- +- spin_lock_irq(&blkcg->lock); +- ret = bfqgd->weight; +- spin_unlock_irq(&blkcg->lock); +- +- return ret; +-} +- +-static int bfqio_cgroup_weight_read_dfl(struct seq_file *sf, void *v) ++static int bfq_io_show_weight(struct seq_file *sf, void *v) + { + struct blkcg *blkcg = css_to_blkcg(seq_css(sf)); + struct bfq_group_data *bfqgd = blkcg_to_bfqgd(blkcg); ++ unsigned int val = 0; + +- spin_lock_irq(&blkcg->lock); +- seq_printf(sf, "%u\n", bfqgd->weight); +- spin_unlock_irq(&blkcg->lock); ++ if (bfqgd) ++ val = bfqgd->weight; ++ ++ seq_printf(sf, "%u\n", val); + + return 0; + } + +-static int bfqio_cgroup_weight_write(struct cgroup_subsys_state *css, +- struct cftype *cftype, +- u64 val) ++static int bfq_io_set_weight_legacy(struct cgroup_subsys_state *css, ++ struct cftype *cftype, ++ u64 val) + { + struct blkcg *blkcg = css_to_blkcg(css); + struct bfq_group_data *bfqgd = blkcg_to_bfqgd(blkcg); + struct blkcg_gq *blkg; +- int ret = -EINVAL; ++ int ret = -ERANGE; + + if (val < BFQ_MIN_WEIGHT || val > BFQ_MAX_WEIGHT) + return ret; +@@ -873,13 +861,18 @@ static int bfqio_cgroup_weight_write(struct cgroup_subsys_state *css, + return ret; + } + +-static ssize_t bfqio_cgroup_weight_write_dfl(struct kernfs_open_file *of, +- char *buf, size_t nbytes, +- loff_t off) ++static ssize_t bfq_io_set_weight(struct kernfs_open_file *of, ++ char *buf, size_t nbytes, ++ loff_t off) + { ++ u64 weight; + /* First unsigned long found in the file is used */ +- return bfqio_cgroup_weight_write(of_css(of), NULL, +- simple_strtoull(strim(buf), NULL, 0)); ++ int ret = kstrtoull(strim(buf), 0, &weight); ++ ++ if (ret) ++ return ret; ++ ++ return bfq_io_set_weight_legacy(of_css(of), NULL, weight); + } + + static int bfqg_print_stat(struct seq_file *sf, void *v) +@@ -899,16 +892,17 @@ static int bfqg_print_rwstat(struct seq_file *sf, void *v) + static u64 bfqg_prfill_stat_recursive(struct seq_file *sf, + struct blkg_policy_data *pd, int off) + { +- u64 sum = bfqg_stat_pd_recursive_sum(pd, off); +- ++ u64 sum = blkg_stat_recursive_sum(pd_to_blkg(pd), ++ &blkcg_policy_bfq, off); + return __blkg_prfill_u64(sf, pd, sum); + } + + static u64 bfqg_prfill_rwstat_recursive(struct seq_file *sf, + struct blkg_policy_data *pd, int off) + { +- struct blkg_rwstat sum = bfqg_rwstat_pd_recursive_sum(pd, off); +- ++ struct blkg_rwstat sum = blkg_rwstat_recursive_sum(pd_to_blkg(pd), ++ &blkcg_policy_bfq, ++ off); + return __blkg_prfill_rwstat(sf, pd, &sum); + } + +@@ -928,6 +922,41 @@ static int bfqg_print_rwstat_recursive(struct seq_file *sf, void *v) + return 0; + } + ++static u64 bfqg_prfill_sectors(struct seq_file *sf, struct blkg_policy_data *pd, ++ int off) ++{ ++ u64 sum = blkg_rwstat_total(&pd->blkg->stat_bytes); ++ ++ return __blkg_prfill_u64(sf, pd, sum >> 9); ++} ++ ++static int bfqg_print_stat_sectors(struct seq_file *sf, void *v) ++{ ++ blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), ++ bfqg_prfill_sectors, &blkcg_policy_bfq, 0, false); ++ return 0; ++} ++ ++static u64 bfqg_prfill_sectors_recursive(struct seq_file *sf, ++ struct blkg_policy_data *pd, int off) ++{ ++ struct blkg_rwstat tmp = blkg_rwstat_recursive_sum(pd->blkg, NULL, ++ offsetof(struct blkcg_gq, stat_bytes)); ++ u64 sum = atomic64_read(&tmp.aux_cnt[BLKG_RWSTAT_READ]) + ++ atomic64_read(&tmp.aux_cnt[BLKG_RWSTAT_WRITE]); ++ ++ return __blkg_prfill_u64(sf, pd, sum >> 9); ++} ++ ++static int bfqg_print_stat_sectors_recursive(struct seq_file *sf, void *v) ++{ ++ blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), ++ bfqg_prfill_sectors_recursive, &blkcg_policy_bfq, 0, ++ false); ++ return 0; ++} ++ ++ + static u64 bfqg_prfill_avg_queue_size(struct seq_file *sf, + struct blkg_policy_data *pd, int off) + { +@@ -964,38 +993,15 @@ bfq_create_group_hierarchy(struct bfq_data *bfqd, int node) + return blkg_to_bfqg(bfqd->queue->root_blkg); + } + +-static struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp) +-{ +- struct bfq_group_data *bgd; +- +- bgd = kzalloc(sizeof(*bgd), GFP_KERNEL); +- if (!bgd) +- return NULL; +- return &bgd->pd; +-} +- +-static void bfq_cpd_free(struct blkcg_policy_data *cpd) +-{ +- kfree(cpd_to_bfqgd(cpd)); +-} +- +-static struct cftype bfqio_files_dfl[] = { ++static struct cftype bfq_blkcg_legacy_files[] = { + { +- .name = "weight", ++ .name = "bfq.weight", + .flags = CFTYPE_NOT_ON_ROOT, +- .seq_show = bfqio_cgroup_weight_read_dfl, +- .write = bfqio_cgroup_weight_write_dfl, ++ .seq_show = bfq_io_show_weight, ++ .write_u64 = bfq_io_set_weight_legacy, + }, +- {} /* terminate */ +-}; + +-static struct cftype bfqio_files[] = { +- { +- .name = "bfq.weight", +- .read_u64 = bfqio_cgroup_weight_read, +- .write_u64 = bfqio_cgroup_weight_write, +- }, +- /* statistics, cover only the tasks in the bfqg */ ++ /* statistics, covers only the tasks in the bfqg */ + { + .name = "bfq.time", + .private = offsetof(struct bfq_group, stats.time), +@@ -1003,18 +1009,17 @@ static struct cftype bfqio_files[] = { + }, + { + .name = "bfq.sectors", +- .private = offsetof(struct bfq_group, stats.sectors), +- .seq_show = bfqg_print_stat, ++ .seq_show = bfqg_print_stat_sectors, + }, + { + .name = "bfq.io_service_bytes", +- .private = offsetof(struct bfq_group, stats.service_bytes), +- .seq_show = bfqg_print_rwstat, ++ .private = (unsigned long)&blkcg_policy_bfq, ++ .seq_show = blkg_print_stat_bytes, + }, + { + .name = "bfq.io_serviced", +- .private = offsetof(struct bfq_group, stats.serviced), +- .seq_show = bfqg_print_rwstat, ++ .private = (unsigned long)&blkcg_policy_bfq, ++ .seq_show = blkg_print_stat_ios, + }, + { + .name = "bfq.io_service_time", +@@ -1045,18 +1050,17 @@ static struct cftype bfqio_files[] = { + }, + { + .name = "bfq.sectors_recursive", +- .private = offsetof(struct bfq_group, stats.sectors), +- .seq_show = bfqg_print_stat_recursive, ++ .seq_show = bfqg_print_stat_sectors_recursive, + }, + { + .name = "bfq.io_service_bytes_recursive", +- .private = offsetof(struct bfq_group, stats.service_bytes), +- .seq_show = bfqg_print_rwstat_recursive, ++ .private = (unsigned long)&blkcg_policy_bfq, ++ .seq_show = blkg_print_stat_bytes_recursive, + }, + { + .name = "bfq.io_serviced_recursive", +- .private = offsetof(struct bfq_group, stats.serviced), +- .seq_show = bfqg_print_rwstat_recursive, ++ .private = (unsigned long)&blkcg_policy_bfq, ++ .seq_show = blkg_print_stat_ios_recursive, + }, + { + .name = "bfq.io_service_time_recursive", +@@ -1102,31 +1106,39 @@ static struct cftype bfqio_files[] = { + .private = offsetof(struct bfq_group, stats.dequeue), + .seq_show = bfqg_print_stat, + }, +- { +- .name = "bfq.unaccounted_time", +- .private = offsetof(struct bfq_group, stats.unaccounted_time), +- .seq_show = bfqg_print_stat, +- }, + { } /* terminate */ + }; + +-static struct blkcg_policy blkcg_policy_bfq = { +- .dfl_cftypes = bfqio_files_dfl, +- .legacy_cftypes = bfqio_files, +- +- .pd_alloc_fn = bfq_pd_alloc, +- .pd_init_fn = bfq_pd_init, +- .pd_offline_fn = bfq_pd_offline, +- .pd_free_fn = bfq_pd_free, +- .pd_reset_stats_fn = bfq_pd_reset_stats, +- +- .cpd_alloc_fn = bfq_cpd_alloc, +- .cpd_init_fn = bfq_cpd_init, +- .cpd_bind_fn = bfq_cpd_init, +- .cpd_free_fn = bfq_cpd_free, ++static struct cftype bfq_blkg_files[] = { ++ { ++ .name = "bfq.weight", ++ .flags = CFTYPE_NOT_ON_ROOT, ++ .seq_show = bfq_io_show_weight, ++ .write = bfq_io_set_weight, ++ }, ++ {} /* terminate */ + }; + +-#else ++#else /* CONFIG_BFQ_GROUP_IOSCHED */ ++ ++static inline void bfqg_stats_update_io_add(struct bfq_group *bfqg, ++ struct bfq_queue *bfqq, int op, int op_flags) { } ++static inline void ++bfqg_stats_update_io_remove(struct bfq_group *bfqg, int op, int op_flags) { } ++static inline void ++bfqg_stats_update_io_merged(struct bfq_group *bfqg, int op, int op_flags) { } ++static inline void bfqg_stats_update_completion(struct bfq_group *bfqg, ++ uint64_t start_time, uint64_t io_start_time, int op, ++ int op_flags) { } ++static inline void ++bfqg_stats_set_start_group_wait_time(struct bfq_group *bfqg, ++ struct bfq_group *curr_bfqg) { } ++static inline void bfqg_stats_end_empty_time(struct bfqg_stats *stats) { } ++static inline void bfqg_stats_update_dequeue(struct bfq_group *bfqg) { } ++static inline void bfqg_stats_set_start_empty_time(struct bfq_group *bfqg) { } ++static inline void bfqg_stats_update_idle_time(struct bfq_group *bfqg) { } ++static inline void bfqg_stats_set_start_idle_time(struct bfq_group *bfqg) { } ++static inline void bfqg_stats_update_avg_queue_size(struct bfq_group *bfqg) { } + + static void bfq_init_entity(struct bfq_entity *entity, + struct bfq_group *bfqg) +@@ -1150,27 +1162,20 @@ bfq_bic_update_cgroup(struct bfq_io_cq *bic, struct bio *bio) + return bfqd->root_group; + } + +-static void bfq_bfqq_move(struct bfq_data *bfqd, +- struct bfq_queue *bfqq, +- struct bfq_entity *entity, +- struct bfq_group *bfqg) +-{ +-} +- + static void bfq_end_wr_async(struct bfq_data *bfqd) + { + bfq_end_wr_async_queues(bfqd, bfqd->root_group); + } + +-static void bfq_disconnect_groups(struct bfq_data *bfqd) ++static struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd, ++ struct blkcg *blkcg) + { +- bfq_put_async_queues(bfqd, bfqd->root_group); ++ return bfqd->root_group; + } + +-static struct bfq_group *bfq_find_alloc_group(struct bfq_data *bfqd, +- struct blkcg *blkcg) ++static struct bfq_group *bfqq_group(struct bfq_queue *bfqq) + { +- return bfqd->root_group; ++ return bfqq->bfqd->root_group; + } + + static struct bfq_group * +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c +index cf3e9b1..0f9cd53 100644 +--- a/block/bfq-iosched.c ++++ b/block/bfq-iosched.c +@@ -1,5 +1,5 @@ + /* +- * Budget Fair Queueing (BFQ) disk scheduler. ++ * Budget Fair Queueing (BFQ) I/O scheduler. + * + * Based on ideas and code from CFQ: + * Copyright (C) 2003 Jens Axboe +@@ -7,25 +7,34 @@ + * Copyright (C) 2008 Fabio Checconi + * Paolo Valente + * +- * Copyright (C) 2010 Paolo Valente ++ * Copyright (C) 2015 Paolo Valente ++ * ++ * Copyright (C) 2016 Paolo Valente + * + * Licensed under the GPL-2 as detailed in the accompanying COPYING.BFQ + * file. + * +- * BFQ is a proportional-share storage-I/O scheduling algorithm based on +- * the slice-by-slice service scheme of CFQ. But BFQ assigns budgets, +- * measured in number of sectors, to processes instead of time slices. The +- * device is not granted to the in-service process for a given time slice, +- * but until it has exhausted its assigned budget. This change from the time +- * to the service domain allows BFQ to distribute the device throughput +- * among processes as desired, without any distortion due to ZBR, workload +- * fluctuations or other factors. BFQ uses an ad hoc internal scheduler, +- * called B-WF2Q+, to schedule processes according to their budgets. More +- * precisely, BFQ schedules queues associated to processes. Thanks to the +- * accurate policy of B-WF2Q+, BFQ can afford to assign high budgets to +- * I/O-bound processes issuing sequential requests (to boost the +- * throughput), and yet guarantee a low latency to interactive and soft +- * real-time applications. ++ * BFQ is a proportional-share I/O scheduler, with some extra ++ * low-latency capabilities. BFQ also supports full hierarchical ++ * scheduling through cgroups. Next paragraphs provide an introduction ++ * on BFQ inner workings. Details on BFQ benefits and usage can be ++ * found in Documentation/block/bfq-iosched.txt. ++ * ++ * BFQ is a proportional-share storage-I/O scheduling algorithm based ++ * on the slice-by-slice service scheme of CFQ. But BFQ assigns ++ * budgets, measured in number of sectors, to processes instead of ++ * time slices. The device is not granted to the in-service process ++ * for a given time slice, but until it has exhausted its assigned ++ * budget. This change from the time to the service domain enables BFQ ++ * to distribute the device throughput among processes as desired, ++ * without any distortion due to throughput fluctuations, or to device ++ * internal queueing. BFQ uses an ad hoc internal scheduler, called ++ * B-WF2Q+, to schedule processes according to their budgets. More ++ * precisely, BFQ schedules queues associated with processes. Thanks to ++ * the accurate policy of B-WF2Q+, BFQ can afford to assign high ++ * budgets to I/O-bound processes issuing sequential requests (to ++ * boost the throughput), and yet guarantee a low latency to ++ * interactive and soft real-time applications. + * + * BFQ is described in [1], where also a reference to the initial, more + * theoretical paper on BFQ can be found. The interested reader can find +@@ -40,10 +49,10 @@ + * H-WF2Q+, while the augmented tree used to implement B-WF2Q+ with O(log N) + * complexity derives from the one introduced with EEVDF in [3]. + * +- * [1] P. Valente and M. Andreolini, ``Improving Application Responsiveness +- * with the BFQ Disk I/O Scheduler'', +- * Proceedings of the 5th Annual International Systems and Storage +- * Conference (SYSTOR '12), June 2012. ++ * [1] P. Valente, A. Avanzini, "Evolution of the BFQ Storage I/O ++ * Scheduler", Proceedings of the First Workshop on Mobile System ++ * Technologies (MST-2015), May 2015. ++ * http://algogroup.unimore.it/people/paolo/disk_sched/mst-2015.pdf + * + * http://algogroup.unimo.it/people/paolo/disk_sched/bf1-v1-suite-results.pdf + * +@@ -70,24 +79,23 @@ + #include "bfq.h" + #include "blk.h" + +-/* Expiration time of sync (0) and async (1) requests, in jiffies. */ +-static const int bfq_fifo_expire[2] = { HZ / 4, HZ / 8 }; ++/* Expiration time of sync (0) and async (1) requests, in ns. */ ++static const u64 bfq_fifo_expire[2] = { NSEC_PER_SEC / 4, NSEC_PER_SEC / 8 }; + + /* Maximum backwards seek, in KiB. */ +-static const int bfq_back_max = 16 * 1024; ++static const int bfq_back_max = (16 * 1024); + + /* Penalty of a backwards seek, in number of sectors. */ + static const int bfq_back_penalty = 2; + +-/* Idling period duration, in jiffies. */ +-static int bfq_slice_idle = HZ / 125; ++/* Idling period duration, in ns. */ ++static u32 bfq_slice_idle = (NSEC_PER_SEC / 125); + + /* Minimum number of assigned budgets for which stats are safe to compute. */ + static const int bfq_stats_min_budgets = 194; + + /* Default maximum budget values, in sectors and number of requests. */ +-static const int bfq_default_max_budget = 16 * 1024; +-static const int bfq_max_budget_async_rq = 4; ++static const int bfq_default_max_budget = (16 * 1024); + + /* + * Async to sync throughput distribution is controlled as follows: +@@ -97,23 +105,28 @@ static const int bfq_max_budget_async_rq = 4; + static const int bfq_async_charge_factor = 10; + + /* Default timeout values, in jiffies, approximating CFQ defaults. */ +-static const int bfq_timeout_sync = HZ / 8; +-static int bfq_timeout_async = HZ / 25; ++static const int bfq_timeout = (HZ / 8); + + struct kmem_cache *bfq_pool; + +-/* Below this threshold (in ms), we consider thinktime immediate. */ +-#define BFQ_MIN_TT 2 ++/* Below this threshold (in ns), we consider thinktime immediate. */ ++#define BFQ_MIN_TT (2 * NSEC_PER_MSEC) + + /* hw_tag detection: parallel requests threshold and min samples needed. */ + #define BFQ_HW_QUEUE_THRESHOLD 4 + #define BFQ_HW_QUEUE_SAMPLES 32 + +-#define BFQQ_SEEK_THR (sector_t)(8 * 1024) +-#define BFQQ_SEEKY(bfqq) ((bfqq)->seek_mean > BFQQ_SEEK_THR) ++#define BFQQ_SEEK_THR (sector_t)(8 * 100) ++#define BFQQ_SECT_THR_NONROT (sector_t)(2 * 32) ++#define BFQQ_CLOSE_THR (sector_t)(8 * 1024) ++#define BFQQ_SEEKY(bfqq) (hweight32(bfqq->seek_history) > 32/8) + +-/* Min samples used for peak rate estimation (for autotuning). */ +-#define BFQ_PEAK_RATE_SAMPLES 32 ++/* Min number of samples required to perform peak-rate update */ ++#define BFQ_RATE_MIN_SAMPLES 32 ++/* Min observation time interval required to perform a peak-rate update (ns) */ ++#define BFQ_RATE_MIN_INTERVAL (300*NSEC_PER_MSEC) ++/* Target observation time interval for a peak-rate update (ns) */ ++#define BFQ_RATE_REF_INTERVAL NSEC_PER_SEC + + /* Shift used for peak rate fixed precision calculations. */ + #define BFQ_RATE_SHIFT 16 +@@ -141,16 +154,24 @@ struct kmem_cache *bfq_pool; + * The device's speed class is dynamically (re)detected in + * bfq_update_peak_rate() every time the estimated peak rate is updated. + * +- * In the following definitions, R_slow[0]/R_fast[0] and T_slow[0]/T_fast[0] +- * are the reference values for a slow/fast rotational device, whereas +- * R_slow[1]/R_fast[1] and T_slow[1]/T_fast[1] are the reference values for +- * a slow/fast non-rotational device. Finally, device_speed_thresh are the +- * thresholds used to switch between speed classes. ++ * In the following definitions, R_slow[0]/R_fast[0] and ++ * T_slow[0]/T_fast[0] are the reference values for a slow/fast ++ * rotational device, whereas R_slow[1]/R_fast[1] and ++ * T_slow[1]/T_fast[1] are the reference values for a slow/fast ++ * non-rotational device. Finally, device_speed_thresh are the ++ * thresholds used to switch between speed classes. The reference ++ * rates are not the actual peak rates of the devices used as a ++ * reference, but slightly lower values. The reason for using these ++ * slightly lower values is that the peak-rate estimator tends to ++ * yield slightly lower values than the actual peak rate (it can yield ++ * the actual peak rate only if there is only one process doing I/O, ++ * and the process does sequential I/O). ++ * + * Both the reference peak rates and the thresholds are measured in + * sectors/usec, left-shifted by BFQ_RATE_SHIFT. + */ +-static int R_slow[2] = {1536, 10752}; +-static int R_fast[2] = {17415, 34791}; ++static int R_slow[2] = {1000, 10700}; ++static int R_fast[2] = {14000, 33000}; + /* + * To improve readability, a conversion function is used to initialize the + * following arrays, which entails that they can be initialized only in a +@@ -183,10 +204,7 @@ static void bfq_schedule_dispatch(struct bfq_data *bfqd); + */ + static int bfq_bio_sync(struct bio *bio) + { +- if (bio_data_dir(bio) == READ || (bio->bi_rw & REQ_SYNC)) +- return 1; +- +- return 0; ++ return bio_data_dir(bio) == READ || (bio->bi_opf & REQ_SYNC); + } + + /* +@@ -409,11 +427,7 @@ static bool bfq_differentiated_weights(struct bfq_data *bfqd) + */ + static bool bfq_symmetric_scenario(struct bfq_data *bfqd) + { +- return +-#ifdef CONFIG_BFQ_GROUP_IOSCHED +- !bfqd->active_numerous_groups && +-#endif +- !bfq_differentiated_weights(bfqd); ++ return !bfq_differentiated_weights(bfqd); + } + + /* +@@ -533,9 +547,19 @@ static struct request *bfq_find_next_rq(struct bfq_data *bfqd, + static unsigned long bfq_serv_to_charge(struct request *rq, + struct bfq_queue *bfqq) + { +- return blk_rq_sectors(rq) * +- (1 + ((!bfq_bfqq_sync(bfqq)) * (bfqq->wr_coeff == 1) * +- bfq_async_charge_factor)); ++ if (bfq_bfqq_sync(bfqq) || bfqq->wr_coeff > 1) ++ return blk_rq_sectors(rq); ++ ++ /* ++ * If there are no weight-raised queues, then amplify service ++ * by just the async charge factor; otherwise amplify service ++ * by twice the async charge factor, to further reduce latency ++ * for weight-raised queues. ++ */ ++ if (bfqq->bfqd->wr_busy_queues == 0) ++ return blk_rq_sectors(rq) * bfq_async_charge_factor; ++ ++ return blk_rq_sectors(rq) * 2 * bfq_async_charge_factor; + } + + /** +@@ -576,7 +600,7 @@ static void bfq_updated_next_req(struct bfq_data *bfqd, + entity->budget = new_budget; + bfq_log_bfqq(bfqd, bfqq, "updated next rq: new budget %lu", + new_budget); +- bfq_activate_bfqq(bfqd, bfqq); ++ bfq_requeue_bfqq(bfqd, bfqq); + } + } + +@@ -590,12 +614,23 @@ static unsigned int bfq_wr_duration(struct bfq_data *bfqd) + dur = bfqd->RT_prod; + do_div(dur, bfqd->peak_rate); + +- return dur; +-} ++ /* ++ * Limit duration between 3 and 13 seconds. Tests show that ++ * higher values than 13 seconds often yield the opposite of ++ * the desired result, i.e., worsen responsiveness by letting ++ * non-interactive and non-soft-real-time applications ++ * preserve weight raising for a too long time interval. ++ * ++ * On the other end, lower values than 3 seconds make it ++ * difficult for most interactive tasks to complete their jobs ++ * before weight-raising finishes. ++ */ ++ if (dur > msecs_to_jiffies(13000)) ++ dur = msecs_to_jiffies(13000); ++ else if (dur < msecs_to_jiffies(3000)) ++ dur = msecs_to_jiffies(3000); + +-static unsigned int bfq_bfqq_cooperations(struct bfq_queue *bfqq) +-{ +- return bfqq->bic ? bfqq->bic->cooperations : 0; ++ return dur; + } + + static void +@@ -605,31 +640,31 @@ bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_io_cq *bic) + bfq_mark_bfqq_idle_window(bfqq); + else + bfq_clear_bfqq_idle_window(bfqq); ++ + if (bic->saved_IO_bound) + bfq_mark_bfqq_IO_bound(bfqq); + else + bfq_clear_bfqq_IO_bound(bfqq); +- /* Assuming that the flag in_large_burst is already correctly set */ +- if (bic->wr_time_left && bfqq->bfqd->low_latency && +- !bfq_bfqq_in_large_burst(bfqq) && +- bic->cooperations < bfqq->bfqd->bfq_coop_thresh) { +- /* +- * Start a weight raising period with the duration given by +- * the raising_time_left snapshot. +- */ +- if (bfq_bfqq_busy(bfqq)) +- bfqq->bfqd->wr_busy_queues++; +- bfqq->wr_coeff = bfqq->bfqd->bfq_wr_coeff; +- bfqq->wr_cur_max_time = bic->wr_time_left; +- bfqq->last_wr_start_finish = jiffies; +- bfqq->entity.prio_changed = 1; ++ ++ bfqq->wr_coeff = bic->saved_wr_coeff; ++ bfqq->wr_start_at_switch_to_srt = bic->saved_wr_start_at_switch_to_srt; ++ BUG_ON(time_is_after_jiffies(bfqq->wr_start_at_switch_to_srt)); ++ bfqq->last_wr_start_finish = bic->saved_last_wr_start_finish; ++ bfqq->wr_cur_max_time = bic->saved_wr_cur_max_time; ++ BUG_ON(time_is_after_jiffies(bfqq->last_wr_start_finish)); ++ ++ if (bfqq->wr_coeff > 1 && (bfq_bfqq_in_large_burst(bfqq) || ++ time_is_before_jiffies(bfqq->last_wr_start_finish + ++ bfqq->wr_cur_max_time))) { ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "resume state: switching off wr (%lu + %lu < %lu)", ++ bfqq->last_wr_start_finish, bfqq->wr_cur_max_time, ++ jiffies); ++ ++ bfqq->wr_coeff = 1; + } +- /* +- * Clear wr_time_left to prevent bfq_bfqq_save_state() from +- * getting confused about the queue's need of a weight-raising +- * period. +- */ +- bic->wr_time_left = 0; ++ /* make sure weight will be updated, however we got here */ ++ bfqq->entity.prio_changed = 1; + } + + static int bfqq_process_refs(struct bfq_queue *bfqq) +@@ -639,7 +674,7 @@ static int bfqq_process_refs(struct bfq_queue *bfqq) + lockdep_assert_held(bfqq->bfqd->queue->queue_lock); + + io_refs = bfqq->allocated[READ] + bfqq->allocated[WRITE]; +- process_refs = atomic_read(&bfqq->ref) - io_refs - bfqq->entity.on_st; ++ process_refs = bfqq->ref - io_refs - bfqq->entity.on_st; + BUG_ON(process_refs < 0); + return process_refs; + } +@@ -654,6 +689,7 @@ static void bfq_reset_burst_list(struct bfq_data *bfqd, struct bfq_queue *bfqq) + hlist_del_init(&item->burst_list_node); + hlist_add_head(&bfqq->burst_list_node, &bfqd->burst_list); + bfqd->burst_size = 1; ++ bfqd->burst_parent_entity = bfqq->entity.parent; + } + + /* Add bfqq to the list of queues in current burst (see bfq_handle_burst) */ +@@ -662,6 +698,10 @@ static void bfq_add_to_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) + /* Increment burst size to take into account also bfqq */ + bfqd->burst_size++; + ++ bfq_log_bfqq(bfqd, bfqq, "add_to_burst %d", bfqd->burst_size); ++ ++ BUG_ON(bfqd->burst_size > bfqd->bfq_large_burst_thresh); ++ + if (bfqd->burst_size == bfqd->bfq_large_burst_thresh) { + struct bfq_queue *pos, *bfqq_item; + struct hlist_node *n; +@@ -671,15 +711,19 @@ static void bfq_add_to_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) + * other to consider this burst as large. + */ + bfqd->large_burst = true; ++ bfq_log_bfqq(bfqd, bfqq, "add_to_burst: large burst started"); + + /* + * We can now mark all queues in the burst list as + * belonging to a large burst. + */ + hlist_for_each_entry(bfqq_item, &bfqd->burst_list, +- burst_list_node) ++ burst_list_node) { + bfq_mark_bfqq_in_large_burst(bfqq_item); ++ bfq_log_bfqq(bfqd, bfqq_item, "marked in large burst"); ++ } + bfq_mark_bfqq_in_large_burst(bfqq); ++ bfq_log_bfqq(bfqd, bfqq, "marked in large burst"); + + /* + * From now on, and until the current burst finishes, any +@@ -691,67 +735,79 @@ static void bfq_add_to_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) + hlist_for_each_entry_safe(pos, n, &bfqd->burst_list, + burst_list_node) + hlist_del_init(&pos->burst_list_node); +- } else /* burst not yet large: add bfqq to the burst list */ ++ } else /* ++ * Burst not yet large: add bfqq to the burst list. Do ++ * not increment the ref counter for bfqq, because bfqq ++ * is removed from the burst list before freeing bfqq ++ * in put_queue. ++ */ + hlist_add_head(&bfqq->burst_list_node, &bfqd->burst_list); + } + + /* +- * If many queues happen to become active shortly after each other, then, +- * to help the processes associated to these queues get their job done as +- * soon as possible, it is usually better to not grant either weight-raising +- * or device idling to these queues. In this comment we describe, firstly, +- * the reasons why this fact holds, and, secondly, the next function, which +- * implements the main steps needed to properly mark these queues so that +- * they can then be treated in a different way. ++ * If many queues belonging to the same group happen to be created ++ * shortly after each other, then the processes associated with these ++ * queues have typically a common goal. In particular, bursts of queue ++ * creations are usually caused by services or applications that spawn ++ * many parallel threads/processes. Examples are systemd during boot, ++ * or git grep. To help these processes get their job done as soon as ++ * possible, it is usually better to not grant either weight-raising ++ * or device idling to their queues. + * +- * As for the terminology, we say that a queue becomes active, i.e., +- * switches from idle to backlogged, either when it is created (as a +- * consequence of the arrival of an I/O request), or, if already existing, +- * when a new request for the queue arrives while the queue is idle. +- * Bursts of activations, i.e., activations of different queues occurring +- * shortly after each other, are typically caused by services or applications +- * that spawn or reactivate many parallel threads/processes. Examples are +- * systemd during boot or git grep. ++ * In this comment we describe, firstly, the reasons why this fact ++ * holds, and, secondly, the next function, which implements the main ++ * steps needed to properly mark these queues so that they can then be ++ * treated in a different way. + * +- * These services or applications benefit mostly from a high throughput: +- * the quicker the requests of the activated queues are cumulatively served, +- * the sooner the target job of these queues gets completed. As a consequence, +- * weight-raising any of these queues, which also implies idling the device +- * for it, is almost always counterproductive: in most cases it just lowers +- * throughput. ++ * The above services or applications benefit mostly from a high ++ * throughput: the quicker the requests of the activated queues are ++ * cumulatively served, the sooner the target job of these queues gets ++ * completed. As a consequence, weight-raising any of these queues, ++ * which also implies idling the device for it, is almost always ++ * counterproductive. In most cases it just lowers throughput. + * +- * On the other hand, a burst of activations may be also caused by the start +- * of an application that does not consist in a lot of parallel I/O-bound +- * threads. In fact, with a complex application, the burst may be just a +- * consequence of the fact that several processes need to be executed to +- * start-up the application. To start an application as quickly as possible, +- * the best thing to do is to privilege the I/O related to the application +- * with respect to all other I/O. Therefore, the best strategy to start as +- * quickly as possible an application that causes a burst of activations is +- * to weight-raise all the queues activated during the burst. This is the ++ * On the other hand, a burst of queue creations may be caused also by ++ * the start of an application that does not consist of a lot of ++ * parallel I/O-bound threads. In fact, with a complex application, ++ * several short processes may need to be executed to start-up the ++ * application. In this respect, to start an application as quickly as ++ * possible, the best thing to do is in any case to privilege the I/O ++ * related to the application with respect to all other ++ * I/O. Therefore, the best strategy to start as quickly as possible ++ * an application that causes a burst of queue creations is to ++ * weight-raise all the queues created during the burst. This is the + * exact opposite of the best strategy for the other type of bursts. + * +- * In the end, to take the best action for each of the two cases, the two +- * types of bursts need to be distinguished. Fortunately, this seems +- * relatively easy to do, by looking at the sizes of the bursts. In +- * particular, we found a threshold such that bursts with a larger size +- * than that threshold are apparently caused only by services or commands +- * such as systemd or git grep. For brevity, hereafter we call just 'large' +- * these bursts. BFQ *does not* weight-raise queues whose activations occur +- * in a large burst. In addition, for each of these queues BFQ performs or +- * does not perform idling depending on which choice boosts the throughput +- * most. The exact choice depends on the device and request pattern at ++ * In the end, to take the best action for each of the two cases, the ++ * two types of bursts need to be distinguished. Fortunately, this ++ * seems relatively easy, by looking at the sizes of the bursts. In ++ * particular, we found a threshold such that only bursts with a ++ * larger size than that threshold are apparently caused by ++ * services or commands such as systemd or git grep. For brevity, ++ * hereafter we call just 'large' these bursts. BFQ *does not* ++ * weight-raise queues whose creation occurs in a large burst. In ++ * addition, for each of these queues BFQ performs or does not perform ++ * idling depending on which choice boosts the throughput more. The ++ * exact choice depends on the device and request pattern at + * hand. + * +- * Turning back to the next function, it implements all the steps needed +- * to detect the occurrence of a large burst and to properly mark all the +- * queues belonging to it (so that they can then be treated in a different +- * way). This goal is achieved by maintaining a special "burst list" that +- * holds, temporarily, the queues that belong to the burst in progress. The +- * list is then used to mark these queues as belonging to a large burst if +- * the burst does become large. The main steps are the following. ++ * Unfortunately, false positives may occur while an interactive task ++ * is starting (e.g., an application is being started). The ++ * consequence is that the queues associated with the task do not ++ * enjoy weight raising as expected. Fortunately these false positives ++ * are very rare. They typically occur if some service happens to ++ * start doing I/O exactly when the interactive task starts. ++ * ++ * Turning back to the next function, it implements all the steps ++ * needed to detect the occurrence of a large burst and to properly ++ * mark all the queues belonging to it (so that they can then be ++ * treated in a different way). This goal is achieved by maintaining a ++ * "burst list" that holds, temporarily, the queues that belong to the ++ * burst in progress. The list is then used to mark these queues as ++ * belonging to a large burst if the burst does become large. The main ++ * steps are the following. + * +- * . when the very first queue is activated, the queue is inserted into the ++ * . when the very first queue is created, the queue is inserted into the + * list (as it could be the first queue in a possible burst) + * + * . if the current burst has not yet become large, and a queue Q that does +@@ -772,13 +828,13 @@ static void bfq_add_to_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) + * + * . the device enters a large-burst mode + * +- * . if a queue Q that does not belong to the burst is activated while ++ * . if a queue Q that does not belong to the burst is created while + * the device is in large-burst mode and shortly after the last time + * at which a queue either entered the burst list or was marked as + * belonging to the current large burst, then Q is immediately marked + * as belonging to a large burst. + * +- * . if a queue Q that does not belong to the burst is activated a while ++ * . if a queue Q that does not belong to the burst is created a while + * later, i.e., not shortly after, than the last time at which a queue + * either entered the burst list or was marked as belonging to the + * current large burst, then the current burst is deemed as finished and: +@@ -791,52 +847,44 @@ static void bfq_add_to_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) + * in a possible new burst (then the burst list contains just Q + * after this step). + */ +-static void bfq_handle_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq, +- bool idle_for_long_time) ++static void bfq_handle_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) + { + /* +- * If bfqq happened to be activated in a burst, but has been idle +- * for at least as long as an interactive queue, then we assume +- * that, in the overall I/O initiated in the burst, the I/O +- * associated to bfqq is finished. So bfqq does not need to be +- * treated as a queue belonging to a burst anymore. Accordingly, +- * we reset bfqq's in_large_burst flag if set, and remove bfqq +- * from the burst list if it's there. We do not decrement instead +- * burst_size, because the fact that bfqq does not need to belong +- * to the burst list any more does not invalidate the fact that +- * bfqq may have been activated during the current burst. +- */ +- if (idle_for_long_time) { +- hlist_del_init(&bfqq->burst_list_node); +- bfq_clear_bfqq_in_large_burst(bfqq); +- } +- +- /* + * If bfqq is already in the burst list or is part of a large +- * burst, then there is nothing else to do. ++ * burst, or finally has just been split, then there is ++ * nothing else to do. + */ + if (!hlist_unhashed(&bfqq->burst_list_node) || +- bfq_bfqq_in_large_burst(bfqq)) ++ bfq_bfqq_in_large_burst(bfqq) || ++ time_is_after_eq_jiffies(bfqq->split_time + ++ msecs_to_jiffies(10))) + return; + + /* +- * If bfqq's activation happens late enough, then the current +- * burst is finished, and related data structures must be reset. ++ * If bfqq's creation happens late enough, or bfqq belongs to ++ * a different group than the burst group, then the current ++ * burst is finished, and related data structures must be ++ * reset. + * +- * In this respect, consider the special case where bfqq is the very +- * first queue being activated. In this case, last_ins_in_burst is +- * not yet significant when we get here. But it is easy to verify +- * that, whether or not the following condition is true, bfqq will +- * end up being inserted into the burst list. In particular the +- * list will happen to contain only bfqq. And this is exactly what +- * has to happen, as bfqq may be the first queue in a possible ++ * In this respect, consider the special case where bfqq is ++ * the very first queue created after BFQ is selected for this ++ * device. In this case, last_ins_in_burst and ++ * burst_parent_entity are not yet significant when we get ++ * here. But it is easy to verify that, whether or not the ++ * following condition is true, bfqq will end up being ++ * inserted into the burst list. In particular the list will ++ * happen to contain only bfqq. And this is exactly what has ++ * to happen, as bfqq may be the first queue of the first + * burst. + */ + if (time_is_before_jiffies(bfqd->last_ins_in_burst + +- bfqd->bfq_burst_interval)) { ++ bfqd->bfq_burst_interval) || ++ bfqq->entity.parent != bfqd->burst_parent_entity) { + bfqd->large_burst = false; + bfq_reset_burst_list(bfqd, bfqq); +- return; ++ bfq_log_bfqq(bfqd, bfqq, ++ "handle_burst: late activation or different group"); ++ goto end; + } + + /* +@@ -845,8 +893,9 @@ static void bfq_handle_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq, + * bfqq as belonging to this large burst immediately. + */ + if (bfqd->large_burst) { ++ bfq_log_bfqq(bfqd, bfqq, "handle_burst: marked in burst"); + bfq_mark_bfqq_in_large_burst(bfqq); +- return; ++ goto end; + } + + /* +@@ -855,25 +904,491 @@ static void bfq_handle_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq, + * queue. Then we add bfqq to the burst. + */ + bfq_add_to_burst(bfqd, bfqq); ++end: ++ /* ++ * At this point, bfqq either has been added to the current ++ * burst or has caused the current burst to terminate and a ++ * possible new burst to start. In particular, in the second ++ * case, bfqq has become the first queue in the possible new ++ * burst. In both cases last_ins_in_burst needs to be moved ++ * forward. ++ */ ++ bfqd->last_ins_in_burst = jiffies; ++ ++} ++ ++static int bfq_bfqq_budget_left(struct bfq_queue *bfqq) ++{ ++ struct bfq_entity *entity = &bfqq->entity; ++ ++ return entity->budget - entity->service; ++} ++ ++/* ++ * If enough samples have been computed, return the current max budget ++ * stored in bfqd, which is dynamically updated according to the ++ * estimated disk peak rate; otherwise return the default max budget ++ */ ++static int bfq_max_budget(struct bfq_data *bfqd) ++{ ++ if (bfqd->budgets_assigned < bfq_stats_min_budgets) ++ return bfq_default_max_budget; ++ else ++ return bfqd->bfq_max_budget; ++} ++ ++/* ++ * Return min budget, which is a fraction of the current or default ++ * max budget (trying with 1/32) ++ */ ++static int bfq_min_budget(struct bfq_data *bfqd) ++{ ++ if (bfqd->budgets_assigned < bfq_stats_min_budgets) ++ return bfq_default_max_budget / 32; ++ else ++ return bfqd->bfq_max_budget / 32; ++} ++ ++static void bfq_bfqq_expire(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq, ++ bool compensate, ++ enum bfqq_expiration reason); ++ ++/* ++ * The next function, invoked after the input queue bfqq switches from ++ * idle to busy, updates the budget of bfqq. The function also tells ++ * whether the in-service queue should be expired, by returning ++ * true. The purpose of expiring the in-service queue is to give bfqq ++ * the chance to possibly preempt the in-service queue, and the reason ++ * for preempting the in-service queue is to achieve one of the two ++ * goals below. ++ * ++ * 1. Guarantee to bfqq its reserved bandwidth even if bfqq has ++ * expired because it has remained idle. In particular, bfqq may have ++ * expired for one of the following two reasons: ++ * ++ * - BFQ_BFQQ_NO_MORE_REQUEST bfqq did not enjoy any device idling and ++ * did not make it to issue a new request before its last request ++ * was served; ++ * ++ * - BFQ_BFQQ_TOO_IDLE bfqq did enjoy device idling, but did not issue ++ * a new request before the expiration of the idling-time. ++ * ++ * Even if bfqq has expired for one of the above reasons, the process ++ * associated with the queue may be however issuing requests greedily, ++ * and thus be sensitive to the bandwidth it receives (bfqq may have ++ * remained idle for other reasons: CPU high load, bfqq not enjoying ++ * idling, I/O throttling somewhere in the path from the process to ++ * the I/O scheduler, ...). But if, after every expiration for one of ++ * the above two reasons, bfqq has to wait for the service of at least ++ * one full budget of another queue before being served again, then ++ * bfqq is likely to get a much lower bandwidth or resource time than ++ * its reserved ones. To address this issue, two countermeasures need ++ * to be taken. ++ * ++ * First, the budget and the timestamps of bfqq need to be updated in ++ * a special way on bfqq reactivation: they need to be updated as if ++ * bfqq did not remain idle and did not expire. In fact, if they are ++ * computed as if bfqq expired and remained idle until reactivation, ++ * then the process associated with bfqq is treated as if, instead of ++ * being greedy, it stopped issuing requests when bfqq remained idle, ++ * and restarts issuing requests only on this reactivation. In other ++ * words, the scheduler does not help the process recover the "service ++ * hole" between bfqq expiration and reactivation. As a consequence, ++ * the process receives a lower bandwidth than its reserved one. In ++ * contrast, to recover this hole, the budget must be updated as if ++ * bfqq was not expired at all before this reactivation, i.e., it must ++ * be set to the value of the remaining budget when bfqq was ++ * expired. Along the same line, timestamps need to be assigned the ++ * value they had the last time bfqq was selected for service, i.e., ++ * before last expiration. Thus timestamps need to be back-shifted ++ * with respect to their normal computation (see [1] for more details ++ * on this tricky aspect). ++ * ++ * Secondly, to allow the process to recover the hole, the in-service ++ * queue must be expired too, to give bfqq the chance to preempt it ++ * immediately. In fact, if bfqq has to wait for a full budget of the ++ * in-service queue to be completed, then it may become impossible to ++ * let the process recover the hole, even if the back-shifted ++ * timestamps of bfqq are lower than those of the in-service queue. If ++ * this happens for most or all of the holes, then the process may not ++ * receive its reserved bandwidth. In this respect, it is worth noting ++ * that, being the service of outstanding requests unpreemptible, a ++ * little fraction of the holes may however be unrecoverable, thereby ++ * causing a little loss of bandwidth. ++ * ++ * The last important point is detecting whether bfqq does need this ++ * bandwidth recovery. In this respect, the next function deems the ++ * process associated with bfqq greedy, and thus allows it to recover ++ * the hole, if: 1) the process is waiting for the arrival of a new ++ * request (which implies that bfqq expired for one of the above two ++ * reasons), and 2) such a request has arrived soon. The first ++ * condition is controlled through the flag non_blocking_wait_rq, ++ * while the second through the flag arrived_in_time. If both ++ * conditions hold, then the function computes the budget in the ++ * above-described special way, and signals that the in-service queue ++ * should be expired. Timestamp back-shifting is done later in ++ * __bfq_activate_entity. ++ * ++ * 2. Reduce latency. Even if timestamps are not backshifted to let ++ * the process associated with bfqq recover a service hole, bfqq may ++ * however happen to have, after being (re)activated, a lower finish ++ * timestamp than the in-service queue. That is, the next budget of ++ * bfqq may have to be completed before the one of the in-service ++ * queue. If this is the case, then preempting the in-service queue ++ * allows this goal to be achieved, apart from the unpreemptible, ++ * outstanding requests mentioned above. ++ * ++ * Unfortunately, regardless of which of the above two goals one wants ++ * to achieve, service trees need first to be updated to know whether ++ * the in-service queue must be preempted. To have service trees ++ * correctly updated, the in-service queue must be expired and ++ * rescheduled, and bfqq must be scheduled too. This is one of the ++ * most costly operations (in future versions, the scheduling ++ * mechanism may be re-designed in such a way to make it possible to ++ * know whether preemption is needed without needing to update service ++ * trees). In addition, queue preemptions almost always cause random ++ * I/O, and thus loss of throughput. Because of these facts, the next ++ * function adopts the following simple scheme to avoid both costly ++ * operations and too frequent preemptions: it requests the expiration ++ * of the in-service queue (unconditionally) only for queues that need ++ * to recover a hole, or that either are weight-raised or deserve to ++ * be weight-raised. ++ */ ++static bool bfq_bfqq_update_budg_for_activation(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq, ++ bool arrived_in_time, ++ bool wr_or_deserves_wr) ++{ ++ struct bfq_entity *entity = &bfqq->entity; ++ ++ if (bfq_bfqq_non_blocking_wait_rq(bfqq) && arrived_in_time) { ++ /* ++ * We do not clear the flag non_blocking_wait_rq here, as ++ * the latter is used in bfq_activate_bfqq to signal ++ * that timestamps need to be back-shifted (and is ++ * cleared right after). ++ */ ++ ++ /* ++ * In next assignment we rely on that either ++ * entity->service or entity->budget are not updated ++ * on expiration if bfqq is empty (see ++ * __bfq_bfqq_recalc_budget). Thus both quantities ++ * remain unchanged after such an expiration, and the ++ * following statement therefore assigns to ++ * entity->budget the remaining budget on such an ++ * expiration. For clarity, entity->service is not ++ * updated on expiration in any case, and, in normal ++ * operation, is reset only when bfqq is selected for ++ * service (see bfq_get_next_queue). ++ */ ++ BUG_ON(bfqq->max_budget < 0); ++ entity->budget = min_t(unsigned long, ++ bfq_bfqq_budget_left(bfqq), ++ bfqq->max_budget); ++ ++ BUG_ON(entity->budget < 0); ++ return true; ++ } ++ ++ BUG_ON(bfqq->max_budget < 0); ++ entity->budget = max_t(unsigned long, bfqq->max_budget, ++ bfq_serv_to_charge(bfqq->next_rq, bfqq)); ++ BUG_ON(entity->budget < 0); ++ ++ bfq_clear_bfqq_non_blocking_wait_rq(bfqq); ++ return wr_or_deserves_wr; ++} ++ ++static void bfq_update_bfqq_wr_on_rq_arrival(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq, ++ unsigned int old_wr_coeff, ++ bool wr_or_deserves_wr, ++ bool interactive, ++ bool in_burst, ++ bool soft_rt) ++{ ++ if (old_wr_coeff == 1 && wr_or_deserves_wr) { ++ /* start a weight-raising period */ ++ if (interactive) { ++ bfqq->wr_coeff = bfqd->bfq_wr_coeff; ++ bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); ++ } else { ++ bfqq->wr_start_at_switch_to_srt = jiffies; ++ bfqq->wr_coeff = bfqd->bfq_wr_coeff * ++ BFQ_SOFTRT_WEIGHT_FACTOR; ++ bfqq->wr_cur_max_time = ++ bfqd->bfq_wr_rt_max_time; ++ } ++ /* ++ * If needed, further reduce budget to make sure it is ++ * close to bfqq's backlog, so as to reduce the ++ * scheduling-error component due to a too large ++ * budget. Do not care about throughput consequences, ++ * but only about latency. Finally, do not assign a ++ * too small budget either, to avoid increasing ++ * latency by causing too frequent expirations. ++ */ ++ bfqq->entity.budget = min_t(unsigned long, ++ bfqq->entity.budget, ++ 2 * bfq_min_budget(bfqd)); ++ ++ bfq_log_bfqq(bfqd, bfqq, ++ "wrais starting at %lu, rais_max_time %u", ++ jiffies, ++ jiffies_to_msecs(bfqq->wr_cur_max_time)); ++ } else if (old_wr_coeff > 1) { ++ if (interactive) { /* update wr coeff and duration */ ++ bfqq->wr_coeff = bfqd->bfq_wr_coeff; ++ bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); ++ } else if (in_burst) { ++ bfqq->wr_coeff = 1; ++ bfq_log_bfqq(bfqd, bfqq, ++ "wrais ending at %lu, rais_max_time %u", ++ jiffies, ++ jiffies_to_msecs(bfqq-> ++ wr_cur_max_time)); ++ } else if (soft_rt) { ++ /* ++ * The application is now or still meeting the ++ * requirements for being deemed soft rt. We ++ * can then correctly and safely (re)charge ++ * the weight-raising duration for the ++ * application with the weight-raising ++ * duration for soft rt applications. ++ * ++ * In particular, doing this recharge now, i.e., ++ * before the weight-raising period for the ++ * application finishes, reduces the probability ++ * of the following negative scenario: ++ * 1) the weight of a soft rt application is ++ * raised at startup (as for any newly ++ * created application), ++ * 2) since the application is not interactive, ++ * at a certain time weight-raising is ++ * stopped for the application, ++ * 3) at that time the application happens to ++ * still have pending requests, and hence ++ * is destined to not have a chance to be ++ * deemed soft rt before these requests are ++ * completed (see the comments to the ++ * function bfq_bfqq_softrt_next_start() ++ * for details on soft rt detection), ++ * 4) these pending requests experience a high ++ * latency because the application is not ++ * weight-raised while they are pending. ++ */ ++ if (bfqq->wr_cur_max_time != ++ bfqd->bfq_wr_rt_max_time) { ++ bfqq->wr_start_at_switch_to_srt = ++ bfqq->last_wr_start_finish; ++ BUG_ON(time_is_after_jiffies(bfqq->last_wr_start_finish)); ++ ++ bfqq->wr_cur_max_time = ++ bfqd->bfq_wr_rt_max_time; ++ bfqq->wr_coeff = bfqd->bfq_wr_coeff * ++ BFQ_SOFTRT_WEIGHT_FACTOR; ++ bfq_log_bfqq(bfqd, bfqq, ++ "switching to soft_rt wr"); ++ } else ++ bfq_log_bfqq(bfqd, bfqq, ++ "moving forward soft_rt wr duration"); ++ bfqq->last_wr_start_finish = jiffies; ++ } ++ } ++} ++ ++static bool bfq_bfqq_idle_for_long_time(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq) ++{ ++ return bfqq->dispatched == 0 && ++ time_is_before_jiffies( ++ bfqq->budget_timeout + ++ bfqd->bfq_wr_min_idle_time); ++} ++ ++static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq, ++ int old_wr_coeff, ++ struct request *rq, ++ bool *interactive) ++{ ++ bool soft_rt, in_burst, wr_or_deserves_wr, ++ bfqq_wants_to_preempt, ++ idle_for_long_time = bfq_bfqq_idle_for_long_time(bfqd, bfqq), ++ /* ++ * See the comments on ++ * bfq_bfqq_update_budg_for_activation for ++ * details on the usage of the next variable. ++ */ ++ arrived_in_time = ktime_get_ns() <= ++ RQ_BIC(rq)->ttime.last_end_request + ++ bfqd->bfq_slice_idle * 3; ++ ++ bfq_log_bfqq(bfqd, bfqq, ++ "bfq_add_request non-busy: " ++ "jiffies %lu, in_time %d, idle_long %d busyw %d " ++ "wr_coeff %u", ++ jiffies, arrived_in_time, ++ idle_for_long_time, ++ bfq_bfqq_non_blocking_wait_rq(bfqq), ++ old_wr_coeff); ++ ++ BUG_ON(bfqq->entity.budget < bfqq->entity.service); ++ ++ BUG_ON(bfqq == bfqd->in_service_queue); ++ bfqg_stats_update_io_add(bfqq_group(RQ_BFQQ(rq)), bfqq, ++ req_op(rq), rq->cmd_flags); ++ ++ /* ++ * bfqq deserves to be weight-raised if: ++ * - it is sync, ++ * - it does not belong to a large burst, ++ * - it has been idle for enough time or is soft real-time, ++ * - is linked to a bfq_io_cq (it is not shared in any sense) ++ */ ++ in_burst = bfq_bfqq_in_large_burst(bfqq); ++ soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && ++ !in_burst && ++ time_is_before_jiffies(bfqq->soft_rt_next_start); ++ *interactive = ++ !in_burst && ++ idle_for_long_time; ++ wr_or_deserves_wr = bfqd->low_latency && ++ (bfqq->wr_coeff > 1 || ++ (bfq_bfqq_sync(bfqq) && ++ bfqq->bic && (*interactive || soft_rt))); ++ ++ bfq_log_bfqq(bfqd, bfqq, ++ "bfq_add_request: " ++ "in_burst %d, " ++ "soft_rt %d (next %lu), inter %d, bic %p", ++ bfq_bfqq_in_large_burst(bfqq), soft_rt, ++ bfqq->soft_rt_next_start, ++ *interactive, ++ bfqq->bic); ++ ++ /* ++ * Using the last flag, update budget and check whether bfqq ++ * may want to preempt the in-service queue. ++ */ ++ bfqq_wants_to_preempt = ++ bfq_bfqq_update_budg_for_activation(bfqd, bfqq, ++ arrived_in_time, ++ wr_or_deserves_wr); ++ ++ /* ++ * If bfqq happened to be activated in a burst, but has been ++ * idle for much more than an interactive queue, then we ++ * assume that, in the overall I/O initiated in the burst, the ++ * I/O associated with bfqq is finished. So bfqq does not need ++ * to be treated as a queue belonging to a burst ++ * anymore. Accordingly, we reset bfqq's in_large_burst flag ++ * if set, and remove bfqq from the burst list if it's ++ * there. We do not decrement burst_size, because the fact ++ * that bfqq does not need to belong to the burst list any ++ * more does not invalidate the fact that bfqq was created in ++ * a burst. ++ */ ++ if (likely(!bfq_bfqq_just_created(bfqq)) && ++ idle_for_long_time && ++ time_is_before_jiffies( ++ bfqq->budget_timeout + ++ msecs_to_jiffies(10000))) { ++ hlist_del_init(&bfqq->burst_list_node); ++ bfq_clear_bfqq_in_large_burst(bfqq); ++ } ++ ++ bfq_clear_bfqq_just_created(bfqq); ++ ++ if (!bfq_bfqq_IO_bound(bfqq)) { ++ if (arrived_in_time) { ++ bfqq->requests_within_timer++; ++ if (bfqq->requests_within_timer >= ++ bfqd->bfq_requests_within_timer) ++ bfq_mark_bfqq_IO_bound(bfqq); ++ } else ++ bfqq->requests_within_timer = 0; ++ bfq_log_bfqq(bfqd, bfqq, "requests in time %d", ++ bfqq->requests_within_timer); ++ } ++ ++ if (bfqd->low_latency) { ++ if (unlikely(time_is_after_jiffies(bfqq->split_time))) ++ /* wraparound */ ++ bfqq->split_time = ++ jiffies - bfqd->bfq_wr_min_idle_time - 1; ++ ++ if (time_is_before_jiffies(bfqq->split_time + ++ bfqd->bfq_wr_min_idle_time)) { ++ bfq_update_bfqq_wr_on_rq_arrival(bfqd, bfqq, ++ old_wr_coeff, ++ wr_or_deserves_wr, ++ *interactive, ++ in_burst, ++ soft_rt); ++ ++ if (old_wr_coeff != bfqq->wr_coeff) ++ bfqq->entity.prio_changed = 1; ++ } ++ } ++ ++ bfqq->last_idle_bklogged = jiffies; ++ bfqq->service_from_backlogged = 0; ++ bfq_clear_bfqq_softrt_update(bfqq); ++ ++ bfq_add_bfqq_busy(bfqd, bfqq); ++ ++ /* ++ * Expire in-service queue only if preemption may be needed ++ * for guarantees. In this respect, the function ++ * next_queue_may_preempt just checks a simple, necessary ++ * condition, and not a sufficient condition based on ++ * timestamps. In fact, for the latter condition to be ++ * evaluated, timestamps would need first to be updated, and ++ * this operation is quite costly (see the comments on the ++ * function bfq_bfqq_update_budg_for_activation). ++ */ ++ if (bfqd->in_service_queue && bfqq_wants_to_preempt && ++ bfqd->in_service_queue->wr_coeff < bfqq->wr_coeff && ++ next_queue_may_preempt(bfqd)) { ++ struct bfq_queue *in_serv = ++ bfqd->in_service_queue; ++ BUG_ON(in_serv == bfqq); ++ ++ bfq_bfqq_expire(bfqd, bfqd->in_service_queue, ++ false, BFQ_BFQQ_PREEMPTED); ++ BUG_ON(in_serv->entity.budget < 0); ++ } + } + + static void bfq_add_request(struct request *rq) + { + struct bfq_queue *bfqq = RQ_BFQQ(rq); +- struct bfq_entity *entity = &bfqq->entity; + struct bfq_data *bfqd = bfqq->bfqd; + struct request *next_rq, *prev; +- unsigned long old_wr_coeff = bfqq->wr_coeff; ++ unsigned int old_wr_coeff = bfqq->wr_coeff; + bool interactive = false; + +- bfq_log_bfqq(bfqd, bfqq, "add_request %d", rq_is_sync(rq)); ++ bfq_log_bfqq(bfqd, bfqq, "add_request: size %u %s", ++ blk_rq_sectors(rq), rq_is_sync(rq) ? "S" : "A"); ++ ++ if (bfqq->wr_coeff > 1) /* queue is being weight-raised */ ++ bfq_log_bfqq(bfqd, bfqq, ++ "raising period dur %u/%u msec, old coeff %u, w %d(%d)", ++ jiffies_to_msecs(jiffies - bfqq->last_wr_start_finish), ++ jiffies_to_msecs(bfqq->wr_cur_max_time), ++ bfqq->wr_coeff, ++ bfqq->entity.weight, bfqq->entity.orig_weight); ++ + bfqq->queued[rq_is_sync(rq)]++; + bfqd->queued++; + + elv_rb_add(&bfqq->sort_list, rq); + + /* +- * Check if this request is a better next-serve candidate. ++ * Check if this request is a better next-to-serve candidate. + */ + prev = bfqq->next_rq; + next_rq = bfq_choose_req(bfqd, bfqq->next_rq, rq, bfqd->last_position); +@@ -886,160 +1401,10 @@ static void bfq_add_request(struct request *rq) + if (prev != bfqq->next_rq) + bfq_pos_tree_add_move(bfqd, bfqq); + +- if (!bfq_bfqq_busy(bfqq)) { +- bool soft_rt, coop_or_in_burst, +- idle_for_long_time = time_is_before_jiffies( +- bfqq->budget_timeout + +- bfqd->bfq_wr_min_idle_time); +- +-#ifdef CONFIG_BFQ_GROUP_IOSCHED +- bfqg_stats_update_io_add(bfqq_group(RQ_BFQQ(rq)), bfqq, +- rq->cmd_flags); +-#endif +- if (bfq_bfqq_sync(bfqq)) { +- bool already_in_burst = +- !hlist_unhashed(&bfqq->burst_list_node) || +- bfq_bfqq_in_large_burst(bfqq); +- bfq_handle_burst(bfqd, bfqq, idle_for_long_time); +- /* +- * If bfqq was not already in the current burst, +- * then, at this point, bfqq either has been +- * added to the current burst or has caused the +- * current burst to terminate. In particular, in +- * the second case, bfqq has become the first +- * queue in a possible new burst. +- * In both cases last_ins_in_burst needs to be +- * moved forward. +- */ +- if (!already_in_burst) +- bfqd->last_ins_in_burst = jiffies; +- } +- +- coop_or_in_burst = bfq_bfqq_in_large_burst(bfqq) || +- bfq_bfqq_cooperations(bfqq) >= bfqd->bfq_coop_thresh; +- soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && +- !coop_or_in_burst && +- time_is_before_jiffies(bfqq->soft_rt_next_start); +- interactive = !coop_or_in_burst && idle_for_long_time; +- entity->budget = max_t(unsigned long, bfqq->max_budget, +- bfq_serv_to_charge(next_rq, bfqq)); +- +- if (!bfq_bfqq_IO_bound(bfqq)) { +- if (time_before(jiffies, +- RQ_BIC(rq)->ttime.last_end_request + +- bfqd->bfq_slice_idle)) { +- bfqq->requests_within_timer++; +- if (bfqq->requests_within_timer >= +- bfqd->bfq_requests_within_timer) +- bfq_mark_bfqq_IO_bound(bfqq); +- } else +- bfqq->requests_within_timer = 0; +- } +- +- if (!bfqd->low_latency) +- goto add_bfqq_busy; +- +- if (bfq_bfqq_just_split(bfqq)) +- goto set_prio_changed; +- +- /* +- * If the queue: +- * - is not being boosted, +- * - has been idle for enough time, +- * - is not a sync queue or is linked to a bfq_io_cq (it is +- * shared "for its nature" or it is not shared and its +- * requests have not been redirected to a shared queue) +- * start a weight-raising period. +- */ +- if (old_wr_coeff == 1 && (interactive || soft_rt) && +- (!bfq_bfqq_sync(bfqq) || bfqq->bic)) { +- bfqq->wr_coeff = bfqd->bfq_wr_coeff; +- if (interactive) +- bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); +- else +- bfqq->wr_cur_max_time = +- bfqd->bfq_wr_rt_max_time; +- bfq_log_bfqq(bfqd, bfqq, +- "wrais starting at %lu, rais_max_time %u", +- jiffies, +- jiffies_to_msecs(bfqq->wr_cur_max_time)); +- } else if (old_wr_coeff > 1) { +- if (interactive) +- bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); +- else if (coop_or_in_burst || +- (bfqq->wr_cur_max_time == +- bfqd->bfq_wr_rt_max_time && +- !soft_rt)) { +- bfqq->wr_coeff = 1; +- bfq_log_bfqq(bfqd, bfqq, +- "wrais ending at %lu, rais_max_time %u", +- jiffies, +- jiffies_to_msecs(bfqq-> +- wr_cur_max_time)); +- } else if (time_before( +- bfqq->last_wr_start_finish + +- bfqq->wr_cur_max_time, +- jiffies + +- bfqd->bfq_wr_rt_max_time) && +- soft_rt) { +- /* +- * +- * The remaining weight-raising time is lower +- * than bfqd->bfq_wr_rt_max_time, which means +- * that the application is enjoying weight +- * raising either because deemed soft-rt in +- * the near past, or because deemed interactive +- * a long ago. +- * In both cases, resetting now the current +- * remaining weight-raising time for the +- * application to the weight-raising duration +- * for soft rt applications would not cause any +- * latency increase for the application (as the +- * new duration would be higher than the +- * remaining time). +- * +- * In addition, the application is now meeting +- * the requirements for being deemed soft rt. +- * In the end we can correctly and safely +- * (re)charge the weight-raising duration for +- * the application with the weight-raising +- * duration for soft rt applications. +- * +- * In particular, doing this recharge now, i.e., +- * before the weight-raising period for the +- * application finishes, reduces the probability +- * of the following negative scenario: +- * 1) the weight of a soft rt application is +- * raised at startup (as for any newly +- * created application), +- * 2) since the application is not interactive, +- * at a certain time weight-raising is +- * stopped for the application, +- * 3) at that time the application happens to +- * still have pending requests, and hence +- * is destined to not have a chance to be +- * deemed soft rt before these requests are +- * completed (see the comments to the +- * function bfq_bfqq_softrt_next_start() +- * for details on soft rt detection), +- * 4) these pending requests experience a high +- * latency because the application is not +- * weight-raised while they are pending. +- */ +- bfqq->last_wr_start_finish = jiffies; +- bfqq->wr_cur_max_time = +- bfqd->bfq_wr_rt_max_time; +- } +- } +-set_prio_changed: +- if (old_wr_coeff != bfqq->wr_coeff) +- entity->prio_changed = 1; +-add_bfqq_busy: +- bfqq->last_idle_bklogged = jiffies; +- bfqq->service_from_backlogged = 0; +- bfq_clear_bfqq_softrt_update(bfqq); +- bfq_add_bfqq_busy(bfqd, bfqq); +- } else { ++ if (!bfq_bfqq_busy(bfqq)) /* switching to busy ... */ ++ bfq_bfqq_handle_idle_busy_switch(bfqd, bfqq, old_wr_coeff, ++ rq, &interactive); ++ else { + if (bfqd->low_latency && old_wr_coeff == 1 && !rq_is_sync(rq) && + time_is_before_jiffies( + bfqq->last_wr_start_finish + +@@ -1048,16 +1413,43 @@ static void bfq_add_request(struct request *rq) + bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); + + bfqd->wr_busy_queues++; +- entity->prio_changed = 1; ++ bfqq->entity.prio_changed = 1; + bfq_log_bfqq(bfqd, bfqq, +- "non-idle wrais starting at %lu, rais_max_time %u", +- jiffies, +- jiffies_to_msecs(bfqq->wr_cur_max_time)); ++ "non-idle wrais starting, " ++ "wr_max_time %u wr_busy %d", ++ jiffies_to_msecs(bfqq->wr_cur_max_time), ++ bfqd->wr_busy_queues); + } + if (prev != bfqq->next_rq) + bfq_updated_next_req(bfqd, bfqq); + } + ++ /* ++ * Assign jiffies to last_wr_start_finish in the following ++ * cases: ++ * ++ * . if bfqq is not going to be weight-raised, because, for ++ * non weight-raised queues, last_wr_start_finish stores the ++ * arrival time of the last request; as of now, this piece ++ * of information is used only for deciding whether to ++ * weight-raise async queues ++ * ++ * . if bfqq is not weight-raised, because, if bfqq is now ++ * switching to weight-raised, then last_wr_start_finish ++ * stores the time when weight-raising starts ++ * ++ * . if bfqq is interactive, because, regardless of whether ++ * bfqq is currently weight-raised, the weight-raising ++ * period must start or restart (this case is considered ++ * separately because it is not detected by the above ++ * conditions, if bfqq is already weight-raised) ++ * ++ * last_wr_start_finish has to be updated also if bfqq is soft ++ * real-time, because the weight-raising period is constantly ++ * restarted on idle-to-busy transitions for these queues, but ++ * this is already done in bfq_bfqq_handle_idle_busy_switch if ++ * needed. ++ */ + if (bfqd->low_latency && + (old_wr_coeff == 1 || bfqq->wr_coeff == 1 || interactive)) + bfqq->last_wr_start_finish = jiffies; +@@ -1081,14 +1473,24 @@ static struct request *bfq_find_rq_fmerge(struct bfq_data *bfqd, + return NULL; + } + ++static sector_t get_sdist(sector_t last_pos, struct request *rq) ++{ ++ sector_t sdist = 0; ++ ++ if (last_pos) { ++ if (last_pos < blk_rq_pos(rq)) ++ sdist = blk_rq_pos(rq) - last_pos; ++ else ++ sdist = last_pos - blk_rq_pos(rq); ++ } ++ ++ return sdist; ++} ++ + static void bfq_activate_request(struct request_queue *q, struct request *rq) + { + struct bfq_data *bfqd = q->elevator->elevator_data; +- + bfqd->rq_in_driver++; +- bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq); +- bfq_log(bfqd, "activate_request: new bfqd->last_position %llu", +- (unsigned long long) bfqd->last_position); + } + + static void bfq_deactivate_request(struct request_queue *q, struct request *rq) +@@ -1105,6 +1507,9 @@ static void bfq_remove_request(struct request *rq) + struct bfq_data *bfqd = bfqq->bfqd; + const int sync = rq_is_sync(rq); + ++ BUG_ON(bfqq->entity.service > bfqq->entity.budget && ++ bfqq == bfqd->in_service_queue); ++ + if (bfqq->next_rq == rq) { + bfqq->next_rq = bfq_find_next_rq(bfqd, bfqq, rq); + bfq_updated_next_req(bfqd, bfqq); +@@ -1118,8 +1523,25 @@ static void bfq_remove_request(struct request *rq) + elv_rb_del(&bfqq->sort_list, rq); + + if (RB_EMPTY_ROOT(&bfqq->sort_list)) { +- if (bfq_bfqq_busy(bfqq) && bfqq != bfqd->in_service_queue) +- bfq_del_bfqq_busy(bfqd, bfqq, 1); ++ BUG_ON(bfqq->entity.budget < 0); ++ ++ if (bfq_bfqq_busy(bfqq) && bfqq != bfqd->in_service_queue) { ++ bfq_del_bfqq_busy(bfqd, bfqq, false); ++ ++ /* bfqq emptied. In normal operation, when ++ * bfqq is empty, bfqq->entity.service and ++ * bfqq->entity.budget must contain, ++ * respectively, the service received and the ++ * budget used last time bfqq emptied. These ++ * facts do not hold in this case, as at least ++ * this last removal occurred while bfqq is ++ * not in service. To avoid inconsistencies, ++ * reset both bfqq->entity.service and ++ * bfqq->entity.budget. ++ */ ++ bfqq->entity.budget = bfqq->entity.service = 0; ++ } ++ + /* + * Remove queue from request-position tree as it is empty. + */ +@@ -1133,9 +1555,8 @@ static void bfq_remove_request(struct request *rq) + BUG_ON(bfqq->meta_pending == 0); + bfqq->meta_pending--; + } +-#ifdef CONFIG_BFQ_GROUP_IOSCHED +- bfqg_stats_update_io_remove(bfqq_group(bfqq), rq->cmd_flags); +-#endif ++ bfqg_stats_update_io_remove(bfqq_group(bfqq), req_op(rq), ++ rq->cmd_flags); + } + + static int bfq_merge(struct request_queue *q, struct request **req, +@@ -1145,7 +1566,7 @@ static int bfq_merge(struct request_queue *q, struct request **req, + struct request *__rq; + + __rq = bfq_find_rq_fmerge(bfqd, bio); +- if (__rq && elv_rq_merge_ok(__rq, bio)) { ++ if (__rq && elv_bio_merge_ok(__rq, bio)) { + *req = __rq; + return ELEVATOR_FRONT_MERGE; + } +@@ -1190,7 +1611,8 @@ static void bfq_merged_request(struct request_queue *q, struct request *req, + static void bfq_bio_merged(struct request_queue *q, struct request *req, + struct bio *bio) + { +- bfqg_stats_update_io_merged(bfqq_group(RQ_BFQQ(req)), bio->bi_rw); ++ bfqg_stats_update_io_merged(bfqq_group(RQ_BFQQ(req)), bio_op(bio), ++ bio->bi_opf); + } + #endif + +@@ -1210,7 +1632,7 @@ static void bfq_merged_requests(struct request_queue *q, struct request *rq, + */ + if (bfqq == next_bfqq && + !list_empty(&rq->queuelist) && !list_empty(&next->queuelist) && +- time_before(next->fifo_time, rq->fifo_time)) { ++ next->fifo_time < rq->fifo_time) { + list_del_init(&rq->queuelist); + list_replace_init(&next->queuelist, &rq->queuelist); + rq->fifo_time = next->fifo_time; +@@ -1220,21 +1642,31 @@ static void bfq_merged_requests(struct request_queue *q, struct request *rq, + bfqq->next_rq = rq; + + bfq_remove_request(next); +-#ifdef CONFIG_BFQ_GROUP_IOSCHED +- bfqg_stats_update_io_merged(bfqq_group(bfqq), next->cmd_flags); +-#endif ++ bfqg_stats_update_io_merged(bfqq_group(bfqq), req_op(next), ++ next->cmd_flags); + } + + /* Must be called with bfqq != NULL */ + static void bfq_bfqq_end_wr(struct bfq_queue *bfqq) + { + BUG_ON(!bfqq); ++ + if (bfq_bfqq_busy(bfqq)) + bfqq->bfqd->wr_busy_queues--; + bfqq->wr_coeff = 1; + bfqq->wr_cur_max_time = 0; +- /* Trigger a weight change on the next activation of the queue */ ++ bfqq->last_wr_start_finish = jiffies; ++ /* ++ * Trigger a weight change on the next invocation of ++ * __bfq_entity_update_weight_prio. ++ */ + bfqq->entity.prio_changed = 1; ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "end_wr: wrais ending at %lu, rais_max_time %u", ++ bfqq->last_wr_start_finish, ++ jiffies_to_msecs(bfqq->wr_cur_max_time)); ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "end_wr: wr_busy %d", ++ bfqq->bfqd->wr_busy_queues); + } + + static void bfq_end_wr_async_queues(struct bfq_data *bfqd, +@@ -1277,7 +1709,7 @@ static int bfq_rq_close_to_sector(void *io_struct, bool request, + sector_t sector) + { + return abs(bfq_io_struct_pos(io_struct, request) - sector) <= +- BFQQ_SEEK_THR; ++ BFQQ_CLOSE_THR; + } + + static struct bfq_queue *bfqq_find_close(struct bfq_data *bfqd, +@@ -1399,7 +1831,7 @@ bfq_setup_merge(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq) + * throughput. + */ + bfqq->new_bfqq = new_bfqq; +- atomic_add(process_refs, &new_bfqq->ref); ++ new_bfqq->ref += process_refs; + return new_bfqq; + } + +@@ -1430,9 +1862,23 @@ static bool bfq_may_be_close_cooperator(struct bfq_queue *bfqq, + } + + /* +- * Attempt to schedule a merge of bfqq with the currently in-service queue +- * or with a close queue among the scheduled queues. +- * Return NULL if no merge was scheduled, a pointer to the shared bfq_queue ++ * If this function returns true, then bfqq cannot be merged. The idea ++ * is that true cooperation happens very early after processes start ++ * to do I/O. Usually, late cooperations are just accidental false ++ * positives. In case bfqq is weight-raised, such false positives ++ * would evidently degrade latency guarantees for bfqq. ++ */ ++bool wr_from_too_long(struct bfq_queue *bfqq) ++{ ++ return bfqq->wr_coeff > 1 && ++ time_is_before_jiffies(bfqq->last_wr_start_finish + ++ msecs_to_jiffies(100)); ++} ++ ++/* ++ * Attempt to schedule a merge of bfqq with the currently in-service ++ * queue or with a close queue among the scheduled queues. Return ++ * NULL if no merge was scheduled, a pointer to the shared bfq_queue + * structure otherwise. + * + * The OOM queue is not allowed to participate to cooperation: in fact, since +@@ -1441,6 +1887,18 @@ static bool bfq_may_be_close_cooperator(struct bfq_queue *bfqq, + * handle merging with the OOM queue would be quite complex and expensive + * to maintain. Besides, in such a critical condition as an out of memory, + * the benefits of queue merging may be little relevant, or even negligible. ++ * ++ * Weight-raised queues can be merged only if their weight-raising ++ * period has just started. In fact cooperating processes are usually ++ * started together. Thus, with this filter we avoid false positives ++ * that would jeopardize low-latency guarantees. ++ * ++ * WARNING: queue merging may impair fairness among non-weight raised ++ * queues, for at least two reasons: 1) the original weight of a ++ * merged queue may change during the merged state, 2) even being the ++ * weight the same, a merged queue may be bloated with many more ++ * requests than the ones produced by its originally-associated ++ * process. + */ + static struct bfq_queue * + bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, +@@ -1450,16 +1908,32 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, + + if (bfqq->new_bfqq) + return bfqq->new_bfqq; +- if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq)) ++ ++ if (io_struct && wr_from_too_long(bfqq) && ++ likely(bfqq != &bfqd->oom_bfqq)) ++ bfq_log_bfqq(bfqd, bfqq, ++ "would have looked for coop, but bfq%d wr", ++ bfqq->pid); ++ ++ if (!io_struct || ++ wr_from_too_long(bfqq) || ++ unlikely(bfqq == &bfqd->oom_bfqq)) + return NULL; +- /* If device has only one backlogged bfq_queue, don't search. */ ++ ++ /* If there is only one backlogged queue, don't search. */ + if (bfqd->busy_queues == 1) + return NULL; + + in_service_bfqq = bfqd->in_service_queue; + ++ if (in_service_bfqq && in_service_bfqq != bfqq && ++ bfqd->in_service_bic && wr_from_too_long(in_service_bfqq) ++ && likely(in_service_bfqq == &bfqd->oom_bfqq)) ++ bfq_log_bfqq(bfqd, bfqq, ++ "would have tried merge with in-service-queue, but wr"); ++ + if (!in_service_bfqq || in_service_bfqq == bfqq || +- !bfqd->in_service_bic || ++ !bfqd->in_service_bic || wr_from_too_long(in_service_bfqq) || + unlikely(in_service_bfqq == &bfqd->oom_bfqq)) + goto check_scheduled; + +@@ -1481,7 +1955,15 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, + + BUG_ON(new_bfqq && bfqq->entity.parent != new_bfqq->entity.parent); + +- if (new_bfqq && likely(new_bfqq != &bfqd->oom_bfqq) && ++ if (new_bfqq && wr_from_too_long(new_bfqq) && ++ likely(new_bfqq != &bfqd->oom_bfqq) && ++ bfq_may_be_close_cooperator(bfqq, new_bfqq)) ++ bfq_log_bfqq(bfqd, bfqq, ++ "would have merged with bfq%d, but wr", ++ new_bfqq->pid); ++ ++ if (new_bfqq && !wr_from_too_long(new_bfqq) && ++ likely(new_bfqq != &bfqd->oom_bfqq) && + bfq_may_be_close_cooperator(bfqq, new_bfqq)) + return bfq_setup_merge(bfqq, new_bfqq); + +@@ -1490,53 +1972,25 @@ bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, + + static void bfq_bfqq_save_state(struct bfq_queue *bfqq) + { ++ struct bfq_io_cq *bic = bfqq->bic; ++ + /* + * If !bfqq->bic, the queue is already shared or its requests + * have already been redirected to a shared queue; both idle window + * and weight raising state have already been saved. Do nothing. + */ +- if (!bfqq->bic) ++ if (!bic) + return; +- if (bfqq->bic->wr_time_left) +- /* +- * This is the queue of a just-started process, and would +- * deserve weight raising: we set wr_time_left to the full +- * weight-raising duration to trigger weight-raising when +- * and if the queue is split and the first request of the +- * queue is enqueued. +- */ +- bfqq->bic->wr_time_left = bfq_wr_duration(bfqq->bfqd); +- else if (bfqq->wr_coeff > 1) { +- unsigned long wr_duration = +- jiffies - bfqq->last_wr_start_finish; +- /* +- * It may happen that a queue's weight raising period lasts +- * longer than its wr_cur_max_time, as weight raising is +- * handled only when a request is enqueued or dispatched (it +- * does not use any timer). If the weight raising period is +- * about to end, don't save it. +- */ +- if (bfqq->wr_cur_max_time <= wr_duration) +- bfqq->bic->wr_time_left = 0; +- else +- bfqq->bic->wr_time_left = +- bfqq->wr_cur_max_time - wr_duration; +- /* +- * The bfq_queue is becoming shared or the requests of the +- * process owning the queue are being redirected to a shared +- * queue. Stop the weight raising period of the queue, as in +- * both cases it should not be owned by an interactive or +- * soft real-time application. +- */ +- bfq_bfqq_end_wr(bfqq); +- } else +- bfqq->bic->wr_time_left = 0; +- bfqq->bic->saved_idle_window = bfq_bfqq_idle_window(bfqq); +- bfqq->bic->saved_IO_bound = bfq_bfqq_IO_bound(bfqq); +- bfqq->bic->saved_in_large_burst = bfq_bfqq_in_large_burst(bfqq); +- bfqq->bic->was_in_burst_list = !hlist_unhashed(&bfqq->burst_list_node); +- bfqq->bic->cooperations++; +- bfqq->bic->failed_cooperations = 0; ++ ++ bic->saved_idle_window = bfq_bfqq_idle_window(bfqq); ++ bic->saved_IO_bound = bfq_bfqq_IO_bound(bfqq); ++ bic->saved_in_large_burst = bfq_bfqq_in_large_burst(bfqq); ++ bic->was_in_burst_list = !hlist_unhashed(&bfqq->burst_list_node); ++ bic->saved_wr_coeff = bfqq->wr_coeff; ++ bic->saved_wr_start_at_switch_to_srt = bfqq->wr_start_at_switch_to_srt; ++ bic->saved_last_wr_start_finish = bfqq->last_wr_start_finish; ++ bic->saved_wr_cur_max_time = bfqq->wr_cur_max_time; ++ BUG_ON(time_is_after_jiffies(bfqq->last_wr_start_finish)); + } + + static void bfq_get_bic_reference(struct bfq_queue *bfqq) +@@ -1561,6 +2015,40 @@ bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic, + if (bfq_bfqq_IO_bound(bfqq)) + bfq_mark_bfqq_IO_bound(new_bfqq); + bfq_clear_bfqq_IO_bound(bfqq); ++ ++ /* ++ * If bfqq is weight-raised, then let new_bfqq inherit ++ * weight-raising. To reduce false positives, neglect the case ++ * where bfqq has just been created, but has not yet made it ++ * to be weight-raised (which may happen because EQM may merge ++ * bfqq even before bfq_add_request is executed for the first ++ * time for bfqq). Handling this case would however be very ++ * easy, thanks to the flag just_created. ++ */ ++ if (new_bfqq->wr_coeff == 1 && bfqq->wr_coeff > 1) { ++ new_bfqq->wr_coeff = bfqq->wr_coeff; ++ new_bfqq->wr_cur_max_time = bfqq->wr_cur_max_time; ++ new_bfqq->last_wr_start_finish = bfqq->last_wr_start_finish; ++ new_bfqq->wr_start_at_switch_to_srt = bfqq->wr_start_at_switch_to_srt; ++ if (bfq_bfqq_busy(new_bfqq)) ++ bfqd->wr_busy_queues++; ++ new_bfqq->entity.prio_changed = 1; ++ bfq_log_bfqq(bfqd, new_bfqq, ++ "wr start after merge with %d, rais_max_time %u", ++ bfqq->pid, ++ jiffies_to_msecs(bfqq->wr_cur_max_time)); ++ } ++ ++ if (bfqq->wr_coeff > 1) { /* bfqq has given its wr to new_bfqq */ ++ bfqq->wr_coeff = 1; ++ bfqq->entity.prio_changed = 1; ++ if (bfq_bfqq_busy(bfqq)) ++ bfqd->wr_busy_queues--; ++ } ++ ++ bfq_log_bfqq(bfqd, new_bfqq, "merge_bfqqs: wr_busy %d", ++ bfqd->wr_busy_queues); ++ + /* + * Grab a reference to the bic, to prevent it from being destroyed + * before being possibly touched by a bfq_split_bfqq(). +@@ -1587,20 +2075,8 @@ bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic, + bfq_put_queue(bfqq); + } + +-static void bfq_bfqq_increase_failed_cooperations(struct bfq_queue *bfqq) +-{ +- struct bfq_io_cq *bic = bfqq->bic; +- struct bfq_data *bfqd = bfqq->bfqd; +- +- if (bic && bfq_bfqq_cooperations(bfqq) >= bfqd->bfq_coop_thresh) { +- bic->failed_cooperations++; +- if (bic->failed_cooperations >= bfqd->bfq_failed_cooperations) +- bic->cooperations = 0; +- } +-} +- +-static int bfq_allow_merge(struct request_queue *q, struct request *rq, +- struct bio *bio) ++static int bfq_allow_bio_merge(struct request_queue *q, struct request *rq, ++ struct bio *bio) + { + struct bfq_data *bfqd = q->elevator->elevator_data; + struct bfq_io_cq *bic; +@@ -1610,7 +2086,7 @@ static int bfq_allow_merge(struct request_queue *q, struct request *rq, + * Disallow merge of a sync bio into an async request. + */ + if (bfq_bio_sync(bio) && !rq_is_sync(rq)) +- return 0; ++ return false; + + /* + * Lookup the bfqq that this bio will be queued with. Allow +@@ -1619,7 +2095,7 @@ static int bfq_allow_merge(struct request_queue *q, struct request *rq, + */ + bic = bfq_bic_lookup(bfqd, current->io_context); + if (!bic) +- return 0; ++ return false; + + bfqq = bic_to_bfqq(bic, bfq_bio_sync(bio)); + /* +@@ -1636,30 +2112,111 @@ static int bfq_allow_merge(struct request_queue *q, struct request *rq, + * to decide whether bio and rq can be merged. + */ + bfqq = new_bfqq; +- } else +- bfq_bfqq_increase_failed_cooperations(bfqq); ++ } + } + + return bfqq == RQ_BFQQ(rq); + } + ++static int bfq_allow_rq_merge(struct request_queue *q, struct request *rq, ++ struct request *next) ++{ ++ return RQ_BFQQ(rq) == RQ_BFQQ(next); ++} ++ ++/* ++ * Set the maximum time for the in-service queue to consume its ++ * budget. This prevents seeky processes from lowering the throughput. ++ * In practice, a time-slice service scheme is used with seeky ++ * processes. ++ */ ++static void bfq_set_budget_timeout(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq) ++{ ++ unsigned int timeout_coeff; ++ ++ if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time) ++ timeout_coeff = 1; ++ else ++ timeout_coeff = bfqq->entity.weight / bfqq->entity.orig_weight; ++ ++ bfqd->last_budget_start = ktime_get(); ++ ++ bfqq->budget_timeout = jiffies + ++ bfqd->bfq_timeout * timeout_coeff; ++ ++ bfq_log_bfqq(bfqd, bfqq, "set budget_timeout %u", ++ jiffies_to_msecs(bfqd->bfq_timeout * timeout_coeff)); ++} ++ + static void __bfq_set_in_service_queue(struct bfq_data *bfqd, + struct bfq_queue *bfqq) + { + if (bfqq) { +-#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_update_avg_queue_size(bfqq_group(bfqq)); +-#endif + bfq_mark_bfqq_must_alloc(bfqq); +- bfq_mark_bfqq_budget_new(bfqq); + bfq_clear_bfqq_fifo_expire(bfqq); + + bfqd->budgets_assigned = (bfqd->budgets_assigned*7 + 256) / 8; + ++ BUG_ON(bfqq == bfqd->in_service_queue); ++ BUG_ON(RB_EMPTY_ROOT(&bfqq->sort_list)); ++ ++ if (time_is_before_jiffies(bfqq->last_wr_start_finish) && ++ bfqq->wr_coeff > 1 && ++ bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && ++ time_is_before_jiffies(bfqq->budget_timeout)) { ++ /* ++ * For soft real-time queues, move the start ++ * of the weight-raising period forward by the ++ * time the queue has not received any ++ * service. Otherwise, a relatively long ++ * service delay is likely to cause the ++ * weight-raising period of the queue to end, ++ * because of the short duration of the ++ * weight-raising period of a soft real-time ++ * queue. It is worth noting that this move ++ * is not so dangerous for the other queues, ++ * because soft real-time queues are not ++ * greedy. ++ * ++ * To not add a further variable, we use the ++ * overloaded field budget_timeout to ++ * determine for how long the queue has not ++ * received service, i.e., how much time has ++ * elapsed since the queue expired. However, ++ * this is a little imprecise, because ++ * budget_timeout is set to jiffies if bfqq ++ * not only expires, but also remains with no ++ * request. ++ */ ++ if (time_after(bfqq->budget_timeout, ++ bfqq->last_wr_start_finish)) ++ bfqq->last_wr_start_finish += ++ jiffies - bfqq->budget_timeout; ++ else ++ bfqq->last_wr_start_finish = jiffies; ++ ++ if (time_is_after_jiffies(bfqq->last_wr_start_finish)) { ++ pr_crit( ++ "BFQ WARNING:last %lu budget %lu jiffies %lu", ++ bfqq->last_wr_start_finish, ++ bfqq->budget_timeout, ++ jiffies); ++ pr_crit("diff %lu", jiffies - ++ max_t(unsigned long, ++ bfqq->last_wr_start_finish, ++ bfqq->budget_timeout)); ++ bfqq->last_wr_start_finish = jiffies; ++ } ++ } ++ ++ bfq_set_budget_timeout(bfqd, bfqq); + bfq_log_bfqq(bfqd, bfqq, + "set_in_service_queue, cur-budget = %d", + bfqq->entity.budget); +- } ++ } else ++ bfq_log(bfqd, "set_in_service_queue: NULL"); + + bfqd->in_service_queue = bfqq; + } +@@ -1675,36 +2232,11 @@ static struct bfq_queue *bfq_set_in_service_queue(struct bfq_data *bfqd) + return bfqq; + } + +-/* +- * If enough samples have been computed, return the current max budget +- * stored in bfqd, which is dynamically updated according to the +- * estimated disk peak rate; otherwise return the default max budget +- */ +-static int bfq_max_budget(struct bfq_data *bfqd) +-{ +- if (bfqd->budgets_assigned < bfq_stats_min_budgets) +- return bfq_default_max_budget; +- else +- return bfqd->bfq_max_budget; +-} +- +-/* +- * Return min budget, which is a fraction of the current or default +- * max budget (trying with 1/32) +- */ +-static int bfq_min_budget(struct bfq_data *bfqd) +-{ +- if (bfqd->budgets_assigned < bfq_stats_min_budgets) +- return bfq_default_max_budget / 32; +- else +- return bfqd->bfq_max_budget / 32; +-} +- + static void bfq_arm_slice_timer(struct bfq_data *bfqd) + { + struct bfq_queue *bfqq = bfqd->in_service_queue; + struct bfq_io_cq *bic; +- unsigned long sl; ++ u32 sl; + + BUG_ON(!RB_EMPTY_ROOT(&bfqq->sort_list)); + +@@ -1728,59 +2260,343 @@ static void bfq_arm_slice_timer(struct bfq_data *bfqd) + sl = bfqd->bfq_slice_idle; + /* + * Unless the queue is being weight-raised or the scenario is +- * asymmetric, grant only minimum idle time if the queue either +- * has been seeky for long enough or has already proved to be +- * constantly seeky. ++ * asymmetric, grant only minimum idle time if the queue ++ * is seeky. A long idling is preserved for a weight-raised ++ * queue, or, more in general, in an asymemtric scenario, ++ * because a long idling is needed for guaranteeing to a queue ++ * its reserved share of the throughput (in particular, it is ++ * needed if the queue has a higher weight than some other ++ * queue). + */ +- if (bfq_sample_valid(bfqq->seek_samples) && +- ((BFQQ_SEEKY(bfqq) && bfqq->entity.service > +- bfq_max_budget(bfqq->bfqd) / 8) || +- bfq_bfqq_constantly_seeky(bfqq)) && bfqq->wr_coeff == 1 && ++ if (BFQQ_SEEKY(bfqq) && bfqq->wr_coeff == 1 && + bfq_symmetric_scenario(bfqd)) +- sl = min(sl, msecs_to_jiffies(BFQ_MIN_TT)); +- else if (bfqq->wr_coeff > 1) +- sl = sl * 3; ++ sl = min_t(u32, sl, BFQ_MIN_TT); ++ + bfqd->last_idling_start = ktime_get(); +- mod_timer(&bfqd->idle_slice_timer, jiffies + sl); +-#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ hrtimer_start(&bfqd->idle_slice_timer, ns_to_ktime(sl), ++ HRTIMER_MODE_REL); + bfqg_stats_set_start_idle_time(bfqq_group(bfqq)); +-#endif +- bfq_log(bfqd, "arm idle: %u/%u ms", +- jiffies_to_msecs(sl), jiffies_to_msecs(bfqd->bfq_slice_idle)); ++ bfq_log(bfqd, "arm idle: %ld/%ld ms", ++ sl / NSEC_PER_MSEC, bfqd->bfq_slice_idle / NSEC_PER_MSEC); + } + + /* +- * Set the maximum time for the in-service queue to consume its +- * budget. This prevents seeky processes from lowering the disk +- * throughput (always guaranteed with a time slice scheme as in CFQ). ++ * In autotuning mode, max_budget is dynamically recomputed as the ++ * amount of sectors transferred in timeout at the estimated peak ++ * rate. This enables BFQ to utilize a full timeslice with a full ++ * budget, even if the in-service queue is served at peak rate. And ++ * this maximises throughput with sequential workloads. + */ +-static void bfq_set_budget_timeout(struct bfq_data *bfqd) ++static unsigned long bfq_calc_max_budget(struct bfq_data *bfqd) + { +- struct bfq_queue *bfqq = bfqd->in_service_queue; +- unsigned int timeout_coeff; ++ return (u64)bfqd->peak_rate * USEC_PER_MSEC * ++ jiffies_to_msecs(bfqd->bfq_timeout)>>BFQ_RATE_SHIFT; ++} + +- if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time) +- timeout_coeff = 1; ++/* ++ * Update parameters related to throughput and responsiveness, as a ++ * function of the estimated peak rate. See comments on ++ * bfq_calc_max_budget(), and on T_slow and T_fast arrays. ++ */ ++void update_thr_responsiveness_params(struct bfq_data *bfqd) ++{ ++ int dev_type = blk_queue_nonrot(bfqd->queue); ++ ++ if (bfqd->bfq_user_max_budget == 0) { ++ bfqd->bfq_max_budget = ++ bfq_calc_max_budget(bfqd); ++ BUG_ON(bfqd->bfq_max_budget < 0); ++ bfq_log(bfqd, "new max_budget = %d", ++ bfqd->bfq_max_budget); ++ } ++ ++ if (bfqd->device_speed == BFQ_BFQD_FAST && ++ bfqd->peak_rate < device_speed_thresh[dev_type]) { ++ bfqd->device_speed = BFQ_BFQD_SLOW; ++ bfqd->RT_prod = R_slow[dev_type] * ++ T_slow[dev_type]; ++ } else if (bfqd->device_speed == BFQ_BFQD_SLOW && ++ bfqd->peak_rate > device_speed_thresh[dev_type]) { ++ bfqd->device_speed = BFQ_BFQD_FAST; ++ bfqd->RT_prod = R_fast[dev_type] * ++ T_fast[dev_type]; ++ } ++ ++ bfq_log(bfqd, ++"dev_type %s dev_speed_class = %s (%llu sects/sec), thresh %llu setcs/sec", ++ dev_type == 0 ? "ROT" : "NONROT", ++ bfqd->device_speed == BFQ_BFQD_FAST ? "FAST" : "SLOW", ++ bfqd->device_speed == BFQ_BFQD_FAST ? ++ (USEC_PER_SEC*(u64)R_fast[dev_type])>>BFQ_RATE_SHIFT : ++ (USEC_PER_SEC*(u64)R_slow[dev_type])>>BFQ_RATE_SHIFT, ++ (USEC_PER_SEC*(u64)device_speed_thresh[dev_type])>> ++ BFQ_RATE_SHIFT); ++} ++ ++void bfq_reset_rate_computation(struct bfq_data *bfqd, struct request *rq) ++{ ++ if (rq != NULL) { /* new rq dispatch now, reset accordingly */ ++ bfqd->last_dispatch = bfqd->first_dispatch = ktime_get_ns() ; ++ bfqd->peak_rate_samples = 1; ++ bfqd->sequential_samples = 0; ++ bfqd->tot_sectors_dispatched = bfqd->last_rq_max_size = ++ blk_rq_sectors(rq); ++ } else /* no new rq dispatched, just reset the number of samples */ ++ bfqd->peak_rate_samples = 0; /* full re-init on next disp. */ ++ ++ bfq_log(bfqd, ++ "reset_rate_computation at end, sample %u/%u tot_sects %llu", ++ bfqd->peak_rate_samples, bfqd->sequential_samples, ++ bfqd->tot_sectors_dispatched); ++} ++ ++void bfq_update_rate_reset(struct bfq_data *bfqd, struct request *rq) ++{ ++ u32 rate, weight, divisor; ++ ++ /* ++ * For the convergence property to hold (see comments on ++ * bfq_update_peak_rate()) and for the assessment to be ++ * reliable, a minimum number of samples must be present, and ++ * a minimum amount of time must have elapsed. If not so, do ++ * not compute new rate. Just reset parameters, to get ready ++ * for a new evaluation attempt. ++ */ ++ if (bfqd->peak_rate_samples < BFQ_RATE_MIN_SAMPLES || ++ bfqd->delta_from_first < BFQ_RATE_MIN_INTERVAL) { ++ bfq_log(bfqd, ++ "update_rate_reset: only resetting, delta_first %lluus samples %d", ++ bfqd->delta_from_first>>10, bfqd->peak_rate_samples); ++ goto reset_computation; ++ } ++ ++ /* ++ * If a new request completion has occurred after last ++ * dispatch, then, to approximate the rate at which requests ++ * have been served by the device, it is more precise to ++ * extend the observation interval to the last completion. ++ */ ++ bfqd->delta_from_first = ++ max_t(u64, bfqd->delta_from_first, ++ bfqd->last_completion - bfqd->first_dispatch); ++ ++ BUG_ON(bfqd->delta_from_first == 0); ++ /* ++ * Rate computed in sects/usec, and not sects/nsec, for ++ * precision issues. ++ */ ++ rate = div64_ul(bfqd->tot_sectors_dispatched<delta_from_first, NSEC_PER_USEC)); ++ ++ bfq_log(bfqd, ++"update_rate_reset: tot_sects %llu delta_first %lluus rate %llu sects/s (%d)", ++ bfqd->tot_sectors_dispatched, bfqd->delta_from_first>>10, ++ ((USEC_PER_SEC*(u64)rate)>>BFQ_RATE_SHIFT), ++ rate > 20< 20M sectors/sec) ++ */ ++ if ((bfqd->peak_rate_samples > (3 * bfqd->sequential_samples)>>2 && ++ rate <= bfqd->peak_rate) || ++ rate > 20<peak_rate_samples, bfqd->sequential_samples, ++ ((USEC_PER_SEC*(u64)rate)>>BFQ_RATE_SHIFT), ++ ((USEC_PER_SEC*(u64)bfqd->peak_rate)>>BFQ_RATE_SHIFT)); ++ goto reset_computation; ++ } else { ++ bfq_log(bfqd, ++ "update_rate_reset: do update, samples %u/%u rate/peak %llu/%llu", ++ bfqd->peak_rate_samples, bfqd->sequential_samples, ++ ((USEC_PER_SEC*(u64)rate)>>BFQ_RATE_SHIFT), ++ ((USEC_PER_SEC*(u64)bfqd->peak_rate)>>BFQ_RATE_SHIFT)); ++ } ++ ++ /* ++ * We have to update the peak rate, at last! To this purpose, ++ * we use a low-pass filter. We compute the smoothing constant ++ * of the filter as a function of the 'weight' of the new ++ * measured rate. ++ * ++ * As can be seen in next formulas, we define this weight as a ++ * quantity proportional to how sequential the workload is, ++ * and to how long the observation time interval is. ++ * ++ * The weight runs from 0 to 8. The maximum value of the ++ * weight, 8, yields the minimum value for the smoothing ++ * constant. At this minimum value for the smoothing constant, ++ * the measured rate contributes for half of the next value of ++ * the estimated peak rate. ++ * ++ * So, the first step is to compute the weight as a function ++ * of how sequential the workload is. Note that the weight ++ * cannot reach 9, because bfqd->sequential_samples cannot ++ * become equal to bfqd->peak_rate_samples, which, in its ++ * turn, holds true because bfqd->sequential_samples is not ++ * incremented for the first sample. ++ */ ++ weight = (9 * bfqd->sequential_samples) / bfqd->peak_rate_samples; ++ ++ /* ++ * Second step: further refine the weight as a function of the ++ * duration of the observation interval. ++ */ ++ weight = min_t(u32, 8, ++ div_u64(weight * bfqd->delta_from_first, ++ BFQ_RATE_REF_INTERVAL)); ++ ++ /* ++ * Divisor ranging from 10, for minimum weight, to 2, for ++ * maximum weight. ++ */ ++ divisor = 10 - weight; ++ BUG_ON(divisor == 0); ++ ++ /* ++ * Finally, update peak rate: ++ * ++ * peak_rate = peak_rate * (divisor-1) / divisor + rate / divisor ++ */ ++ bfqd->peak_rate *= divisor-1; ++ bfqd->peak_rate /= divisor; ++ rate /= divisor; /* smoothing constant alpha = 1/divisor */ ++ ++ bfq_log(bfqd, ++ "update_rate_reset: divisor %d tmp_peak_rate %llu tmp_rate %u", ++ divisor, ++ ((USEC_PER_SEC*(u64)bfqd->peak_rate)>>BFQ_RATE_SHIFT), ++ (u32)((USEC_PER_SEC*(u64)rate)>>BFQ_RATE_SHIFT)); ++ ++ BUG_ON(bfqd->peak_rate == 0); ++ BUG_ON(bfqd->peak_rate > 20<peak_rate += rate; ++ update_thr_responsiveness_params(bfqd); ++ BUG_ON(bfqd->peak_rate > 20<peak_rate_samples == 0) { /* first dispatch */ ++ bfq_log(bfqd, ++ "update_peak_rate: goto reset, samples %d", ++ bfqd->peak_rate_samples) ; ++ bfq_reset_rate_computation(bfqd, rq); ++ goto update_last_values; /* will add one sample */ ++ } ++ ++ /* ++ * Device idle for very long: the observation interval lasting ++ * up to this dispatch cannot be a valid observation interval ++ * for computing a new peak rate (similarly to the late- ++ * completion event in bfq_completed_request()). Go to ++ * update_rate_and_reset to have the following three steps ++ * taken: ++ * - close the observation interval at the last (previous) ++ * request dispatch or completion ++ * - compute rate, if possible, for that observation interval ++ * - start a new observation interval with this dispatch ++ */ ++ if (now_ns - bfqd->last_dispatch > 100*NSEC_PER_MSEC && ++ bfqd->rq_in_driver == 0) { ++ bfq_log(bfqd, ++"update_peak_rate: jumping to updating&resetting delta_last %lluus samples %d", ++ (now_ns - bfqd->last_dispatch)>>10, ++ bfqd->peak_rate_samples) ; ++ goto update_rate_and_reset; ++ } ++ ++ /* Update sampling information */ ++ bfqd->peak_rate_samples++; ++ ++ if ((bfqd->rq_in_driver > 0 || ++ now_ns - bfqd->last_completion < BFQ_MIN_TT) ++ && get_sdist(bfqd->last_position, rq) < BFQQ_SEEK_THR) ++ bfqd->sequential_samples++; ++ ++ bfqd->tot_sectors_dispatched += blk_rq_sectors(rq); ++ ++ /* Reset max observed rq size every 32 dispatches */ ++ if (likely(bfqd->peak_rate_samples % 32)) ++ bfqd->last_rq_max_size = ++ max_t(u32, blk_rq_sectors(rq), bfqd->last_rq_max_size); + else +- timeout_coeff = bfqq->entity.weight / bfqq->entity.orig_weight; ++ bfqd->last_rq_max_size = blk_rq_sectors(rq); + +- bfqd->last_budget_start = ktime_get(); ++ bfqd->delta_from_first = now_ns - bfqd->first_dispatch; + +- bfq_clear_bfqq_budget_new(bfqq); +- bfqq->budget_timeout = jiffies + +- bfqd->bfq_timeout[bfq_bfqq_sync(bfqq)] * timeout_coeff; ++ bfq_log(bfqd, ++ "update_peak_rate: added samples %u/%u tot_sects %llu delta_first %lluus", ++ bfqd->peak_rate_samples, bfqd->sequential_samples, ++ bfqd->tot_sectors_dispatched, ++ bfqd->delta_from_first>>10); + +- bfq_log_bfqq(bfqd, bfqq, "set budget_timeout %u", +- jiffies_to_msecs(bfqd->bfq_timeout[bfq_bfqq_sync(bfqq)] * +- timeout_coeff)); ++ /* Target observation interval not yet reached, go on sampling */ ++ if (bfqd->delta_from_first < BFQ_RATE_REF_INTERVAL) ++ goto update_last_values; ++ ++update_rate_and_reset: ++ bfq_update_rate_reset(bfqd, rq); ++update_last_values: ++ bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq); ++ bfqd->last_dispatch = now_ns; ++ ++ bfq_log(bfqd, ++ "update_peak_rate: delta_first %lluus last_pos %llu peak_rate %llu", ++ (now_ns - bfqd->first_dispatch)>>10, ++ (unsigned long long) bfqd->last_position, ++ ((USEC_PER_SEC*(u64)bfqd->peak_rate)>>BFQ_RATE_SHIFT)); ++ bfq_log(bfqd, ++ "update_peak_rate: samples at end %d", bfqd->peak_rate_samples); + } + + /* +- * Move request from internal lists to the request queue dispatch list. ++ * Move request from internal lists to the dispatch list of the request queue + */ + static void bfq_dispatch_insert(struct request_queue *q, struct request *rq) + { +- struct bfq_data *bfqd = q->elevator->elevator_data; + struct bfq_queue *bfqq = RQ_BFQQ(rq); + + /* +@@ -1794,15 +2610,10 @@ static void bfq_dispatch_insert(struct request_queue *q, struct request *rq) + * incrementing bfqq->dispatched. + */ + bfqq->dispatched++; ++ bfq_update_peak_rate(q->elevator->elevator_data, rq); ++ + bfq_remove_request(rq); + elv_dispatch_sort(q, rq); +- +- if (bfq_bfqq_sync(bfqq)) +- bfqd->sync_flight++; +-#ifdef CONFIG_BFQ_GROUP_IOSCHED +- bfqg_stats_update_dispatch(bfqq_group(bfqq), blk_rq_bytes(rq), +- rq->cmd_flags); +-#endif + } + + /* +@@ -1822,25 +2633,16 @@ static struct request *bfq_check_fifo(struct bfq_queue *bfqq) + + rq = rq_entry_fifo(bfqq->fifo.next); + +- if (time_before(jiffies, rq->fifo_time)) ++ if (ktime_get_ns() < rq->fifo_time) + return NULL; + + return rq; + } + +-static int bfq_bfqq_budget_left(struct bfq_queue *bfqq) +-{ +- struct bfq_entity *entity = &bfqq->entity; +- +- return entity->budget - entity->service; +-} +- + static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq) + { + BUG_ON(bfqq != bfqd->in_service_queue); + +- __bfq_bfqd_reset_in_service(bfqd); +- + /* + * If this bfqq is shared between multiple processes, check + * to make sure that those processes are still issuing I/Os +@@ -1851,20 +2653,30 @@ static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq) + bfq_mark_bfqq_split_coop(bfqq); + + if (RB_EMPTY_ROOT(&bfqq->sort_list)) { +- /* +- * Overloading budget_timeout field to store the time +- * at which the queue remains with no backlog; used by +- * the weight-raising mechanism. +- */ +- bfqq->budget_timeout = jiffies; +- bfq_del_bfqq_busy(bfqd, bfqq, 1); ++ if (bfqq->dispatched == 0) ++ /* ++ * Overloading budget_timeout field to store ++ * the time at which the queue remains with no ++ * backlog and no outstanding request; used by ++ * the weight-raising mechanism. ++ */ ++ bfqq->budget_timeout = jiffies; ++ ++ bfq_del_bfqq_busy(bfqd, bfqq, true); + } else { +- bfq_activate_bfqq(bfqd, bfqq); ++ bfq_requeue_bfqq(bfqd, bfqq); + /* + * Resort priority tree of potential close cooperators. + */ + bfq_pos_tree_add_move(bfqd, bfqq); + } ++ ++ /* ++ * All in-service entities must have been properly deactivated ++ * or requeued before executing the next function, which ++ * resets all in-service entites as no more in service. ++ */ ++ __bfq_bfqd_reset_in_service(bfqd); + } + + /** +@@ -1883,10 +2695,19 @@ static void __bfq_bfqq_recalc_budget(struct bfq_data *bfqd, + struct request *next_rq; + int budget, min_budget; + +- budget = bfqq->max_budget; ++ BUG_ON(bfqq != bfqd->in_service_queue); ++ + min_budget = bfq_min_budget(bfqd); + +- BUG_ON(bfqq != bfqd->in_service_queue); ++ if (bfqq->wr_coeff == 1) ++ budget = bfqq->max_budget; ++ else /* ++ * Use a constant, low budget for weight-raised queues, ++ * to help achieve a low latency. Keep it slightly higher ++ * than the minimum possible budget, to cause a little ++ * bit fewer expirations. ++ */ ++ budget = 2 * min_budget; + + bfq_log_bfqq(bfqd, bfqq, "recalc_budg: last budg %d, budg left %d", + bfqq->entity.budget, bfq_bfqq_budget_left(bfqq)); +@@ -1895,7 +2716,7 @@ static void __bfq_bfqq_recalc_budget(struct bfq_data *bfqd, + bfq_log_bfqq(bfqd, bfqq, "recalc_budg: sync %d, seeky %d", + bfq_bfqq_sync(bfqq), BFQQ_SEEKY(bfqd->in_service_queue)); + +- if (bfq_bfqq_sync(bfqq)) { ++ if (bfq_bfqq_sync(bfqq) && bfqq->wr_coeff == 1) { + switch (reason) { + /* + * Caveat: in all the following cases we trade latency +@@ -1937,14 +2758,10 @@ static void __bfq_bfqq_recalc_budget(struct bfq_data *bfqd, + break; + case BFQ_BFQQ_BUDGET_TIMEOUT: + /* +- * We double the budget here because: 1) it +- * gives the chance to boost the throughput if +- * this is not a seeky process (which may have +- * bumped into this timeout because of, e.g., +- * ZBR), 2) together with charge_full_budget +- * it helps give seeky processes higher +- * timestamps, and hence be served less +- * frequently. ++ * We double the budget here because it gives ++ * the chance to boost the throughput if this ++ * is not a seeky process (and has bumped into ++ * this timeout because of, e.g., ZBR). + */ + budget = min(budget * 2, bfqd->bfq_max_budget); + break; +@@ -1961,17 +2778,49 @@ static void __bfq_bfqq_recalc_budget(struct bfq_data *bfqd, + budget = min(budget * 4, bfqd->bfq_max_budget); + break; + case BFQ_BFQQ_NO_MORE_REQUESTS: +- /* +- * Leave the budget unchanged. +- */ ++ /* ++ * For queues that expire for this reason, it ++ * is particularly important to keep the ++ * budget close to the actual service they ++ * need. Doing so reduces the timestamp ++ * misalignment problem described in the ++ * comments in the body of ++ * __bfq_activate_entity. In fact, suppose ++ * that a queue systematically expires for ++ * BFQ_BFQQ_NO_MORE_REQUESTS and presents a ++ * new request in time to enjoy timestamp ++ * back-shifting. The larger the budget of the ++ * queue is with respect to the service the ++ * queue actually requests in each service ++ * slot, the more times the queue can be ++ * reactivated with the same virtual finish ++ * time. It follows that, even if this finish ++ * time is pushed to the system virtual time ++ * to reduce the consequent timestamp ++ * misalignment, the queue unjustly enjoys for ++ * many re-activations a lower finish time ++ * than all newly activated queues. ++ * ++ * The service needed by bfqq is measured ++ * quite precisely by bfqq->entity.service. ++ * Since bfqq does not enjoy device idling, ++ * bfqq->entity.service is equal to the number ++ * of sectors that the process associated with ++ * bfqq requested to read/write before waiting ++ * for request completions, or blocking for ++ * other reasons. ++ */ ++ budget = max_t(int, bfqq->entity.service, min_budget); ++ break; + default: + return; + } +- } else ++ } else if (!bfq_bfqq_sync(bfqq)) + /* +- * Async queues get always the maximum possible budget +- * (their ability to dispatch is limited by +- * @bfqd->bfq_max_budget_async_rq). ++ * Async queues get always the maximum possible ++ * budget, as for them we do not care about latency ++ * (in addition, their ability to dispatch is limited ++ * by the charging factor). + */ + budget = bfqd->bfq_max_budget; + +@@ -1982,160 +2831,120 @@ static void __bfq_bfqq_recalc_budget(struct bfq_data *bfqd, + bfqq->max_budget = min(bfqq->max_budget, bfqd->bfq_max_budget); + + /* +- * Make sure that we have enough budget for the next request. +- * Since the finish time of the bfqq must be kept in sync with +- * the budget, be sure to call __bfq_bfqq_expire() after the ++ * If there is still backlog, then assign a new budget, making ++ * sure that it is large enough for the next request. Since ++ * the finish time of bfqq must be kept in sync with the ++ * budget, be sure to call __bfq_bfqq_expire() *after* this + * update. ++ * ++ * If there is no backlog, then no need to update the budget; ++ * it will be updated on the arrival of a new request. + */ + next_rq = bfqq->next_rq; +- if (next_rq) ++ if (next_rq) { ++ BUG_ON(reason == BFQ_BFQQ_TOO_IDLE || ++ reason == BFQ_BFQQ_NO_MORE_REQUESTS); + bfqq->entity.budget = max_t(unsigned long, bfqq->max_budget, + bfq_serv_to_charge(next_rq, bfqq)); +- else +- bfqq->entity.budget = bfqq->max_budget; ++ BUG_ON(!bfq_bfqq_busy(bfqq)); ++ BUG_ON(RB_EMPTY_ROOT(&bfqq->sort_list)); ++ } + + bfq_log_bfqq(bfqd, bfqq, "head sect: %u, new budget %d", + next_rq ? blk_rq_sectors(next_rq) : 0, + bfqq->entity.budget); + } + +-static unsigned long bfq_calc_max_budget(u64 peak_rate, u64 timeout) +-{ +- unsigned long max_budget; +- +- /* +- * The max_budget calculated when autotuning is equal to the +- * amount of sectors transfered in timeout_sync at the +- * estimated peak rate. +- */ +- max_budget = (unsigned long)(peak_rate * 1000 * +- timeout >> BFQ_RATE_SHIFT); +- +- return max_budget; +-} +- + /* +- * In addition to updating the peak rate, checks whether the process +- * is "slow", and returns 1 if so. This slow flag is used, in addition +- * to the budget timeout, to reduce the amount of service provided to +- * seeky processes, and hence reduce their chances to lower the +- * throughput. See the code for more details. ++ * Return true if the process associated with bfqq is "slow". The slow ++ * flag is used, in addition to the budget timeout, to reduce the ++ * amount of service provided to seeky processes, and thus reduce ++ * their chances to lower the throughput. More details in the comments ++ * on the function bfq_bfqq_expire(). ++ * ++ * An important observation is in order: as discussed in the comments ++ * on the function bfq_update_peak_rate(), with devices with internal ++ * queues, it is hard if ever possible to know when and for how long ++ * an I/O request is processed by the device (apart from the trivial ++ * I/O pattern where a new request is dispatched only after the ++ * previous one has been completed). This makes it hard to evaluate ++ * the real rate at which the I/O requests of each bfq_queue are ++ * served. In fact, for an I/O scheduler like BFQ, serving a ++ * bfq_queue means just dispatching its requests during its service ++ * slot (i.e., until the budget of the queue is exhausted, or the ++ * queue remains idle, or, finally, a timeout fires). But, during the ++ * service slot of a bfq_queue, around 100 ms at most, the device may ++ * be even still processing requests of bfq_queues served in previous ++ * service slots. On the opposite end, the requests of the in-service ++ * bfq_queue may be completed after the service slot of the queue ++ * finishes. ++ * ++ * Anyway, unless more sophisticated solutions are used ++ * (where possible), the sum of the sizes of the requests dispatched ++ * during the service slot of a bfq_queue is probably the only ++ * approximation available for the service received by the bfq_queue ++ * during its service slot. And this sum is the quantity used in this ++ * function to evaluate the I/O speed of a process. + */ +-static bool bfq_update_peak_rate(struct bfq_data *bfqd, struct bfq_queue *bfqq, +- bool compensate, enum bfqq_expiration reason) ++static bool bfq_bfqq_is_slow(struct bfq_data *bfqd, struct bfq_queue *bfqq, ++ bool compensate, enum bfqq_expiration reason, ++ unsigned long *delta_ms) + { +- u64 bw, usecs, expected, timeout; +- ktime_t delta; +- int update = 0; ++ ktime_t delta_ktime; ++ u32 delta_usecs; ++ bool slow = BFQQ_SEEKY(bfqq); /* if delta too short, use seekyness */ + +- if (!bfq_bfqq_sync(bfqq) || bfq_bfqq_budget_new(bfqq)) ++ if (!bfq_bfqq_sync(bfqq)) + return false; + + if (compensate) +- delta = bfqd->last_idling_start; ++ delta_ktime = bfqd->last_idling_start; + else +- delta = ktime_get(); +- delta = ktime_sub(delta, bfqd->last_budget_start); +- usecs = ktime_to_us(delta); +- +- /* Don't trust short/unrealistic values. */ +- if (usecs < 100 || usecs >= LONG_MAX) +- return false; +- +- /* +- * Calculate the bandwidth for the last slice. We use a 64 bit +- * value to store the peak rate, in sectors per usec in fixed +- * point math. We do so to have enough precision in the estimate +- * and to avoid overflows. +- */ +- bw = (u64)bfqq->entity.service << BFQ_RATE_SHIFT; +- do_div(bw, (unsigned long)usecs); +- +- timeout = jiffies_to_msecs(bfqd->bfq_timeout[BLK_RW_SYNC]); +- +- /* +- * Use only long (> 20ms) intervals to filter out spikes for +- * the peak rate estimation. +- */ +- if (usecs > 20000) { +- if (bw > bfqd->peak_rate || +- (!BFQQ_SEEKY(bfqq) && +- reason == BFQ_BFQQ_BUDGET_TIMEOUT)) { +- bfq_log(bfqd, "measured bw =%llu", bw); +- /* +- * To smooth oscillations use a low-pass filter with +- * alpha=7/8, i.e., +- * new_rate = (7/8) * old_rate + (1/8) * bw +- */ +- do_div(bw, 8); +- if (bw == 0) +- return 0; +- bfqd->peak_rate *= 7; +- do_div(bfqd->peak_rate, 8); +- bfqd->peak_rate += bw; +- update = 1; +- bfq_log(bfqd, "new peak_rate=%llu", bfqd->peak_rate); +- } +- +- update |= bfqd->peak_rate_samples == BFQ_PEAK_RATE_SAMPLES - 1; +- +- if (bfqd->peak_rate_samples < BFQ_PEAK_RATE_SAMPLES) +- bfqd->peak_rate_samples++; +- +- if (bfqd->peak_rate_samples == BFQ_PEAK_RATE_SAMPLES && +- update) { +- int dev_type = blk_queue_nonrot(bfqd->queue); +- +- if (bfqd->bfq_user_max_budget == 0) { +- bfqd->bfq_max_budget = +- bfq_calc_max_budget(bfqd->peak_rate, +- timeout); +- bfq_log(bfqd, "new max_budget=%d", +- bfqd->bfq_max_budget); +- } +- if (bfqd->device_speed == BFQ_BFQD_FAST && +- bfqd->peak_rate < device_speed_thresh[dev_type]) { +- bfqd->device_speed = BFQ_BFQD_SLOW; +- bfqd->RT_prod = R_slow[dev_type] * +- T_slow[dev_type]; +- } else if (bfqd->device_speed == BFQ_BFQD_SLOW && +- bfqd->peak_rate > device_speed_thresh[dev_type]) { +- bfqd->device_speed = BFQ_BFQD_FAST; +- bfqd->RT_prod = R_fast[dev_type] * +- T_fast[dev_type]; +- } +- } ++ delta_ktime = ktime_get(); ++ delta_ktime = ktime_sub(delta_ktime, bfqd->last_budget_start); ++ delta_usecs = ktime_to_us(delta_ktime); ++ ++ /* don't trust short/unrealistic values. */ ++ if (delta_usecs < 1000 || delta_usecs >= LONG_MAX) { ++ if (blk_queue_nonrot(bfqd->queue)) ++ /* ++ * give same worst-case guarantees as idling ++ * for seeky ++ */ ++ *delta_ms = BFQ_MIN_TT / NSEC_PER_MSEC; ++ else /* charge at least one seek */ ++ *delta_ms = bfq_slice_idle / NSEC_PER_MSEC; ++ ++ bfq_log(bfqd, "bfq_bfqq_is_slow: unrealistic %u", delta_usecs); ++ ++ return slow; + } + +- /* +- * If the process has been served for a too short time +- * interval to let its possible sequential accesses prevail on +- * the initial seek time needed to move the disk head on the +- * first sector it requested, then give the process a chance +- * and for the moment return false. +- */ +- if (bfqq->entity.budget <= bfq_max_budget(bfqd) / 8) +- return false; ++ *delta_ms = delta_usecs / USEC_PER_MSEC; + + /* +- * A process is considered ``slow'' (i.e., seeky, so that we +- * cannot treat it fairly in the service domain, as it would +- * slow down too much the other processes) if, when a slice +- * ends for whatever reason, it has received service at a +- * rate that would not be high enough to complete the budget +- * before the budget timeout expiration. ++ * Use only long (> 20ms) intervals to filter out excessive ++ * spikes in service rate estimation. + */ +- expected = bw * 1000 * timeout >> BFQ_RATE_SHIFT; ++ if (delta_usecs > 20000) { ++ /* ++ * Caveat for rotational devices: processes doing I/O ++ * in the slower disk zones tend to be slow(er) even ++ * if not seeky. In this respect, the estimated peak ++ * rate is likely to be an average over the disk ++ * surface. Accordingly, to not be too harsh with ++ * unlucky processes, a process is deemed slow only if ++ * its rate has been lower than half of the estimated ++ * peak rate. ++ */ ++ slow = bfqq->entity.service < bfqd->bfq_max_budget / 2; ++ bfq_log(bfqd, "bfq_bfqq_is_slow: relative rate %d/%d", ++ bfqq->entity.service, bfqd->bfq_max_budget); ++ } + +- /* +- * Caveat: processes doing IO in the slower disk zones will +- * tend to be slow(er) even if not seeky. And the estimated +- * peak rate will actually be an average over the disk +- * surface. Hence, to not be too harsh with unlucky processes, +- * we keep a budget/3 margin of safety before declaring a +- * process slow. +- */ +- return expected > (4 * bfqq->entity.budget) / 3; ++ bfq_log_bfqq(bfqd, bfqq, "bfq_bfqq_is_slow: slow %d", slow); ++ ++ return slow; + } + + /* +@@ -2193,20 +3002,35 @@ static bool bfq_update_peak_rate(struct bfq_data *bfqd, struct bfq_queue *bfqq, + static unsigned long bfq_bfqq_softrt_next_start(struct bfq_data *bfqd, + struct bfq_queue *bfqq) + { ++ bfq_log_bfqq(bfqd, bfqq, ++"softrt_next_start: service_blkg %lu soft_rate %u sects/sec interval %u", ++ bfqq->service_from_backlogged, ++ bfqd->bfq_wr_max_softrt_rate, ++ jiffies_to_msecs(HZ * bfqq->service_from_backlogged / ++ bfqd->bfq_wr_max_softrt_rate)); ++ + return max(bfqq->last_idle_bklogged + + HZ * bfqq->service_from_backlogged / + bfqd->bfq_wr_max_softrt_rate, +- jiffies + bfqq->bfqd->bfq_slice_idle + 4); ++ jiffies + nsecs_to_jiffies(bfqq->bfqd->bfq_slice_idle) + 4); ++} ++ ++/* ++ * Return the farthest future time instant according to jiffies ++ * macros. ++ */ ++static unsigned long bfq_greatest_from_now(void) ++{ ++ return jiffies + MAX_JIFFY_OFFSET; + } + + /* +- * Return the largest-possible time instant such that, for as long as possible, +- * the current time will be lower than this time instant according to the macro +- * time_is_before_jiffies(). ++ * Return the farthest past time instant according to jiffies ++ * macros. + */ +-static unsigned long bfq_infinity_from_now(unsigned long now) ++static unsigned long bfq_smallest_from_now(void) + { +- return now + ULONG_MAX / 2; ++ return jiffies - MAX_JIFFY_OFFSET; + } + + /** +@@ -2216,28 +3040,24 @@ static unsigned long bfq_infinity_from_now(unsigned long now) + * @compensate: if true, compensate for the time spent idling. + * @reason: the reason causing the expiration. + * ++ * If the process associated with bfqq does slow I/O (e.g., because it ++ * issues random requests), we charge bfqq with the time it has been ++ * in service instead of the service it has received (see ++ * bfq_bfqq_charge_time for details on how this goal is achieved). As ++ * a consequence, bfqq will typically get higher timestamps upon ++ * reactivation, and hence it will be rescheduled as if it had ++ * received more service than what it has actually received. In the ++ * end, bfqq receives less service in proportion to how slowly its ++ * associated process consumes its budgets (and hence how seriously it ++ * tends to lower the throughput). In addition, this time-charging ++ * strategy guarantees time fairness among slow processes. In ++ * contrast, if the process associated with bfqq is not slow, we ++ * charge bfqq exactly with the service it has received. + * +- * If the process associated to the queue is slow (i.e., seeky), or in +- * case of budget timeout, or, finally, if it is async, we +- * artificially charge it an entire budget (independently of the +- * actual service it received). As a consequence, the queue will get +- * higher timestamps than the correct ones upon reactivation, and +- * hence it will be rescheduled as if it had received more service +- * than what it actually received. In the end, this class of processes +- * will receive less service in proportion to how slowly they consume +- * their budgets (and hence how seriously they tend to lower the +- * throughput). +- * +- * In contrast, when a queue expires because it has been idling for +- * too much or because it exhausted its budget, we do not touch the +- * amount of service it has received. Hence when the queue will be +- * reactivated and its timestamps updated, the latter will be in sync +- * with the actual service received by the queue until expiration. +- * +- * Charging a full budget to the first type of queues and the exact +- * service to the others has the effect of using the WF2Q+ policy to +- * schedule the former on a timeslice basis, without violating the +- * service domain guarantees of the latter. ++ * Charging time to the first type of queues and the exact service to ++ * the other has the effect of using the WF2Q+ policy to schedule the ++ * former on a timeslice basis, without violating service domain ++ * guarantees among the latter. + */ + static void bfq_bfqq_expire(struct bfq_data *bfqd, + struct bfq_queue *bfqq, +@@ -2245,41 +3065,52 @@ static void bfq_bfqq_expire(struct bfq_data *bfqd, + enum bfqq_expiration reason) + { + bool slow; ++ unsigned long delta = 0; ++ struct bfq_entity *entity = &bfqq->entity; + + BUG_ON(bfqq != bfqd->in_service_queue); + + /* +- * Update disk peak rate for autotuning and check whether the +- * process is slow (see bfq_update_peak_rate). ++ * Check whether the process is slow (see bfq_bfqq_is_slow). + */ +- slow = bfq_update_peak_rate(bfqd, bfqq, compensate, reason); ++ slow = bfq_bfqq_is_slow(bfqd, bfqq, compensate, reason, &delta); + + /* +- * As above explained, 'punish' slow (i.e., seeky), timed-out +- * and async queues, to favor sequential sync workloads. +- * +- * Processes doing I/O in the slower disk zones will tend to be +- * slow(er) even if not seeky. Hence, since the estimated peak +- * rate is actually an average over the disk surface, these +- * processes may timeout just for bad luck. To avoid punishing +- * them we do not charge a full budget to a process that +- * succeeded in consuming at least 2/3 of its budget. ++ * Increase service_from_backlogged before next statement, ++ * because the possible next invocation of ++ * bfq_bfqq_charge_time would likely inflate ++ * entity->service. In contrast, service_from_backlogged must ++ * contain real service, to enable the soft real-time ++ * heuristic to correctly compute the bandwidth consumed by ++ * bfqq. + */ +- if (slow || (reason == BFQ_BFQQ_BUDGET_TIMEOUT && +- bfq_bfqq_budget_left(bfqq) >= bfqq->entity.budget / 3)) +- bfq_bfqq_charge_full_budget(bfqq); ++ bfqq->service_from_backlogged += entity->service; + +- bfqq->service_from_backlogged += bfqq->entity.service; ++ /* ++ * As above explained, charge slow (typically seeky) and ++ * timed-out queues with the time and not the service ++ * received, to favor sequential workloads. ++ * ++ * Processes doing I/O in the slower disk zones will tend to ++ * be slow(er) even if not seeky. Therefore, since the ++ * estimated peak rate is actually an average over the disk ++ * surface, these processes may timeout just for bad luck. To ++ * avoid punishing them, do not charge time to processes that ++ * succeeded in consuming at least 2/3 of their budget. This ++ * allows BFQ to preserve enough elasticity to still perform ++ * bandwidth, and not time, distribution with little unlucky ++ * or quasi-sequential processes. ++ */ ++ if (bfqq->wr_coeff == 1 && ++ (slow || ++ (reason == BFQ_BFQQ_BUDGET_TIMEOUT && ++ bfq_bfqq_budget_left(bfqq) >= entity->budget / 3))) ++ bfq_bfqq_charge_time(bfqd, bfqq, delta); + +- if (BFQQ_SEEKY(bfqq) && reason == BFQ_BFQQ_BUDGET_TIMEOUT && +- !bfq_bfqq_constantly_seeky(bfqq)) { +- bfq_mark_bfqq_constantly_seeky(bfqq); +- if (!blk_queue_nonrot(bfqd->queue)) +- bfqd->const_seeky_busy_in_flight_queues++; +- } ++ BUG_ON(bfqq->entity.budget < bfqq->entity.service); + + if (reason == BFQ_BFQQ_TOO_IDLE && +- bfqq->entity.service <= 2 * bfqq->entity.budget / 10) ++ entity->service <= 2 * entity->budget / 10) + bfq_clear_bfqq_IO_bound(bfqq); + + if (bfqd->low_latency && bfqq->wr_coeff == 1) +@@ -2288,19 +3119,23 @@ static void bfq_bfqq_expire(struct bfq_data *bfqd, + if (bfqd->low_latency && bfqd->bfq_wr_max_softrt_rate > 0 && + RB_EMPTY_ROOT(&bfqq->sort_list)) { + /* +- * If we get here, and there are no outstanding requests, +- * then the request pattern is isochronous (see the comments +- * to the function bfq_bfqq_softrt_next_start()). Hence we +- * can compute soft_rt_next_start. If, instead, the queue +- * still has outstanding requests, then we have to wait +- * for the completion of all the outstanding requests to ++ * If we get here, and there are no outstanding ++ * requests, then the request pattern is isochronous ++ * (see the comments on the function ++ * bfq_bfqq_softrt_next_start()). Thus we can compute ++ * soft_rt_next_start. If, instead, the queue still ++ * has outstanding requests, then we have to wait for ++ * the completion of all the outstanding requests to + * discover whether the request pattern is actually + * isochronous. + */ +- if (bfqq->dispatched == 0) ++ BUG_ON(bfqd->busy_queues < 1); ++ if (bfqq->dispatched == 0) { + bfqq->soft_rt_next_start = + bfq_bfqq_softrt_next_start(bfqd, bfqq); +- else { ++ bfq_log_bfqq(bfqd, bfqq, "new soft_rt_next %lu", ++ bfqq->soft_rt_next_start); ++ } else { + /* + * The application is still waiting for the + * completion of one or more requests: +@@ -2317,7 +3152,7 @@ static void bfq_bfqq_expire(struct bfq_data *bfqd, + * happened to be in the past. + */ + bfqq->soft_rt_next_start = +- bfq_infinity_from_now(jiffies); ++ bfq_greatest_from_now(); + /* + * Schedule an update of soft_rt_next_start to when + * the task may be discovered to be isochronous. +@@ -2327,15 +3162,27 @@ static void bfq_bfqq_expire(struct bfq_data *bfqd, + } + + bfq_log_bfqq(bfqd, bfqq, +- "expire (%d, slow %d, num_disp %d, idle_win %d)", reason, +- slow, bfqq->dispatched, bfq_bfqq_idle_window(bfqq)); ++ "expire (%d, slow %d, num_disp %d, idle_win %d, weight %d)", ++ reason, slow, bfqq->dispatched, ++ bfq_bfqq_idle_window(bfqq), entity->weight); + + /* + * Increase, decrease or leave budget unchanged according to + * reason. + */ ++ BUG_ON(bfqq->entity.budget < bfqq->entity.service); + __bfq_bfqq_recalc_budget(bfqd, bfqq, reason); ++ BUG_ON(bfqq->next_rq == NULL && ++ bfqq->entity.budget < bfqq->entity.service); + __bfq_bfqq_expire(bfqd, bfqq); ++ ++ BUG_ON(!bfq_bfqq_busy(bfqq) && reason == BFQ_BFQQ_BUDGET_EXHAUSTED && ++ !bfq_class_idle(bfqq)); ++ ++ if (!bfq_bfqq_busy(bfqq) && ++ reason != BFQ_BFQQ_BUDGET_TIMEOUT && ++ reason != BFQ_BFQQ_BUDGET_EXHAUSTED) ++ bfq_mark_bfqq_non_blocking_wait_rq(bfqq); + } + + /* +@@ -2345,20 +3192,17 @@ static void bfq_bfqq_expire(struct bfq_data *bfqd, + */ + static bool bfq_bfqq_budget_timeout(struct bfq_queue *bfqq) + { +- if (bfq_bfqq_budget_new(bfqq) || +- time_before(jiffies, bfqq->budget_timeout)) +- return false; +- return true; ++ return time_is_before_eq_jiffies(bfqq->budget_timeout); + } + + /* +- * If we expire a queue that is waiting for the arrival of a new +- * request, we may prevent the fictitious timestamp back-shifting that +- * allows the guarantees of the queue to be preserved (see [1] for +- * this tricky aspect). Hence we return true only if this condition +- * does not hold, or if the queue is slow enough to deserve only to be +- * kicked off for preserving a high throughput. +-*/ ++ * If we expire a queue that is actively waiting (i.e., with the ++ * device idled) for the arrival of a new request, then we may incur ++ * the timestamp misalignment problem described in the body of the ++ * function __bfq_activate_entity. Hence we return true only if this ++ * condition does not hold, or if the queue is slow enough to deserve ++ * only to be kicked off for preserving a high throughput. ++ */ + static bool bfq_may_expire_for_budg_timeout(struct bfq_queue *bfqq) + { + bfq_log_bfqq(bfqq->bfqd, bfqq, +@@ -2400,10 +3244,12 @@ static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) + { + struct bfq_data *bfqd = bfqq->bfqd; + bool idling_boosts_thr, idling_boosts_thr_without_issues, +- all_queues_seeky, on_hdd_and_not_all_queues_seeky, + idling_needed_for_service_guarantees, + asymmetric_scenario; + ++ if (bfqd->strict_guarantees) ++ return true; ++ + /* + * The next variable takes into account the cases where idling + * boosts the throughput. +@@ -2466,74 +3312,27 @@ static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) + bfqd->wr_busy_queues == 0; + + /* +- * There are then two cases where idling must be performed not ++ * There is then a case where idling must be performed not + * for throughput concerns, but to preserve service +- * guarantees. In the description of these cases, we say, for +- * short, that a queue is sequential/random if the process +- * associated to the queue issues sequential/random requests +- * (in the second case the queue may be tagged as seeky or +- * even constantly_seeky). ++ * guarantees. + * +- * To introduce the first case, we note that, since +- * bfq_bfqq_idle_window(bfqq) is false if the device is +- * NCQ-capable and bfqq is random (see +- * bfq_update_idle_window()), then, from the above two +- * assignments it follows that +- * idling_boosts_thr_without_issues is false if the device is +- * NCQ-capable and bfqq is random. Therefore, for this case, +- * device idling would never be allowed if we used just +- * idling_boosts_thr_without_issues to decide whether to allow +- * it. And, beneficially, this would imply that throughput +- * would always be boosted also with random I/O on NCQ-capable +- * HDDs. +- * +- * But we must be careful on this point, to avoid an unfair +- * treatment for bfqq. In fact, because of the same above +- * assignments, idling_boosts_thr_without_issues is, on the +- * other hand, true if 1) the device is an HDD and bfqq is +- * sequential, and 2) there are no busy weight-raised +- * queues. As a consequence, if we used just +- * idling_boosts_thr_without_issues to decide whether to idle +- * the device, then with an HDD we might easily bump into a +- * scenario where queues that are sequential and I/O-bound +- * would enjoy idling, whereas random queues would not. The +- * latter might then get a low share of the device throughput, +- * simply because the former would get many requests served +- * after being set as in service, while the latter would not. +- * +- * To address this issue, we start by setting to true a +- * sentinel variable, on_hdd_and_not_all_queues_seeky, if the +- * device is rotational and not all queues with pending or +- * in-flight requests are constantly seeky (i.e., there are +- * active sequential queues, and bfqq might then be mistreated +- * if it does not enjoy idling because it is random). +- */ +- all_queues_seeky = bfq_bfqq_constantly_seeky(bfqq) && +- bfqd->busy_in_flight_queues == +- bfqd->const_seeky_busy_in_flight_queues; +- +- on_hdd_and_not_all_queues_seeky = +- !blk_queue_nonrot(bfqd->queue) && !all_queues_seeky; +- +- /* +- * To introduce the second case where idling needs to be +- * performed to preserve service guarantees, we can note that +- * allowing the drive to enqueue more than one request at a +- * time, and hence delegating de facto final scheduling +- * decisions to the drive's internal scheduler, causes loss of +- * control on the actual request service order. In particular, +- * the critical situation is when requests from different +- * processes happens to be present, at the same time, in the +- * internal queue(s) of the drive. In such a situation, the +- * drive, by deciding the service order of the +- * internally-queued requests, does determine also the actual +- * throughput distribution among these processes. But the +- * drive typically has no notion or concern about per-process +- * throughput distribution, and makes its decisions only on a +- * per-request basis. Therefore, the service distribution +- * enforced by the drive's internal scheduler is likely to +- * coincide with the desired device-throughput distribution +- * only in a completely symmetric scenario where: ++ * To introduce this case, we can note that allowing the drive ++ * to enqueue more than one request at a time, and hence ++ * delegating de facto final scheduling decisions to the ++ * drive's internal scheduler, entails loss of control on the ++ * actual request service order. In particular, the critical ++ * situation is when requests from different processes happen ++ * to be present, at the same time, in the internal queue(s) ++ * of the drive. In such a situation, the drive, by deciding ++ * the service order of the internally-queued requests, does ++ * determine also the actual throughput distribution among ++ * these processes. But the drive typically has no notion or ++ * concern about per-process throughput distribution, and ++ * makes its decisions only on a per-request basis. Therefore, ++ * the service distribution enforced by the drive's internal ++ * scheduler is likely to coincide with the desired ++ * device-throughput distribution only in a completely ++ * symmetric scenario where: + * (i) each of these processes must get the same throughput as + * the others; + * (ii) all these processes have the same I/O pattern +@@ -2555,26 +3354,53 @@ static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) + * words, only if sub-condition (i) holds, then idling is + * allowed, and the device tends to be prevented from queueing + * many requests, possibly of several processes. The reason +- * for not controlling also sub-condition (ii) is that, first, +- * in the case of an HDD, the asymmetry in terms of types of +- * I/O patterns is already taken in to account in the above +- * sentinel variable +- * on_hdd_and_not_all_queues_seeky. Secondly, in the case of a +- * flash-based device, we prefer however to privilege +- * throughput (and idling lowers throughput for this type of +- * devices), for the following reasons: +- * 1) differently from HDDs, the service time of random +- * requests is not orders of magnitudes lower than the service +- * time of sequential requests; thus, even if processes doing +- * sequential I/O get a preferential treatment with respect to +- * others doing random I/O, the consequences are not as +- * dramatic as with HDDs; +- * 2) if a process doing random I/O does need strong +- * throughput guarantees, it is hopefully already being +- * weight-raised, or the user is likely to have assigned it a +- * higher weight than the other processes (and thus +- * sub-condition (i) is likely to be false, which triggers +- * idling). ++ * for not controlling also sub-condition (ii) is that we ++ * exploit preemption to preserve guarantees in case of ++ * symmetric scenarios, even if (ii) does not hold, as ++ * explained in the next two paragraphs. ++ * ++ * Even if a queue, say Q, is expired when it remains idle, Q ++ * can still preempt the new in-service queue if the next ++ * request of Q arrives soon (see the comments on ++ * bfq_bfqq_update_budg_for_activation). If all queues and ++ * groups have the same weight, this form of preemption, ++ * combined with the hole-recovery heuristic described in the ++ * comments on function bfq_bfqq_update_budg_for_activation, ++ * are enough to preserve a correct bandwidth distribution in ++ * the mid term, even without idling. In fact, even if not ++ * idling allows the internal queues of the device to contain ++ * many requests, and thus to reorder requests, we can rather ++ * safely assume that the internal scheduler still preserves a ++ * minimum of mid-term fairness. The motivation for using ++ * preemption instead of idling is that, by not idling, ++ * service guarantees are preserved without minimally ++ * sacrificing throughput. In other words, both a high ++ * throughput and its desired distribution are obtained. ++ * ++ * More precisely, this preemption-based, idleless approach ++ * provides fairness in terms of IOPS, and not sectors per ++ * second. This can be seen with a simple example. Suppose ++ * that there are two queues with the same weight, but that ++ * the first queue receives requests of 8 sectors, while the ++ * second queue receives requests of 1024 sectors. In ++ * addition, suppose that each of the two queues contains at ++ * most one request at a time, which implies that each queue ++ * always remains idle after it is served. Finally, after ++ * remaining idle, each queue receives very quickly a new ++ * request. It follows that the two queues are served ++ * alternatively, preempting each other if needed. This ++ * implies that, although both queues have the same weight, ++ * the queue with large requests receives a service that is ++ * 1024/8 times as high as the service received by the other ++ * queue. ++ * ++ * On the other hand, device idling is performed, and thus ++ * pure sector-domain guarantees are provided, for the ++ * following queues, which are likely to need stronger ++ * throughput guarantees: weight-raised queues, and queues ++ * with a higher weight than other queues. When such queues ++ * are active, sub-condition (i) is false, which triggers ++ * device idling. + * + * According to the above considerations, the next variable is + * true (only) if sub-condition (i) holds. To compute the +@@ -2582,7 +3408,7 @@ static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) + * the function bfq_symmetric_scenario(), but also check + * whether bfqq is being weight-raised, because + * bfq_symmetric_scenario() does not take into account also +- * weight-raised queues (see comments to ++ * weight-raised queues (see comments on + * bfq_weights_tree_add()). + * + * As a side note, it is worth considering that the above +@@ -2604,17 +3430,16 @@ static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) + * bfqq. Such a case is when bfqq became active in a burst of + * queue activations. Queues that became active during a large + * burst benefit only from throughput, as discussed in the +- * comments to bfq_handle_burst. Thus, if bfqq became active ++ * comments on bfq_handle_burst. Thus, if bfqq became active + * in a burst and not idling the device maximizes throughput, + * then the device must no be idled, because not idling the + * device provides bfqq and all other queues in the burst with +- * maximum benefit. Combining this and the two cases above, we +- * can now establish when idling is actually needed to +- * preserve service guarantees. ++ * maximum benefit. Combining this and the above case, we can ++ * now establish when idling is actually needed to preserve ++ * service guarantees. + */ + idling_needed_for_service_guarantees = +- (on_hdd_and_not_all_queues_seeky || asymmetric_scenario) && +- !bfq_bfqq_in_large_burst(bfqq); ++ asymmetric_scenario && !bfq_bfqq_in_large_burst(bfqq); + + /* + * We have now all the components we need to compute the return +@@ -2624,6 +3449,16 @@ static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) + * 2) idling either boosts the throughput (without issues), or + * is necessary to preserve service guarantees. + */ ++ bfq_log_bfqq(bfqd, bfqq, "may_idle: sync %d idling_boosts_thr %d", ++ bfq_bfqq_sync(bfqq), idling_boosts_thr); ++ ++ bfq_log_bfqq(bfqd, bfqq, ++ "may_idle: wr_busy %d boosts %d IO-bound %d guar %d", ++ bfqd->wr_busy_queues, ++ idling_boosts_thr_without_issues, ++ bfq_bfqq_IO_bound(bfqq), ++ idling_needed_for_service_guarantees); ++ + return bfq_bfqq_sync(bfqq) && + (idling_boosts_thr_without_issues || + idling_needed_for_service_guarantees); +@@ -2635,7 +3470,7 @@ static bool bfq_bfqq_may_idle(struct bfq_queue *bfqq) + * 1) the queue must remain in service and cannot be expired, and + * 2) the device must be idled to wait for the possible arrival of a new + * request for the queue. +- * See the comments to the function bfq_bfqq_may_idle for the reasons ++ * See the comments on the function bfq_bfqq_may_idle for the reasons + * why performing device idling is the best choice to boost the throughput + * and preserve service guarantees when bfq_bfqq_may_idle itself + * returns true. +@@ -2665,7 +3500,7 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) + bfq_log_bfqq(bfqd, bfqq, "select_queue: already in-service queue"); + + if (bfq_may_expire_for_budg_timeout(bfqq) && +- !timer_pending(&bfqd->idle_slice_timer) && ++ !hrtimer_active(&bfqd->idle_slice_timer) && + !bfq_bfqq_must_idle(bfqq)) + goto expire; + +@@ -2685,7 +3520,8 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) + * not disable disk idling even when a new request + * arrives. + */ +- if (timer_pending(&bfqd->idle_slice_timer)) { ++ if (bfq_bfqq_wait_request(bfqq)) { ++ BUG_ON(!hrtimer_active(&bfqd->idle_slice_timer)); + /* + * If we get here: 1) at least a new request + * has arrived but we have not disabled the +@@ -2700,10 +3536,8 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) + * So we disable idling. + */ + bfq_clear_bfqq_wait_request(bfqq); +- del_timer(&bfqd->idle_slice_timer); +-#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ hrtimer_try_to_cancel(&bfqd->idle_slice_timer); + bfqg_stats_update_idle_time(bfqq_group(bfqq)); +-#endif + } + goto keep_queue; + } +@@ -2714,7 +3548,7 @@ static struct bfq_queue *bfq_select_queue(struct bfq_data *bfqd) + * for a new request, or has requests waiting for a completion and + * may idle after their completion, then keep it anyway. + */ +- if (timer_pending(&bfqd->idle_slice_timer) || ++ if (hrtimer_active(&bfqd->idle_slice_timer) || + (bfqq->dispatched != 0 && bfq_bfqq_may_idle(bfqq))) { + bfqq = NULL; + goto keep_queue; +@@ -2736,6 +3570,9 @@ static void bfq_update_wr_data(struct bfq_data *bfqd, struct bfq_queue *bfqq) + struct bfq_entity *entity = &bfqq->entity; + + if (bfqq->wr_coeff > 1) { /* queue is being weight-raised */ ++ BUG_ON(bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && ++ time_is_after_jiffies(bfqq->last_wr_start_finish)); ++ + bfq_log_bfqq(bfqd, bfqq, + "raising period dur %u/%u msec, old coeff %u, w %d(%d)", + jiffies_to_msecs(jiffies - bfqq->last_wr_start_finish), +@@ -2749,22 +3586,30 @@ static void bfq_update_wr_data(struct bfq_data *bfqd, struct bfq_queue *bfqq) + bfq_log_bfqq(bfqd, bfqq, "WARN: pending prio change"); + + /* +- * If the queue was activated in a burst, or +- * too much time has elapsed from the beginning +- * of this weight-raising period, or the queue has +- * exceeded the acceptable number of cooperations, +- * then end weight raising. ++ * If the queue was activated in a burst, or too much ++ * time has elapsed from the beginning of this ++ * weight-raising period, then end weight raising. + */ +- if (bfq_bfqq_in_large_burst(bfqq) || +- bfq_bfqq_cooperations(bfqq) >= bfqd->bfq_coop_thresh || +- time_is_before_jiffies(bfqq->last_wr_start_finish + +- bfqq->wr_cur_max_time)) { +- bfqq->last_wr_start_finish = jiffies; +- bfq_log_bfqq(bfqd, bfqq, +- "wrais ending at %lu, rais_max_time %u", +- bfqq->last_wr_start_finish, +- jiffies_to_msecs(bfqq->wr_cur_max_time)); ++ if (bfq_bfqq_in_large_burst(bfqq)) + bfq_bfqq_end_wr(bfqq); ++ else if (time_is_before_jiffies(bfqq->last_wr_start_finish + ++ bfqq->wr_cur_max_time)) { ++ if (bfqq->wr_cur_max_time != bfqd->bfq_wr_rt_max_time || ++ time_is_before_jiffies(bfqq->wr_start_at_switch_to_srt + ++ bfq_wr_duration(bfqd))) ++ bfq_bfqq_end_wr(bfqq); ++ else { ++ /* switch back to interactive wr */ ++ bfqq->wr_coeff = bfqd->bfq_wr_coeff; ++ bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); ++ bfqq->last_wr_start_finish = ++ bfqq->wr_start_at_switch_to_srt; ++ BUG_ON(time_is_after_jiffies( ++ bfqq->last_wr_start_finish)); ++ bfqq->entity.prio_changed = 1; ++ bfq_log_bfqq(bfqd, bfqq, ++ "back to interactive wr"); ++ } + } + } + /* Update weight both if it must be raised and if it must be lowered */ +@@ -2815,13 +3660,29 @@ static int bfq_dispatch_request(struct bfq_data *bfqd, + */ + if (!bfqd->rq_in_driver) + bfq_schedule_dispatch(bfqd); ++ BUG_ON(bfqq->entity.budget < bfqq->entity.service); + goto expire; + } + ++ BUG_ON(bfqq->entity.budget < bfqq->entity.service); + /* Finally, insert request into driver dispatch list. */ + bfq_bfqq_served(bfqq, service_to_charge); ++ ++ BUG_ON(bfqq->entity.budget < bfqq->entity.service); ++ + bfq_dispatch_insert(bfqd->queue, rq); + ++ /* ++ * If weight raising has to terminate for bfqq, then next ++ * function causes an immediate update of bfqq's weight, ++ * without waiting for next activation. As a consequence, on ++ * expiration, bfqq will be timestamped as if has never been ++ * weight-raised during this service slot, even if it has ++ * received part or even most of the service as a ++ * weight-raised queue. This inflates bfqq's timestamps, which ++ * is beneficial, as bfqq is then more willing to leave the ++ * device immediately to possible other weight-raised queues. ++ */ + bfq_update_wr_data(bfqd, bfqq); + + bfq_log_bfqq(bfqd, bfqq, +@@ -2837,9 +3698,7 @@ static int bfq_dispatch_request(struct bfq_data *bfqd, + bfqd->in_service_bic = RQ_BIC(rq); + } + +- if (bfqd->busy_queues > 1 && ((!bfq_bfqq_sync(bfqq) && +- dispatched >= bfqd->bfq_max_budget_async_rq) || +- bfq_class_idle(bfqq))) ++ if (bfqd->busy_queues > 1 && bfq_class_idle(bfqq)) + goto expire; + + return dispatched; +@@ -2885,8 +3744,8 @@ static int bfq_forced_dispatch(struct bfq_data *bfqd) + st = bfq_entity_service_tree(&bfqq->entity); + + dispatched += __bfq_forced_dispatch_bfqq(bfqq); +- bfqq->max_budget = bfq_max_budget(bfqd); + ++ bfqq->max_budget = bfq_max_budget(bfqd); + bfq_forget_idle(st); + } + +@@ -2899,37 +3758,37 @@ static int bfq_dispatch_requests(struct request_queue *q, int force) + { + struct bfq_data *bfqd = q->elevator->elevator_data; + struct bfq_queue *bfqq; +- int max_dispatch; + + bfq_log(bfqd, "dispatch requests: %d busy queues", bfqd->busy_queues); ++ + if (bfqd->busy_queues == 0) + return 0; + + if (unlikely(force)) + return bfq_forced_dispatch(bfqd); + ++ /* ++ * Force device to serve one request at a time if ++ * strict_guarantees is true. Forcing this service scheme is ++ * currently the ONLY way to guarantee that the request ++ * service order enforced by the scheduler is respected by a ++ * queueing device. Otherwise the device is free even to make ++ * some unlucky request wait for as long as the device ++ * wishes. ++ * ++ * Of course, serving one request at at time may cause loss of ++ * throughput. ++ */ ++ if (bfqd->strict_guarantees && bfqd->rq_in_driver > 0) ++ return 0; ++ + bfqq = bfq_select_queue(bfqd); + if (!bfqq) + return 0; + +- if (bfq_class_idle(bfqq)) +- max_dispatch = 1; +- +- if (!bfq_bfqq_sync(bfqq)) +- max_dispatch = bfqd->bfq_max_budget_async_rq; +- +- if (!bfq_bfqq_sync(bfqq) && bfqq->dispatched >= max_dispatch) { +- if (bfqd->busy_queues > 1) +- return 0; +- if (bfqq->dispatched >= 4 * max_dispatch) +- return 0; +- } +- +- if (bfqd->sync_flight != 0 && !bfq_bfqq_sync(bfqq)) +- return 0; ++ BUG_ON(bfqq->entity.budget < bfqq->entity.service); + +- bfq_clear_bfqq_wait_request(bfqq); +- BUG_ON(timer_pending(&bfqd->idle_slice_timer)); ++ BUG_ON(bfq_bfqq_wait_request(bfqq)); + + if (!bfq_dispatch_request(bfqd, bfqq)) + return 0; +@@ -2937,6 +3796,8 @@ static int bfq_dispatch_requests(struct request_queue *q, int force) + bfq_log_bfqq(bfqd, bfqq, "dispatched %s request", + bfq_bfqq_sync(bfqq) ? "sync" : "async"); + ++ BUG_ON(bfqq->next_rq == NULL && ++ bfqq->entity.budget < bfqq->entity.service); + return 1; + } + +@@ -2948,23 +3809,21 @@ static int bfq_dispatch_requests(struct request_queue *q, int force) + */ + static void bfq_put_queue(struct bfq_queue *bfqq) + { +- struct bfq_data *bfqd = bfqq->bfqd; + #ifdef CONFIG_BFQ_GROUP_IOSCHED + struct bfq_group *bfqg = bfqq_group(bfqq); + #endif + +- BUG_ON(atomic_read(&bfqq->ref) <= 0); ++ BUG_ON(bfqq->ref <= 0); + +- bfq_log_bfqq(bfqd, bfqq, "put_queue: %p %d", bfqq, +- atomic_read(&bfqq->ref)); +- if (!atomic_dec_and_test(&bfqq->ref)) ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "put_queue: %p %d", bfqq, bfqq->ref); ++ bfqq->ref--; ++ if (bfqq->ref) + return; + + BUG_ON(rb_first(&bfqq->sort_list)); + BUG_ON(bfqq->allocated[READ] + bfqq->allocated[WRITE] != 0); + BUG_ON(bfqq->entity.tree); + BUG_ON(bfq_bfqq_busy(bfqq)); +- BUG_ON(bfqd->in_service_queue == bfqq); + + if (bfq_bfqq_sync(bfqq)) + /* +@@ -2977,7 +3836,7 @@ static void bfq_put_queue(struct bfq_queue *bfqq) + */ + hlist_del_init(&bfqq->burst_list_node); + +- bfq_log_bfqq(bfqd, bfqq, "put_queue: %p freed", bfqq); ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "put_queue: %p freed", bfqq); + + kmem_cache_free(bfq_pool, bfqq); + #ifdef CONFIG_BFQ_GROUP_IOSCHED +@@ -3011,8 +3870,7 @@ static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) + bfq_schedule_dispatch(bfqd); + } + +- bfq_log_bfqq(bfqd, bfqq, "exit_bfqq: %p, %d", bfqq, +- atomic_read(&bfqq->ref)); ++ bfq_log_bfqq(bfqd, bfqq, "exit_bfqq: %p, %d", bfqq, bfqq->ref); + + bfq_put_cooperator(bfqq); + +@@ -3021,28 +3879,7 @@ static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) + + static void bfq_init_icq(struct io_cq *icq) + { +- struct bfq_io_cq *bic = icq_to_bic(icq); +- +- bic->ttime.last_end_request = jiffies; +- /* +- * A newly created bic indicates that the process has just +- * started doing I/O, and is probably mapping into memory its +- * executable and libraries: it definitely needs weight raising. +- * There is however the possibility that the process performs, +- * for a while, I/O close to some other process. EQM intercepts +- * this behavior and may merge the queue corresponding to the +- * process with some other queue, BEFORE the weight of the queue +- * is raised. Merged queues are not weight-raised (they are assumed +- * to belong to processes that benefit only from high throughput). +- * If the merge is basically the consequence of an accident, then +- * the queue will be split soon and will get back its old weight. +- * It is then important to write down somewhere that this queue +- * does need weight raising, even if it did not make it to get its +- * weight raised before being merged. To this purpose, we overload +- * the field raising_time_left and assign 1 to it, to mark the queue +- * as needing weight raising. +- */ +- bic->wr_time_left = 1; ++ icq_to_bic(icq)->ttime.last_end_request = ktime_get_ns() - (1ULL<<32); + } + + static void bfq_exit_icq(struct io_cq *icq) +@@ -3050,21 +3887,21 @@ static void bfq_exit_icq(struct io_cq *icq) + struct bfq_io_cq *bic = icq_to_bic(icq); + struct bfq_data *bfqd = bic_to_bfqd(bic); + +- if (bic->bfqq[BLK_RW_ASYNC]) { +- bfq_exit_bfqq(bfqd, bic->bfqq[BLK_RW_ASYNC]); +- bic->bfqq[BLK_RW_ASYNC] = NULL; ++ if (bic_to_bfqq(bic, false)) { ++ bfq_exit_bfqq(bfqd, bic_to_bfqq(bic, false)); ++ bic_set_bfqq(bic, NULL, false); + } + +- if (bic->bfqq[BLK_RW_SYNC]) { ++ if (bic_to_bfqq(bic, true)) { + /* + * If the bic is using a shared queue, put the reference + * taken on the io_context when the bic started using a + * shared bfq_queue. + */ +- if (bfq_bfqq_coop(bic->bfqq[BLK_RW_SYNC])) ++ if (bfq_bfqq_coop(bic_to_bfqq(bic, true))) + put_io_context(icq->ioc); +- bfq_exit_bfqq(bfqd, bic->bfqq[BLK_RW_SYNC]); +- bic->bfqq[BLK_RW_SYNC] = NULL; ++ bfq_exit_bfqq(bfqd, bic_to_bfqq(bic, true)); ++ bic_set_bfqq(bic, NULL, true); + } + } + +@@ -3072,8 +3909,8 @@ static void bfq_exit_icq(struct io_cq *icq) + * Update the entity prio values; note that the new values will not + * be used until the next (re)activation. + */ +-static void +-bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) ++static void bfq_set_next_ioprio_data(struct bfq_queue *bfqq, ++ struct bfq_io_cq *bic) + { + struct task_struct *tsk = current; + int ioprio_class; +@@ -3105,7 +3942,7 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) + break; + } + +- if (bfqq->new_ioprio < 0 || bfqq->new_ioprio >= IOPRIO_BE_NR) { ++ if (bfqq->new_ioprio >= IOPRIO_BE_NR) { + pr_crit("bfq_set_next_ioprio_data: new_ioprio %d\n", + bfqq->new_ioprio); + BUG(); +@@ -3113,45 +3950,40 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) + + bfqq->entity.new_weight = bfq_ioprio_to_weight(bfqq->new_ioprio); + bfqq->entity.prio_changed = 1; ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "set_next_ioprio_data: bic_class %d prio %d class %d", ++ ioprio_class, bfqq->new_ioprio, bfqq->new_ioprio_class); + } + + static void bfq_check_ioprio_change(struct bfq_io_cq *bic, struct bio *bio) + { +- struct bfq_data *bfqd; +- struct bfq_queue *bfqq, *new_bfqq; ++ struct bfq_data *bfqd = bic_to_bfqd(bic); ++ struct bfq_queue *bfqq; + unsigned long uninitialized_var(flags); + int ioprio = bic->icq.ioc->ioprio; + +- bfqd = bfq_get_bfqd_locked(&(bic->icq.q->elevator->elevator_data), +- &flags); + /* + * This condition may trigger on a newly created bic, be sure to + * drop the lock before returning. + */ + if (unlikely(!bfqd) || likely(bic->ioprio == ioprio)) +- goto out; ++ return; + + bic->ioprio = ioprio; + +- bfqq = bic->bfqq[BLK_RW_ASYNC]; ++ bfqq = bic_to_bfqq(bic, false); + if (bfqq) { +- new_bfqq = bfq_get_queue(bfqd, bio, BLK_RW_ASYNC, bic, +- GFP_ATOMIC); +- if (new_bfqq) { +- bic->bfqq[BLK_RW_ASYNC] = new_bfqq; +- bfq_log_bfqq(bfqd, bfqq, +- "check_ioprio_change: bfqq %p %d", +- bfqq, atomic_read(&bfqq->ref)); +- bfq_put_queue(bfqq); +- } ++ bfq_put_queue(bfqq); ++ bfqq = bfq_get_queue(bfqd, bio, BLK_RW_ASYNC, bic); ++ bic_set_bfqq(bic, bfqq, false); ++ bfq_log_bfqq(bfqd, bfqq, ++ "check_ioprio_change: bfqq %p %d", ++ bfqq, bfqq->ref); + } + +- bfqq = bic->bfqq[BLK_RW_SYNC]; ++ bfqq = bic_to_bfqq(bic, true); + if (bfqq) + bfq_set_next_ioprio_data(bfqq, bic); +- +-out: +- bfq_put_bfqd_unlock(bfqd, &flags); + } + + static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, +@@ -3160,8 +3992,9 @@ static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, + RB_CLEAR_NODE(&bfqq->entity.rb_node); + INIT_LIST_HEAD(&bfqq->fifo); + INIT_HLIST_NODE(&bfqq->burst_list_node); ++ BUG_ON(!hlist_unhashed(&bfqq->burst_list_node)); + +- atomic_set(&bfqq->ref, 0); ++ bfqq->ref = 0; + bfqq->bfqd = bfqd; + + if (bic) +@@ -3171,6 +4004,7 @@ static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, + if (!bfq_class_idle(bfqq)) + bfq_mark_bfqq_idle_window(bfqq); + bfq_mark_bfqq_sync(bfqq); ++ bfq_mark_bfqq_just_created(bfqq); + } else + bfq_clear_bfqq_sync(bfqq); + bfq_mark_bfqq_IO_bound(bfqq); +@@ -3180,72 +4014,19 @@ static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, + bfqq->pid = pid; + + bfqq->wr_coeff = 1; +- bfqq->last_wr_start_finish = 0; ++ bfqq->last_wr_start_finish = jiffies; ++ bfqq->wr_start_at_switch_to_srt = bfq_smallest_from_now(); ++ bfqq->budget_timeout = bfq_smallest_from_now(); ++ bfqq->split_time = bfq_smallest_from_now(); ++ + /* + * Set to the value for which bfqq will not be deemed as + * soft rt when it becomes backlogged. + */ +- bfqq->soft_rt_next_start = bfq_infinity_from_now(jiffies); +-} +- +-static struct bfq_queue *bfq_find_alloc_queue(struct bfq_data *bfqd, +- struct bio *bio, int is_sync, +- struct bfq_io_cq *bic, +- gfp_t gfp_mask) +-{ +- struct bfq_group *bfqg; +- struct bfq_queue *bfqq, *new_bfqq = NULL; +- struct blkcg *blkcg; +- +-retry: +- rcu_read_lock(); +- +- blkcg = bio_blkcg(bio); +- bfqg = bfq_find_alloc_group(bfqd, blkcg); +- /* bic always exists here */ +- bfqq = bic_to_bfqq(bic, is_sync); +- +- /* +- * Always try a new alloc if we fall back to the OOM bfqq +- * originally, since it should just be a temporary situation. +- */ +- if (!bfqq || bfqq == &bfqd->oom_bfqq) { +- bfqq = NULL; +- if (new_bfqq) { +- bfqq = new_bfqq; +- new_bfqq = NULL; +- } else if (gfpflags_allow_blocking(gfp_mask)) { +- rcu_read_unlock(); +- spin_unlock_irq(bfqd->queue->queue_lock); +- new_bfqq = kmem_cache_alloc_node(bfq_pool, +- gfp_mask | __GFP_ZERO, +- bfqd->queue->node); +- spin_lock_irq(bfqd->queue->queue_lock); +- if (new_bfqq) +- goto retry; +- } else { +- bfqq = kmem_cache_alloc_node(bfq_pool, +- gfp_mask | __GFP_ZERO, +- bfqd->queue->node); +- } +- +- if (bfqq) { +- bfq_init_bfqq(bfqd, bfqq, bic, current->pid, +- is_sync); +- bfq_init_entity(&bfqq->entity, bfqg); +- bfq_log_bfqq(bfqd, bfqq, "allocated"); +- } else { +- bfqq = &bfqd->oom_bfqq; +- bfq_log_bfqq(bfqd, bfqq, "using oom bfqq"); +- } +- } ++ bfqq->soft_rt_next_start = bfq_greatest_from_now(); + +- if (new_bfqq) +- kmem_cache_free(bfq_pool, new_bfqq); +- +- rcu_read_unlock(); +- +- return bfqq; ++ /* first request is almost certainly seeky */ ++ bfqq->seek_history = 1; + } + + static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, +@@ -3268,90 +4049,86 @@ static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, + } + + static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, +- struct bio *bio, int is_sync, +- struct bfq_io_cq *bic, gfp_t gfp_mask) ++ struct bio *bio, bool is_sync, ++ struct bfq_io_cq *bic) + { + const int ioprio = IOPRIO_PRIO_DATA(bic->ioprio); + const int ioprio_class = IOPRIO_PRIO_CLASS(bic->ioprio); + struct bfq_queue **async_bfqq = NULL; +- struct bfq_queue *bfqq = NULL; ++ struct bfq_queue *bfqq; ++ struct bfq_group *bfqg; + +- if (!is_sync) { +- struct blkcg *blkcg; +- struct bfq_group *bfqg; ++ rcu_read_lock(); ++ ++ bfqg = bfq_find_set_group(bfqd, bio_blkcg(bio)); ++ if (!bfqg) { ++ bfqq = &bfqd->oom_bfqq; ++ goto out; ++ } + +- rcu_read_lock(); +- blkcg = bio_blkcg(bio); +- rcu_read_unlock(); +- bfqg = bfq_find_alloc_group(bfqd, blkcg); ++ if (!is_sync) { + async_bfqq = bfq_async_queue_prio(bfqd, bfqg, ioprio_class, + ioprio); + bfqq = *async_bfqq; ++ if (bfqq) ++ goto out; + } + +- if (!bfqq) +- bfqq = bfq_find_alloc_queue(bfqd, bio, is_sync, bic, gfp_mask); ++ bfqq = kmem_cache_alloc_node(bfq_pool, GFP_NOWAIT | __GFP_ZERO, ++ bfqd->queue->node); ++ ++ if (bfqq) { ++ bfq_init_bfqq(bfqd, bfqq, bic, current->pid, ++ is_sync); ++ bfq_init_entity(&bfqq->entity, bfqg); ++ bfq_log_bfqq(bfqd, bfqq, "allocated"); ++ } else { ++ bfqq = &bfqd->oom_bfqq; ++ bfq_log_bfqq(bfqd, bfqq, "using oom bfqq"); ++ goto out; ++ } + + /* + * Pin the queue now that it's allocated, scheduler exit will + * prune it. + */ +- if (!is_sync && !(*async_bfqq)) { +- atomic_inc(&bfqq->ref); ++ if (async_bfqq) { ++ bfqq->ref++; + bfq_log_bfqq(bfqd, bfqq, "get_queue, bfqq not in async: %p, %d", +- bfqq, atomic_read(&bfqq->ref)); ++ bfqq, bfqq->ref); + *async_bfqq = bfqq; + } + +- atomic_inc(&bfqq->ref); +- bfq_log_bfqq(bfqd, bfqq, "get_queue, at end: %p, %d", bfqq, +- atomic_read(&bfqq->ref)); ++out: ++ bfqq->ref++; ++ bfq_log_bfqq(bfqd, bfqq, "get_queue, at end: %p, %d", bfqq, bfqq->ref); ++ rcu_read_unlock(); + return bfqq; + } + + static void bfq_update_io_thinktime(struct bfq_data *bfqd, + struct bfq_io_cq *bic) + { +- unsigned long elapsed = jiffies - bic->ttime.last_end_request; +- unsigned long ttime = min(elapsed, 2UL * bfqd->bfq_slice_idle); ++ struct bfq_ttime *ttime = &bic->ttime; ++ u64 elapsed = ktime_get_ns() - bic->ttime.last_end_request; + +- bic->ttime.ttime_samples = (7*bic->ttime.ttime_samples + 256) / 8; +- bic->ttime.ttime_total = (7*bic->ttime.ttime_total + 256*ttime) / 8; +- bic->ttime.ttime_mean = (bic->ttime.ttime_total + 128) / +- bic->ttime.ttime_samples; ++ elapsed = min_t(u64, elapsed, 2 * bfqd->bfq_slice_idle); ++ ++ ttime->ttime_samples = (7*bic->ttime.ttime_samples + 256) / 8; ++ ttime->ttime_total = div_u64(7*ttime->ttime_total + 256*elapsed, 8); ++ ttime->ttime_mean = div64_ul(ttime->ttime_total + 128, ++ ttime->ttime_samples); + } + +-static void bfq_update_io_seektime(struct bfq_data *bfqd, +- struct bfq_queue *bfqq, +- struct request *rq) ++static void ++bfq_update_io_seektime(struct bfq_data *bfqd, struct bfq_queue *bfqq, ++ struct request *rq) + { +- sector_t sdist; +- u64 total; +- +- if (bfqq->last_request_pos < blk_rq_pos(rq)) +- sdist = blk_rq_pos(rq) - bfqq->last_request_pos; +- else +- sdist = bfqq->last_request_pos - blk_rq_pos(rq); +- +- /* +- * Don't allow the seek distance to get too large from the +- * odd fragment, pagein, etc. +- */ +- if (bfqq->seek_samples == 0) /* first request, not really a seek */ +- sdist = 0; +- else if (bfqq->seek_samples <= 60) /* second & third seek */ +- sdist = min(sdist, (bfqq->seek_mean * 4) + 2*1024*1024); +- else +- sdist = min(sdist, (bfqq->seek_mean * 4) + 2*1024*64); +- +- bfqq->seek_samples = (7*bfqq->seek_samples + 256) / 8; +- bfqq->seek_total = (7*bfqq->seek_total + (u64)256*sdist) / 8; +- total = bfqq->seek_total + (bfqq->seek_samples/2); +- do_div(total, bfqq->seek_samples); +- bfqq->seek_mean = (sector_t)total; +- +- bfq_log_bfqq(bfqd, bfqq, "dist=%llu mean=%llu", (u64)sdist, +- (u64)bfqq->seek_mean); ++ bfqq->seek_history <<= 1; ++ bfqq->seek_history |= ++ get_sdist(bfqq->last_request_pos, rq) > BFQQ_SEEK_THR && ++ (!blk_queue_nonrot(bfqd->queue) || ++ blk_rq_sectors(rq) < BFQQ_SECT_THR_NONROT); + } + + /* +@@ -3369,7 +4146,8 @@ static void bfq_update_idle_window(struct bfq_data *bfqd, + return; + + /* Idle window just restored, statistics are meaningless. */ +- if (bfq_bfqq_just_split(bfqq)) ++ if (time_is_after_eq_jiffies(bfqq->split_time + ++ bfqd->bfq_wr_min_idle_time)) + return; + + enable_idle = bfq_bfqq_idle_window(bfqq); +@@ -3409,22 +4187,13 @@ static void bfq_rq_enqueued(struct bfq_data *bfqd, struct bfq_queue *bfqq, + + bfq_update_io_thinktime(bfqd, bic); + bfq_update_io_seektime(bfqd, bfqq, rq); +- if (!BFQQ_SEEKY(bfqq) && bfq_bfqq_constantly_seeky(bfqq)) { +- bfq_clear_bfqq_constantly_seeky(bfqq); +- if (!blk_queue_nonrot(bfqd->queue)) { +- BUG_ON(!bfqd->const_seeky_busy_in_flight_queues); +- bfqd->const_seeky_busy_in_flight_queues--; +- } +- } + if (bfqq->entity.service > bfq_max_budget(bfqd) / 8 || + !BFQQ_SEEKY(bfqq)) + bfq_update_idle_window(bfqd, bfqq, bic); +- bfq_clear_bfqq_just_split(bfqq); + + bfq_log_bfqq(bfqd, bfqq, +- "rq_enqueued: idle_window=%d (seeky %d, mean %llu)", +- bfq_bfqq_idle_window(bfqq), BFQQ_SEEKY(bfqq), +- (unsigned long long) bfqq->seek_mean); ++ "rq_enqueued: idle_window=%d (seeky %d)", ++ bfq_bfqq_idle_window(bfqq), BFQQ_SEEKY(bfqq)); + + bfqq->last_request_pos = blk_rq_pos(rq) + blk_rq_sectors(rq); + +@@ -3438,14 +4207,15 @@ static void bfq_rq_enqueued(struct bfq_data *bfqd, struct bfq_queue *bfqq, + * is small and the queue is not to be expired, then + * just exit. + * +- * In this way, if the disk is being idled to wait for +- * a new request from the in-service queue, we avoid +- * unplugging the device and committing the disk to serve +- * just a small request. On the contrary, we wait for +- * the block layer to decide when to unplug the device: +- * hopefully, new requests will be merged to this one +- * quickly, then the device will be unplugged and +- * larger requests will be dispatched. ++ * In this way, if the device is being idled to wait ++ * for a new request from the in-service queue, we ++ * avoid unplugging the device and committing the ++ * device to serve just a small request. On the ++ * contrary, we wait for the block layer to decide ++ * when to unplug the device: hopefully, new requests ++ * will be merged to this one quickly, then the device ++ * will be unplugged and larger requests will be ++ * dispatched. + */ + if (small_req && !budget_timeout) + return; +@@ -3457,10 +4227,8 @@ static void bfq_rq_enqueued(struct bfq_data *bfqd, struct bfq_queue *bfqq, + * timer. + */ + bfq_clear_bfqq_wait_request(bfqq); +- del_timer(&bfqd->idle_slice_timer); +-#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ hrtimer_try_to_cancel(&bfqd->idle_slice_timer); + bfqg_stats_update_idle_time(bfqq_group(bfqq)); +-#endif + + /* + * The queue is not empty, because a new request just +@@ -3504,28 +4272,20 @@ static void bfq_insert_request(struct request_queue *q, struct request *rq) + */ + new_bfqq->allocated[rq_data_dir(rq)]++; + bfqq->allocated[rq_data_dir(rq)]--; +- atomic_inc(&new_bfqq->ref); ++ new_bfqq->ref++; ++ bfq_clear_bfqq_just_created(bfqq); + bfq_put_queue(bfqq); + if (bic_to_bfqq(RQ_BIC(rq), 1) == bfqq) + bfq_merge_bfqqs(bfqd, RQ_BIC(rq), + bfqq, new_bfqq); + rq->elv.priv[1] = new_bfqq; + bfqq = new_bfqq; +- } else +- bfq_bfqq_increase_failed_cooperations(bfqq); ++ } + } + + bfq_add_request(rq); + +- /* +- * Here a newly-created bfq_queue has already started a weight-raising +- * period: clear raising_time_left to prevent bfq_bfqq_save_state() +- * from assigning it a full weight-raising period. See the detailed +- * comments about this field in bfq_init_icq(). +- */ +- if (bfqq->bic) +- bfqq->bic->wr_time_left = 0; +- rq->fifo_time = jiffies + bfqd->bfq_fifo_expire[rq_is_sync(rq)]; ++ rq->fifo_time = ktime_get_ns() + bfqd->bfq_fifo_expire[rq_is_sync(rq)]; + list_add_tail(&rq->queuelist, &bfqq->fifo); + + bfq_rq_enqueued(bfqd, bfqq, rq); +@@ -3533,8 +4293,8 @@ static void bfq_insert_request(struct request_queue *q, struct request *rq) + + static void bfq_update_hw_tag(struct bfq_data *bfqd) + { +- bfqd->max_rq_in_driver = max(bfqd->max_rq_in_driver, +- bfqd->rq_in_driver); ++ bfqd->max_rq_in_driver = max_t(int, bfqd->max_rq_in_driver, ++ bfqd->rq_in_driver); + + if (bfqd->hw_tag == 1) + return; +@@ -3560,48 +4320,85 @@ static void bfq_completed_request(struct request_queue *q, struct request *rq) + { + struct bfq_queue *bfqq = RQ_BFQQ(rq); + struct bfq_data *bfqd = bfqq->bfqd; +- bool sync = bfq_bfqq_sync(bfqq); ++ u64 now_ns; ++ u32 delta_us; + +- bfq_log_bfqq(bfqd, bfqq, "completed one req with %u sects left (%d)", +- blk_rq_sectors(rq), sync); ++ bfq_log_bfqq(bfqd, bfqq, "completed one req with %u sects left", ++ blk_rq_sectors(rq)); + ++ assert_spin_locked(bfqd->queue->queue_lock); + bfq_update_hw_tag(bfqd); + + BUG_ON(!bfqd->rq_in_driver); + BUG_ON(!bfqq->dispatched); + bfqd->rq_in_driver--; + bfqq->dispatched--; +-#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_update_completion(bfqq_group(bfqq), + rq_start_time_ns(rq), +- rq_io_start_time_ns(rq), rq->cmd_flags); +-#endif ++ rq_io_start_time_ns(rq), req_op(rq), ++ rq->cmd_flags); + + if (!bfqq->dispatched && !bfq_bfqq_busy(bfqq)) { ++ BUG_ON(!RB_EMPTY_ROOT(&bfqq->sort_list)); ++ /* ++ * Set budget_timeout (which we overload to store the ++ * time at which the queue remains with no backlog and ++ * no outstanding request; used by the weight-raising ++ * mechanism). ++ */ ++ bfqq->budget_timeout = jiffies; ++ + bfq_weights_tree_remove(bfqd, &bfqq->entity, + &bfqd->queue_weights_tree); +- if (!blk_queue_nonrot(bfqd->queue)) { +- BUG_ON(!bfqd->busy_in_flight_queues); +- bfqd->busy_in_flight_queues--; +- if (bfq_bfqq_constantly_seeky(bfqq)) { +- BUG_ON(!bfqd-> +- const_seeky_busy_in_flight_queues); +- bfqd->const_seeky_busy_in_flight_queues--; +- } +- } + } + +- if (sync) { +- bfqd->sync_flight--; +- RQ_BIC(rq)->ttime.last_end_request = jiffies; +- } ++ now_ns = ktime_get_ns(); ++ ++ RQ_BIC(rq)->ttime.last_end_request = now_ns; ++ ++ /* ++ * Using us instead of ns, to get a reasonable precision in ++ * computing rate in next check. ++ */ ++ delta_us = div_u64(now_ns - bfqd->last_completion, NSEC_PER_USEC); ++ ++ bfq_log(bfqd, "rq_completed: delta %uus/%luus max_size %u rate %llu/%llu", ++ delta_us, BFQ_MIN_TT/NSEC_PER_USEC, bfqd->last_rq_max_size, ++ (USEC_PER_SEC* ++ (u64)((bfqd->last_rq_max_size<>BFQ_RATE_SHIFT, ++ (USEC_PER_SEC*(u64)(1UL<<(BFQ_RATE_SHIFT-10)))>>BFQ_RATE_SHIFT); ++ ++ /* ++ * If the request took rather long to complete, and, according ++ * to the maximum request size recorded, this completion latency ++ * implies that the request was certainly served at a very low ++ * rate (less than 1M sectors/sec), then the whole observation ++ * interval that lasts up to this time instant cannot be a ++ * valid time interval for computing a new peak rate. Invoke ++ * bfq_update_rate_reset to have the following three steps ++ * taken: ++ * - close the observation interval at the last (previous) ++ * request dispatch or completion ++ * - compute rate, if possible, for that observation interval ++ * - reset to zero samples, which will trigger a proper ++ * re-initialization of the observation interval on next ++ * dispatch ++ */ ++ if (delta_us > BFQ_MIN_TT/NSEC_PER_USEC && ++ (bfqd->last_rq_max_size<last_completion = now_ns; + + /* +- * If we are waiting to discover whether the request pattern of the +- * task associated with the queue is actually isochronous, and +- * both requisites for this condition to hold are satisfied, then +- * compute soft_rt_next_start (see the comments to the function +- * bfq_bfqq_softrt_next_start()). ++ * If we are waiting to discover whether the request pattern ++ * of the task associated with the queue is actually ++ * isochronous, and both requisites for this condition to hold ++ * are now satisfied, then compute soft_rt_next_start (see the ++ * comments on the function bfq_bfqq_softrt_next_start()). We ++ * schedule this delayed check when bfqq expires, if it still ++ * has in-flight requests. + */ + if (bfq_bfqq_softrt_update(bfqq) && bfqq->dispatched == 0 && + RB_EMPTY_ROOT(&bfqq->sort_list)) +@@ -3613,10 +4410,7 @@ static void bfq_completed_request(struct request_queue *q, struct request *rq) + * or if we want to idle in case it has no pending requests. + */ + if (bfqd->in_service_queue == bfqq) { +- if (bfq_bfqq_budget_new(bfqq)) +- bfq_set_budget_timeout(bfqd); +- +- if (bfq_bfqq_must_idle(bfqq)) { ++ if (bfqq->dispatched == 0 && bfq_bfqq_must_idle(bfqq)) { + bfq_arm_slice_timer(bfqd); + goto out; + } else if (bfq_may_expire_for_budg_timeout(bfqq)) +@@ -3646,7 +4440,7 @@ static int __bfq_may_queue(struct bfq_queue *bfqq) + return ELV_MQUEUE_MAY; + } + +-static int bfq_may_queue(struct request_queue *q, int rw) ++static int bfq_may_queue(struct request_queue *q, int op, int op_flags) + { + struct bfq_data *bfqd = q->elevator->elevator_data; + struct task_struct *tsk = current; +@@ -3663,7 +4457,7 @@ static int bfq_may_queue(struct request_queue *q, int rw) + if (!bic) + return ELV_MQUEUE_MAY; + +- bfqq = bic_to_bfqq(bic, rw_is_sync(rw)); ++ bfqq = bic_to_bfqq(bic, rw_is_sync(op, op_flags)); + if (bfqq) + return __bfq_may_queue(bfqq); + +@@ -3687,14 +4481,14 @@ static void bfq_put_request(struct request *rq) + rq->elv.priv[1] = NULL; + + bfq_log_bfqq(bfqq->bfqd, bfqq, "put_request %p, %d", +- bfqq, atomic_read(&bfqq->ref)); ++ bfqq, bfqq->ref); + bfq_put_queue(bfqq); + } + } + + /* + * Returns NULL if a new bfqq should be allocated, or the old bfqq if this +- * was the last process referring to said bfqq. ++ * was the last process referring to that bfqq. + */ + static struct bfq_queue * + bfq_split_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq) +@@ -3732,11 +4526,8 @@ static int bfq_set_request(struct request_queue *q, struct request *rq, + unsigned long flags; + bool split = false; + +- might_sleep_if(gfpflags_allow_blocking(gfp_mask)); +- +- bfq_check_ioprio_change(bic, bio); +- + spin_lock_irqsave(q->queue_lock, flags); ++ bfq_check_ioprio_change(bic, bio); + + if (!bic) + goto queue_fail; +@@ -3746,23 +4537,47 @@ static int bfq_set_request(struct request_queue *q, struct request *rq, + new_queue: + bfqq = bic_to_bfqq(bic, is_sync); + if (!bfqq || bfqq == &bfqd->oom_bfqq) { +- bfqq = bfq_get_queue(bfqd, bio, is_sync, bic, gfp_mask); ++ if (bfqq) ++ bfq_put_queue(bfqq); ++ bfqq = bfq_get_queue(bfqd, bio, is_sync, bic); ++ BUG_ON(!hlist_unhashed(&bfqq->burst_list_node)); ++ + bic_set_bfqq(bic, bfqq, is_sync); + if (split && is_sync) { ++ bfq_log_bfqq(bfqd, bfqq, ++ "set_request: was_in_list %d " ++ "was_in_large_burst %d " ++ "large burst in progress %d", ++ bic->was_in_burst_list, ++ bic->saved_in_large_burst, ++ bfqd->large_burst); ++ + if ((bic->was_in_burst_list && bfqd->large_burst) || +- bic->saved_in_large_burst) ++ bic->saved_in_large_burst) { ++ bfq_log_bfqq(bfqd, bfqq, ++ "set_request: marking in " ++ "large burst"); + bfq_mark_bfqq_in_large_burst(bfqq); +- else { ++ } else { ++ bfq_log_bfqq(bfqd, bfqq, ++ "set_request: clearing in " ++ "large burst"); + bfq_clear_bfqq_in_large_burst(bfqq); + if (bic->was_in_burst_list) + hlist_add_head(&bfqq->burst_list_node, + &bfqd->burst_list); + } ++ bfqq->split_time = jiffies; + } + } else { + /* If the queue was seeky for too long, break it apart. */ + if (bfq_bfqq_coop(bfqq) && bfq_bfqq_split_coop(bfqq)) { + bfq_log_bfqq(bfqd, bfqq, "breaking apart bfqq"); ++ ++ /* Update bic before losing reference to bfqq */ ++ if (bfq_bfqq_in_large_burst(bfqq)) ++ bic->saved_in_large_burst = true; ++ + bfqq = bfq_split_bfqq(bic, bfqq); + split = true; + if (!bfqq) +@@ -3771,9 +4586,8 @@ static int bfq_set_request(struct request_queue *q, struct request *rq, + } + + bfqq->allocated[rw]++; +- atomic_inc(&bfqq->ref); +- bfq_log_bfqq(bfqd, bfqq, "set_request: bfqq %p, %d", bfqq, +- atomic_read(&bfqq->ref)); ++ bfqq->ref++; ++ bfq_log_bfqq(bfqd, bfqq, "set_request: bfqq %p, %d", bfqq, bfqq->ref); + + rq->elv.priv[0] = bic; + rq->elv.priv[1] = bfqq; +@@ -3788,7 +4602,6 @@ static int bfq_set_request(struct request_queue *q, struct request *rq, + if (likely(bfqq != &bfqd->oom_bfqq) && bfqq_process_refs(bfqq) == 1) { + bfqq->bic = bic; + if (split) { +- bfq_mark_bfqq_just_split(bfqq); + /* + * If the queue has just been split from a shared + * queue, restore the idle window and the possible +@@ -3798,6 +4611,9 @@ static int bfq_set_request(struct request_queue *q, struct request *rq, + } + } + ++ if (unlikely(bfq_bfqq_just_created(bfqq))) ++ bfq_handle_burst(bfqd, bfqq); ++ + spin_unlock_irqrestore(q->queue_lock, flags); + + return 0; +@@ -3824,9 +4640,10 @@ static void bfq_kick_queue(struct work_struct *work) + * Handler of the expiration of the timer running if the in-service queue + * is idling inside its time slice. + */ +-static void bfq_idle_slice_timer(unsigned long data) ++static enum hrtimer_restart bfq_idle_slice_timer(struct hrtimer *timer) + { +- struct bfq_data *bfqd = (struct bfq_data *)data; ++ struct bfq_data *bfqd = container_of(timer, struct bfq_data, ++ idle_slice_timer); + struct bfq_queue *bfqq; + unsigned long flags; + enum bfqq_expiration reason; +@@ -3844,6 +4661,8 @@ static void bfq_idle_slice_timer(unsigned long data) + */ + if (bfqq) { + bfq_log_bfqq(bfqd, bfqq, "slice_timer expired"); ++ bfq_clear_bfqq_wait_request(bfqq); ++ + if (bfq_bfqq_budget_timeout(bfqq)) + /* + * Also here the queue can be safely expired +@@ -3869,14 +4688,16 @@ static void bfq_idle_slice_timer(unsigned long data) + bfq_schedule_dispatch(bfqd); + + spin_unlock_irqrestore(bfqd->queue->queue_lock, flags); ++ return HRTIMER_NORESTART; + } + + static void bfq_shutdown_timer_wq(struct bfq_data *bfqd) + { +- del_timer_sync(&bfqd->idle_slice_timer); ++ hrtimer_cancel(&bfqd->idle_slice_timer); + cancel_work_sync(&bfqd->unplug_work); + } + ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + static void __bfq_put_async_bfqq(struct bfq_data *bfqd, + struct bfq_queue **bfqq_ptr) + { +@@ -3885,9 +4706,9 @@ static void __bfq_put_async_bfqq(struct bfq_data *bfqd, + + bfq_log(bfqd, "put_async_bfqq: %p", bfqq); + if (bfqq) { +- bfq_bfqq_move(bfqd, bfqq, &bfqq->entity, root_group); ++ bfq_bfqq_move(bfqd, bfqq, root_group); + bfq_log_bfqq(bfqd, bfqq, "put_async_bfqq: putting %p, %d", +- bfqq, atomic_read(&bfqq->ref)); ++ bfqq, bfqq->ref); + bfq_put_queue(bfqq); + *bfqq_ptr = NULL; + } +@@ -3909,6 +4730,7 @@ static void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg) + + __bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq); + } ++#endif + + static void bfq_exit_queue(struct elevator_queue *e) + { +@@ -3922,15 +4744,13 @@ static void bfq_exit_queue(struct elevator_queue *e) + + BUG_ON(bfqd->in_service_queue); + list_for_each_entry_safe(bfqq, n, &bfqd->idle_list, bfqq_list) +- bfq_deactivate_bfqq(bfqd, bfqq, 0); ++ bfq_deactivate_bfqq(bfqd, bfqq, false, false); + + spin_unlock_irq(q->queue_lock); + + bfq_shutdown_timer_wq(bfqd); + +- synchronize_rcu(); +- +- BUG_ON(timer_pending(&bfqd->idle_slice_timer)); ++ BUG_ON(hrtimer_active(&bfqd->idle_slice_timer)); + + #ifdef CONFIG_BFQ_GROUP_IOSCHED + blkcg_deactivate_policy(q, &blkcg_policy_bfq); +@@ -3954,6 +4774,7 @@ static void bfq_init_root_group(struct bfq_group *root_group, + root_group->rq_pos_tree = RB_ROOT; + for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) + root_group->sched_data.service_tree[i] = BFQ_SERVICE_TREE_INIT; ++ root_group->sched_data.bfq_class_idle_last_service = jiffies; + } + + static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) +@@ -3978,11 +4799,14 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) + * will not attempt to free it. + */ + bfq_init_bfqq(bfqd, &bfqd->oom_bfqq, NULL, 1, 0); +- atomic_inc(&bfqd->oom_bfqq.ref); ++ bfqd->oom_bfqq.ref++; + bfqd->oom_bfqq.new_ioprio = BFQ_DEFAULT_QUEUE_IOPRIO; + bfqd->oom_bfqq.new_ioprio_class = IOPRIO_CLASS_BE; + bfqd->oom_bfqq.entity.new_weight = + bfq_ioprio_to_weight(bfqd->oom_bfqq.new_ioprio); ++ ++ /* oom_bfqq does not participate to bursts */ ++ bfq_clear_bfqq_just_created(&bfqd->oom_bfqq); + /* + * Trigger weight initialization, according to ioprio, at the + * oom_bfqq's first activation. The oom_bfqq's ioprio and ioprio +@@ -4001,13 +4825,10 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) + goto out_free; + bfq_init_root_group(bfqd->root_group, bfqd); + bfq_init_entity(&bfqd->oom_bfqq.entity, bfqd->root_group); +-#ifdef CONFIG_BFQ_GROUP_IOSCHED +- bfqd->active_numerous_groups = 0; +-#endif + +- init_timer(&bfqd->idle_slice_timer); ++ hrtimer_init(&bfqd->idle_slice_timer, CLOCK_MONOTONIC, ++ HRTIMER_MODE_REL); + bfqd->idle_slice_timer.function = bfq_idle_slice_timer; +- bfqd->idle_slice_timer.data = (unsigned long)bfqd; + + bfqd->queue_weights_tree = RB_ROOT; + bfqd->group_weights_tree = RB_ROOT; +@@ -4027,21 +4848,19 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) + bfqd->bfq_back_max = bfq_back_max; + bfqd->bfq_back_penalty = bfq_back_penalty; + bfqd->bfq_slice_idle = bfq_slice_idle; +- bfqd->bfq_class_idle_last_service = 0; +- bfqd->bfq_max_budget_async_rq = bfq_max_budget_async_rq; +- bfqd->bfq_timeout[BLK_RW_ASYNC] = bfq_timeout_async; +- bfqd->bfq_timeout[BLK_RW_SYNC] = bfq_timeout_sync; ++ bfqd->bfq_timeout = bfq_timeout; + +- bfqd->bfq_coop_thresh = 2; +- bfqd->bfq_failed_cooperations = 7000; + bfqd->bfq_requests_within_timer = 120; + +- bfqd->bfq_large_burst_thresh = 11; +- bfqd->bfq_burst_interval = msecs_to_jiffies(500); ++ bfqd->bfq_large_burst_thresh = 8; ++ bfqd->bfq_burst_interval = msecs_to_jiffies(180); + + bfqd->low_latency = true; + +- bfqd->bfq_wr_coeff = 20; ++ /* ++ * Trade-off between responsiveness and fairness. ++ */ ++ bfqd->bfq_wr_coeff = 30; + bfqd->bfq_wr_rt_max_time = msecs_to_jiffies(300); + bfqd->bfq_wr_max_time = 0; + bfqd->bfq_wr_min_idle_time = msecs_to_jiffies(2000); +@@ -4053,16 +4872,15 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) + * video. + */ + bfqd->wr_busy_queues = 0; +- bfqd->busy_in_flight_queues = 0; +- bfqd->const_seeky_busy_in_flight_queues = 0; + + /* +- * Begin by assuming, optimistically, that the device peak rate is +- * equal to the highest reference rate. ++ * Begin by assuming, optimistically, that the device is a ++ * high-speed one, and that its peak rate is equal to 2/3 of ++ * the highest reference rate. + */ + bfqd->RT_prod = R_fast[blk_queue_nonrot(bfqd->queue)] * + T_fast[blk_queue_nonrot(bfqd->queue)]; +- bfqd->peak_rate = R_fast[blk_queue_nonrot(bfqd->queue)]; ++ bfqd->peak_rate = R_fast[blk_queue_nonrot(bfqd->queue)] * 2 / 3; + bfqd->device_speed = BFQ_BFQD_FAST; + + return 0; +@@ -4088,7 +4906,7 @@ static int __init bfq_slab_setup(void) + + static ssize_t bfq_var_show(unsigned int var, char *page) + { +- return sprintf(page, "%d\n", var); ++ return sprintf(page, "%u\n", var); + } + + static ssize_t bfq_var_store(unsigned long *var, const char *page, +@@ -4159,21 +4977,21 @@ static ssize_t bfq_weights_show(struct elevator_queue *e, char *page) + static ssize_t __FUNC(struct elevator_queue *e, char *page) \ + { \ + struct bfq_data *bfqd = e->elevator_data; \ +- unsigned int __data = __VAR; \ +- if (__CONV) \ ++ u64 __data = __VAR; \ ++ if (__CONV == 1) \ + __data = jiffies_to_msecs(__data); \ ++ else if (__CONV == 2) \ ++ __data = div_u64(__data, NSEC_PER_MSEC); \ + return bfq_var_show(__data, (page)); \ + } +-SHOW_FUNCTION(bfq_fifo_expire_sync_show, bfqd->bfq_fifo_expire[1], 1); +-SHOW_FUNCTION(bfq_fifo_expire_async_show, bfqd->bfq_fifo_expire[0], 1); ++SHOW_FUNCTION(bfq_fifo_expire_sync_show, bfqd->bfq_fifo_expire[1], 2); ++SHOW_FUNCTION(bfq_fifo_expire_async_show, bfqd->bfq_fifo_expire[0], 2); + SHOW_FUNCTION(bfq_back_seek_max_show, bfqd->bfq_back_max, 0); + SHOW_FUNCTION(bfq_back_seek_penalty_show, bfqd->bfq_back_penalty, 0); +-SHOW_FUNCTION(bfq_slice_idle_show, bfqd->bfq_slice_idle, 1); ++SHOW_FUNCTION(bfq_slice_idle_show, bfqd->bfq_slice_idle, 2); + SHOW_FUNCTION(bfq_max_budget_show, bfqd->bfq_user_max_budget, 0); +-SHOW_FUNCTION(bfq_max_budget_async_rq_show, +- bfqd->bfq_max_budget_async_rq, 0); +-SHOW_FUNCTION(bfq_timeout_sync_show, bfqd->bfq_timeout[BLK_RW_SYNC], 1); +-SHOW_FUNCTION(bfq_timeout_async_show, bfqd->bfq_timeout[BLK_RW_ASYNC], 1); ++SHOW_FUNCTION(bfq_timeout_sync_show, bfqd->bfq_timeout, 1); ++SHOW_FUNCTION(bfq_strict_guarantees_show, bfqd->strict_guarantees, 0); + SHOW_FUNCTION(bfq_low_latency_show, bfqd->low_latency, 0); + SHOW_FUNCTION(bfq_wr_coeff_show, bfqd->bfq_wr_coeff, 0); + SHOW_FUNCTION(bfq_wr_rt_max_time_show, bfqd->bfq_wr_rt_max_time, 1); +@@ -4183,6 +5001,17 @@ SHOW_FUNCTION(bfq_wr_min_inter_arr_async_show, bfqd->bfq_wr_min_inter_arr_async, + SHOW_FUNCTION(bfq_wr_max_softrt_rate_show, bfqd->bfq_wr_max_softrt_rate, 0); + #undef SHOW_FUNCTION + ++#define USEC_SHOW_FUNCTION(__FUNC, __VAR) \ ++static ssize_t __FUNC(struct elevator_queue *e, char *page) \ ++{ \ ++ struct bfq_data *bfqd = e->elevator_data; \ ++ u64 __data = __VAR; \ ++ __data = div_u64(__data, NSEC_PER_USEC); \ ++ return bfq_var_show(__data, (page)); \ ++} ++USEC_SHOW_FUNCTION(bfq_slice_idle_us_show, bfqd->bfq_slice_idle); ++#undef USEC_SHOW_FUNCTION ++ + #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ + static ssize_t \ + __FUNC(struct elevator_queue *e, const char *page, size_t count) \ +@@ -4194,24 +5023,22 @@ __FUNC(struct elevator_queue *e, const char *page, size_t count) \ + __data = (MIN); \ + else if (__data > (MAX)) \ + __data = (MAX); \ +- if (__CONV) \ ++ if (__CONV == 1) \ + *(__PTR) = msecs_to_jiffies(__data); \ ++ else if (__CONV == 2) \ ++ *(__PTR) = (u64)__data * NSEC_PER_MSEC; \ + else \ + *(__PTR) = __data; \ + return ret; \ + } + STORE_FUNCTION(bfq_fifo_expire_sync_store, &bfqd->bfq_fifo_expire[1], 1, +- INT_MAX, 1); ++ INT_MAX, 2); + STORE_FUNCTION(bfq_fifo_expire_async_store, &bfqd->bfq_fifo_expire[0], 1, +- INT_MAX, 1); ++ INT_MAX, 2); + STORE_FUNCTION(bfq_back_seek_max_store, &bfqd->bfq_back_max, 0, INT_MAX, 0); + STORE_FUNCTION(bfq_back_seek_penalty_store, &bfqd->bfq_back_penalty, 1, + INT_MAX, 0); +-STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 1); +-STORE_FUNCTION(bfq_max_budget_async_rq_store, &bfqd->bfq_max_budget_async_rq, +- 1, INT_MAX, 0); +-STORE_FUNCTION(bfq_timeout_async_store, &bfqd->bfq_timeout[BLK_RW_ASYNC], 0, +- INT_MAX, 1); ++STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2); + STORE_FUNCTION(bfq_wr_coeff_store, &bfqd->bfq_wr_coeff, 1, INT_MAX, 0); + STORE_FUNCTION(bfq_wr_max_time_store, &bfqd->bfq_wr_max_time, 0, INT_MAX, 1); + STORE_FUNCTION(bfq_wr_rt_max_time_store, &bfqd->bfq_wr_rt_max_time, 0, INT_MAX, +@@ -4224,6 +5051,23 @@ STORE_FUNCTION(bfq_wr_max_softrt_rate_store, &bfqd->bfq_wr_max_softrt_rate, 0, + INT_MAX, 0); + #undef STORE_FUNCTION + ++#define USEC_STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \ ++static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)\ ++{ \ ++ struct bfq_data *bfqd = e->elevator_data; \ ++ unsigned long uninitialized_var(__data); \ ++ int ret = bfq_var_store(&__data, (page), count); \ ++ if (__data < (MIN)) \ ++ __data = (MIN); \ ++ else if (__data > (MAX)) \ ++ __data = (MAX); \ ++ *(__PTR) = (u64)__data * NSEC_PER_USEC; \ ++ return ret; \ ++} ++USEC_STORE_FUNCTION(bfq_slice_idle_us_store, &bfqd->bfq_slice_idle, 0, ++ UINT_MAX); ++#undef USEC_STORE_FUNCTION ++ + /* do nothing for the moment */ + static ssize_t bfq_weights_store(struct elevator_queue *e, + const char *page, size_t count) +@@ -4231,16 +5075,6 @@ static ssize_t bfq_weights_store(struct elevator_queue *e, + return count; + } + +-static unsigned long bfq_estimated_max_budget(struct bfq_data *bfqd) +-{ +- u64 timeout = jiffies_to_msecs(bfqd->bfq_timeout[BLK_RW_SYNC]); +- +- if (bfqd->peak_rate_samples >= BFQ_PEAK_RATE_SAMPLES) +- return bfq_calc_max_budget(bfqd->peak_rate, timeout); +- else +- return bfq_default_max_budget; +-} +- + static ssize_t bfq_max_budget_store(struct elevator_queue *e, + const char *page, size_t count) + { +@@ -4249,7 +5083,7 @@ static ssize_t bfq_max_budget_store(struct elevator_queue *e, + int ret = bfq_var_store(&__data, (page), count); + + if (__data == 0) +- bfqd->bfq_max_budget = bfq_estimated_max_budget(bfqd); ++ bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); + else { + if (__data > INT_MAX) + __data = INT_MAX; +@@ -4261,6 +5095,10 @@ static ssize_t bfq_max_budget_store(struct elevator_queue *e, + return ret; + } + ++/* ++ * Leaving this name to preserve name compatibility with cfq ++ * parameters, but this timeout is used for both sync and async. ++ */ + static ssize_t bfq_timeout_sync_store(struct elevator_queue *e, + const char *page, size_t count) + { +@@ -4273,9 +5111,27 @@ static ssize_t bfq_timeout_sync_store(struct elevator_queue *e, + else if (__data > INT_MAX) + __data = INT_MAX; + +- bfqd->bfq_timeout[BLK_RW_SYNC] = msecs_to_jiffies(__data); ++ bfqd->bfq_timeout = msecs_to_jiffies(__data); + if (bfqd->bfq_user_max_budget == 0) +- bfqd->bfq_max_budget = bfq_estimated_max_budget(bfqd); ++ bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); ++ ++ return ret; ++} ++ ++static ssize_t bfq_strict_guarantees_store(struct elevator_queue *e, ++ const char *page, size_t count) ++{ ++ struct bfq_data *bfqd = e->elevator_data; ++ unsigned long uninitialized_var(__data); ++ int ret = bfq_var_store(&__data, (page), count); ++ ++ if (__data > 1) ++ __data = 1; ++ if (!bfqd->strict_guarantees && __data == 1 ++ && bfqd->bfq_slice_idle < 8 * NSEC_PER_MSEC) ++ bfqd->bfq_slice_idle = 8 * NSEC_PER_MSEC; ++ ++ bfqd->strict_guarantees = __data; + + return ret; + } +@@ -4305,10 +5161,10 @@ static struct elv_fs_entry bfq_attrs[] = { + BFQ_ATTR(back_seek_max), + BFQ_ATTR(back_seek_penalty), + BFQ_ATTR(slice_idle), ++ BFQ_ATTR(slice_idle_us), + BFQ_ATTR(max_budget), +- BFQ_ATTR(max_budget_async_rq), + BFQ_ATTR(timeout_sync), +- BFQ_ATTR(timeout_async), ++ BFQ_ATTR(strict_guarantees), + BFQ_ATTR(low_latency), + BFQ_ATTR(wr_coeff), + BFQ_ATTR(wr_max_time), +@@ -4328,7 +5184,8 @@ static struct elevator_type iosched_bfq = { + #ifdef CONFIG_BFQ_GROUP_IOSCHED + .elevator_bio_merged_fn = bfq_bio_merged, + #endif +- .elevator_allow_merge_fn = bfq_allow_merge, ++ .elevator_allow_bio_merge_fn = bfq_allow_bio_merge, ++ .elevator_allow_rq_merge_fn = bfq_allow_rq_merge, + .elevator_dispatch_fn = bfq_dispatch_requests, + .elevator_add_req_fn = bfq_insert_request, + .elevator_activate_req_fn = bfq_activate_request, +@@ -4351,18 +5208,28 @@ static struct elevator_type iosched_bfq = { + .elevator_owner = THIS_MODULE, + }; + ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++static struct blkcg_policy blkcg_policy_bfq = { ++ .dfl_cftypes = bfq_blkg_files, ++ .legacy_cftypes = bfq_blkcg_legacy_files, ++ ++ .cpd_alloc_fn = bfq_cpd_alloc, ++ .cpd_init_fn = bfq_cpd_init, ++ .cpd_bind_fn = bfq_cpd_init, ++ .cpd_free_fn = bfq_cpd_free, ++ ++ .pd_alloc_fn = bfq_pd_alloc, ++ .pd_init_fn = bfq_pd_init, ++ .pd_offline_fn = bfq_pd_offline, ++ .pd_free_fn = bfq_pd_free, ++ .pd_reset_stats_fn = bfq_pd_reset_stats, ++}; ++#endif ++ + static int __init bfq_init(void) + { + int ret; +- +- /* +- * Can be 0 on HZ < 1000 setups. +- */ +- if (bfq_slice_idle == 0) +- bfq_slice_idle = 1; +- +- if (bfq_timeout_async == 0) +- bfq_timeout_async = 1; ++ char msg[60] = "BFQ I/O-scheduler: v8r6"; + + #ifdef CONFIG_BFQ_GROUP_IOSCHED + ret = blkcg_policy_register(&blkcg_policy_bfq); +@@ -4375,27 +5242,46 @@ static int __init bfq_init(void) + goto err_pol_unreg; + + /* +- * Times to load large popular applications for the typical systems +- * installed on the reference devices (see the comments before the +- * definitions of the two arrays). ++ * Times to load large popular applications for the typical ++ * systems installed on the reference devices (see the ++ * comments before the definitions of the next two ++ * arrays). Actually, we use slightly slower values, as the ++ * estimated peak rate tends to be smaller than the actual ++ * peak rate. The reason for this last fact is that estimates ++ * are computed over much shorter time intervals than the long ++ * intervals typically used for benchmarking. Why? First, to ++ * adapt more quickly to variations. Second, because an I/O ++ * scheduler cannot rely on a peak-rate-evaluation workload to ++ * be run for a long time. + */ +- T_slow[0] = msecs_to_jiffies(2600); +- T_slow[1] = msecs_to_jiffies(1000); +- T_fast[0] = msecs_to_jiffies(5500); +- T_fast[1] = msecs_to_jiffies(2000); ++ T_slow[0] = msecs_to_jiffies(3500); /* actually 4 sec */ ++ T_slow[1] = msecs_to_jiffies(1000); /* actually 1.5 sec */ ++ T_fast[0] = msecs_to_jiffies(7000); /* actually 8 sec */ ++ T_fast[1] = msecs_to_jiffies(2500); /* actually 3 sec */ + + /* +- * Thresholds that determine the switch between speed classes (see +- * the comments before the definition of the array). ++ * Thresholds that determine the switch between speed classes ++ * (see the comments before the definition of the array ++ * device_speed_thresh). These thresholds are biased towards ++ * transitions to the fast class. This is safer than the ++ * opposite bias. In fact, a wrong transition to the slow ++ * class results in short weight-raising periods, because the ++ * speed of the device then tends to be higher that the ++ * reference peak rate. On the opposite end, a wrong ++ * transition to the fast class tends to increase ++ * weight-raising periods, because of the opposite reason. + */ +- device_speed_thresh[0] = (R_fast[0] + R_slow[0]) / 2; +- device_speed_thresh[1] = (R_fast[1] + R_slow[1]) / 2; ++ device_speed_thresh[0] = (4 * R_slow[0]) / 3; ++ device_speed_thresh[1] = (4 * R_slow[1]) / 3; + + ret = elv_register(&iosched_bfq); + if (ret) + goto err_pol_unreg; + +- pr_info("BFQ I/O-scheduler: v7r11"); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ strcat(msg, " (with cgroups support)"); ++#endif ++ pr_info("%s", msg); + + return 0; + +diff --git a/block/bfq-sched.c b/block/bfq-sched.c +index a5ed694..4af77f4 100644 +--- a/block/bfq-sched.c ++++ b/block/bfq-sched.c +@@ -7,28 +7,46 @@ + * Copyright (C) 2008 Fabio Checconi + * Paolo Valente + * +- * Copyright (C) 2010 Paolo Valente ++ * Copyright (C) 2015 Paolo Valente ++ * ++ * Copyright (C) 2016 Paolo Valente + */ + ++static struct bfq_group *bfqq_group(struct bfq_queue *bfqq); ++ ++/** ++ * bfq_gt - compare two timestamps. ++ * @a: first ts. ++ * @b: second ts. ++ * ++ * Return @a > @b, dealing with wrapping correctly. ++ */ ++static int bfq_gt(u64 a, u64 b) ++{ ++ return (s64)(a - b) > 0; ++} ++ + #ifdef CONFIG_BFQ_GROUP_IOSCHED +-#define for_each_entity(entity) \ ++/* both next loops stop at one of the child entities of the root group */ ++#define for_each_entity(entity) \ + for (; entity ; entity = entity->parent) + + #define for_each_entity_safe(entity, parent) \ + for (; entity && ({ parent = entity->parent; 1; }); entity = parent) + + +-static struct bfq_entity *bfq_lookup_next_entity(struct bfq_sched_data *sd, +- int extract, +- struct bfq_data *bfqd); +- +-static struct bfq_group *bfqq_group(struct bfq_queue *bfqq); ++static struct bfq_entity *bfq_lookup_next_entity(struct bfq_sched_data *sd); + +-static void bfq_update_budget(struct bfq_entity *next_in_service) ++/* ++ * Returns true if this budget changes may let next_in_service->parent ++ * become the next_in_service entity for its parent entity. ++ */ ++static bool bfq_update_parent_budget(struct bfq_entity *next_in_service) + { + struct bfq_entity *bfqg_entity; + struct bfq_group *bfqg; + struct bfq_sched_data *group_sd; ++ bool ret = false; + + BUG_ON(!next_in_service); + +@@ -41,39 +59,134 @@ static void bfq_update_budget(struct bfq_entity *next_in_service) + * as it must never become an in-service entity. + */ + bfqg_entity = bfqg->my_entity; +- if (bfqg_entity) ++ if (bfqg_entity) { ++ if (bfqg_entity->budget > next_in_service->budget) ++ ret = true; + bfqg_entity->budget = next_in_service->budget; ++ } ++ ++ return ret; + } + +-static int bfq_update_next_in_service(struct bfq_sched_data *sd) ++static struct bfq_entity *bfq_root_active_entity(struct rb_root *tree) + { +- struct bfq_entity *next_in_service; ++ struct rb_node *node = tree->rb_node; + +- if (sd->in_service_entity) +- /* will update/requeue at the end of service */ +- return 0; ++ return rb_entry(node, struct bfq_entity, rb_node); ++} ++ ++/** ++ * bfq_update_next_in_service - update sd->next_in_service ++ * @sd: sched_data for which to perform the update. ++ * @new_entity: if not NULL, pointer to the entity whose activation, ++ * requeueing or repositionig triggered the invocation of ++ * this function. ++ * ++ * This function is called to update sd->next_in_service, which, in ++ * its turn, may change as a consequence of the insertion or ++ * extraction of an entity into/from one of the active trees of ++ * sd. These insertions/extractions occur as a consequence of ++ * activations/deactivations of entities, with some activations being ++ * 'true' activations, and other activations being requeueings (i.e., ++ * implementing the second, requeueing phase of the mechanism used to ++ * reposition an entity in its active tree; see comments on ++ * __bfq_activate_entity and __bfq_requeue_entity for details). In ++ * both the last two activation sub-cases, new_entity points to the ++ * just activated or requeued entity. ++ * ++ * Returns true if sd->next_in_service changes in such a way that ++ * entity->parent may become the next_in_service for its parent ++ * entity. ++ */ ++static bool bfq_update_next_in_service(struct bfq_sched_data *sd, ++ struct bfq_entity *new_entity) ++{ ++ struct bfq_entity *next_in_service = sd->next_in_service; ++ struct bfq_queue *bfqq; ++ bool parent_sched_may_change = false; + + /* +- * NOTE: this can be improved in many ways, such as returning +- * 1 (and thus propagating upwards the update) only when the +- * budget changes, or caching the bfqq that will be scheduled +- * next from this subtree. By now we worry more about +- * correctness than about performance... ++ * If this update is triggered by the activation, requeueing ++ * or repositiong of an entity that does not coincide with ++ * sd->next_in_service, then a full lookup in the active tree ++ * can be avoided. In fact, it is enough to check whether the ++ * just-modified entity has a higher priority than ++ * sd->next_in_service, or, even if it has the same priority ++ * as sd->next_in_service, is eligible and has a lower virtual ++ * finish time than sd->next_in_service. If this compound ++ * condition holds, then the new entity becomes the new ++ * next_in_service. Otherwise no change is needed. + */ +- next_in_service = bfq_lookup_next_entity(sd, 0, NULL); ++ if (new_entity && new_entity != sd->next_in_service) { ++ /* ++ * Flag used to decide whether to replace ++ * sd->next_in_service with new_entity. Tentatively ++ * set to true, and left as true if ++ * sd->next_in_service is NULL. ++ */ ++ bool replace_next = true; ++ ++ /* ++ * If there is already a next_in_service candidate ++ * entity, then compare class priorities or timestamps ++ * to decide whether to replace sd->service_tree with ++ * new_entity. ++ */ ++ if (next_in_service) { ++ unsigned int new_entity_class_idx = ++ bfq_class_idx(new_entity); ++ struct bfq_service_tree *st = ++ sd->service_tree + new_entity_class_idx; ++ ++ /* ++ * For efficiency, evaluate the most likely ++ * sub-condition first. ++ */ ++ replace_next = ++ (new_entity_class_idx == ++ bfq_class_idx(next_in_service) ++ && ++ !bfq_gt(new_entity->start, st->vtime) ++ && ++ bfq_gt(next_in_service->finish, ++ new_entity->finish)) ++ || ++ new_entity_class_idx < ++ bfq_class_idx(next_in_service); ++ } ++ ++ if (replace_next) ++ next_in_service = new_entity; ++ } else /* invoked because of a deactivation: lookup needed */ ++ next_in_service = bfq_lookup_next_entity(sd); ++ ++ if (next_in_service) { ++ parent_sched_may_change = !sd->next_in_service || ++ bfq_update_parent_budget(next_in_service); ++ } ++ + sd->next_in_service = next_in_service; + +- if (next_in_service) +- bfq_update_budget(next_in_service); ++ if (!next_in_service) ++ return parent_sched_may_change; + +- return 1; +-} ++ bfqq = bfq_entity_to_bfqq(next_in_service); ++ if (bfqq) ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "update_next_in_service: chosen this queue"); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ else { ++ struct bfq_group *bfqg = ++ container_of(next_in_service, ++ struct bfq_group, entity); + +-static void bfq_check_next_in_service(struct bfq_sched_data *sd, +- struct bfq_entity *entity) +-{ +- BUG_ON(sd->next_in_service != entity); ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "update_next_in_service: chosen this entity"); ++ } ++#endif ++ return parent_sched_may_change; + } ++ + #else + #define for_each_entity(entity) \ + for (; entity ; entity = NULL) +@@ -86,12 +199,7 @@ static int bfq_update_next_in_service(struct bfq_sched_data *sd) + return 0; + } + +-static void bfq_check_next_in_service(struct bfq_sched_data *sd, +- struct bfq_entity *entity) +-{ +-} +- +-static void bfq_update_budget(struct bfq_entity *next_in_service) ++static void bfq_update_parent_budget(struct bfq_entity *next_in_service) + { + } + #endif +@@ -105,18 +213,6 @@ static void bfq_update_budget(struct bfq_entity *next_in_service) + */ + #define WFQ_SERVICE_SHIFT 22 + +-/** +- * bfq_gt - compare two timestamps. +- * @a: first ts. +- * @b: second ts. +- * +- * Return @a > @b, dealing with wrapping correctly. +- */ +-static int bfq_gt(u64 a, u64 b) +-{ +- return (s64)(a - b) > 0; +-} +- + static struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity) + { + struct bfq_queue *bfqq = NULL; +@@ -151,20 +247,36 @@ static u64 bfq_delta(unsigned long service, unsigned long weight) + static void bfq_calc_finish(struct bfq_entity *entity, unsigned long service) + { + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); ++ unsigned long long start, finish, delta; + + BUG_ON(entity->weight == 0); + + entity->finish = entity->start + + bfq_delta(service, entity->weight); + ++ start = ((entity->start>>10)*1000)>>12; ++ finish = ((entity->finish>>10)*1000)>>12; ++ delta = ((bfq_delta(service, entity->weight)>>10)*1000)>>12; ++ + if (bfqq) { + bfq_log_bfqq(bfqq->bfqd, bfqq, + "calc_finish: serv %lu, w %d", + service, entity->weight); + bfq_log_bfqq(bfqq->bfqd, bfqq, + "calc_finish: start %llu, finish %llu, delta %llu", +- entity->start, entity->finish, +- bfq_delta(service, entity->weight)); ++ start, finish, delta); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ } else { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "calc_finish group: serv %lu, w %d", ++ service, entity->weight); ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "calc_finish group: start %llu, finish %llu, delta %llu", ++ start, finish, delta); ++#endif + } + } + +@@ -293,10 +405,26 @@ static void bfq_update_min(struct bfq_entity *entity, struct rb_node *node) + static void bfq_update_active_node(struct rb_node *node) + { + struct bfq_entity *entity = rb_entry(node, struct bfq_entity, rb_node); ++ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); + + entity->min_start = entity->start; + bfq_update_min(entity, node->rb_right); + bfq_update_min(entity, node->rb_left); ++ ++ if (bfqq) { ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "update_active_node: new min_start %llu", ++ ((entity->min_start>>10)*1000)>>12); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ } else { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "update_active_node: new min_start %llu", ++ ((entity->min_start>>10)*1000)>>12); ++#endif ++ } + } + + /** +@@ -386,8 +514,6 @@ static void bfq_active_insert(struct bfq_service_tree *st, + BUG_ON(!bfqg); + BUG_ON(!bfqd); + bfqg->active_entities++; +- if (bfqg->active_entities == 2) +- bfqd->active_numerous_groups++; + } + #endif + } +@@ -399,7 +525,7 @@ static void bfq_active_insert(struct bfq_service_tree *st, + static unsigned short bfq_ioprio_to_weight(int ioprio) + { + BUG_ON(ioprio < 0 || ioprio >= IOPRIO_BE_NR); +- return IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF - ioprio; ++ return (IOPRIO_BE_NR - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF; + } + + /** +@@ -422,9 +548,9 @@ static void bfq_get_entity(struct bfq_entity *entity) + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); + + if (bfqq) { +- atomic_inc(&bfqq->ref); ++ bfqq->ref++; + bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d", +- bfqq, atomic_read(&bfqq->ref)); ++ bfqq, bfqq->ref); + } + } + +@@ -499,10 +625,6 @@ static void bfq_active_extract(struct bfq_service_tree *st, + BUG_ON(!bfqd); + BUG_ON(!bfqg->active_entities); + bfqg->active_entities--; +- if (bfqg->active_entities == 1) { +- BUG_ON(!bfqd->active_numerous_groups); +- bfqd->active_numerous_groups--; +- } + } + #endif + } +@@ -547,12 +669,12 @@ static void bfq_forget_entity(struct bfq_service_tree *st, + + BUG_ON(!entity->on_st); + +- entity->on_st = 0; ++ entity->on_st = false; + st->wsum -= entity->weight; + if (bfqq) { + sd = entity->sched_data; + bfq_log_bfqq(bfqq->bfqd, bfqq, "forget_entity: %p %d", +- bfqq, atomic_read(&bfqq->ref)); ++ bfqq, bfqq->ref); + bfq_put_queue(bfqq); + } + } +@@ -602,7 +724,7 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, + + if (entity->prio_changed) { + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); +- unsigned short prev_weight, new_weight; ++ unsigned int prev_weight, new_weight; + struct bfq_data *bfqd = NULL; + struct rb_root *root; + #ifdef CONFIG_BFQ_GROUP_IOSCHED +@@ -630,7 +752,10 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, + entity->new_weight > BFQ_MAX_WEIGHT) { + pr_crit("update_weight_prio: new_weight %d\n", + entity->new_weight); +- BUG(); ++ if (entity->new_weight < BFQ_MIN_WEIGHT) ++ entity->new_weight = BFQ_MIN_WEIGHT; ++ else ++ entity->new_weight = BFQ_MAX_WEIGHT; + } + entity->orig_weight = entity->new_weight; + if (bfqq) +@@ -661,6 +786,13 @@ __bfq_entity_update_weight_prio(struct bfq_service_tree *old_st, + * associated with its new weight. + */ + if (prev_weight != new_weight) { ++ if (bfqq) ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "weight changed %d %d(%d %d)", ++ prev_weight, new_weight, ++ entity->orig_weight, ++ bfqq->wr_coeff); ++ + root = bfqq ? &bfqd->queue_weights_tree : + &bfqd->group_weights_tree; + bfq_weights_tree_remove(bfqd, entity, root); +@@ -707,7 +839,7 @@ static void bfq_bfqq_served(struct bfq_queue *bfqq, int served) + st = bfq_entity_service_tree(entity); + + entity->service += served; +- BUG_ON(entity->service > entity->budget); ++ + BUG_ON(st->wsum == 0); + + st->vtime += bfq_delta(served, st->wsum); +@@ -716,170 +848,419 @@ static void bfq_bfqq_served(struct bfq_queue *bfqq, int served) + #ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_set_start_empty_time(bfqq_group(bfqq)); + #endif +- bfq_log_bfqq(bfqq->bfqd, bfqq, "bfqq_served %d secs", served); ++ st = bfq_entity_service_tree(&bfqq->entity); ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "bfqq_served %d secs, vtime %llu on %p", ++ served, ((st->vtime>>10)*1000)>>12, st); + } + + /** +- * bfq_bfqq_charge_full_budget - set the service to the entity budget. ++ * bfq_bfqq_charge_time - charge an amount of service equivalent to the length ++ * of the time interval during which bfqq has been in ++ * service. ++ * @bfqd: the device + * @bfqq: the queue that needs a service update. ++ * @time_ms: the amount of time during which the queue has received service ++ * ++ * If a queue does not consume its budget fast enough, then providing ++ * the queue with service fairness may impair throughput, more or less ++ * severely. For this reason, queues that consume their budget slowly ++ * are provided with time fairness instead of service fairness. This ++ * goal is achieved through the BFQ scheduling engine, even if such an ++ * engine works in the service, and not in the time domain. The trick ++ * is charging these queues with an inflated amount of service, equal ++ * to the amount of service that they would have received during their ++ * service slot if they had been fast, i.e., if their requests had ++ * been dispatched at a rate equal to the estimated peak rate. + * +- * When it's not possible to be fair in the service domain, because +- * a queue is not consuming its budget fast enough (the meaning of +- * fast depends on the timeout parameter), we charge it a full +- * budget. In this way we should obtain a sort of time-domain +- * fairness among all the seeky/slow queues. ++ * It is worth noting that time fairness can cause important ++ * distortions in terms of bandwidth distribution, on devices with ++ * internal queueing. The reason is that I/O requests dispatched ++ * during the service slot of a queue may be served after that service ++ * slot is finished, and may have a total processing time loosely ++ * correlated with the duration of the service slot. This is ++ * especially true for short service slots. + */ +-static void bfq_bfqq_charge_full_budget(struct bfq_queue *bfqq) ++static void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq, ++ unsigned long time_ms) + { + struct bfq_entity *entity = &bfqq->entity; ++ int tot_serv_to_charge = entity->service; ++ unsigned int timeout_ms = jiffies_to_msecs(bfq_timeout); ++ ++ if (time_ms > 0 && time_ms < timeout_ms) ++ tot_serv_to_charge = ++ (bfqd->bfq_max_budget * time_ms) / timeout_ms; ++ ++ if (tot_serv_to_charge < entity->service) ++ tot_serv_to_charge = entity->service; + +- bfq_log_bfqq(bfqq->bfqd, bfqq, "charge_full_budget"); ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "charge_time: %lu/%u ms, %d/%d/%d sectors", ++ time_ms, timeout_ms, entity->service, ++ tot_serv_to_charge, entity->budget); + +- bfq_bfqq_served(bfqq, entity->budget - entity->service); ++ /* Increase budget to avoid inconsistencies */ ++ if (tot_serv_to_charge > entity->budget) ++ entity->budget = tot_serv_to_charge; ++ ++ bfq_bfqq_served(bfqq, ++ max_t(int, 0, tot_serv_to_charge - entity->service)); ++} ++ ++static void bfq_update_fin_time_enqueue(struct bfq_entity *entity, ++ struct bfq_service_tree *st, ++ bool backshifted) ++{ ++ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); ++ struct bfq_sched_data *sd = entity->sched_data; ++ ++ st = __bfq_entity_update_weight_prio(st, entity); ++ bfq_calc_finish(entity, entity->budget); ++ ++ /* ++ * If some queues enjoy backshifting for a while, then their ++ * (virtual) finish timestamps may happen to become lower and ++ * lower than the system virtual time. In particular, if ++ * these queues often happen to be idle for short time ++ * periods, and during such time periods other queues with ++ * higher timestamps happen to be busy, then the backshifted ++ * timestamps of the former queues can become much lower than ++ * the system virtual time. In fact, to serve the queues with ++ * higher timestamps while the ones with lower timestamps are ++ * idle, the system virtual time may be pushed-up to much ++ * higher values than the finish timestamps of the idle ++ * queues. As a consequence, the finish timestamps of all new ++ * or newly activated queues may end up being much larger than ++ * those of lucky queues with backshifted timestamps. The ++ * latter queues may then monopolize the device for a lot of ++ * time. This would simply break service guarantees. ++ * ++ * To reduce this problem, push up a little bit the ++ * backshifted timestamps of the queue associated with this ++ * entity (only a queue can happen to have the backshifted ++ * flag set): just enough to let the finish timestamp of the ++ * queue be equal to the current value of the system virtual ++ * time. This may introduce a little unfairness among queues ++ * with backshifted timestamps, but it does not break ++ * worst-case fairness guarantees. ++ * ++ * As a special case, if bfqq is weight-raised, push up ++ * timestamps much less, to keep very low the probability that ++ * this push up causes the backshifted finish timestamps of ++ * weight-raised queues to become higher than the backshifted ++ * finish timestamps of non weight-raised queues. ++ */ ++ if (backshifted && bfq_gt(st->vtime, entity->finish)) { ++ unsigned long delta = st->vtime - entity->finish; ++ ++ if (bfqq) ++ delta /= bfqq->wr_coeff; ++ ++ entity->start += delta; ++ entity->finish += delta; ++ ++ if (bfqq) { ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "__activate_entity: new queue finish %llu", ++ ((entity->finish>>10)*1000)>>12); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ } else { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "__activate_entity: new group finish %llu", ++ ((entity->finish>>10)*1000)>>12); ++#endif ++ } ++ } ++ ++ bfq_active_insert(st, entity); ++ ++ if (bfqq) { ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "__activate_entity: queue %seligible in st %p", ++ entity->start <= st->vtime ? "" : "non ", st); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ } else { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "__activate_entity: group %seligible in st %p", ++ entity->start <= st->vtime ? "" : "non ", st); ++#endif ++ } ++ BUG_ON(RB_EMPTY_ROOT(&st->active)); ++ BUG_ON(&st->active != &sd->service_tree->active && ++ &st->active != &(sd->service_tree+1)->active && ++ &st->active != &(sd->service_tree+2)->active); + } + + /** +- * __bfq_activate_entity - activate an entity. ++ * __bfq_activate_entity - handle activation of entity. + * @entity: the entity being activated. ++ * @non_blocking_wait_rq: true if entity was waiting for a request ++ * ++ * Called for a 'true' activation, i.e., if entity is not active and ++ * one of its children receives a new request. + * +- * Called whenever an entity is activated, i.e., it is not active and one +- * of its children receives a new request, or has to be reactivated due to +- * budget exhaustion. It uses the current budget of the entity (and the +- * service received if @entity is active) of the queue to calculate its +- * timestamps. ++ * Basically, this function updates the timestamps of entity and ++ * inserts entity into its active tree, ater possible extracting it ++ * from its idle tree. + */ +-static void __bfq_activate_entity(struct bfq_entity *entity) ++static void __bfq_activate_entity(struct bfq_entity *entity, ++ bool non_blocking_wait_rq) + { + struct bfq_sched_data *sd = entity->sched_data; + struct bfq_service_tree *st = bfq_entity_service_tree(entity); ++ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); ++ bool backshifted = false; ++ unsigned long long min_vstart; + +- if (entity == sd->in_service_entity) { +- BUG_ON(entity->tree); +- /* +- * If we are requeueing the current entity we have +- * to take care of not charging to it service it has +- * not received. +- */ +- bfq_calc_finish(entity, entity->service); +- entity->start = entity->finish; +- sd->in_service_entity = NULL; +- } else if (entity->tree == &st->active) { +- /* +- * Requeueing an entity due to a change of some +- * next_in_service entity below it. We reuse the +- * old start time. +- */ +- bfq_active_extract(st, entity); +- } else if (entity->tree == &st->idle) { ++ BUG_ON(!sd); ++ BUG_ON(!st); ++ ++ /* See comments on bfq_fqq_update_budg_for_activation */ ++ if (non_blocking_wait_rq && bfq_gt(st->vtime, entity->finish)) { ++ backshifted = true; ++ min_vstart = entity->finish; ++ } else ++ min_vstart = st->vtime; ++ ++ if (entity->tree == &st->idle) { + /* + * Must be on the idle tree, bfq_idle_extract() will + * check for that. + */ + bfq_idle_extract(st, entity); +- entity->start = bfq_gt(st->vtime, entity->finish) ? +- st->vtime : entity->finish; ++ entity->start = bfq_gt(min_vstart, entity->finish) ? ++ min_vstart : entity->finish; + } else { + /* + * The finish time of the entity may be invalid, and + * it is in the past for sure, otherwise the queue + * would have been on the idle tree. + */ +- entity->start = st->vtime; ++ entity->start = min_vstart; + st->wsum += entity->weight; + bfq_get_entity(entity); + +- BUG_ON(entity->on_st); +- entity->on_st = 1; ++ BUG_ON(entity->on_st && bfqq); ++ ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ if (entity->on_st && !bfqq) { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, ++ entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, ++ bfqg, ++ "activate bug, class %d in_service %p", ++ bfq_class_idx(entity), sd->in_service_entity); ++ } ++#endif ++ BUG_ON(entity->on_st && !bfqq); ++ entity->on_st = true; + } + +- st = __bfq_entity_update_weight_prio(st, entity); +- bfq_calc_finish(entity, entity->budget); +- bfq_active_insert(st, entity); ++ bfq_update_fin_time_enqueue(entity, st, backshifted); + } + + /** +- * bfq_activate_entity - activate an entity and its ancestors if necessary. +- * @entity: the entity to activate. ++ * __bfq_requeue_entity - handle requeueing or repositioning of an entity. ++ * @entity: the entity being requeued or repositioned. + * +- * Activate @entity and all the entities on the path from it to the root. ++ * Requeueing is needed if this entity stops being served, which ++ * happens if a leaf descendant entity has expired. On the other hand, ++ * repositioning is needed if the next_inservice_entity for the child ++ * entity has changed. See the comments inside the function for ++ * details. ++ * ++ * Basically, this function: 1) removes entity from its active tree if ++ * present there, 2) updates the timestamps of entity and 3) inserts ++ * entity back into its active tree (in the new, right position for ++ * the new values of the timestamps). ++ */ ++static void __bfq_requeue_entity(struct bfq_entity *entity) ++{ ++ struct bfq_sched_data *sd = entity->sched_data; ++ struct bfq_service_tree *st = bfq_entity_service_tree(entity); ++ ++ BUG_ON(!sd); ++ BUG_ON(!st); ++ ++ BUG_ON(entity != sd->in_service_entity && ++ entity->tree != &st->active); ++ ++ if (entity == sd->in_service_entity) { ++ /* ++ * We are requeueing the current in-service entity, ++ * which may have to be done for one of the following ++ * reasons: ++ * - entity represents the in-service queue, and the ++ * in-service queue is being requeued after an ++ * expiration; ++ * - entity represents a group, and its budget has ++ * changed because one of its child entities has ++ * just been either activated or requeued for some ++ * reason; the timestamps of the entity need then to ++ * be updated, and the entity needs to be enqueued ++ * or repositioned accordingly. ++ * ++ * In particular, before requeueing, the start time of ++ * the entity must be moved forward to account for the ++ * service that the entity has received while in ++ * service. This is done by the next instructions. The ++ * finish time will then be updated according to this ++ * new value of the start time, and to the budget of ++ * the entity. ++ */ ++ bfq_calc_finish(entity, entity->service); ++ entity->start = entity->finish; ++ BUG_ON(entity->tree && entity->tree != &st->active); ++ /* ++ * In addition, if the entity had more than one child ++ * when set in service, then was not extracted from ++ * the active tree. This implies that the position of ++ * the entity in the active tree may need to be ++ * changed now, because we have just updated the start ++ * time of the entity, and we will update its finish ++ * time in a moment (the requeueing is then, more ++ * precisely, a repositioning in this case). To ++ * implement this repositioning, we: 1) dequeue the ++ * entity here, 2) update the finish time and ++ * requeue the entity according to the new ++ * timestamps below. ++ */ ++ if (entity->tree) ++ bfq_active_extract(st, entity); ++ } else { /* The entity is already active, and not in service */ ++ /* ++ * In this case, this function gets called only if the ++ * next_in_service entity below this entity has ++ * changed, and this change has caused the budget of ++ * this entity to change, which, finally implies that ++ * the finish time of this entity must be ++ * updated. Such an update may cause the scheduling, ++ * i.e., the position in the active tree, of this ++ * entity to change. We handle this change by: 1) ++ * dequeueing the entity here, 2) updating the finish ++ * time and requeueing the entity according to the new ++ * timestamps below. This is the same approach as the ++ * non-extracted-entity sub-case above. ++ */ ++ bfq_active_extract(st, entity); ++ } ++ ++ bfq_update_fin_time_enqueue(entity, st, false); ++} ++ ++static void __bfq_activate_requeue_entity(struct bfq_entity *entity, ++ struct bfq_sched_data *sd, ++ bool non_blocking_wait_rq) ++{ ++ struct bfq_service_tree *st = bfq_entity_service_tree(entity); ++ ++ if (sd->in_service_entity == entity || entity->tree == &st->active) ++ /* ++ * in service or already queued on the active tree, ++ * requeue or reposition ++ */ ++ __bfq_requeue_entity(entity); ++ else ++ /* ++ * Not in service and not queued on its active tree: ++ * the activity is idle and this is a true activation. ++ */ ++ __bfq_activate_entity(entity, non_blocking_wait_rq); ++} ++ ++ ++/** ++ * bfq_activate_entity - activate or requeue an entity representing a bfq_queue, ++ * and activate, requeue or reposition all ancestors ++ * for which such an update becomes necessary. ++ * @entity: the entity to activate. ++ * @non_blocking_wait_rq: true if this entity was waiting for a request ++ * @requeue: true if this is a requeue, which implies that bfqq is ++ * being expired; thus ALL its ancestors stop being served and must ++ * therefore be requeued + */ +-static void bfq_activate_entity(struct bfq_entity *entity) ++static void bfq_activate_requeue_entity(struct bfq_entity *entity, ++ bool non_blocking_wait_rq, ++ bool requeue) + { + struct bfq_sched_data *sd; + + for_each_entity(entity) { +- __bfq_activate_entity(entity); +- ++ BUG_ON(!entity); + sd = entity->sched_data; +- if (!bfq_update_next_in_service(sd)) +- /* +- * No need to propagate the activation to the +- * upper entities, as they will be updated when +- * the in-service entity is rescheduled. +- */ ++ __bfq_activate_requeue_entity(entity, sd, non_blocking_wait_rq); ++ ++ BUG_ON(RB_EMPTY_ROOT(&sd->service_tree->active) && ++ RB_EMPTY_ROOT(&(sd->service_tree+1)->active) && ++ RB_EMPTY_ROOT(&(sd->service_tree+2)->active)); ++ ++ if (!bfq_update_next_in_service(sd, entity) && !requeue) { ++ BUG_ON(!sd->next_in_service); + break; ++ } ++ BUG_ON(!sd->next_in_service); + } + } + + /** + * __bfq_deactivate_entity - deactivate an entity from its service tree. + * @entity: the entity to deactivate. +- * @requeue: if false, the entity will not be put into the idle tree. +- * +- * Deactivate an entity, independently from its previous state. If the +- * entity was not on a service tree just return, otherwise if it is on +- * any scheduler tree, extract it from that tree, and if necessary +- * and if the caller did not specify @requeue, put it on the idle tree. ++ * @ins_into_idle_tree: if false, the entity will not be put into the ++ * idle tree. + * +- * Return %1 if the caller should update the entity hierarchy, i.e., +- * if the entity was in service or if it was the next_in_service for +- * its sched_data; return %0 otherwise. ++ * Deactivates an entity, independently from its previous state. Must ++ * be invoked only if entity is on a service tree. Extracts the entity ++ * from that tree, and if necessary and allowed, puts it on the idle ++ * tree. + */ +-static int __bfq_deactivate_entity(struct bfq_entity *entity, int requeue) ++static bool __bfq_deactivate_entity(struct bfq_entity *entity, ++ bool ins_into_idle_tree) + { + struct bfq_sched_data *sd = entity->sched_data; +- struct bfq_service_tree *st; +- int was_in_service; +- int ret = 0; +- +- if (sd == NULL || !entity->on_st) /* never activated, or inactive */ +- return 0; ++ struct bfq_service_tree *st = bfq_entity_service_tree(entity); ++ bool was_in_service = entity == sd->in_service_entity; + +- st = bfq_entity_service_tree(entity); +- was_in_service = entity == sd->in_service_entity; ++ if (!entity->on_st) { /* entity never activated, or already inactive */ ++ BUG_ON(entity == entity->sched_data->in_service_entity); ++ return false; ++ } + +- BUG_ON(was_in_service && entity->tree); ++ BUG_ON(was_in_service && entity->tree && entity->tree != &st->active); + +- if (was_in_service) { ++ if (was_in_service) + bfq_calc_finish(entity, entity->service); +- sd->in_service_entity = NULL; +- } else if (entity->tree == &st->active) ++ ++ if (entity->tree == &st->active) + bfq_active_extract(st, entity); +- else if (entity->tree == &st->idle) ++ else if (!was_in_service && entity->tree == &st->idle) + bfq_idle_extract(st, entity); + else if (entity->tree) + BUG(); + +- if (was_in_service || sd->next_in_service == entity) +- ret = bfq_update_next_in_service(sd); +- +- if (!requeue || !bfq_gt(entity->finish, st->vtime)) ++ if (!ins_into_idle_tree || !bfq_gt(entity->finish, st->vtime)) + bfq_forget_entity(st, entity); + else + bfq_idle_insert(st, entity); + +- BUG_ON(sd->in_service_entity == entity); +- BUG_ON(sd->next_in_service == entity); +- +- return ret; ++ return true; + } + + /** +- * bfq_deactivate_entity - deactivate an entity. ++ * bfq_deactivate_entity - deactivate an entity representing a bfq_queue. + * @entity: the entity to deactivate. +- * @requeue: true if the entity can be put on the idle tree ++ * @ins_into_idle_tree: true if the entity can be put on the idle tree + */ +-static void bfq_deactivate_entity(struct bfq_entity *entity, int requeue) ++static void bfq_deactivate_entity(struct bfq_entity *entity, ++ bool ins_into_idle_tree, ++ bool expiration) + { + struct bfq_sched_data *sd; + struct bfq_entity *parent; +@@ -887,63 +1268,153 @@ static void bfq_deactivate_entity(struct bfq_entity *entity, int requeue) + for_each_entity_safe(entity, parent) { + sd = entity->sched_data; + +- if (!__bfq_deactivate_entity(entity, requeue)) ++ BUG_ON(sd == NULL); /* ++ * It would mean that this is the ++ * root group. ++ */ ++ ++ BUG_ON(expiration && entity != sd->in_service_entity); ++ ++ BUG_ON(entity != sd->in_service_entity && ++ entity->tree == ++ &bfq_entity_service_tree(entity)->active && ++ !sd->next_in_service); ++ ++ if (!__bfq_deactivate_entity(entity, ins_into_idle_tree)) { + /* +- * The parent entity is still backlogged, and +- * we don't need to update it as it is still +- * in service. ++ * Entity is not any tree any more, so, this ++ * deactivation is a no-op, and there is ++ * nothing to change for upper-level entities ++ * (in case of expiration, this can never ++ * happen). + */ +- break; ++ BUG_ON(expiration); /* ++ * entity cannot be already out of ++ * any tree ++ */ ++ return; ++ } + +- if (sd->next_in_service) ++ if (sd->next_in_service == entity) + /* +- * The parent entity is still backlogged and +- * the budgets on the path towards the root +- * need to be updated. ++ * entity was the next_in_service entity, ++ * then, since entity has just been ++ * deactivated, a new one must be found. + */ +- goto update; ++ bfq_update_next_in_service(sd, NULL); ++ ++ if (sd->next_in_service) { ++ /* ++ * The parent entity is still backlogged, ++ * because next_in_service is not NULL. So, no ++ * further upwards deactivation must be ++ * performed. Yet, next_in_service has ++ * changed. Then the schedule does need to be ++ * updated upwards. ++ */ ++ BUG_ON(sd->next_in_service == entity); ++ break; ++ } + + /* +- * If we reach there the parent is no more backlogged and +- * we want to propagate the dequeue upwards. ++ * If we get here, then the parent is no more ++ * backlogged and we need to propagate the ++ * deactivation upwards. Thus let the loop go on. + */ +- requeue = 1; +- } + +- return; ++ /* ++ * Also let parent be queued into the idle tree on ++ * deactivation, to preserve service guarantees, and ++ * assuming that who invoked this function does not ++ * need parent entities too to be removed completely. ++ */ ++ ins_into_idle_tree = true; ++ } + +-update: ++ /* ++ * If the deactivation loop is fully executed, then there are ++ * no more entities to touch and next loop is not executed at ++ * all. Otherwise, requeue remaining entities if they are ++ * about to stop receiving service, or reposition them if this ++ * is not the case. ++ */ + entity = parent; + for_each_entity(entity) { +- __bfq_activate_entity(entity); ++ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); ++ ++ /* ++ * Invoke __bfq_requeue_entity on entity, even if ++ * already active, to requeue/reposition it in the ++ * active tree (because sd->next_in_service has ++ * changed) ++ */ ++ __bfq_requeue_entity(entity); + + sd = entity->sched_data; +- if (!bfq_update_next_in_service(sd)) ++ BUG_ON(expiration && sd->in_service_entity != entity); ++ ++ if (bfqq) ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "invoking udpdate_next for this queue"); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ else { ++ struct bfq_group *bfqg = ++ container_of(entity, ++ struct bfq_group, entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "invoking udpdate_next for this entity"); ++ } ++#endif ++ if (!bfq_update_next_in_service(sd, entity) && ++ !expiration) ++ /* ++ * next_in_service unchanged, and no ++ * requeueing needed for expiration: stop ++ * here. ++ */ + break; + } + } + + /** +- * bfq_update_vtime - update vtime if necessary. ++ * bfq_calc_vtime_jump - compute the value to which the vtime should jump, ++ * if needed, to have at least one entity eligible. + * @st: the service tree to act upon. + * +- * If necessary update the service tree vtime to have at least one +- * eligible entity, skipping to its start time. Assumes that the +- * active tree of the device is not empty. +- * +- * NOTE: this hierarchical implementation updates vtimes quite often, +- * we may end up with reactivated processes getting timestamps after a +- * vtime skip done because we needed a ->first_active entity on some +- * intermediate node. ++ * Assumes that st is not empty. + */ +-static void bfq_update_vtime(struct bfq_service_tree *st) ++static u64 bfq_calc_vtime_jump(struct bfq_service_tree *st) + { +- struct bfq_entity *entry; +- struct rb_node *node = st->active.rb_node; ++ struct bfq_entity *root_entity = bfq_root_active_entity(&st->active); + +- entry = rb_entry(node, struct bfq_entity, rb_node); +- if (bfq_gt(entry->min_start, st->vtime)) { +- st->vtime = entry->min_start; ++ if (bfq_gt(root_entity->min_start, st->vtime)) { ++ struct bfq_queue *bfqq = bfq_entity_to_bfqq(root_entity); ++ ++ if (bfqq) ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "calc_vtime_jump: new value %llu", ++ root_entity->min_start); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ else { ++ struct bfq_group *bfqg = ++ container_of(root_entity, struct bfq_group, ++ entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "calc_vtime_jump: new value %llu", ++ root_entity->min_start); ++ } ++#endif ++ return root_entity->min_start; ++ } ++ return st->vtime; ++} ++ ++static void bfq_update_vtime(struct bfq_service_tree *st, u64 new_value) ++{ ++ if (new_value > st->vtime) { ++ st->vtime = new_value; + bfq_forget_idle(st); + } + } +@@ -952,6 +1423,7 @@ static void bfq_update_vtime(struct bfq_service_tree *st) + * bfq_first_active_entity - find the eligible entity with + * the smallest finish time + * @st: the service tree to select from. ++ * @vtime: the system virtual to use as a reference for eligibility + * + * This function searches the first schedulable entity, starting from the + * root of the tree and going on the left every time on this side there is +@@ -959,7 +1431,8 @@ static void bfq_update_vtime(struct bfq_service_tree *st) + * the right is followed only if a) the left subtree contains no eligible + * entities and b) no eligible entity has been found yet. + */ +-static struct bfq_entity *bfq_first_active_entity(struct bfq_service_tree *st) ++static struct bfq_entity *bfq_first_active_entity(struct bfq_service_tree *st, ++ u64 vtime) + { + struct bfq_entity *entry, *first = NULL; + struct rb_node *node = st->active.rb_node; +@@ -967,15 +1440,15 @@ static struct bfq_entity *bfq_first_active_entity(struct bfq_service_tree *st) + while (node) { + entry = rb_entry(node, struct bfq_entity, rb_node); + left: +- if (!bfq_gt(entry->start, st->vtime)) ++ if (!bfq_gt(entry->start, vtime)) + first = entry; + +- BUG_ON(bfq_gt(entry->min_start, st->vtime)); ++ BUG_ON(bfq_gt(entry->min_start, vtime)); + + if (node->rb_left) { + entry = rb_entry(node->rb_left, + struct bfq_entity, rb_node); +- if (!bfq_gt(entry->min_start, st->vtime)) { ++ if (!bfq_gt(entry->min_start, vtime)) { + node = node->rb_left; + goto left; + } +@@ -993,31 +1466,84 @@ static struct bfq_entity *bfq_first_active_entity(struct bfq_service_tree *st) + * __bfq_lookup_next_entity - return the first eligible entity in @st. + * @st: the service tree. + * +- * Update the virtual time in @st and return the first eligible entity +- * it contains. ++ * If there is no in-service entity for the sched_data st belongs to, ++ * then return the entity that will be set in service if: ++ * 1) the parent entity this st belongs to is set in service; ++ * 2) no entity belonging to such parent entity undergoes a state change ++ * that would influence the timestamps of the entity (e.g., becomes idle, ++ * becomes backlogged, changes its budget, ...). ++ * ++ * In this first case, update the virtual time in @st too (see the ++ * comments on this update inside the function). ++ * ++ * In constrast, if there is an in-service entity, then return the ++ * entity that would be set in service if not only the above ++ * conditions, but also the next one held true: the currently ++ * in-service entity, on expiration, ++ * 1) gets a finish time equal to the current one, or ++ * 2) is not eligible any more, or ++ * 3) is idle. + */ +-static struct bfq_entity *__bfq_lookup_next_entity(struct bfq_service_tree *st, +- bool force) ++static struct bfq_entity * ++__bfq_lookup_next_entity(struct bfq_service_tree *st, bool in_service ++#if 0 ++ , bool force ++#endif ++ ) + { +- struct bfq_entity *entity, *new_next_in_service = NULL; ++ struct bfq_entity *entity ++#if 0 ++ , *new_next_in_service = NULL ++#endif ++ ; ++ u64 new_vtime; ++ struct bfq_queue *bfqq; + + if (RB_EMPTY_ROOT(&st->active)) + return NULL; + +- bfq_update_vtime(st); +- entity = bfq_first_active_entity(st); +- BUG_ON(bfq_gt(entity->start, st->vtime)); ++ /* ++ * Get the value of the system virtual time for which at ++ * least one entity is eligible. ++ */ ++ new_vtime = bfq_calc_vtime_jump(st); + + /* +- * If the chosen entity does not match with the sched_data's +- * next_in_service and we are forcedly serving the IDLE priority +- * class tree, bubble up budget update. ++ * If there is no in-service entity for the sched_data this ++ * active tree belongs to, then push the system virtual time ++ * up to the value that guarantees that at least one entity is ++ * eligible. If, instead, there is an in-service entity, then ++ * do not make any such update, because there is already an ++ * eligible entity, namely the in-service one (even if the ++ * entity is not on st, because it was extracted when set in ++ * service). + */ +- if (unlikely(force && entity != entity->sched_data->next_in_service)) { +- new_next_in_service = entity; +- for_each_entity(new_next_in_service) +- bfq_update_budget(new_next_in_service); ++ if (!in_service) ++ bfq_update_vtime(st, new_vtime); ++ ++ entity = bfq_first_active_entity(st, new_vtime); ++ BUG_ON(bfq_gt(entity->start, new_vtime)); ++ ++ /* Log some information */ ++ bfqq = bfq_entity_to_bfqq(entity); ++ if (bfqq) ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "__lookup_next: start %llu vtime %llu st %p", ++ ((entity->start>>10)*1000)>>12, ++ ((new_vtime>>10)*1000)>>12, st); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ else { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "__lookup_next: start %llu vtime %llu st %p", ++ ((entity->start>>10)*1000)>>12, ++ ((new_vtime>>10)*1000)>>12, st); + } ++#endif ++ ++ BUG_ON(!entity); + + return entity; + } +@@ -1025,50 +1551,118 @@ static struct bfq_entity *__bfq_lookup_next_entity(struct bfq_service_tree *st, + /** + * bfq_lookup_next_entity - return the first eligible entity in @sd. + * @sd: the sched_data. +- * @extract: if true the returned entity will be also extracted from @sd. + * +- * NOTE: since we cache the next_in_service entity at each level of the +- * hierarchy, the complexity of the lookup can be decreased with +- * absolutely no effort just returning the cached next_in_service value; +- * we prefer to do full lookups to test the consistency of * the data +- * structures. ++ * This function is invoked when there has been a change in the trees ++ * for sd, and we need know what is the new next entity after this ++ * change. + */ +-static struct bfq_entity *bfq_lookup_next_entity(struct bfq_sched_data *sd, +- int extract, +- struct bfq_data *bfqd) ++static struct bfq_entity *bfq_lookup_next_entity(struct bfq_sched_data *sd) + { + struct bfq_service_tree *st = sd->service_tree; +- struct bfq_entity *entity; +- int i = 0; +- +- BUG_ON(sd->in_service_entity); ++ struct bfq_service_tree *idle_class_st = st + (BFQ_IOPRIO_CLASSES - 1); ++ struct bfq_entity *entity = NULL; ++ struct bfq_queue *bfqq; ++ int class_idx = 0; + +- if (bfqd && +- jiffies - bfqd->bfq_class_idle_last_service > BFQ_CL_IDLE_TIMEOUT) { +- entity = __bfq_lookup_next_entity(st + BFQ_IOPRIO_CLASSES - 1, +- true); +- if (entity) { +- i = BFQ_IOPRIO_CLASSES - 1; +- bfqd->bfq_class_idle_last_service = jiffies; +- sd->next_in_service = entity; +- } ++ BUG_ON(!sd); ++ BUG_ON(!st); ++ /* ++ * Choose from idle class, if needed to guarantee a minimum ++ * bandwidth to this class (and if there is some active entity ++ * in idle class). This should also mitigate ++ * priority-inversion problems in case a low priority task is ++ * holding file system resources. ++ */ ++ if (time_is_before_jiffies(sd->bfq_class_idle_last_service + ++ BFQ_CL_IDLE_TIMEOUT)) { ++ if (!RB_EMPTY_ROOT(&idle_class_st->active)) ++ class_idx = BFQ_IOPRIO_CLASSES - 1; ++ /* About to be served if backlogged, or not yet backlogged */ ++ sd->bfq_class_idle_last_service = jiffies; + } +- for (; i < BFQ_IOPRIO_CLASSES; i++) { +- entity = __bfq_lookup_next_entity(st + i, false); +- if (entity) { +- if (extract) { +- bfq_check_next_in_service(sd, entity); +- bfq_active_extract(st + i, entity); +- sd->in_service_entity = entity; +- sd->next_in_service = NULL; +- } ++ ++ /* ++ * Find the next entity to serve for the highest-priority ++ * class, unless the idle class needs to be served. ++ */ ++ for (; class_idx < BFQ_IOPRIO_CLASSES; class_idx++) { ++ entity = __bfq_lookup_next_entity(st + class_idx, ++ sd->in_service_entity); ++ ++ if (entity) + break; +- } + } + ++ BUG_ON(!entity && ++ (!RB_EMPTY_ROOT(&st->active) || !RB_EMPTY_ROOT(&(st+1)->active) || ++ !RB_EMPTY_ROOT(&(st+2)->active))); ++ ++ if (!entity) ++ return NULL; ++ ++ /* Log some information */ ++ bfqq = bfq_entity_to_bfqq(entity); ++ if (bfqq) ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "chosen from st %p %d", ++ st + class_idx, class_idx); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ else { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "chosen from st %p %d", ++ st + class_idx, class_idx); ++ } ++#endif ++ + return entity; + } + ++static bool next_queue_may_preempt(struct bfq_data *bfqd) ++{ ++ struct bfq_sched_data *sd = &bfqd->root_group->sched_data; ++ ++ return sd->next_in_service != sd->in_service_entity; ++} ++ ++/* ++ * This function tells whether entity stops being a candidate for next ++ * service, according to the following logic. ++ * ++ * This function is invoked for an entity that is about to be set in ++ * service. If such an entity is a queue, then the entity is no longer ++ * a candidate for next service (i.e, a candidate entity to serve ++ * after the in-service entity is expired). The function then returns ++ * true. ++ * ++ * In contrast, the entity could stil be a candidate for next service ++ * if it is not a queue, and has more than one child. In fact, even if ++ * one of its children is about to be set in service, other children ++ * may still be the next to serve. As a consequence, a non-queue ++ * entity is not a candidate for next-service only if it has only one ++ * child. And only if this condition holds, then the function returns ++ * true for a non-queue entity. ++ */ ++static bool bfq_no_longer_next_in_service(struct bfq_entity *entity) ++{ ++ struct bfq_group *bfqg; ++ ++ if (bfq_entity_to_bfqq(entity)) ++ return true; ++ ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ bfqg = container_of(entity, struct bfq_group, entity); ++ ++ BUG_ON(bfqg == ((struct bfq_data *)(bfqg->bfqd))->root_group); ++ BUG_ON(bfqg->active_entities == 0); ++ if (bfqg->active_entities == 1) ++ return true; ++#endif ++ ++ return false; ++} ++ + /* + * Get next queue for service. + */ +@@ -1083,58 +1677,208 @@ static struct bfq_queue *bfq_get_next_queue(struct bfq_data *bfqd) + if (bfqd->busy_queues == 0) + return NULL; + ++ /* ++ * Traverse the path from the root to the leaf entity to ++ * serve. Set in service all the entities visited along the ++ * way. ++ */ + sd = &bfqd->root_group->sched_data; + for (; sd ; sd = entity->my_sched_data) { +- entity = bfq_lookup_next_entity(sd, 1, bfqd); +- BUG_ON(!entity); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ if (entity) { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg(bfqd, bfqg, ++ "get_next_queue: lookup in this group"); ++ if (!sd->next_in_service) ++ pr_crit("get_next_queue: lookup in this group"); ++ } else { ++ bfq_log_bfqg(bfqd, bfqd->root_group, ++ "get_next_queue: lookup in root group"); ++ if (!sd->next_in_service) ++ pr_crit("get_next_queue: lookup in root group"); ++ } ++#endif ++ ++ BUG_ON(!sd->next_in_service); ++ ++ /* ++ * WARNING. We are about to set the in-service entity ++ * to sd->next_in_service, i.e., to the (cached) value ++ * returned by bfq_lookup_next_entity(sd) the last ++ * time it was invoked, i.e., the last time when the ++ * service order in sd changed as a consequence of the ++ * activation or deactivation of an entity. In this ++ * respect, if we execute bfq_lookup_next_entity(sd) ++ * in this very moment, it may, although with low ++ * probability, yield a different entity than that ++ * pointed to by sd->next_in_service. This rare event ++ * happens in case there was no CLASS_IDLE entity to ++ * serve for sd when bfq_lookup_next_entity(sd) was ++ * invoked for the last time, while there is now one ++ * such entity. ++ * ++ * If the above event happens, then the scheduling of ++ * such entity in CLASS_IDLE is postponed until the ++ * service of the sd->next_in_service entity ++ * finishes. In fact, when the latter is expired, ++ * bfq_lookup_next_entity(sd) gets called again, ++ * exactly to update sd->next_in_service. ++ */ ++ ++ /* Make next_in_service entity become in_service_entity */ ++ entity = sd->next_in_service; ++ sd->in_service_entity = entity; ++ ++ /* ++ * Reset the accumulator of the amount of service that ++ * the entity is about to receive. ++ */ + entity->service = 0; ++ ++ /* ++ * If entity is no longer a candidate for next ++ * service, then we extract it from its active tree, ++ * for the following reason. To further boost the ++ * throughput in some special case, BFQ needs to know ++ * which is the next candidate entity to serve, while ++ * there is already an entity in service. In this ++ * respect, to make it easy to compute/update the next ++ * candidate entity to serve after the current ++ * candidate has been set in service, there is a case ++ * where it is necessary to extract the current ++ * candidate from its service tree. Such a case is ++ * when the entity just set in service cannot be also ++ * a candidate for next service. Details about when ++ * this conditions holds are reported in the comments ++ * on the function bfq_no_longer_next_in_service() ++ * invoked below. ++ */ ++ if (bfq_no_longer_next_in_service(entity)) ++ bfq_active_extract(bfq_entity_service_tree(entity), ++ entity); ++ ++ /* ++ * For the same reason why we may have just extracted ++ * entity from its active tree, we may need to update ++ * next_in_service for the sched_data of entity too, ++ * regardless of whether entity has been extracted. ++ * In fact, even if entity has not been extracted, a ++ * descendant entity may get extracted. Such an event ++ * would cause a change in next_in_service for the ++ * level of the descendant entity, and thus possibly ++ * back to upper levels. ++ * ++ * We cannot perform the resulting needed update ++ * before the end of this loop, because, to know which ++ * is the correct next-to-serve candidate entity for ++ * each level, we need first to find the leaf entity ++ * to set in service. In fact, only after we know ++ * which is the next-to-serve leaf entity, we can ++ * discover whether the parent entity of the leaf ++ * entity becomes the next-to-serve, and so on. ++ */ ++ ++ /* Log some information */ ++ bfqq = bfq_entity_to_bfqq(entity); ++ if (bfqq) ++ bfq_log_bfqq(bfqd, bfqq, ++ "get_next_queue: this queue, finish %llu", ++ (((entity->finish>>10)*1000)>>10)>>2); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ else { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg(bfqd, bfqg, ++ "get_next_queue: this entity, finish %llu", ++ (((entity->finish>>10)*1000)>>10)>>2); ++ } ++#endif ++ + } + ++ BUG_ON(!entity); + bfqq = bfq_entity_to_bfqq(entity); + BUG_ON(!bfqq); + ++ /* ++ * We can finally update all next-to-serve entities along the ++ * path from the leaf entity just set in service to the root. ++ */ ++ for_each_entity(entity) { ++ struct bfq_sched_data *sd = entity->sched_data; ++ ++ if(!bfq_update_next_in_service(sd, NULL)) ++ break; ++ } ++ + return bfqq; + } + + static void __bfq_bfqd_reset_in_service(struct bfq_data *bfqd) + { ++ struct bfq_entity *entity = &bfqd->in_service_queue->entity; ++ + if (bfqd->in_service_bic) { + put_io_context(bfqd->in_service_bic->icq.ioc); + bfqd->in_service_bic = NULL; + } + ++ bfq_clear_bfqq_wait_request(bfqd->in_service_queue); ++ hrtimer_try_to_cancel(&bfqd->idle_slice_timer); + bfqd->in_service_queue = NULL; +- del_timer(&bfqd->idle_slice_timer); ++ ++ /* ++ * When this function is called, all in-service entities have ++ * been properly deactivated or requeued, so we can safely ++ * execute the final step: reset in_service_entity along the ++ * path from entity to the root. ++ */ ++ for_each_entity(entity) ++ entity->sched_data->in_service_entity = NULL; + } + + static void bfq_deactivate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, +- int requeue) ++ bool ins_into_idle_tree, bool expiration) + { + struct bfq_entity *entity = &bfqq->entity; + +- if (bfqq == bfqd->in_service_queue) +- __bfq_bfqd_reset_in_service(bfqd); +- +- bfq_deactivate_entity(entity, requeue); ++ bfq_deactivate_entity(entity, ins_into_idle_tree, expiration); + } + + static void bfq_activate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) + { + struct bfq_entity *entity = &bfqq->entity; ++ struct bfq_service_tree *st = bfq_entity_service_tree(entity); ++ ++ BUG_ON(bfqq == bfqd->in_service_queue); ++ BUG_ON(entity->tree != &st->active && entity->tree != &st->idle && ++ entity->on_st); + +- bfq_activate_entity(entity); ++ bfq_activate_requeue_entity(entity, bfq_bfqq_non_blocking_wait_rq(bfqq), ++ false); ++ bfq_clear_bfqq_non_blocking_wait_rq(bfqq); ++} ++ ++static void bfq_requeue_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) ++{ ++ struct bfq_entity *entity = &bfqq->entity; ++ ++ bfq_activate_requeue_entity(entity, false, ++ bfqq == bfqd->in_service_queue); + } + +-#ifdef CONFIG_BFQ_GROUP_IOSCHED + static void bfqg_stats_update_dequeue(struct bfq_group *bfqg); +-#endif + + /* + * Called when the bfqq no longer has requests pending, remove it from +- * the service tree. ++ * the service tree. As a special case, it can be invoked during an ++ * expiration. + */ + static void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq, +- int requeue) ++ bool expiration) + { + BUG_ON(!bfq_bfqq_busy(bfqq)); + BUG_ON(!RB_EMPTY_ROOT(&bfqq->sort_list)); +@@ -1146,27 +1890,20 @@ static void bfq_del_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq, + BUG_ON(bfqd->busy_queues == 0); + bfqd->busy_queues--; + +- if (!bfqq->dispatched) { ++ if (!bfqq->dispatched) + bfq_weights_tree_remove(bfqd, &bfqq->entity, + &bfqd->queue_weights_tree); +- if (!blk_queue_nonrot(bfqd->queue)) { +- BUG_ON(!bfqd->busy_in_flight_queues); +- bfqd->busy_in_flight_queues--; +- if (bfq_bfqq_constantly_seeky(bfqq)) { +- BUG_ON(!bfqd-> +- const_seeky_busy_in_flight_queues); +- bfqd->const_seeky_busy_in_flight_queues--; +- } +- } +- } ++ + if (bfqq->wr_coeff > 1) + bfqd->wr_busy_queues--; + +-#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_update_dequeue(bfqq_group(bfqq)); +-#endif + +- bfq_deactivate_bfqq(bfqd, bfqq, requeue); ++ BUG_ON(bfqq->entity.budget < 0); ++ ++ bfq_deactivate_bfqq(bfqd, bfqq, true, expiration); ++ ++ BUG_ON(bfqq->entity.budget < 0); + } + + /* +@@ -1184,16 +1921,11 @@ static void bfq_add_bfqq_busy(struct bfq_data *bfqd, struct bfq_queue *bfqq) + bfq_mark_bfqq_busy(bfqq); + bfqd->busy_queues++; + +- if (!bfqq->dispatched) { ++ if (!bfqq->dispatched) + if (bfqq->wr_coeff == 1) + bfq_weights_tree_add(bfqd, &bfqq->entity, + &bfqd->queue_weights_tree); +- if (!blk_queue_nonrot(bfqd->queue)) { +- bfqd->busy_in_flight_queues++; +- if (bfq_bfqq_constantly_seeky(bfqq)) +- bfqd->const_seeky_busy_in_flight_queues++; +- } +- } ++ + if (bfqq->wr_coeff > 1) + bfqd->wr_busy_queues++; + } +diff --git a/block/bfq.h b/block/bfq.h +index fcce855..57ab51d 100644 +--- a/block/bfq.h ++++ b/block/bfq.h +@@ -1,5 +1,5 @@ + /* +- * BFQ-v7r11 for 4.5.0: data structures and common functions prototypes. ++ * BFQ v8r6 for 4.9.0: data structures and common functions prototypes. + * + * Based on ideas and code from CFQ: + * Copyright (C) 2003 Jens Axboe +@@ -7,7 +7,9 @@ + * Copyright (C) 2008 Fabio Checconi + * Paolo Valente + * +- * Copyright (C) 2010 Paolo Valente ++ * Copyright (C) 2015 Paolo Valente ++ * ++ * Copyright (C) 2016 Paolo Valente + */ + + #ifndef _BFQ_H +@@ -28,20 +30,21 @@ + + #define BFQ_DEFAULT_QUEUE_IOPRIO 4 + +-#define BFQ_DEFAULT_GRP_WEIGHT 10 ++#define BFQ_WEIGHT_LEGACY_DFL 100 + #define BFQ_DEFAULT_GRP_IOPRIO 0 + #define BFQ_DEFAULT_GRP_CLASS IOPRIO_CLASS_BE + ++/* ++ * Soft real-time applications are extremely more latency sensitive ++ * than interactive ones. Over-raise the weight of the former to ++ * privilege them against the latter. ++ */ ++#define BFQ_SOFTRT_WEIGHT_FACTOR 100 ++ + struct bfq_entity; + + /** + * struct bfq_service_tree - per ioprio_class service tree. +- * @active: tree for active entities (i.e., those backlogged). +- * @idle: tree for idle entities (i.e., those not backlogged, with V <= F_i). +- * @first_idle: idle entity with minimum F_i. +- * @last_idle: idle entity with maximum F_i. +- * @vtime: scheduler virtual time. +- * @wsum: scheduler weight sum; active and idle entities contribute to it. + * + * Each service tree represents a B-WF2Q+ scheduler on its own. Each + * ioprio_class has its own independent scheduler, and so its own +@@ -49,27 +52,28 @@ struct bfq_entity; + * of the containing bfqd. + */ + struct bfq_service_tree { ++ /* tree for active entities (i.e., those backlogged) */ + struct rb_root active; ++ /* tree for idle entities (i.e., not backlogged, with V <= F_i)*/ + struct rb_root idle; + +- struct bfq_entity *first_idle; +- struct bfq_entity *last_idle; ++ struct bfq_entity *first_idle; /* idle entity with minimum F_i */ ++ struct bfq_entity *last_idle; /* idle entity with maximum F_i */ + +- u64 vtime; ++ u64 vtime; /* scheduler virtual time */ ++ /* scheduler weight sum; active and idle entities contribute to it */ + unsigned long wsum; + }; + + /** + * struct bfq_sched_data - multi-class scheduler. +- * @in_service_entity: entity in service. +- * @next_in_service: head-of-the-line entity in the scheduler. +- * @service_tree: array of service trees, one per ioprio_class. + * + * bfq_sched_data is the basic scheduler queue. It supports three +- * ioprio_classes, and can be used either as a toplevel queue or as +- * an intermediate queue on a hierarchical setup. +- * @next_in_service points to the active entity of the sched_data +- * service trees that will be scheduled next. ++ * ioprio_classes, and can be used either as a toplevel queue or as an ++ * intermediate queue on a hierarchical setup. @next_in_service ++ * points to the active entity of the sched_data service trees that ++ * will be scheduled next. It is used to reduce the number of steps ++ * needed for each hierarchical-schedule update. + * + * The supported ioprio_classes are the same as in CFQ, in descending + * priority order, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE. +@@ -79,48 +83,32 @@ struct bfq_service_tree { + * All the fields are protected by the queue lock of the containing bfqd. + */ + struct bfq_sched_data { +- struct bfq_entity *in_service_entity; ++ struct bfq_entity *in_service_entity; /* entity in service */ ++ /* head-of-the-line entity in the scheduler (see comments above) */ + struct bfq_entity *next_in_service; ++ /* array of service trees, one per ioprio_class */ + struct bfq_service_tree service_tree[BFQ_IOPRIO_CLASSES]; ++ /* last time CLASS_IDLE was served */ ++ unsigned long bfq_class_idle_last_service; ++ + }; + + /** + * struct bfq_weight_counter - counter of the number of all active entities + * with a given weight. +- * @weight: weight of the entities that this counter refers to. +- * @num_active: number of active entities with this weight. +- * @weights_node: weights tree member (see bfq_data's @queue_weights_tree +- * and @group_weights_tree). + */ + struct bfq_weight_counter { +- short int weight; +- unsigned int num_active; ++ unsigned int weight; /* weight of the entities this counter refers to */ ++ unsigned int num_active; /* nr of active entities with this weight */ ++ /* ++ * Weights tree member (see bfq_data's @queue_weights_tree and ++ * @group_weights_tree) ++ */ + struct rb_node weights_node; + }; + + /** + * struct bfq_entity - schedulable entity. +- * @rb_node: service_tree member. +- * @weight_counter: pointer to the weight counter associated with this entity. +- * @on_st: flag, true if the entity is on a tree (either the active or +- * the idle one of its service_tree). +- * @finish: B-WF2Q+ finish timestamp (aka F_i). +- * @start: B-WF2Q+ start timestamp (aka S_i). +- * @tree: tree the entity is enqueued into; %NULL if not on a tree. +- * @min_start: minimum start time of the (active) subtree rooted at +- * this entity; used for O(log N) lookups into active trees. +- * @service: service received during the last round of service. +- * @budget: budget used to calculate F_i; F_i = S_i + @budget / @weight. +- * @weight: weight of the queue +- * @parent: parent entity, for hierarchical scheduling. +- * @my_sched_data: for non-leaf nodes in the cgroup hierarchy, the +- * associated scheduler queue, %NULL on leaf nodes. +- * @sched_data: the scheduler queue this entity belongs to. +- * @ioprio: the ioprio in use. +- * @new_weight: when a weight change is requested, the new weight value. +- * @orig_weight: original weight, used to implement weight boosting +- * @prio_changed: flag, true when the user requested a weight, ioprio or +- * ioprio_class change. + * + * A bfq_entity is used to represent either a bfq_queue (leaf node in the + * cgroup hierarchy) or a bfq_group into the upper level scheduler. Each +@@ -147,27 +135,52 @@ struct bfq_weight_counter { + * containing bfqd. + */ + struct bfq_entity { +- struct rb_node rb_node; ++ struct rb_node rb_node; /* service_tree member */ ++ /* pointer to the weight counter associated with this entity */ + struct bfq_weight_counter *weight_counter; + +- int on_st; ++ /* ++ * Flag, true if the entity is on a tree (either the active or ++ * the idle one of its service_tree) or is in service. ++ */ ++ bool on_st; + +- u64 finish; +- u64 start; ++ u64 finish; /* B-WF2Q+ finish timestamp (aka F_i) */ ++ u64 start; /* B-WF2Q+ start timestamp (aka S_i) */ + ++ /* tree the entity is enqueued into; %NULL if not on a tree */ + struct rb_root *tree; + ++ /* ++ * minimum start time of the (active) subtree rooted at this ++ * entity; used for O(log N) lookups into active trees ++ */ + u64 min_start; + +- int service, budget; +- unsigned short weight, new_weight; +- unsigned short orig_weight; ++ /* amount of service received during the last service slot */ ++ int service; ++ ++ /* budget, used also to calculate F_i: F_i = S_i + @budget / @weight */ ++ int budget; ++ ++ unsigned int weight; /* weight of the queue */ ++ unsigned int new_weight; /* next weight if a change is in progress */ ++ ++ /* original weight, used to implement weight boosting */ ++ unsigned int orig_weight; + ++ /* parent entity, for hierarchical scheduling */ + struct bfq_entity *parent; + ++ /* ++ * For non-leaf nodes in the hierarchy, the associated ++ * scheduler queue, %NULL on leaf nodes. ++ */ + struct bfq_sched_data *my_sched_data; ++ /* the scheduler queue this entity belongs to */ + struct bfq_sched_data *sched_data; + ++ /* flag, set to request a weight, ioprio or ioprio_class change */ + int prio_changed; + }; + +@@ -175,56 +188,6 @@ struct bfq_group; + + /** + * struct bfq_queue - leaf schedulable entity. +- * @ref: reference counter. +- * @bfqd: parent bfq_data. +- * @new_ioprio: when an ioprio change is requested, the new ioprio value. +- * @ioprio_class: the ioprio_class in use. +- * @new_ioprio_class: when an ioprio_class change is requested, the new +- * ioprio_class value. +- * @new_bfqq: shared bfq_queue if queue is cooperating with +- * one or more other queues. +- * @pos_node: request-position tree member (see bfq_group's @rq_pos_tree). +- * @pos_root: request-position tree root (see bfq_group's @rq_pos_tree). +- * @sort_list: sorted list of pending requests. +- * @next_rq: if fifo isn't expired, next request to serve. +- * @queued: nr of requests queued in @sort_list. +- * @allocated: currently allocated requests. +- * @meta_pending: pending metadata requests. +- * @fifo: fifo list of requests in sort_list. +- * @entity: entity representing this queue in the scheduler. +- * @max_budget: maximum budget allowed from the feedback mechanism. +- * @budget_timeout: budget expiration (in jiffies). +- * @dispatched: number of requests on the dispatch list or inside driver. +- * @flags: status flags. +- * @bfqq_list: node for active/idle bfqq list inside our bfqd. +- * @burst_list_node: node for the device's burst list. +- * @seek_samples: number of seeks sampled +- * @seek_total: sum of the distances of the seeks sampled +- * @seek_mean: mean seek distance +- * @last_request_pos: position of the last request enqueued +- * @requests_within_timer: number of consecutive pairs of request completion +- * and arrival, such that the queue becomes idle +- * after the completion, but the next request arrives +- * within an idle time slice; used only if the queue's +- * IO_bound has been cleared. +- * @pid: pid of the process owning the queue, used for logging purposes. +- * @last_wr_start_finish: start time of the current weight-raising period if +- * the @bfq-queue is being weight-raised, otherwise +- * finish time of the last weight-raising period +- * @wr_cur_max_time: current max raising time for this queue +- * @soft_rt_next_start: minimum time instant such that, only if a new +- * request is enqueued after this time instant in an +- * idle @bfq_queue with no outstanding requests, then +- * the task associated with the queue it is deemed as +- * soft real-time (see the comments to the function +- * bfq_bfqq_softrt_next_start()) +- * @last_idle_bklogged: time of the last transition of the @bfq_queue from +- * idle to backlogged +- * @service_from_backlogged: cumulative service received from the @bfq_queue +- * since the last transition from idle to +- * backlogged +- * @bic: pointer to the bfq_io_cq owning the bfq_queue, set to %NULL if the +- * queue is shared + * + * A bfq_queue is a leaf request queue; it can be associated with an + * io_context or more, if it is async or shared between cooperating +@@ -235,117 +198,175 @@ struct bfq_group; + * All the fields are protected by the queue lock of the containing bfqd. + */ + struct bfq_queue { +- atomic_t ref; ++ /* reference counter */ ++ int ref; ++ /* parent bfq_data */ + struct bfq_data *bfqd; + +- unsigned short ioprio, new_ioprio; +- unsigned short ioprio_class, new_ioprio_class; ++ /* current ioprio and ioprio class */ ++ unsigned short ioprio, ioprio_class; ++ /* next ioprio and ioprio class if a change is in progress */ ++ unsigned short new_ioprio, new_ioprio_class; + +- /* fields for cooperating queues handling */ ++ /* ++ * Shared bfq_queue if queue is cooperating with one or more ++ * other queues. ++ */ + struct bfq_queue *new_bfqq; ++ /* request-position tree member (see bfq_group's @rq_pos_tree) */ + struct rb_node pos_node; ++ /* request-position tree root (see bfq_group's @rq_pos_tree) */ + struct rb_root *pos_root; + ++ /* sorted list of pending requests */ + struct rb_root sort_list; ++ /* if fifo isn't expired, next request to serve */ + struct request *next_rq; ++ /* number of sync and async requests queued */ + int queued[2]; ++ /* number of sync and async requests currently allocated */ + int allocated[2]; ++ /* number of pending metadata requests */ + int meta_pending; ++ /* fifo list of requests in sort_list */ + struct list_head fifo; + ++ /* entity representing this queue in the scheduler */ + struct bfq_entity entity; + ++ /* maximum budget allowed from the feedback mechanism */ + int max_budget; ++ /* budget expiration (in jiffies) */ + unsigned long budget_timeout; + ++ /* number of requests on the dispatch list or inside driver */ + int dispatched; + +- unsigned int flags; ++ unsigned int flags; /* status flags.*/ + ++ /* node for active/idle bfqq list inside parent bfqd */ + struct list_head bfqq_list; + ++ /* bit vector: a 1 for each seeky requests in history */ ++ u32 seek_history; ++ ++ /* node for the device's burst list */ + struct hlist_node burst_list_node; + +- unsigned int seek_samples; +- u64 seek_total; +- sector_t seek_mean; ++ /* position of the last request enqueued */ + sector_t last_request_pos; + ++ /* Number of consecutive pairs of request completion and ++ * arrival, such that the queue becomes idle after the ++ * completion, but the next request arrives within an idle ++ * time slice; used only if the queue's IO_bound flag has been ++ * cleared. ++ */ + unsigned int requests_within_timer; + ++ /* pid of the process owning the queue, used for logging purposes */ + pid_t pid; ++ ++ /* ++ * Pointer to the bfq_io_cq owning the bfq_queue, set to %NULL ++ * if the queue is shared. ++ */ + struct bfq_io_cq *bic; + +- /* weight-raising fields */ ++ /* current maximum weight-raising time for this queue */ + unsigned long wr_cur_max_time; ++ /* ++ * Minimum time instant such that, only if a new request is ++ * enqueued after this time instant in an idle @bfq_queue with ++ * no outstanding requests, then the task associated with the ++ * queue it is deemed as soft real-time (see the comments on ++ * the function bfq_bfqq_softrt_next_start()) ++ */ + unsigned long soft_rt_next_start; ++ /* ++ * Start time of the current weight-raising period if ++ * the @bfq-queue is being weight-raised, otherwise ++ * finish time of the last weight-raising period. ++ */ + unsigned long last_wr_start_finish; ++ /* factor by which the weight of this queue is multiplied */ + unsigned int wr_coeff; ++ /* ++ * Time of the last transition of the @bfq_queue from idle to ++ * backlogged. ++ */ + unsigned long last_idle_bklogged; ++ /* ++ * Cumulative service received from the @bfq_queue since the ++ * last transition from idle to backlogged. ++ */ + unsigned long service_from_backlogged; ++ /* ++ * Value of wr start time when switching to soft rt ++ */ ++ unsigned long wr_start_at_switch_to_srt; ++ ++ unsigned long split_time; /* time of last split */ + }; + + /** + * struct bfq_ttime - per process thinktime stats. +- * @ttime_total: total process thinktime +- * @ttime_samples: number of thinktime samples +- * @ttime_mean: average process thinktime + */ + struct bfq_ttime { +- unsigned long last_end_request; ++ u64 last_end_request; /* completion time of last request */ ++ ++ u64 ttime_total; /* total process thinktime */ ++ unsigned long ttime_samples; /* number of thinktime samples */ ++ u64 ttime_mean; /* average process thinktime */ + +- unsigned long ttime_total; +- unsigned long ttime_samples; +- unsigned long ttime_mean; + }; + + /** + * struct bfq_io_cq - per (request_queue, io_context) structure. +- * @icq: associated io_cq structure +- * @bfqq: array of two process queues, the sync and the async +- * @ttime: associated @bfq_ttime struct +- * @ioprio: per (request_queue, blkcg) ioprio. +- * @blkcg_id: id of the blkcg the related io_cq belongs to. +- * @wr_time_left: snapshot of the time left before weight raising ends +- * for the sync queue associated to this process; this +- * snapshot is taken to remember this value while the weight +- * raising is suspended because the queue is merged with a +- * shared queue, and is used to set @raising_cur_max_time +- * when the queue is split from the shared queue and its +- * weight is raised again +- * @saved_idle_window: same purpose as the previous field for the idle +- * window +- * @saved_IO_bound: same purpose as the previous two fields for the I/O +- * bound classification of a queue +- * @saved_in_large_burst: same purpose as the previous fields for the +- * value of the field keeping the queue's belonging +- * to a large burst +- * @was_in_burst_list: true if the queue belonged to a burst list +- * before its merge with another cooperating queue +- * @cooperations: counter of consecutive successful queue merges underwent +- * by any of the process' @bfq_queues +- * @failed_cooperations: counter of consecutive failed queue merges of any +- * of the process' @bfq_queues + */ + struct bfq_io_cq { ++ /* associated io_cq structure */ + struct io_cq icq; /* must be the first member */ ++ /* array of two process queues, the sync and the async */ + struct bfq_queue *bfqq[2]; ++ /* associated @bfq_ttime struct */ + struct bfq_ttime ttime; ++ /* per (request_queue, blkcg) ioprio */ + int ioprio; +- + #ifdef CONFIG_BFQ_GROUP_IOSCHED +- uint64_t blkcg_id; /* the current blkcg ID */ ++ uint64_t blkcg_serial_nr; /* the current blkcg serial */ + #endif + +- unsigned int wr_time_left; ++ /* ++ * Snapshot of the idle window before merging; taken to ++ * remember this value while the queue is merged, so as to be ++ * able to restore it in case of split. ++ */ + bool saved_idle_window; ++ /* ++ * Same purpose as the previous two fields for the I/O bound ++ * classification of a queue. ++ */ + bool saved_IO_bound; + ++ /* ++ * Same purpose as the previous fields for the value of the ++ * field keeping the queue's belonging to a large burst ++ */ + bool saved_in_large_burst; ++ /* ++ * True if the queue belonged to a burst list before its merge ++ * with another cooperating queue. ++ */ + bool was_in_burst_list; + +- unsigned int cooperations; +- unsigned int failed_cooperations; ++ /* ++ * Similar to previous fields: save wr information. ++ */ ++ unsigned long saved_wr_coeff; ++ unsigned long saved_last_wr_start_finish; ++ unsigned long saved_wr_start_at_switch_to_srt; ++ unsigned int saved_wr_cur_max_time; + }; + + enum bfq_device_speed { +@@ -354,224 +375,232 @@ enum bfq_device_speed { + }; + + /** +- * struct bfq_data - per device data structure. +- * @queue: request queue for the managed device. +- * @root_group: root bfq_group for the device. +- * @active_numerous_groups: number of bfq_groups containing more than one +- * active @bfq_entity. +- * @queue_weights_tree: rbtree of weight counters of @bfq_queues, sorted by +- * weight. Used to keep track of whether all @bfq_queues +- * have the same weight. The tree contains one counter +- * for each distinct weight associated to some active +- * and not weight-raised @bfq_queue (see the comments to +- * the functions bfq_weights_tree_[add|remove] for +- * further details). +- * @group_weights_tree: rbtree of non-queue @bfq_entity weight counters, sorted +- * by weight. Used to keep track of whether all +- * @bfq_groups have the same weight. The tree contains +- * one counter for each distinct weight associated to +- * some active @bfq_group (see the comments to the +- * functions bfq_weights_tree_[add|remove] for further +- * details). +- * @busy_queues: number of bfq_queues containing requests (including the +- * queue in service, even if it is idling). +- * @busy_in_flight_queues: number of @bfq_queues containing pending or +- * in-flight requests, plus the @bfq_queue in +- * service, even if idle but waiting for the +- * possible arrival of its next sync request. This +- * field is updated only if the device is rotational, +- * but used only if the device is also NCQ-capable. +- * The reason why the field is updated also for non- +- * NCQ-capable rotational devices is related to the +- * fact that the value of @hw_tag may be set also +- * later than when busy_in_flight_queues may need to +- * be incremented for the first time(s). Taking also +- * this possibility into account, to avoid unbalanced +- * increments/decrements, would imply more overhead +- * than just updating busy_in_flight_queues +- * regardless of the value of @hw_tag. +- * @const_seeky_busy_in_flight_queues: number of constantly-seeky @bfq_queues +- * (that is, seeky queues that expired +- * for budget timeout at least once) +- * containing pending or in-flight +- * requests, including the in-service +- * @bfq_queue if constantly seeky. This +- * field is updated only if the device +- * is rotational, but used only if the +- * device is also NCQ-capable (see the +- * comments to @busy_in_flight_queues). +- * @wr_busy_queues: number of weight-raised busy @bfq_queues. +- * @queued: number of queued requests. +- * @rq_in_driver: number of requests dispatched and waiting for completion. +- * @sync_flight: number of sync requests in the driver. +- * @max_rq_in_driver: max number of reqs in driver in the last +- * @hw_tag_samples completed requests. +- * @hw_tag_samples: nr of samples used to calculate hw_tag. +- * @hw_tag: flag set to one if the driver is showing a queueing behavior. +- * @budgets_assigned: number of budgets assigned. +- * @idle_slice_timer: timer set when idling for the next sequential request +- * from the queue in service. +- * @unplug_work: delayed work to restart dispatching on the request queue. +- * @in_service_queue: bfq_queue in service. +- * @in_service_bic: bfq_io_cq (bic) associated with the @in_service_queue. +- * @last_position: on-disk position of the last served request. +- * @last_budget_start: beginning of the last budget. +- * @last_idling_start: beginning of the last idle slice. +- * @peak_rate: peak transfer rate observed for a budget. +- * @peak_rate_samples: number of samples used to calculate @peak_rate. +- * @bfq_max_budget: maximum budget allotted to a bfq_queue before +- * rescheduling. +- * @active_list: list of all the bfq_queues active on the device. +- * @idle_list: list of all the bfq_queues idle on the device. +- * @bfq_fifo_expire: timeout for async/sync requests; when it expires +- * requests are served in fifo order. +- * @bfq_back_penalty: weight of backward seeks wrt forward ones. +- * @bfq_back_max: maximum allowed backward seek. +- * @bfq_slice_idle: maximum idling time. +- * @bfq_user_max_budget: user-configured max budget value +- * (0 for auto-tuning). +- * @bfq_max_budget_async_rq: maximum budget (in nr of requests) allotted to +- * async queues. +- * @bfq_timeout: timeout for bfq_queues to consume their budget; used to +- * to prevent seeky queues to impose long latencies to well +- * behaved ones (this also implies that seeky queues cannot +- * receive guarantees in the service domain; after a timeout +- * they are charged for the whole allocated budget, to try +- * to preserve a behavior reasonably fair among them, but +- * without service-domain guarantees). +- * @bfq_coop_thresh: number of queue merges after which a @bfq_queue is +- * no more granted any weight-raising. +- * @bfq_failed_cooperations: number of consecutive failed cooperation +- * chances after which weight-raising is restored +- * to a queue subject to more than bfq_coop_thresh +- * queue merges. +- * @bfq_requests_within_timer: number of consecutive requests that must be +- * issued within the idle time slice to set +- * again idling to a queue which was marked as +- * non-I/O-bound (see the definition of the +- * IO_bound flag for further details). +- * @last_ins_in_burst: last time at which a queue entered the current +- * burst of queues being activated shortly after +- * each other; for more details about this and the +- * following parameters related to a burst of +- * activations, see the comments to the function +- * @bfq_handle_burst. +- * @bfq_burst_interval: reference time interval used to decide whether a +- * queue has been activated shortly after +- * @last_ins_in_burst. +- * @burst_size: number of queues in the current burst of queue activations. +- * @bfq_large_burst_thresh: maximum burst size above which the current +- * queue-activation burst is deemed as 'large'. +- * @large_burst: true if a large queue-activation burst is in progress. +- * @burst_list: head of the burst list (as for the above fields, more details +- * in the comments to the function bfq_handle_burst). +- * @low_latency: if set to true, low-latency heuristics are enabled. +- * @bfq_wr_coeff: maximum factor by which the weight of a weight-raised +- * queue is multiplied. +- * @bfq_wr_max_time: maximum duration of a weight-raising period (jiffies). +- * @bfq_wr_rt_max_time: maximum duration for soft real-time processes. +- * @bfq_wr_min_idle_time: minimum idle period after which weight-raising +- * may be reactivated for a queue (in jiffies). +- * @bfq_wr_min_inter_arr_async: minimum period between request arrivals +- * after which weight-raising may be +- * reactivated for an already busy queue +- * (in jiffies). +- * @bfq_wr_max_softrt_rate: max service-rate for a soft real-time queue, +- * sectors per seconds. +- * @RT_prod: cached value of the product R*T used for computing the maximum +- * duration of the weight raising automatically. +- * @device_speed: device-speed class for the low-latency heuristic. +- * @oom_bfqq: fallback dummy bfqq for extreme OOM conditions. ++ * struct bfq_data - per-device data structure. + * + * All the fields are protected by the @queue lock. + */ + struct bfq_data { ++ /* request queue for the device */ + struct request_queue *queue; + ++ /* root bfq_group for the device */ + struct bfq_group *root_group; + +-#ifdef CONFIG_BFQ_GROUP_IOSCHED +- int active_numerous_groups; +-#endif +- ++ /* ++ * rbtree of weight counters of @bfq_queues, sorted by ++ * weight. Used to keep track of whether all @bfq_queues have ++ * the same weight. The tree contains one counter for each ++ * distinct weight associated to some active and not ++ * weight-raised @bfq_queue (see the comments to the functions ++ * bfq_weights_tree_[add|remove] for further details). ++ */ + struct rb_root queue_weights_tree; ++ /* ++ * rbtree of non-queue @bfq_entity weight counters, sorted by ++ * weight. Used to keep track of whether all @bfq_groups have ++ * the same weight. The tree contains one counter for each ++ * distinct weight associated to some active @bfq_group (see ++ * the comments to the functions bfq_weights_tree_[add|remove] ++ * for further details). ++ */ + struct rb_root group_weights_tree; + ++ /* ++ * Number of bfq_queues containing requests (including the ++ * queue in service, even if it is idling). ++ */ + int busy_queues; +- int busy_in_flight_queues; +- int const_seeky_busy_in_flight_queues; ++ /* number of weight-raised busy @bfq_queues */ + int wr_busy_queues; ++ /* number of queued requests */ + int queued; ++ /* number of requests dispatched and waiting for completion */ + int rq_in_driver; +- int sync_flight; + ++ /* ++ * Maximum number of requests in driver in the last ++ * @hw_tag_samples completed requests. ++ */ + int max_rq_in_driver; ++ /* number of samples used to calculate hw_tag */ + int hw_tag_samples; ++ /* flag set to one if the driver is showing a queueing behavior */ + int hw_tag; + ++ /* number of budgets assigned */ + int budgets_assigned; + +- struct timer_list idle_slice_timer; ++ /* ++ * Timer set when idling (waiting) for the next request from ++ * the queue in service. ++ */ ++ struct hrtimer idle_slice_timer; ++ /* delayed work to restart dispatching on the request queue */ + struct work_struct unplug_work; + ++ /* bfq_queue in service */ + struct bfq_queue *in_service_queue; ++ /* bfq_io_cq (bic) associated with the @in_service_queue */ + struct bfq_io_cq *in_service_bic; + ++ /* on-disk position of the last served request */ + sector_t last_position; + ++ /* time of last request completion (ns) */ ++ u64 last_completion; ++ ++ /* time of first rq dispatch in current observation interval (ns) */ ++ u64 first_dispatch; ++ /* time of last rq dispatch in current observation interval (ns) */ ++ u64 last_dispatch; ++ ++ /* beginning of the last budget */ + ktime_t last_budget_start; ++ /* beginning of the last idle slice */ + ktime_t last_idling_start; ++ ++ /* number of samples in current observation interval */ + int peak_rate_samples; +- u64 peak_rate; ++ /* num of samples of seq dispatches in current observation interval */ ++ u32 sequential_samples; ++ /* total num of sectors transferred in current observation interval */ ++ u64 tot_sectors_dispatched; ++ /* max rq size seen during current observation interval (sectors) */ ++ u32 last_rq_max_size; ++ /* time elapsed from first dispatch in current observ. interval (us) */ ++ u64 delta_from_first; ++ /* current estimate of device peak rate */ ++ u32 peak_rate; ++ ++ /* maximum budget allotted to a bfq_queue before rescheduling */ + int bfq_max_budget; + ++ /* list of all the bfq_queues active on the device */ + struct list_head active_list; ++ /* list of all the bfq_queues idle on the device */ + struct list_head idle_list; + +- unsigned int bfq_fifo_expire[2]; ++ /* ++ * Timeout for async/sync requests; when it fires, requests ++ * are served in fifo order. ++ */ ++ u64 bfq_fifo_expire[2]; ++ /* weight of backward seeks wrt forward ones */ + unsigned int bfq_back_penalty; ++ /* maximum allowed backward seek */ + unsigned int bfq_back_max; +- unsigned int bfq_slice_idle; +- u64 bfq_class_idle_last_service; ++ /* maximum idling time */ ++ u32 bfq_slice_idle; + ++ /* user-configured max budget value (0 for auto-tuning) */ + int bfq_user_max_budget; +- int bfq_max_budget_async_rq; +- unsigned int bfq_timeout[2]; +- +- unsigned int bfq_coop_thresh; +- unsigned int bfq_failed_cooperations; ++ /* ++ * Timeout for bfq_queues to consume their budget; used to ++ * prevent seeky queues from imposing long latencies to ++ * sequential or quasi-sequential ones (this also implies that ++ * seeky queues cannot receive guarantees in the service ++ * domain; after a timeout they are charged for the time they ++ * have been in service, to preserve fairness among them, but ++ * without service-domain guarantees). ++ */ ++ unsigned int bfq_timeout; ++ ++ /* ++ * Number of consecutive requests that must be issued within ++ * the idle time slice to set again idling to a queue which ++ * was marked as non-I/O-bound (see the definition of the ++ * IO_bound flag for further details). ++ */ + unsigned int bfq_requests_within_timer; + ++ /* ++ * Force device idling whenever needed to provide accurate ++ * service guarantees, without caring about throughput ++ * issues. CAVEAT: this may even increase latencies, in case ++ * of useless idling for processes that did stop doing I/O. ++ */ ++ bool strict_guarantees; ++ ++ /* ++ * Last time at which a queue entered the current burst of ++ * queues being activated shortly after each other; for more ++ * details about this and the following parameters related to ++ * a burst of activations, see the comments on the function ++ * bfq_handle_burst. ++ */ + unsigned long last_ins_in_burst; ++ /* ++ * Reference time interval used to decide whether a queue has ++ * been activated shortly after @last_ins_in_burst. ++ */ + unsigned long bfq_burst_interval; ++ /* number of queues in the current burst of queue activations */ + int burst_size; ++ ++ /* common parent entity for the queues in the burst */ ++ struct bfq_entity *burst_parent_entity; ++ /* Maximum burst size above which the current queue-activation ++ * burst is deemed as 'large'. ++ */ + unsigned long bfq_large_burst_thresh; ++ /* true if a large queue-activation burst is in progress */ + bool large_burst; ++ /* ++ * Head of the burst list (as for the above fields, more ++ * details in the comments on the function bfq_handle_burst). ++ */ + struct hlist_head burst_list; + ++ /* if set to true, low-latency heuristics are enabled */ + bool low_latency; +- +- /* parameters of the low_latency heuristics */ ++ /* ++ * Maximum factor by which the weight of a weight-raised queue ++ * is multiplied. ++ */ + unsigned int bfq_wr_coeff; ++ /* maximum duration of a weight-raising period (jiffies) */ + unsigned int bfq_wr_max_time; ++ ++ /* Maximum weight-raising duration for soft real-time processes */ + unsigned int bfq_wr_rt_max_time; ++ /* ++ * Minimum idle period after which weight-raising may be ++ * reactivated for a queue (in jiffies). ++ */ + unsigned int bfq_wr_min_idle_time; ++ /* ++ * Minimum period between request arrivals after which ++ * weight-raising may be reactivated for an already busy async ++ * queue (in jiffies). ++ */ + unsigned long bfq_wr_min_inter_arr_async; ++ ++ /* Max service-rate for a soft real-time queue, in sectors/sec */ + unsigned int bfq_wr_max_softrt_rate; ++ /* ++ * Cached value of the product R*T, used for computing the ++ * maximum duration of weight raising automatically. ++ */ + u64 RT_prod; ++ /* device-speed class for the low-latency heuristic */ + enum bfq_device_speed device_speed; + ++ /* fallback dummy bfqq for extreme OOM conditions */ + struct bfq_queue oom_bfqq; + }; + + enum bfqq_state_flags { +- BFQ_BFQQ_FLAG_busy = 0, /* has requests or is in service */ ++ BFQ_BFQQ_FLAG_just_created = 0, /* queue just allocated */ ++ BFQ_BFQQ_FLAG_busy, /* has requests or is in service */ + BFQ_BFQQ_FLAG_wait_request, /* waiting for a request */ ++ BFQ_BFQQ_FLAG_non_blocking_wait_rq, /* ++ * waiting for a request ++ * without idling the device ++ */ + BFQ_BFQQ_FLAG_must_alloc, /* must be allowed rq alloc */ + BFQ_BFQQ_FLAG_fifo_expire, /* FIFO checked in this slice */ + BFQ_BFQQ_FLAG_idle_window, /* slice idling enabled */ + BFQ_BFQQ_FLAG_sync, /* synchronous queue */ +- BFQ_BFQQ_FLAG_budget_new, /* no completion with this budget */ + BFQ_BFQQ_FLAG_IO_bound, /* + * bfqq has timed-out at least once + * having consumed at most 2/10 of +@@ -581,17 +610,12 @@ enum bfqq_state_flags { + * bfqq activated in a large burst, + * see comments to bfq_handle_burst. + */ +- BFQ_BFQQ_FLAG_constantly_seeky, /* +- * bfqq has proved to be slow and +- * seeky until budget timeout +- */ + BFQ_BFQQ_FLAG_softrt_update, /* + * may need softrt-next-start + * update + */ + BFQ_BFQQ_FLAG_coop, /* bfqq is shared */ +- BFQ_BFQQ_FLAG_split_coop, /* shared bfqq will be split */ +- BFQ_BFQQ_FLAG_just_split, /* queue has just been split */ ++ BFQ_BFQQ_FLAG_split_coop /* shared bfqq will be split */ + }; + + #define BFQ_BFQQ_FNS(name) \ +@@ -608,28 +632,94 @@ static int bfq_bfqq_##name(const struct bfq_queue *bfqq) \ + return ((bfqq)->flags & (1 << BFQ_BFQQ_FLAG_##name)) != 0; \ + } + ++BFQ_BFQQ_FNS(just_created); + BFQ_BFQQ_FNS(busy); + BFQ_BFQQ_FNS(wait_request); ++BFQ_BFQQ_FNS(non_blocking_wait_rq); + BFQ_BFQQ_FNS(must_alloc); + BFQ_BFQQ_FNS(fifo_expire); + BFQ_BFQQ_FNS(idle_window); + BFQ_BFQQ_FNS(sync); +-BFQ_BFQQ_FNS(budget_new); + BFQ_BFQQ_FNS(IO_bound); + BFQ_BFQQ_FNS(in_large_burst); +-BFQ_BFQQ_FNS(constantly_seeky); + BFQ_BFQQ_FNS(coop); + BFQ_BFQQ_FNS(split_coop); +-BFQ_BFQQ_FNS(just_split); + BFQ_BFQQ_FNS(softrt_update); + #undef BFQ_BFQQ_FNS + + /* Logging facilities. */ +-#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) \ +- blk_add_trace_msg((bfqd)->queue, "bfq%d " fmt, (bfqq)->pid, ##args) ++#ifdef CONFIG_BFQ_REDIRECT_TO_CONSOLE ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++static struct bfq_group *bfqq_group(struct bfq_queue *bfqq); ++static struct blkcg_gq *bfqg_to_blkg(struct bfq_group *bfqg); ++ ++#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \ ++ char __pbuf[128]; \ ++ \ ++ assert_spin_locked((bfqd)->queue->queue_lock); \ ++ blkg_path(bfqg_to_blkg(bfqq_group(bfqq)), __pbuf, sizeof(__pbuf)); \ ++ pr_crit("bfq%d%c %s " fmt "\n", \ ++ (bfqq)->pid, \ ++ bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \ ++ __pbuf, ##args); \ ++} while (0) ++ ++#define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do { \ ++ char __pbuf[128]; \ ++ \ ++ blkg_path(bfqg_to_blkg(bfqg), __pbuf, sizeof(__pbuf)); \ ++ pr_crit("%s " fmt "\n", __pbuf, ##args); \ ++} while (0) ++ ++#else /* CONFIG_BFQ_GROUP_IOSCHED */ ++ ++#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) \ ++ pr_crit("bfq%d%c " fmt "\n", (bfqq)->pid, \ ++ bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \ ++ ##args) ++#define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do {} while (0) ++ ++#endif /* CONFIG_BFQ_GROUP_IOSCHED */ ++ ++#define bfq_log(bfqd, fmt, args...) \ ++ pr_crit("bfq " fmt "\n", ##args) ++ ++#else /* CONFIG_BFQ_REDIRECT_TO_CONSOLE */ ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++static struct bfq_group *bfqq_group(struct bfq_queue *bfqq); ++static struct blkcg_gq *bfqg_to_blkg(struct bfq_group *bfqg); ++ ++#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \ ++ char __pbuf[128]; \ ++ \ ++ assert_spin_locked((bfqd)->queue->queue_lock); \ ++ blkg_path(bfqg_to_blkg(bfqq_group(bfqq)), __pbuf, sizeof(__pbuf)); \ ++ blk_add_trace_msg((bfqd)->queue, "bfq%d%c %s " fmt, \ ++ (bfqq)->pid, \ ++ bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \ ++ __pbuf, ##args); \ ++} while (0) ++ ++#define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do { \ ++ char __pbuf[128]; \ ++ \ ++ blkg_path(bfqg_to_blkg(bfqg), __pbuf, sizeof(__pbuf)); \ ++ blk_add_trace_msg((bfqd)->queue, "%s " fmt, __pbuf, ##args); \ ++} while (0) ++ ++#else /* CONFIG_BFQ_GROUP_IOSCHED */ ++ ++#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) \ ++ blk_add_trace_msg((bfqd)->queue, "bfq%d%c " fmt, (bfqq)->pid, \ ++ bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \ ++ ##args) ++#define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do {} while (0) ++ ++#endif /* CONFIG_BFQ_GROUP_IOSCHED */ + + #define bfq_log(bfqd, fmt, args...) \ + blk_add_trace_msg((bfqd)->queue, "bfq " fmt, ##args) ++#endif /* CONFIG_BFQ_REDIRECT_TO_CONSOLE */ + + /* Expiration reasons. */ + enum bfqq_expiration { +@@ -640,15 +730,12 @@ enum bfqq_expiration { + BFQ_BFQQ_BUDGET_TIMEOUT, /* budget took too long to be used */ + BFQ_BFQQ_BUDGET_EXHAUSTED, /* budget consumed */ + BFQ_BFQQ_NO_MORE_REQUESTS, /* the queue has no more requests */ ++ BFQ_BFQQ_PREEMPTED /* preemption in progress */ + }; + +-#ifdef CONFIG_BFQ_GROUP_IOSCHED + + struct bfqg_stats { +- /* total bytes transferred */ +- struct blkg_rwstat service_bytes; +- /* total IOs serviced, post merge */ +- struct blkg_rwstat serviced; ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + /* number of ios merged */ + struct blkg_rwstat merged; + /* total time spent on device in ns, may not be accurate w/ queueing */ +@@ -657,12 +744,8 @@ struct bfqg_stats { + struct blkg_rwstat wait_time; + /* number of IOs queued up */ + struct blkg_rwstat queued; +- /* total sectors transferred */ +- struct blkg_stat sectors; + /* total disk time and nr sectors dispatched by this group */ + struct blkg_stat time; +- /* time not charged to this cgroup */ +- struct blkg_stat unaccounted_time; + /* sum of number of ios queued across all samples */ + struct blkg_stat avg_queue_size_sum; + /* count of samples taken for average */ +@@ -680,8 +763,10 @@ struct bfqg_stats { + uint64_t start_idle_time; + uint64_t start_empty_time; + uint16_t flags; ++#endif + }; + ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + /* + * struct bfq_group_data - per-blkcg storage for the blkio subsystem. + * +@@ -692,7 +777,7 @@ struct bfq_group_data { + /* must be the first member */ + struct blkcg_policy_data pd; + +- unsigned short weight; ++ unsigned int weight; + }; + + /** +@@ -712,7 +797,7 @@ struct bfq_group_data { + * unused for the root group. Used to know whether there + * are groups with more than one active @bfq_entity + * (see the comments to the function +- * bfq_bfqq_must_not_expire()). ++ * bfq_bfqq_may_idle()). + * @rq_pos_tree: rbtree sorted by next_request position, used when + * determining if two or more queues have interleaving + * requests (see bfq_find_close_cooperator()). +@@ -745,7 +830,6 @@ struct bfq_group { + struct rb_root rq_pos_tree; + + struct bfqg_stats stats; +- struct bfqg_stats dead_stats; /* stats pushed from dead children */ + }; + + #else +@@ -761,17 +845,38 @@ struct bfq_group { + + static struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity); + ++static unsigned int bfq_class_idx(struct bfq_entity *entity) ++{ ++ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); ++ ++ return bfqq ? bfqq->ioprio_class - 1 : ++ BFQ_DEFAULT_GRP_CLASS - 1; ++} ++ + static struct bfq_service_tree * + bfq_entity_service_tree(struct bfq_entity *entity) + { + struct bfq_sched_data *sched_data = entity->sched_data; + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); +- unsigned int idx = bfqq ? bfqq->ioprio_class - 1 : +- BFQ_DEFAULT_GRP_CLASS; ++ unsigned int idx = bfq_class_idx(entity); + + BUG_ON(idx >= BFQ_IOPRIO_CLASSES); + BUG_ON(sched_data == NULL); + ++ if (bfqq) ++ bfq_log_bfqq(bfqq->bfqd, bfqq, ++ "entity_service_tree %p %d", ++ sched_data->service_tree + idx, idx); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ else { ++ struct bfq_group *bfqg = ++ container_of(entity, struct bfq_group, entity); ++ ++ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, ++ "entity_service_tree %p %d", ++ sched_data->service_tree + idx, idx); ++ } ++#endif + return sched_data->service_tree + idx; + } + +@@ -791,47 +896,6 @@ static struct bfq_data *bic_to_bfqd(struct bfq_io_cq *bic) + return bic->icq.q->elevator->elevator_data; + } + +-/** +- * bfq_get_bfqd_locked - get a lock to a bfqd using a RCU protected pointer. +- * @ptr: a pointer to a bfqd. +- * @flags: storage for the flags to be saved. +- * +- * This function allows bfqg->bfqd to be protected by the +- * queue lock of the bfqd they reference; the pointer is dereferenced +- * under RCU, so the storage for bfqd is assured to be safe as long +- * as the RCU read side critical section does not end. After the +- * bfqd->queue->queue_lock is taken the pointer is rechecked, to be +- * sure that no other writer accessed it. If we raced with a writer, +- * the function returns NULL, with the queue unlocked, otherwise it +- * returns the dereferenced pointer, with the queue locked. +- */ +-static struct bfq_data *bfq_get_bfqd_locked(void **ptr, unsigned long *flags) +-{ +- struct bfq_data *bfqd; +- +- rcu_read_lock(); +- bfqd = rcu_dereference(*(struct bfq_data **)ptr); +- +- if (bfqd != NULL) { +- spin_lock_irqsave(bfqd->queue->queue_lock, *flags); +- if (ptr == NULL) +- printk(KERN_CRIT "get_bfqd_locked pointer NULL\n"); +- else if (*ptr == bfqd) +- goto out; +- spin_unlock_irqrestore(bfqd->queue->queue_lock, *flags); +- } +- +- bfqd = NULL; +-out: +- rcu_read_unlock(); +- return bfqd; +-} +- +-static void bfq_put_bfqd_unlock(struct bfq_data *bfqd, unsigned long *flags) +-{ +- spin_unlock_irqrestore(bfqd->queue->queue_lock, *flags); +-} +- + #ifdef CONFIG_BFQ_GROUP_IOSCHED + + static struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) +@@ -857,11 +921,13 @@ static void bfq_check_ioprio_change(struct bfq_io_cq *bic, struct bio *bio); + static void bfq_put_queue(struct bfq_queue *bfqq); + static void bfq_dispatch_insert(struct request_queue *q, struct request *rq); + static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, +- struct bio *bio, int is_sync, +- struct bfq_io_cq *bic, gfp_t gfp_mask); ++ struct bio *bio, bool is_sync, ++ struct bfq_io_cq *bic); + static void bfq_end_wr_async_queues(struct bfq_data *bfqd, + struct bfq_group *bfqg); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + static void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg); ++#endif + static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq); + + #endif /* _BFQ_H */ +-- +2.10.0 + diff --git a/kernel/kernel/files/patches/mageia/block-bfq-add-Early-Queue-Merge-EQM-to-BFQ-v7r11-for.patch b/kernel/kernel/files/patches/mageia/block-bfq-add-Early-Queue-Merge-EQM-to-BFQ-v7r11-for.patch new file mode 100644 index 00000000..e3a09b34 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/block-bfq-add-Early-Queue-Merge-EQM-to-BFQ-v7r11-for.patch @@ -0,0 +1,1101 @@ +From 52135041a6bf118c80a6858f63aff70b325389c4 Mon Sep 17 00:00:00 2001 +From: Mauro Andreolini +Date: Sun, 6 Sep 2015 16:09:05 +0200 +Subject: [PATCH 3/4] block, bfq: add Early Queue Merge (EQM) to BFQ-v7r11 for + 4.5.0 + +A set of processes may happen to perform interleaved reads, i.e.,requests +whose union would give rise to a sequential read pattern. There are two +typical cases: in the first case, processes read fixed-size chunks of +data at a fixed distance from each other, while in the second case processes +may read variable-size chunks at variable distances. The latter case occurs +for example with QEMU, which splits the I/O generated by the guest into +multiple chunks, and lets these chunks be served by a pool of cooperating +processes, iteratively assigning the next chunk of I/O to the first +available process. CFQ uses actual queue merging for the first type of +rocesses, whereas it uses preemption to get a sequential read pattern out +of the read requests performed by the second type of processes. In the end +it uses two different mechanisms to achieve the same goal: boosting the +throughput with interleaved I/O. + +This patch introduces Early Queue Merge (EQM), a unified mechanism to get a +sequential read pattern with both types of processes. The main idea is +checking newly arrived requests against the next request of the active queue +both in case of actual request insert and in case of request merge. By doing +so, both the types of processes can be handled by just merging their queues. +EQM is then simpler and more compact than the pair of mechanisms used in +CFQ. + +Finally, EQM also preserves the typical low-latency properties of BFQ, by +properly restoring the weight-raising state of a queue when it gets back to +a non-merged state. + +Signed-off-by: Mauro Andreolini +Signed-off-by: Arianna Avanzini +Signed-off-by: Paolo Valente +Signed-off-by: Linus Walleij +--- + block/bfq-cgroup.c | 5 + + block/bfq-iosched.c | 685 +++++++++++++++++++++++++++++++++++++++++++++++++++- + block/bfq.h | 66 +++++ + 3 files changed, 743 insertions(+), 13 deletions(-) + +diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c +index 8b08a57..0367996 100644 +--- a/block/bfq-cgroup.c ++++ b/block/bfq-cgroup.c +@@ -440,6 +440,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd) + */ + bfqg->bfqd = bfqd; + bfqg->active_entities = 0; ++ bfqg->rq_pos_tree = RB_ROOT; + } + + static void bfq_pd_free(struct blkg_policy_data *pd) +@@ -533,6 +534,9 @@ static struct bfq_group *bfq_find_alloc_group(struct bfq_data *bfqd, + return bfqg; + } + ++static void bfq_pos_tree_add_move(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq); ++ + /** + * bfq_bfqq_move - migrate @bfqq to @bfqg. + * @bfqd: queue descriptor. +@@ -580,6 +584,7 @@ static void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq, + bfqg_get(bfqg); + + if (busy) { ++ bfq_pos_tree_add_move(bfqd, bfqq); + if (resume) + bfq_activate_bfqq(bfqd, bfqq); + } +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c +index 85e2169..cf3e9b1 100644 +--- a/block/bfq-iosched.c ++++ b/block/bfq-iosched.c +@@ -295,6 +295,72 @@ static struct request *bfq_choose_req(struct bfq_data *bfqd, + } + } + ++static struct bfq_queue * ++bfq_rq_pos_tree_lookup(struct bfq_data *bfqd, struct rb_root *root, ++ sector_t sector, struct rb_node **ret_parent, ++ struct rb_node ***rb_link) ++{ ++ struct rb_node **p, *parent; ++ struct bfq_queue *bfqq = NULL; ++ ++ parent = NULL; ++ p = &root->rb_node; ++ while (*p) { ++ struct rb_node **n; ++ ++ parent = *p; ++ bfqq = rb_entry(parent, struct bfq_queue, pos_node); ++ ++ /* ++ * Sort strictly based on sector. Smallest to the left, ++ * largest to the right. ++ */ ++ if (sector > blk_rq_pos(bfqq->next_rq)) ++ n = &(*p)->rb_right; ++ else if (sector < blk_rq_pos(bfqq->next_rq)) ++ n = &(*p)->rb_left; ++ else ++ break; ++ p = n; ++ bfqq = NULL; ++ } ++ ++ *ret_parent = parent; ++ if (rb_link) ++ *rb_link = p; ++ ++ bfq_log(bfqd, "rq_pos_tree_lookup %llu: returning %d", ++ (unsigned long long) sector, ++ bfqq ? bfqq->pid : 0); ++ ++ return bfqq; ++} ++ ++static void bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq) ++{ ++ struct rb_node **p, *parent; ++ struct bfq_queue *__bfqq; ++ ++ if (bfqq->pos_root) { ++ rb_erase(&bfqq->pos_node, bfqq->pos_root); ++ bfqq->pos_root = NULL; ++ } ++ ++ if (bfq_class_idle(bfqq)) ++ return; ++ if (!bfqq->next_rq) ++ return; ++ ++ bfqq->pos_root = &bfq_bfqq_to_bfqg(bfqq)->rq_pos_tree; ++ __bfqq = bfq_rq_pos_tree_lookup(bfqd, bfqq->pos_root, ++ blk_rq_pos(bfqq->next_rq), &parent, &p); ++ if (!__bfqq) { ++ rb_link_node(&bfqq->pos_node, parent, p); ++ rb_insert_color(&bfqq->pos_node, bfqq->pos_root); ++ } else ++ bfqq->pos_root = NULL; ++} ++ + /* + * Tell whether there are active queues or groups with differentiated weights. + */ +@@ -527,6 +593,57 @@ static unsigned int bfq_wr_duration(struct bfq_data *bfqd) + return dur; + } + ++static unsigned int bfq_bfqq_cooperations(struct bfq_queue *bfqq) ++{ ++ return bfqq->bic ? bfqq->bic->cooperations : 0; ++} ++ ++static void ++bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_io_cq *bic) ++{ ++ if (bic->saved_idle_window) ++ bfq_mark_bfqq_idle_window(bfqq); ++ else ++ bfq_clear_bfqq_idle_window(bfqq); ++ if (bic->saved_IO_bound) ++ bfq_mark_bfqq_IO_bound(bfqq); ++ else ++ bfq_clear_bfqq_IO_bound(bfqq); ++ /* Assuming that the flag in_large_burst is already correctly set */ ++ if (bic->wr_time_left && bfqq->bfqd->low_latency && ++ !bfq_bfqq_in_large_burst(bfqq) && ++ bic->cooperations < bfqq->bfqd->bfq_coop_thresh) { ++ /* ++ * Start a weight raising period with the duration given by ++ * the raising_time_left snapshot. ++ */ ++ if (bfq_bfqq_busy(bfqq)) ++ bfqq->bfqd->wr_busy_queues++; ++ bfqq->wr_coeff = bfqq->bfqd->bfq_wr_coeff; ++ bfqq->wr_cur_max_time = bic->wr_time_left; ++ bfqq->last_wr_start_finish = jiffies; ++ bfqq->entity.prio_changed = 1; ++ } ++ /* ++ * Clear wr_time_left to prevent bfq_bfqq_save_state() from ++ * getting confused about the queue's need of a weight-raising ++ * period. ++ */ ++ bic->wr_time_left = 0; ++} ++ ++static int bfqq_process_refs(struct bfq_queue *bfqq) ++{ ++ int process_refs, io_refs; ++ ++ lockdep_assert_held(bfqq->bfqd->queue->queue_lock); ++ ++ io_refs = bfqq->allocated[READ] + bfqq->allocated[WRITE]; ++ process_refs = atomic_read(&bfqq->ref) - io_refs - bfqq->entity.on_st; ++ BUG_ON(process_refs < 0); ++ return process_refs; ++} ++ + /* Empty burst list and add just bfqq (see comments to bfq_handle_burst) */ + static void bfq_reset_burst_list(struct bfq_data *bfqd, struct bfq_queue *bfqq) + { +@@ -763,8 +880,14 @@ static void bfq_add_request(struct request *rq) + BUG_ON(!next_rq); + bfqq->next_rq = next_rq; + ++ /* ++ * Adjust priority tree position, if next_rq changes. ++ */ ++ if (prev != bfqq->next_rq) ++ bfq_pos_tree_add_move(bfqd, bfqq); ++ + if (!bfq_bfqq_busy(bfqq)) { +- bool soft_rt, in_burst, ++ bool soft_rt, coop_or_in_burst, + idle_for_long_time = time_is_before_jiffies( + bfqq->budget_timeout + + bfqd->bfq_wr_min_idle_time); +@@ -792,11 +915,12 @@ static void bfq_add_request(struct request *rq) + bfqd->last_ins_in_burst = jiffies; + } + +- in_burst = bfq_bfqq_in_large_burst(bfqq); ++ coop_or_in_burst = bfq_bfqq_in_large_burst(bfqq) || ++ bfq_bfqq_cooperations(bfqq) >= bfqd->bfq_coop_thresh; + soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && +- !in_burst && ++ !coop_or_in_burst && + time_is_before_jiffies(bfqq->soft_rt_next_start); +- interactive = !in_burst && idle_for_long_time; ++ interactive = !coop_or_in_burst && idle_for_long_time; + entity->budget = max_t(unsigned long, bfqq->max_budget, + bfq_serv_to_charge(next_rq, bfqq)); + +@@ -815,6 +939,9 @@ static void bfq_add_request(struct request *rq) + if (!bfqd->low_latency) + goto add_bfqq_busy; + ++ if (bfq_bfqq_just_split(bfqq)) ++ goto set_prio_changed; ++ + /* + * If the queue: + * - is not being boosted, +@@ -839,7 +966,7 @@ static void bfq_add_request(struct request *rq) + } else if (old_wr_coeff > 1) { + if (interactive) + bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); +- else if (in_burst || ++ else if (coop_or_in_burst || + (bfqq->wr_cur_max_time == + bfqd->bfq_wr_rt_max_time && + !soft_rt)) { +@@ -904,6 +1031,7 @@ static void bfq_add_request(struct request *rq) + bfqd->bfq_wr_rt_max_time; + } + } ++set_prio_changed: + if (old_wr_coeff != bfqq->wr_coeff) + entity->prio_changed = 1; + add_bfqq_busy: +@@ -1046,6 +1174,15 @@ static void bfq_merged_request(struct request_queue *q, struct request *req, + bfqd->last_position); + BUG_ON(!next_rq); + bfqq->next_rq = next_rq; ++ /* ++ * If next_rq changes, update both the queue's budget to ++ * fit the new request and the queue's position in its ++ * rq_pos_tree. ++ */ ++ if (prev != bfqq->next_rq) { ++ bfq_updated_next_req(bfqd, bfqq); ++ bfq_pos_tree_add_move(bfqd, bfqq); ++ } + } + } + +@@ -1128,11 +1265,346 @@ static void bfq_end_wr(struct bfq_data *bfqd) + spin_unlock_irq(bfqd->queue->queue_lock); + } + ++static sector_t bfq_io_struct_pos(void *io_struct, bool request) ++{ ++ if (request) ++ return blk_rq_pos(io_struct); ++ else ++ return ((struct bio *)io_struct)->bi_iter.bi_sector; ++} ++ ++static int bfq_rq_close_to_sector(void *io_struct, bool request, ++ sector_t sector) ++{ ++ return abs(bfq_io_struct_pos(io_struct, request) - sector) <= ++ BFQQ_SEEK_THR; ++} ++ ++static struct bfq_queue *bfqq_find_close(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq, ++ sector_t sector) ++{ ++ struct rb_root *root = &bfq_bfqq_to_bfqg(bfqq)->rq_pos_tree; ++ struct rb_node *parent, *node; ++ struct bfq_queue *__bfqq; ++ ++ if (RB_EMPTY_ROOT(root)) ++ return NULL; ++ ++ /* ++ * First, if we find a request starting at the end of the last ++ * request, choose it. ++ */ ++ __bfqq = bfq_rq_pos_tree_lookup(bfqd, root, sector, &parent, NULL); ++ if (__bfqq) ++ return __bfqq; ++ ++ /* ++ * If the exact sector wasn't found, the parent of the NULL leaf ++ * will contain the closest sector (rq_pos_tree sorted by ++ * next_request position). ++ */ ++ __bfqq = rb_entry(parent, struct bfq_queue, pos_node); ++ if (bfq_rq_close_to_sector(__bfqq->next_rq, true, sector)) ++ return __bfqq; ++ ++ if (blk_rq_pos(__bfqq->next_rq) < sector) ++ node = rb_next(&__bfqq->pos_node); ++ else ++ node = rb_prev(&__bfqq->pos_node); ++ if (!node) ++ return NULL; ++ ++ __bfqq = rb_entry(node, struct bfq_queue, pos_node); ++ if (bfq_rq_close_to_sector(__bfqq->next_rq, true, sector)) ++ return __bfqq; ++ ++ return NULL; ++} ++ ++static struct bfq_queue *bfq_find_close_cooperator(struct bfq_data *bfqd, ++ struct bfq_queue *cur_bfqq, ++ sector_t sector) ++{ ++ struct bfq_queue *bfqq; ++ ++ /* ++ * We shall notice if some of the queues are cooperating, ++ * e.g., working closely on the same area of the device. In ++ * that case, we can group them together and: 1) don't waste ++ * time idling, and 2) serve the union of their requests in ++ * the best possible order for throughput. ++ */ ++ bfqq = bfqq_find_close(bfqd, cur_bfqq, sector); ++ if (!bfqq || bfqq == cur_bfqq) ++ return NULL; ++ ++ return bfqq; ++} ++ ++static struct bfq_queue * ++bfq_setup_merge(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq) ++{ ++ int process_refs, new_process_refs; ++ struct bfq_queue *__bfqq; ++ ++ /* ++ * If there are no process references on the new_bfqq, then it is ++ * unsafe to follow the ->new_bfqq chain as other bfqq's in the chain ++ * may have dropped their last reference (not just their last process ++ * reference). ++ */ ++ if (!bfqq_process_refs(new_bfqq)) ++ return NULL; ++ ++ /* Avoid a circular list and skip interim queue merges. */ ++ while ((__bfqq = new_bfqq->new_bfqq)) { ++ if (__bfqq == bfqq) ++ return NULL; ++ new_bfqq = __bfqq; ++ } ++ ++ process_refs = bfqq_process_refs(bfqq); ++ new_process_refs = bfqq_process_refs(new_bfqq); ++ /* ++ * If the process for the bfqq has gone away, there is no ++ * sense in merging the queues. ++ */ ++ if (process_refs == 0 || new_process_refs == 0) ++ return NULL; ++ ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "scheduling merge with queue %d", ++ new_bfqq->pid); ++ ++ /* ++ * Merging is just a redirection: the requests of the process ++ * owning one of the two queues are redirected to the other queue. ++ * The latter queue, in its turn, is set as shared if this is the ++ * first time that the requests of some process are redirected to ++ * it. ++ * ++ * We redirect bfqq to new_bfqq and not the opposite, because we ++ * are in the context of the process owning bfqq, hence we have ++ * the io_cq of this process. So we can immediately configure this ++ * io_cq to redirect the requests of the process to new_bfqq. ++ * ++ * NOTE, even if new_bfqq coincides with the in-service queue, the ++ * io_cq of new_bfqq is not available, because, if the in-service ++ * queue is shared, bfqd->in_service_bic may not point to the ++ * io_cq of the in-service queue. ++ * Redirecting the requests of the process owning bfqq to the ++ * currently in-service queue is in any case the best option, as ++ * we feed the in-service queue with new requests close to the ++ * last request served and, by doing so, hopefully increase the ++ * throughput. ++ */ ++ bfqq->new_bfqq = new_bfqq; ++ atomic_add(process_refs, &new_bfqq->ref); ++ return new_bfqq; ++} ++ ++static bool bfq_may_be_close_cooperator(struct bfq_queue *bfqq, ++ struct bfq_queue *new_bfqq) ++{ ++ if (bfq_class_idle(bfqq) || bfq_class_idle(new_bfqq) || ++ (bfqq->ioprio_class != new_bfqq->ioprio_class)) ++ return false; ++ ++ /* ++ * If either of the queues has already been detected as seeky, ++ * then merging it with the other queue is unlikely to lead to ++ * sequential I/O. ++ */ ++ if (BFQQ_SEEKY(bfqq) || BFQQ_SEEKY(new_bfqq)) ++ return false; ++ ++ /* ++ * Interleaved I/O is known to be done by (some) applications ++ * only for reads, so it does not make sense to merge async ++ * queues. ++ */ ++ if (!bfq_bfqq_sync(bfqq) || !bfq_bfqq_sync(new_bfqq)) ++ return false; ++ ++ return true; ++} ++ ++/* ++ * Attempt to schedule a merge of bfqq with the currently in-service queue ++ * or with a close queue among the scheduled queues. ++ * Return NULL if no merge was scheduled, a pointer to the shared bfq_queue ++ * structure otherwise. ++ * ++ * The OOM queue is not allowed to participate to cooperation: in fact, since ++ * the requests temporarily redirected to the OOM queue could be redirected ++ * again to dedicated queues at any time, the state needed to correctly ++ * handle merging with the OOM queue would be quite complex and expensive ++ * to maintain. Besides, in such a critical condition as an out of memory, ++ * the benefits of queue merging may be little relevant, or even negligible. ++ */ ++static struct bfq_queue * ++bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, ++ void *io_struct, bool request) ++{ ++ struct bfq_queue *in_service_bfqq, *new_bfqq; ++ ++ if (bfqq->new_bfqq) ++ return bfqq->new_bfqq; ++ if (!io_struct || unlikely(bfqq == &bfqd->oom_bfqq)) ++ return NULL; ++ /* If device has only one backlogged bfq_queue, don't search. */ ++ if (bfqd->busy_queues == 1) ++ return NULL; ++ ++ in_service_bfqq = bfqd->in_service_queue; ++ ++ if (!in_service_bfqq || in_service_bfqq == bfqq || ++ !bfqd->in_service_bic || ++ unlikely(in_service_bfqq == &bfqd->oom_bfqq)) ++ goto check_scheduled; ++ ++ if (bfq_rq_close_to_sector(io_struct, request, bfqd->last_position) && ++ bfqq->entity.parent == in_service_bfqq->entity.parent && ++ bfq_may_be_close_cooperator(bfqq, in_service_bfqq)) { ++ new_bfqq = bfq_setup_merge(bfqq, in_service_bfqq); ++ if (new_bfqq) ++ return new_bfqq; ++ } ++ /* ++ * Check whether there is a cooperator among currently scheduled ++ * queues. The only thing we need is that the bio/request is not ++ * NULL, as we need it to establish whether a cooperator exists. ++ */ ++check_scheduled: ++ new_bfqq = bfq_find_close_cooperator(bfqd, bfqq, ++ bfq_io_struct_pos(io_struct, request)); ++ ++ BUG_ON(new_bfqq && bfqq->entity.parent != new_bfqq->entity.parent); ++ ++ if (new_bfqq && likely(new_bfqq != &bfqd->oom_bfqq) && ++ bfq_may_be_close_cooperator(bfqq, new_bfqq)) ++ return bfq_setup_merge(bfqq, new_bfqq); ++ ++ return NULL; ++} ++ ++static void bfq_bfqq_save_state(struct bfq_queue *bfqq) ++{ ++ /* ++ * If !bfqq->bic, the queue is already shared or its requests ++ * have already been redirected to a shared queue; both idle window ++ * and weight raising state have already been saved. Do nothing. ++ */ ++ if (!bfqq->bic) ++ return; ++ if (bfqq->bic->wr_time_left) ++ /* ++ * This is the queue of a just-started process, and would ++ * deserve weight raising: we set wr_time_left to the full ++ * weight-raising duration to trigger weight-raising when ++ * and if the queue is split and the first request of the ++ * queue is enqueued. ++ */ ++ bfqq->bic->wr_time_left = bfq_wr_duration(bfqq->bfqd); ++ else if (bfqq->wr_coeff > 1) { ++ unsigned long wr_duration = ++ jiffies - bfqq->last_wr_start_finish; ++ /* ++ * It may happen that a queue's weight raising period lasts ++ * longer than its wr_cur_max_time, as weight raising is ++ * handled only when a request is enqueued or dispatched (it ++ * does not use any timer). If the weight raising period is ++ * about to end, don't save it. ++ */ ++ if (bfqq->wr_cur_max_time <= wr_duration) ++ bfqq->bic->wr_time_left = 0; ++ else ++ bfqq->bic->wr_time_left = ++ bfqq->wr_cur_max_time - wr_duration; ++ /* ++ * The bfq_queue is becoming shared or the requests of the ++ * process owning the queue are being redirected to a shared ++ * queue. Stop the weight raising period of the queue, as in ++ * both cases it should not be owned by an interactive or ++ * soft real-time application. ++ */ ++ bfq_bfqq_end_wr(bfqq); ++ } else ++ bfqq->bic->wr_time_left = 0; ++ bfqq->bic->saved_idle_window = bfq_bfqq_idle_window(bfqq); ++ bfqq->bic->saved_IO_bound = bfq_bfqq_IO_bound(bfqq); ++ bfqq->bic->saved_in_large_burst = bfq_bfqq_in_large_burst(bfqq); ++ bfqq->bic->was_in_burst_list = !hlist_unhashed(&bfqq->burst_list_node); ++ bfqq->bic->cooperations++; ++ bfqq->bic->failed_cooperations = 0; ++} ++ ++static void bfq_get_bic_reference(struct bfq_queue *bfqq) ++{ ++ /* ++ * If bfqq->bic has a non-NULL value, the bic to which it belongs ++ * is about to begin using a shared bfq_queue. ++ */ ++ if (bfqq->bic) ++ atomic_long_inc(&bfqq->bic->icq.ioc->refcount); ++} ++ ++static void ++bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic, ++ struct bfq_queue *bfqq, struct bfq_queue *new_bfqq) ++{ ++ bfq_log_bfqq(bfqd, bfqq, "merging with queue %lu", ++ (unsigned long) new_bfqq->pid); ++ /* Save weight raising and idle window of the merged queues */ ++ bfq_bfqq_save_state(bfqq); ++ bfq_bfqq_save_state(new_bfqq); ++ if (bfq_bfqq_IO_bound(bfqq)) ++ bfq_mark_bfqq_IO_bound(new_bfqq); ++ bfq_clear_bfqq_IO_bound(bfqq); ++ /* ++ * Grab a reference to the bic, to prevent it from being destroyed ++ * before being possibly touched by a bfq_split_bfqq(). ++ */ ++ bfq_get_bic_reference(bfqq); ++ bfq_get_bic_reference(new_bfqq); ++ /* ++ * Merge queues (that is, let bic redirect its requests to new_bfqq) ++ */ ++ bic_set_bfqq(bic, new_bfqq, 1); ++ bfq_mark_bfqq_coop(new_bfqq); ++ /* ++ * new_bfqq now belongs to at least two bics (it is a shared queue): ++ * set new_bfqq->bic to NULL. bfqq either: ++ * - does not belong to any bic any more, and hence bfqq->bic must ++ * be set to NULL, or ++ * - is a queue whose owning bics have already been redirected to a ++ * different queue, hence the queue is destined to not belong to ++ * any bic soon and bfqq->bic is already NULL (therefore the next ++ * assignment causes no harm). ++ */ ++ new_bfqq->bic = NULL; ++ bfqq->bic = NULL; ++ bfq_put_queue(bfqq); ++} ++ ++static void bfq_bfqq_increase_failed_cooperations(struct bfq_queue *bfqq) ++{ ++ struct bfq_io_cq *bic = bfqq->bic; ++ struct bfq_data *bfqd = bfqq->bfqd; ++ ++ if (bic && bfq_bfqq_cooperations(bfqq) >= bfqd->bfq_coop_thresh) { ++ bic->failed_cooperations++; ++ if (bic->failed_cooperations >= bfqd->bfq_failed_cooperations) ++ bic->cooperations = 0; ++ } ++} ++ + static int bfq_allow_merge(struct request_queue *q, struct request *rq, + struct bio *bio) + { + struct bfq_data *bfqd = q->elevator->elevator_data; + struct bfq_io_cq *bic; ++ struct bfq_queue *bfqq, *new_bfqq; + + /* + * Disallow merge of a sync bio into an async request. +@@ -1149,7 +1621,26 @@ static int bfq_allow_merge(struct request_queue *q, struct request *rq, + if (!bic) + return 0; + +- return bic_to_bfqq(bic, bfq_bio_sync(bio)) == RQ_BFQQ(rq); ++ bfqq = bic_to_bfqq(bic, bfq_bio_sync(bio)); ++ /* ++ * We take advantage of this function to perform an early merge ++ * of the queues of possible cooperating processes. ++ */ ++ if (bfqq) { ++ new_bfqq = bfq_setup_cooperator(bfqd, bfqq, bio, false); ++ if (new_bfqq) { ++ bfq_merge_bfqqs(bfqd, bic, bfqq, new_bfqq); ++ /* ++ * If we get here, the bio will be queued in the ++ * shared queue, i.e., new_bfqq, so use new_bfqq ++ * to decide whether bio and rq can be merged. ++ */ ++ bfqq = new_bfqq; ++ } else ++ bfq_bfqq_increase_failed_cooperations(bfqq); ++ } ++ ++ return bfqq == RQ_BFQQ(rq); + } + + static void __bfq_set_in_service_queue(struct bfq_data *bfqd, +@@ -1350,6 +1841,15 @@ static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq) + + __bfq_bfqd_reset_in_service(bfqd); + ++ /* ++ * If this bfqq is shared between multiple processes, check ++ * to make sure that those processes are still issuing I/Os ++ * within the mean seek distance. If not, it may be time to ++ * break the queues apart again. ++ */ ++ if (bfq_bfqq_coop(bfqq) && BFQQ_SEEKY(bfqq)) ++ bfq_mark_bfqq_split_coop(bfqq); ++ + if (RB_EMPTY_ROOT(&bfqq->sort_list)) { + /* + * Overloading budget_timeout field to store the time +@@ -1358,8 +1858,13 @@ static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq) + */ + bfqq->budget_timeout = jiffies; + bfq_del_bfqq_busy(bfqd, bfqq, 1); +- } else ++ } else { + bfq_activate_bfqq(bfqd, bfqq); ++ /* ++ * Resort priority tree of potential close cooperators. ++ */ ++ bfq_pos_tree_add_move(bfqd, bfqq); ++ } + } + + /** +@@ -2246,10 +2751,12 @@ static void bfq_update_wr_data(struct bfq_data *bfqd, struct bfq_queue *bfqq) + /* + * If the queue was activated in a burst, or + * too much time has elapsed from the beginning +- * of this weight-raising period, then end weight +- * raising. ++ * of this weight-raising period, or the queue has ++ * exceeded the acceptable number of cooperations, ++ * then end weight raising. + */ + if (bfq_bfqq_in_large_burst(bfqq) || ++ bfq_bfqq_cooperations(bfqq) >= bfqd->bfq_coop_thresh || + time_is_before_jiffies(bfqq->last_wr_start_finish + + bfqq->wr_cur_max_time)) { + bfqq->last_wr_start_finish = jiffies; +@@ -2478,6 +2985,25 @@ static void bfq_put_queue(struct bfq_queue *bfqq) + #endif + } + ++static void bfq_put_cooperator(struct bfq_queue *bfqq) ++{ ++ struct bfq_queue *__bfqq, *next; ++ ++ /* ++ * If this queue was scheduled to merge with another queue, be ++ * sure to drop the reference taken on that queue (and others in ++ * the merge chain). See bfq_setup_merge and bfq_merge_bfqqs. ++ */ ++ __bfqq = bfqq->new_bfqq; ++ while (__bfqq) { ++ if (__bfqq == bfqq) ++ break; ++ next = __bfqq->new_bfqq; ++ bfq_put_queue(__bfqq); ++ __bfqq = next; ++ } ++} ++ + static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) + { + if (bfqq == bfqd->in_service_queue) { +@@ -2488,6 +3014,8 @@ static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) + bfq_log_bfqq(bfqd, bfqq, "exit_bfqq: %p, %d", bfqq, + atomic_read(&bfqq->ref)); + ++ bfq_put_cooperator(bfqq); ++ + bfq_put_queue(bfqq); + } + +@@ -2496,6 +3024,25 @@ static void bfq_init_icq(struct io_cq *icq) + struct bfq_io_cq *bic = icq_to_bic(icq); + + bic->ttime.last_end_request = jiffies; ++ /* ++ * A newly created bic indicates that the process has just ++ * started doing I/O, and is probably mapping into memory its ++ * executable and libraries: it definitely needs weight raising. ++ * There is however the possibility that the process performs, ++ * for a while, I/O close to some other process. EQM intercepts ++ * this behavior and may merge the queue corresponding to the ++ * process with some other queue, BEFORE the weight of the queue ++ * is raised. Merged queues are not weight-raised (they are assumed ++ * to belong to processes that benefit only from high throughput). ++ * If the merge is basically the consequence of an accident, then ++ * the queue will be split soon and will get back its old weight. ++ * It is then important to write down somewhere that this queue ++ * does need weight raising, even if it did not make it to get its ++ * weight raised before being merged. To this purpose, we overload ++ * the field raising_time_left and assign 1 to it, to mark the queue ++ * as needing weight raising. ++ */ ++ bic->wr_time_left = 1; + } + + static void bfq_exit_icq(struct io_cq *icq) +@@ -2509,6 +3056,13 @@ static void bfq_exit_icq(struct io_cq *icq) + } + + if (bic->bfqq[BLK_RW_SYNC]) { ++ /* ++ * If the bic is using a shared queue, put the reference ++ * taken on the io_context when the bic started using a ++ * shared bfq_queue. ++ */ ++ if (bfq_bfqq_coop(bic->bfqq[BLK_RW_SYNC])) ++ put_io_context(icq->ioc); + bfq_exit_bfqq(bfqd, bic->bfqq[BLK_RW_SYNC]); + bic->bfqq[BLK_RW_SYNC] = NULL; + } +@@ -2814,6 +3368,10 @@ static void bfq_update_idle_window(struct bfq_data *bfqd, + if (!bfq_bfqq_sync(bfqq) || bfq_class_idle(bfqq)) + return; + ++ /* Idle window just restored, statistics are meaningless. */ ++ if (bfq_bfqq_just_split(bfqq)) ++ return; ++ + enable_idle = bfq_bfqq_idle_window(bfqq); + + if (atomic_read(&bic->icq.ioc->active_ref) == 0 || +@@ -2861,6 +3419,7 @@ static void bfq_rq_enqueued(struct bfq_data *bfqd, struct bfq_queue *bfqq, + if (bfqq->entity.service > bfq_max_budget(bfqd) / 8 || + !BFQQ_SEEKY(bfqq)) + bfq_update_idle_window(bfqd, bfqq, bic); ++ bfq_clear_bfqq_just_split(bfqq); + + bfq_log_bfqq(bfqd, bfqq, + "rq_enqueued: idle_window=%d (seeky %d, mean %llu)", +@@ -2925,12 +3484,47 @@ static void bfq_rq_enqueued(struct bfq_data *bfqd, struct bfq_queue *bfqq, + static void bfq_insert_request(struct request_queue *q, struct request *rq) + { + struct bfq_data *bfqd = q->elevator->elevator_data; +- struct bfq_queue *bfqq = RQ_BFQQ(rq); ++ struct bfq_queue *bfqq = RQ_BFQQ(rq), *new_bfqq; + + assert_spin_locked(bfqd->queue->queue_lock); + ++ /* ++ * An unplug may trigger a requeue of a request from the device ++ * driver: make sure we are in process context while trying to ++ * merge two bfq_queues. ++ */ ++ if (!in_interrupt()) { ++ new_bfqq = bfq_setup_cooperator(bfqd, bfqq, rq, true); ++ if (new_bfqq) { ++ if (bic_to_bfqq(RQ_BIC(rq), 1) != bfqq) ++ new_bfqq = bic_to_bfqq(RQ_BIC(rq), 1); ++ /* ++ * Release the request's reference to the old bfqq ++ * and make sure one is taken to the shared queue. ++ */ ++ new_bfqq->allocated[rq_data_dir(rq)]++; ++ bfqq->allocated[rq_data_dir(rq)]--; ++ atomic_inc(&new_bfqq->ref); ++ bfq_put_queue(bfqq); ++ if (bic_to_bfqq(RQ_BIC(rq), 1) == bfqq) ++ bfq_merge_bfqqs(bfqd, RQ_BIC(rq), ++ bfqq, new_bfqq); ++ rq->elv.priv[1] = new_bfqq; ++ bfqq = new_bfqq; ++ } else ++ bfq_bfqq_increase_failed_cooperations(bfqq); ++ } ++ + bfq_add_request(rq); + ++ /* ++ * Here a newly-created bfq_queue has already started a weight-raising ++ * period: clear raising_time_left to prevent bfq_bfqq_save_state() ++ * from assigning it a full weight-raising period. See the detailed ++ * comments about this field in bfq_init_icq(). ++ */ ++ if (bfqq->bic) ++ bfqq->bic->wr_time_left = 0; + rq->fifo_time = jiffies + bfqd->bfq_fifo_expire[rq_is_sync(rq)]; + list_add_tail(&rq->queuelist, &bfqq->fifo); + +@@ -3099,6 +3693,32 @@ static void bfq_put_request(struct request *rq) + } + + /* ++ * Returns NULL if a new bfqq should be allocated, or the old bfqq if this ++ * was the last process referring to said bfqq. ++ */ ++static struct bfq_queue * ++bfq_split_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq) ++{ ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "splitting queue"); ++ ++ put_io_context(bic->icq.ioc); ++ ++ if (bfqq_process_refs(bfqq) == 1) { ++ bfqq->pid = current->pid; ++ bfq_clear_bfqq_coop(bfqq); ++ bfq_clear_bfqq_split_coop(bfqq); ++ return bfqq; ++ } ++ ++ bic_set_bfqq(bic, NULL, 1); ++ ++ bfq_put_cooperator(bfqq); ++ ++ bfq_put_queue(bfqq); ++ return NULL; ++} ++ ++/* + * Allocate bfq data structures associated with this request. + */ + static int bfq_set_request(struct request_queue *q, struct request *rq, +@@ -3110,6 +3730,7 @@ static int bfq_set_request(struct request_queue *q, struct request *rq, + const int is_sync = rq_is_sync(rq); + struct bfq_queue *bfqq; + unsigned long flags; ++ bool split = false; + + might_sleep_if(gfpflags_allow_blocking(gfp_mask)); + +@@ -3122,15 +3743,30 @@ static int bfq_set_request(struct request_queue *q, struct request *rq, + + bfq_bic_update_cgroup(bic, bio); + ++new_queue: + bfqq = bic_to_bfqq(bic, is_sync); + if (!bfqq || bfqq == &bfqd->oom_bfqq) { + bfqq = bfq_get_queue(bfqd, bio, is_sync, bic, gfp_mask); + bic_set_bfqq(bic, bfqq, is_sync); +- if (is_sync) { +- if (bfqd->large_burst) ++ if (split && is_sync) { ++ if ((bic->was_in_burst_list && bfqd->large_burst) || ++ bic->saved_in_large_burst) + bfq_mark_bfqq_in_large_burst(bfqq); +- else ++ else { + bfq_clear_bfqq_in_large_burst(bfqq); ++ if (bic->was_in_burst_list) ++ hlist_add_head(&bfqq->burst_list_node, ++ &bfqd->burst_list); ++ } ++ } ++ } else { ++ /* If the queue was seeky for too long, break it apart. */ ++ if (bfq_bfqq_coop(bfqq) && bfq_bfqq_split_coop(bfqq)) { ++ bfq_log_bfqq(bfqd, bfqq, "breaking apart bfqq"); ++ bfqq = bfq_split_bfqq(bic, bfqq); ++ split = true; ++ if (!bfqq) ++ goto new_queue; + } + } + +@@ -3142,6 +3778,26 @@ static int bfq_set_request(struct request_queue *q, struct request *rq, + rq->elv.priv[0] = bic; + rq->elv.priv[1] = bfqq; + ++ /* ++ * If a bfq_queue has only one process reference, it is owned ++ * by only one bfq_io_cq: we can set the bic field of the ++ * bfq_queue to the address of that structure. Also, if the ++ * queue has just been split, mark a flag so that the ++ * information is available to the other scheduler hooks. ++ */ ++ if (likely(bfqq != &bfqd->oom_bfqq) && bfqq_process_refs(bfqq) == 1) { ++ bfqq->bic = bic; ++ if (split) { ++ bfq_mark_bfqq_just_split(bfqq); ++ /* ++ * If the queue has just been split from a shared ++ * queue, restore the idle window and the possible ++ * weight raising period. ++ */ ++ bfq_bfqq_resume_state(bfqq, bic); ++ } ++ } ++ + spin_unlock_irqrestore(q->queue_lock, flags); + + return 0; +@@ -3295,6 +3951,7 @@ static void bfq_init_root_group(struct bfq_group *root_group, + root_group->my_entity = NULL; + root_group->bfqd = bfqd; + #endif ++ root_group->rq_pos_tree = RB_ROOT; + for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) + root_group->sched_data.service_tree[i] = BFQ_SERVICE_TREE_INIT; + } +@@ -3375,6 +4032,8 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e) + bfqd->bfq_timeout[BLK_RW_ASYNC] = bfq_timeout_async; + bfqd->bfq_timeout[BLK_RW_SYNC] = bfq_timeout_sync; + ++ bfqd->bfq_coop_thresh = 2; ++ bfqd->bfq_failed_cooperations = 7000; + bfqd->bfq_requests_within_timer = 120; + + bfqd->bfq_large_burst_thresh = 11; +diff --git a/block/bfq.h b/block/bfq.h +index 2bf54ae..fcce855 100644 +--- a/block/bfq.h ++++ b/block/bfq.h +@@ -183,6 +183,8 @@ struct bfq_group; + * ioprio_class value. + * @new_bfqq: shared bfq_queue if queue is cooperating with + * one or more other queues. ++ * @pos_node: request-position tree member (see bfq_group's @rq_pos_tree). ++ * @pos_root: request-position tree root (see bfq_group's @rq_pos_tree). + * @sort_list: sorted list of pending requests. + * @next_rq: if fifo isn't expired, next request to serve. + * @queued: nr of requests queued in @sort_list. +@@ -304,6 +306,26 @@ struct bfq_ttime { + * @ttime: associated @bfq_ttime struct + * @ioprio: per (request_queue, blkcg) ioprio. + * @blkcg_id: id of the blkcg the related io_cq belongs to. ++ * @wr_time_left: snapshot of the time left before weight raising ends ++ * for the sync queue associated to this process; this ++ * snapshot is taken to remember this value while the weight ++ * raising is suspended because the queue is merged with a ++ * shared queue, and is used to set @raising_cur_max_time ++ * when the queue is split from the shared queue and its ++ * weight is raised again ++ * @saved_idle_window: same purpose as the previous field for the idle ++ * window ++ * @saved_IO_bound: same purpose as the previous two fields for the I/O ++ * bound classification of a queue ++ * @saved_in_large_burst: same purpose as the previous fields for the ++ * value of the field keeping the queue's belonging ++ * to a large burst ++ * @was_in_burst_list: true if the queue belonged to a burst list ++ * before its merge with another cooperating queue ++ * @cooperations: counter of consecutive successful queue merges underwent ++ * by any of the process' @bfq_queues ++ * @failed_cooperations: counter of consecutive failed queue merges of any ++ * of the process' @bfq_queues + */ + struct bfq_io_cq { + struct io_cq icq; /* must be the first member */ +@@ -314,6 +336,16 @@ struct bfq_io_cq { + #ifdef CONFIG_BFQ_GROUP_IOSCHED + uint64_t blkcg_id; /* the current blkcg ID */ + #endif ++ ++ unsigned int wr_time_left; ++ bool saved_idle_window; ++ bool saved_IO_bound; ++ ++ bool saved_in_large_burst; ++ bool was_in_burst_list; ++ ++ unsigned int cooperations; ++ unsigned int failed_cooperations; + }; + + enum bfq_device_speed { +@@ -557,6 +589,9 @@ enum bfqq_state_flags { + * may need softrt-next-start + * update + */ ++ BFQ_BFQQ_FLAG_coop, /* bfqq is shared */ ++ BFQ_BFQQ_FLAG_split_coop, /* shared bfqq will be split */ ++ BFQ_BFQQ_FLAG_just_split, /* queue has just been split */ + }; + + #define BFQ_BFQQ_FNS(name) \ +@@ -583,6 +618,9 @@ BFQ_BFQQ_FNS(budget_new); + BFQ_BFQQ_FNS(IO_bound); + BFQ_BFQQ_FNS(in_large_burst); + BFQ_BFQQ_FNS(constantly_seeky); ++BFQ_BFQQ_FNS(coop); ++BFQ_BFQQ_FNS(split_coop); ++BFQ_BFQQ_FNS(just_split); + BFQ_BFQQ_FNS(softrt_update); + #undef BFQ_BFQQ_FNS + +@@ -675,6 +713,9 @@ struct bfq_group_data { + * are groups with more than one active @bfq_entity + * (see the comments to the function + * bfq_bfqq_must_not_expire()). ++ * @rq_pos_tree: rbtree sorted by next_request position, used when ++ * determining if two or more queues have interleaving ++ * requests (see bfq_find_close_cooperator()). + * + * Each (device, cgroup) pair has its own bfq_group, i.e., for each cgroup + * there is a set of bfq_groups, each one collecting the lower-level +@@ -701,6 +742,8 @@ struct bfq_group { + + int active_entities; + ++ struct rb_root rq_pos_tree; ++ + struct bfqg_stats stats; + struct bfqg_stats dead_stats; /* stats pushed from dead children */ + }; +@@ -711,6 +754,8 @@ struct bfq_group { + + struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; + struct bfq_queue *async_idle_bfqq; ++ ++ struct rb_root rq_pos_tree; + }; + #endif + +@@ -787,6 +832,27 @@ static void bfq_put_bfqd_unlock(struct bfq_data *bfqd, unsigned long *flags) + spin_unlock_irqrestore(bfqd->queue->queue_lock, *flags); + } + ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ ++static struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) ++{ ++ struct bfq_entity *group_entity = bfqq->entity.parent; ++ ++ if (!group_entity) ++ group_entity = &bfqq->bfqd->root_group->entity; ++ ++ return container_of(group_entity, struct bfq_group, entity); ++} ++ ++#else ++ ++static struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) ++{ ++ return bfqq->bfqd->root_group; ++} ++ ++#endif ++ + static void bfq_check_ioprio_change(struct bfq_io_cq *bic, struct bio *bio); + static void bfq_put_queue(struct bfq_queue *bfqq); + static void bfq_dispatch_insert(struct request_queue *q, struct request *rq); +-- +2.10.0 + diff --git a/kernel/kernel/files/patches/mageia/block-cgroups-kconfig-build-bits-for-BFQ-v7r11-4.5.0.patch b/kernel/kernel/files/patches/mageia/block-cgroups-kconfig-build-bits-for-BFQ-v7r11-4.5.0.patch new file mode 100644 index 00000000..1d358d74 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/block-cgroups-kconfig-build-bits-for-BFQ-v7r11-4.5.0.patch @@ -0,0 +1,103 @@ +From 465ed48c05de63f5bdd34d83915f1b8998a62134 Mon Sep 17 00:00:00 2001 +From: Paolo Valente +Date: Tue, 7 Apr 2015 13:39:12 +0200 +Subject: [PATCH 1/4] block: cgroups, kconfig, build bits for BFQ-v7r11-4.5.0 + +Update Kconfig.iosched and do the related Makefile changes to include +kernel configuration options for BFQ. Also increase the number of +policies supported by the blkio controller so that BFQ can add its +own. + +Signed-off-by: Paolo Valente +Signed-off-by: Arianna Avanzini +--- + block/Kconfig.iosched | 32 ++++++++++++++++++++++++++++++++ + block/Makefile | 1 + + include/linux/blkdev.h | 2 +- + 3 files changed, 34 insertions(+), 1 deletion(-) + +diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched +index 421bef9..0ee5f0f 100644 +--- a/block/Kconfig.iosched ++++ b/block/Kconfig.iosched +@@ -39,6 +39,27 @@ config CFQ_GROUP_IOSCHED + ---help--- + Enable group IO scheduling in CFQ. + ++config IOSCHED_BFQ ++ tristate "BFQ I/O scheduler" ++ default n ++ ---help--- ++ The BFQ I/O scheduler tries to distribute bandwidth among ++ all processes according to their weights. ++ It aims at distributing the bandwidth as desired, independently of ++ the disk parameters and with any workload. It also tries to ++ guarantee low latency to interactive and soft real-time ++ applications. If compiled built-in (saying Y here), BFQ can ++ be configured to support hierarchical scheduling. ++ ++config CGROUP_BFQIO ++ bool "BFQ hierarchical scheduling support" ++ depends on CGROUPS && IOSCHED_BFQ=y ++ default n ++ ---help--- ++ Enable hierarchical scheduling in BFQ, using the cgroups ++ filesystem interface. The name of the subsystem will be ++ bfqio. ++ + choice + prompt "Default I/O scheduler" + default DEFAULT_CFQ +@@ -52,6 +73,16 @@ choice + config DEFAULT_CFQ + bool "CFQ" if IOSCHED_CFQ=y + ++ config DEFAULT_BFQ ++ bool "BFQ" if IOSCHED_BFQ=y ++ help ++ Selects BFQ as the default I/O scheduler which will be ++ used by default for all block devices. ++ The BFQ I/O scheduler aims at distributing the bandwidth ++ as desired, independently of the disk parameters and with ++ any workload. It also tries to guarantee low latency to ++ interactive and soft real-time applications. ++ + config DEFAULT_NOOP + bool "No-op" + +@@ -61,6 +92,7 @@ config DEFAULT_IOSCHED + string + default "deadline" if DEFAULT_DEADLINE + default "cfq" if DEFAULT_CFQ ++ default "bfq" if DEFAULT_BFQ + default "noop" if DEFAULT_NOOP + + endmenu +diff --git a/block/Makefile b/block/Makefile +index 36acdd7..736e91a 100644 +--- a/block/Makefile ++++ b/block/Makefile +@@ -18,6 +18,7 @@ obj-$(CONFIG_BLK_DEV_THROTTLING) += blk-throttle.o + obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o + obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o + obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o ++obj-$(CONFIG_IOSCHED_BFQ) += bfq-iosched.o + + obj-$(CONFIG_BLOCK_COMPAT) += compat_ioctl.o + obj-$(CONFIG_BLK_CMDLINE_PARSER) += cmdline-parser.o +diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h +index c47c358..1047d99 100644 +--- a/include/linux/blkdev.h ++++ b/include/linux/blkdev.h +@@ -45,7 +45,7 @@ struct pr_ops; + * Maximum number of blkcg policies allowed to be registered concurrently. + * Defined here to simplify include dependency. + */ +-#define BLKCG_MAX_POLS 2 ++#define BLKCG_MAX_POLS 3 + + typedef void (rq_end_io_fn)(struct request *, int); + +-- +2.10.0 + diff --git a/kernel/kernel/files/patches/mageia/linux-BFQ-v8r4.patch b/kernel/kernel/files/patches/mageia/block-introduce-the-BFQ-v7r11-I-O-sched-for-4.5.0.patch similarity index 54% rename from kernel/kernel/files/patches/mageia/linux-BFQ-v8r4.patch rename to kernel/kernel/files/patches/mageia/block-introduce-the-BFQ-v7r11-I-O-sched-for-4.5.0.patch index abb33847..33216e38 100644 --- a/kernel/kernel/files/patches/mageia/linux-BFQ-v8r4.patch +++ b/kernel/kernel/files/patches/mageia/block-introduce-the-BFQ-v7r11-I-O-sched-for-4.5.0.patch @@ -1,7 +1,100 @@ -diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/bfq-cgroup.c ---- linux-4.8/block/bfq-cgroup.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux-4.8-bfq/block/bfq-cgroup.c 2016-10-18 12:57:57.691164881 +0200 -@@ -0,0 +1,1196 @@ +From a43c7e21bccd510d72a003e350247b1b4c6b71c3 Mon Sep 17 00:00:00 2001 +From: Paolo Valente +Date: Thu, 9 May 2013 19:10:02 +0200 +Subject: [PATCH 2/4] block: introduce the BFQ-v7r11 I/O sched for 4.5.0 + +The general structure is borrowed from CFQ, as much of the code for +handling I/O contexts. Over time, several useful features have been +ported from CFQ as well (details in the changelog in README.BFQ). A +(bfq_)queue is associated to each task doing I/O on a device, and each +time a scheduling decision has to be made a queue is selected and served +until it expires. + + - Slices are given in the service domain: tasks are assigned + budgets, measured in number of sectors. Once got the disk, a task + must however consume its assigned budget within a configurable + maximum time (by default, the maximum possible value of the + budgets is automatically computed to comply with this timeout). + This allows the desired latency vs "throughput boosting" tradeoff + to be set. + + - Budgets are scheduled according to a variant of WF2Q+, implemented + using an augmented rb-tree to take eligibility into account while + preserving an O(log N) overall complexity. + + - A low-latency tunable is provided; if enabled, both interactive + and soft real-time applications are guaranteed a very low latency. + + - Latency guarantees are preserved also in the presence of NCQ. + + - Also with flash-based devices, a high throughput is achieved + while still preserving latency guarantees. + + - BFQ features Early Queue Merge (EQM), a sort of fusion of the + cooperating-queue-merging and the preemption mechanisms present + in CFQ. EQM is in fact a unified mechanism that tries to get a + sequential read pattern, and hence a high throughput, with any + set of processes performing interleaved I/O over a contiguous + sequence of sectors. + + - BFQ supports full hierarchical scheduling, exporting a cgroups + interface. Since each node has a full scheduler, each group can + be assigned its own weight. + + - If the cgroups interface is not used, only I/O priorities can be + assigned to processes, with ioprio values mapped to weights + with the relation weight = IOPRIO_BE_NR - ioprio. + + - ioprio classes are served in strict priority order, i.e., lower + priority queues are not served as long as there are higher + priority queues. Among queues in the same class the bandwidth is + distributed in proportion to the weight of each queue. A very + thin extra bandwidth is however guaranteed to the Idle class, to + prevent it from starving. + +Signed-off-by: Paolo Valente +Signed-off-by: Arianna Avanzini +--- + block/Kconfig.iosched | 6 +- + block/bfq-cgroup.c | 1186 ++++++++++++++++ + block/bfq-ioc.c | 36 + + block/bfq-iosched.c | 3763 +++++++++++++++++++++++++++++++++++++++++++++++++ + block/bfq-sched.c | 1199 ++++++++++++++++ + block/bfq.h | 801 +++++++++++ + 6 files changed, 6987 insertions(+), 4 deletions(-) + create mode 100644 block/bfq-cgroup.c + create mode 100644 block/bfq-ioc.c + create mode 100644 block/bfq-iosched.c + create mode 100644 block/bfq-sched.c + create mode 100644 block/bfq.h + +diff --git a/block/Kconfig.iosched b/block/Kconfig.iosched +index 0ee5f0f..f78cd1a 100644 +--- a/block/Kconfig.iosched ++++ b/block/Kconfig.iosched +@@ -51,14 +51,12 @@ config IOSCHED_BFQ + applications. If compiled built-in (saying Y here), BFQ can + be configured to support hierarchical scheduling. + +-config CGROUP_BFQIO ++config BFQ_GROUP_IOSCHED + bool "BFQ hierarchical scheduling support" + depends on CGROUPS && IOSCHED_BFQ=y + default n + ---help--- +- Enable hierarchical scheduling in BFQ, using the cgroups +- filesystem interface. The name of the subsystem will be +- bfqio. ++ Enable hierarchical scheduling in BFQ, using the blkio controller. + + choice + prompt "Default I/O scheduler" +diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c +new file mode 100644 +index 0000000..8b08a57 +--- /dev/null ++++ b/block/bfq-cgroup.c +@@ -0,0 +1,1186 @@ +/* + * BFQ: CGROUPS support. + * @@ -11,9 +104,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + * Copyright (C) 2008 Fabio Checconi + * Paolo Valente + * -+ * Copyright (C) 2015 Paolo Valente -+ * -+ * Copyright (C) 2016 Paolo Valente ++ * Copyright (C) 2010 Paolo Valente + * + * Licensed under the GPL-2 as detailed in the accompanying COPYING.BFQ + * file. @@ -169,6 +260,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b +{ + struct blkg_policy_data *pd = blkg_to_pd(blkg, &blkcg_policy_bfq); + ++ BUG_ON(!pd); ++ + return pd_to_bfqg(pd); +} + @@ -212,49 +305,59 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + +static void bfqg_stats_update_io_add(struct bfq_group *bfqg, + struct bfq_queue *bfqq, -+ int op, int op_flags) ++ int rw) +{ -+ blkg_rwstat_add(&bfqg->stats.queued, op, op_flags, 1); ++ blkg_rwstat_add(&bfqg->stats.queued, rw, 1); + bfqg_stats_end_empty_time(&bfqg->stats); + if (!(bfqq == ((struct bfq_data *)bfqg->bfqd)->in_service_queue)) + bfqg_stats_set_start_group_wait_time(bfqg, bfqq_group(bfqq)); +} + -+static void bfqg_stats_update_io_remove(struct bfq_group *bfqg, int op, -+ int op_flags) ++static void bfqg_stats_update_io_remove(struct bfq_group *bfqg, int rw) +{ -+ blkg_rwstat_add(&bfqg->stats.queued, op, op_flags, -1); ++ blkg_rwstat_add(&bfqg->stats.queued, rw, -1); +} + -+static void bfqg_stats_update_io_merged(struct bfq_group *bfqg, int op, -+ int op_flags) ++static void bfqg_stats_update_io_merged(struct bfq_group *bfqg, int rw) +{ -+ blkg_rwstat_add(&bfqg->stats.merged, op, op_flags, 1); ++ blkg_rwstat_add(&bfqg->stats.merged, rw, 1); ++} ++ ++static void bfqg_stats_update_dispatch(struct bfq_group *bfqg, ++ uint64_t bytes, int rw) ++{ ++ blkg_stat_add(&bfqg->stats.sectors, bytes >> 9); ++ blkg_rwstat_add(&bfqg->stats.serviced, rw, 1); ++ blkg_rwstat_add(&bfqg->stats.service_bytes, rw, bytes); +} + +static void bfqg_stats_update_completion(struct bfq_group *bfqg, -+ uint64_t start_time, uint64_t io_start_time, int op, -+ int op_flags) ++ uint64_t start_time, uint64_t io_start_time, int rw) +{ + struct bfqg_stats *stats = &bfqg->stats; + unsigned long long now = sched_clock(); + + if (time_after64(now, io_start_time)) -+ blkg_rwstat_add(&stats->service_time, op, op_flags, -+ now - io_start_time); ++ blkg_rwstat_add(&stats->service_time, rw, now - io_start_time); + if (time_after64(io_start_time, start_time)) -+ blkg_rwstat_add(&stats->wait_time, op, op_flags, ++ blkg_rwstat_add(&stats->wait_time, rw, + io_start_time - start_time); +} + +/* @stats = 0 */ +static void bfqg_stats_reset(struct bfqg_stats *stats) +{ ++ if (!stats) ++ return; ++ + /* queued stats shouldn't be cleared */ ++ blkg_rwstat_reset(&stats->service_bytes); ++ blkg_rwstat_reset(&stats->serviced); + blkg_rwstat_reset(&stats->merged); + blkg_rwstat_reset(&stats->service_time); + blkg_rwstat_reset(&stats->wait_time); + blkg_stat_reset(&stats->time); ++ blkg_stat_reset(&stats->unaccounted_time); + blkg_stat_reset(&stats->avg_queue_size_sum); + blkg_stat_reset(&stats->avg_queue_size_samples); + blkg_stat_reset(&stats->dequeue); @@ -264,16 +367,19 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b +} + +/* @to += @from */ -+static void bfqg_stats_add_aux(struct bfqg_stats *to, struct bfqg_stats *from) ++static void bfqg_stats_merge(struct bfqg_stats *to, struct bfqg_stats *from) +{ + if (!to || !from) + return; + + /* queued stats shouldn't be cleared */ ++ blkg_rwstat_add_aux(&to->service_bytes, &from->service_bytes); ++ blkg_rwstat_add_aux(&to->serviced, &from->serviced); + blkg_rwstat_add_aux(&to->merged, &from->merged); + blkg_rwstat_add_aux(&to->service_time, &from->service_time); + blkg_rwstat_add_aux(&to->wait_time, &from->wait_time); + blkg_stat_add_aux(&from->time, &from->time); ++ blkg_stat_add_aux(&to->unaccounted_time, &from->unaccounted_time); + blkg_stat_add_aux(&to->avg_queue_size_sum, &from->avg_queue_size_sum); + blkg_stat_add_aux(&to->avg_queue_size_samples, + &from->avg_queue_size_samples); @@ -302,8 +408,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + if (unlikely(!parent)) + return; + -+ bfqg_stats_add_aux(&parent->stats, &bfqg->stats); ++ bfqg_stats_merge(&parent->dead_stats, &bfqg->stats); ++ bfqg_stats_merge(&parent->dead_stats, &bfqg->dead_stats); + bfqg_stats_reset(&bfqg->stats); ++ bfqg_stats_reset(&bfqg->dead_stats); +} + +static void bfq_init_entity(struct bfq_entity *entity, @@ -324,11 +432,15 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + +static void bfqg_stats_exit(struct bfqg_stats *stats) +{ ++ blkg_rwstat_exit(&stats->service_bytes); ++ blkg_rwstat_exit(&stats->serviced); + blkg_rwstat_exit(&stats->merged); + blkg_rwstat_exit(&stats->service_time); + blkg_rwstat_exit(&stats->wait_time); + blkg_rwstat_exit(&stats->queued); ++ blkg_stat_exit(&stats->sectors); + blkg_stat_exit(&stats->time); ++ blkg_stat_exit(&stats->unaccounted_time); + blkg_stat_exit(&stats->avg_queue_size_sum); + blkg_stat_exit(&stats->avg_queue_size_samples); + blkg_stat_exit(&stats->dequeue); @@ -339,11 +451,15 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + +static int bfqg_stats_init(struct bfqg_stats *stats, gfp_t gfp) +{ -+ if (blkg_rwstat_init(&stats->merged, gfp) || ++ if (blkg_rwstat_init(&stats->service_bytes, gfp) || ++ blkg_rwstat_init(&stats->serviced, gfp) || ++ blkg_rwstat_init(&stats->merged, gfp) || + blkg_rwstat_init(&stats->service_time, gfp) || + blkg_rwstat_init(&stats->wait_time, gfp) || + blkg_rwstat_init(&stats->queued, gfp) || ++ blkg_stat_init(&stats->sectors, gfp) || + blkg_stat_init(&stats->time, gfp) || ++ blkg_stat_init(&stats->unaccounted_time, gfp) || + blkg_stat_init(&stats->avg_queue_size_sum, gfp) || + blkg_stat_init(&stats->avg_queue_size_samples, gfp) || + blkg_stat_init(&stats->dequeue, gfp) || @@ -367,27 +483,11 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + return cpd_to_bfqgd(blkcg_to_cpd(blkcg, &blkcg_policy_bfq)); +} + -+static struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp) -+{ -+ struct bfq_group_data *bgd; -+ -+ bgd = kzalloc(sizeof(*bgd), GFP_KERNEL); -+ if (!bgd) -+ return NULL; -+ return &bgd->pd; -+} -+ +static void bfq_cpd_init(struct blkcg_policy_data *cpd) +{ + struct bfq_group_data *d = cpd_to_bfqgd(cpd); + -+ d->weight = cgroup_subsys_on_dfl(io_cgrp_subsys) ? -+ CGROUP_WEIGHT_DFL : BFQ_WEIGHT_LEGACY_DFL; -+} -+ -+static void bfq_cpd_free(struct blkcg_policy_data *cpd) -+{ -+ kfree(cpd_to_bfqgd(cpd)); ++ d->weight = BFQ_DEFAULT_GRP_WEIGHT; +} + +static struct blkg_policy_data *bfq_pd_alloc(gfp_t gfp, int node) @@ -398,7 +498,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + if (!bfqg) + return NULL; + -+ if (bfqg_stats_init(&bfqg->stats, gfp)) { ++ if (bfqg_stats_init(&bfqg->stats, gfp) || ++ bfqg_stats_init(&bfqg->dead_stats, gfp)) { + kfree(bfqg); + return NULL; + } @@ -406,47 +507,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + return &bfqg->pd; +} + -+static void bfq_pd_init(struct blkg_policy_data *pd) -+{ -+ struct blkcg_gq *blkg; -+ struct bfq_group *bfqg; -+ struct bfq_data *bfqd; -+ struct bfq_entity *entity; -+ struct bfq_group_data *d; -+ -+ blkg = pd_to_blkg(pd); -+ BUG_ON(!blkg); -+ bfqg = blkg_to_bfqg(blkg); -+ bfqd = blkg->q->elevator->elevator_data; -+ entity = &bfqg->entity; -+ d = blkcg_to_bfqgd(blkg->blkcg); -+ -+ entity->orig_weight = entity->weight = entity->new_weight = d->weight; -+ entity->my_sched_data = &bfqg->sched_data; -+ bfqg->my_entity = entity; /* -+ * the root_group's will be set to NULL -+ * in bfq_init_queue() -+ */ -+ bfqg->bfqd = bfqd; -+ bfqg->active_entities = 0; -+ bfqg->rq_pos_tree = RB_ROOT; -+} -+ -+static void bfq_pd_free(struct blkg_policy_data *pd) -+{ -+ struct bfq_group *bfqg = pd_to_bfqg(pd); -+ -+ bfqg_stats_exit(&bfqg->stats); -+ return kfree(bfqg); -+} -+ -+static void bfq_pd_reset_stats(struct blkg_policy_data *pd) -+{ -+ struct bfq_group *bfqg = pd_to_bfqg(pd); -+ -+ bfqg_stats_reset(&bfqg->stats); -+} -+ +static void bfq_group_set_parent(struct bfq_group *bfqg, + struct bfq_group *parent) +{ @@ -461,29 +521,93 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + entity->sched_data = &parent->sched_data; +} + -+static struct bfq_group *bfq_lookup_bfqg(struct bfq_data *bfqd, -+ struct blkcg *blkcg) ++static void bfq_pd_init(struct blkg_policy_data *pd) +{ -+ struct blkcg_gq *blkg; ++ struct blkcg_gq *blkg = pd_to_blkg(pd); ++ struct bfq_group *bfqg = blkg_to_bfqg(blkg); ++ struct bfq_data *bfqd = blkg->q->elevator->elevator_data; ++ struct bfq_entity *entity = &bfqg->entity; ++ struct bfq_group_data *d = blkcg_to_bfqgd(blkg->blkcg); + -+ blkg = blkg_lookup(blkcg, bfqd->queue); -+ if (likely(blkg)) -+ return blkg_to_bfqg(blkg); -+ return NULL; ++ entity->orig_weight = entity->weight = entity->new_weight = d->weight; ++ entity->my_sched_data = &bfqg->sched_data; ++ bfqg->my_entity = entity; /* ++ * the root_group's will be set to NULL ++ * in bfq_init_queue() ++ */ ++ bfqg->bfqd = bfqd; ++ bfqg->active_entities = 0; +} + -+static struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd, -+ struct blkcg *blkcg) ++static void bfq_pd_free(struct blkg_policy_data *pd) +{ -+ struct bfq_group *bfqg, *parent; -+ struct bfq_entity *entity; ++ struct bfq_group *bfqg = pd_to_bfqg(pd); ++ ++ bfqg_stats_exit(&bfqg->stats); ++ bfqg_stats_exit(&bfqg->dead_stats); ++ ++ return kfree(bfqg); ++} ++ ++/* offset delta from bfqg->stats to bfqg->dead_stats */ ++static const int dead_stats_off_delta = offsetof(struct bfq_group, dead_stats) - ++ offsetof(struct bfq_group, stats); ++ ++/* to be used by recursive prfill, sums live and dead stats recursively */ ++static u64 bfqg_stat_pd_recursive_sum(struct blkg_policy_data *pd, int off) ++{ ++ u64 sum = 0; ++ ++ sum += blkg_stat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, off); ++ sum += blkg_stat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, ++ off + dead_stats_off_delta); ++ return sum; ++} ++ ++/* to be used by recursive prfill, sums live and dead rwstats recursively */ ++static struct blkg_rwstat ++bfqg_rwstat_pd_recursive_sum(struct blkg_policy_data *pd, int off) ++{ ++ struct blkg_rwstat a, b; ++ ++ a = blkg_rwstat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, off); ++ b = blkg_rwstat_recursive_sum(pd_to_blkg(pd), &blkcg_policy_bfq, ++ off + dead_stats_off_delta); ++ blkg_rwstat_add_aux(&a, &b); ++ return a; ++} ++ ++static void bfq_pd_reset_stats(struct blkg_policy_data *pd) ++{ ++ struct bfq_group *bfqg = pd_to_bfqg(pd); ++ ++ bfqg_stats_reset(&bfqg->stats); ++ bfqg_stats_reset(&bfqg->dead_stats); ++} ++ ++static struct bfq_group *bfq_find_alloc_group(struct bfq_data *bfqd, ++ struct blkcg *blkcg) ++{ ++ struct request_queue *q = bfqd->queue; ++ struct bfq_group *bfqg = NULL, *parent; ++ struct bfq_entity *entity = NULL; + + assert_spin_locked(bfqd->queue->queue_lock); + -+ bfqg = bfq_lookup_bfqg(bfqd, blkcg); ++ /* avoid lookup for the common case where there's no blkcg */ ++ if (blkcg == &blkcg_root) { ++ bfqg = bfqd->root_group; ++ } else { ++ struct blkcg_gq *blkg; + -+ if (unlikely(!bfqg)) -+ return NULL; ++ blkg = blkg_lookup_create(blkcg, q); ++ if (!IS_ERR(blkg)) ++ bfqg = blkg_to_bfqg(blkg); ++ else /* fallback to root_group */ ++ bfqg = bfqd->root_group; ++ } ++ ++ BUG_ON(!bfqg); + + /* + * Update chain of bfq_groups as we might be handling a leaf group @@ -506,18 +630,11 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + return bfqg; +} + -+static void bfq_pos_tree_add_move(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq); -+ -+static void bfq_bfqq_expire(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq, -+ bool compensate, -+ enum bfqq_expiration reason); -+ +/** + * bfq_bfqq_move - migrate @bfqq to @bfqg. + * @bfqd: queue descriptor. + * @bfqq: the queue to move. ++ * @entity: @bfqq's entity. + * @bfqg: the group to move to. + * + * Move @bfqq to @bfqg, deactivating it from its old group and reactivating @@ -528,40 +645,26 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + * rcu_read_lock()). + */ +static void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq, -+ struct bfq_group *bfqg) ++ struct bfq_entity *entity, struct bfq_group *bfqg) +{ -+ struct bfq_entity *entity = &bfqq->entity; ++ int busy, resume; + -+ BUG_ON(!bfq_bfqq_busy(bfqq) && !RB_EMPTY_ROOT(&bfqq->sort_list)); -+ BUG_ON(!RB_EMPTY_ROOT(&bfqq->sort_list) && !entity->on_st); -+ BUG_ON(bfq_bfqq_busy(bfqq) && RB_EMPTY_ROOT(&bfqq->sort_list) -+ && entity->on_st && ++ busy = bfq_bfqq_busy(bfqq); ++ resume = !RB_EMPTY_ROOT(&bfqq->sort_list); ++ ++ BUG_ON(resume && !entity->on_st); ++ BUG_ON(busy && !resume && entity->on_st && + bfqq != bfqd->in_service_queue); -+ BUG_ON(!bfq_bfqq_busy(bfqq) && bfqq == bfqd->in_service_queue); + -+ /* If bfqq is empty, then bfq_bfqq_expire also invokes -+ * bfq_del_bfqq_busy, thereby removing bfqq and its entity -+ * from data structures related to current group. Otherwise we -+ * need to remove bfqq explicitly with bfq_deactivate_bfqq, as -+ * we do below. -+ */ -+ if (bfqq == bfqd->in_service_queue) -+ bfq_bfqq_expire(bfqd, bfqd->in_service_queue, -+ false, BFQ_BFQQ_PREEMPTED); ++ if (busy) { ++ BUG_ON(atomic_read(&bfqq->ref) < 2); + -+ BUG_ON(entity->on_st && !bfq_bfqq_busy(bfqq) -+ && &bfq_entity_service_tree(entity)->idle != -+ entity->tree); -+ -+ BUG_ON(RB_EMPTY_ROOT(&bfqq->sort_list) && bfq_bfqq_busy(bfqq)); -+ -+ if (bfq_bfqq_busy(bfqq)) -+ bfq_deactivate_bfqq(bfqd, bfqq, 0); -+ else if (entity->on_st) { -+ BUG_ON(&bfq_entity_service_tree(entity)->idle != -+ entity->tree); ++ if (!resume) ++ bfq_del_bfqq_busy(bfqd, bfqq, 0); ++ else ++ bfq_deactivate_bfqq(bfqd, bfqq, 0); ++ } else if (entity->on_st) + bfq_put_idle_entity(bfq_entity_service_tree(entity), entity); -+ } + bfqg_put(bfqq_group(bfqq)); + + /* @@ -573,17 +676,13 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + entity->sched_data = &bfqg->sched_data; + bfqg_get(bfqg); + -+ BUG_ON(RB_EMPTY_ROOT(&bfqq->sort_list) && bfq_bfqq_busy(bfqq)); -+ if (bfq_bfqq_busy(bfqq)) { -+ bfq_pos_tree_add_move(bfqd, bfqq); -+ bfq_activate_bfqq(bfqd, bfqq); ++ if (busy) { ++ if (resume) ++ bfq_activate_bfqq(bfqd, bfqq); + } + + if (!bfqd->in_service_queue && !bfqd->rq_in_driver) + bfq_schedule_dispatch(bfqd); -+ BUG_ON(entity->on_st && !bfq_bfqq_busy(bfqq) -+ && &bfq_entity_service_tree(entity)->idle != -+ entity->tree); +} + +/** @@ -610,11 +709,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + + lockdep_assert_held(bfqd->queue->queue_lock); + -+ bfqg = bfq_find_set_group(bfqd, blkcg); -+ -+ if (unlikely(!bfqg)) -+ bfqg = bfqd->root_group; -+ ++ bfqg = bfq_find_alloc_group(bfqd, blkcg); + if (async_bfqq) { + entity = &async_bfqq->entity; + @@ -622,8 +717,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + bic_set_bfqq(bic, NULL, 0); + bfq_log_bfqq(bfqd, async_bfqq, + "bic_change_group: %p %d", -+ async_bfqq, -+ async_bfqq->ref); ++ async_bfqq, atomic_read(&async_bfqq->ref)); + bfq_put_queue(async_bfqq); + } + } @@ -631,7 +725,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + if (sync_bfqq) { + entity = &sync_bfqq->entity; + if (entity->sched_data != &bfqg->sched_data) -+ bfq_bfqq_move(bfqd, sync_bfqq, bfqg); ++ bfq_bfqq_move(bfqd, sync_bfqq, entity, bfqg); + } + + return bfqg; @@ -640,23 +734,25 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b +static void bfq_bic_update_cgroup(struct bfq_io_cq *bic, struct bio *bio) +{ + struct bfq_data *bfqd = bic_to_bfqd(bic); ++ struct blkcg *blkcg; + struct bfq_group *bfqg = NULL; -+ uint64_t serial_nr; ++ uint64_t id; + + rcu_read_lock(); -+ serial_nr = bio_blkcg(bio)->css.serial_nr; ++ blkcg = bio_blkcg(bio); ++ id = blkcg->css.serial_nr; ++ rcu_read_unlock(); + + /* + * Check whether blkcg has changed. The condition may trigger + * spuriously on a newly created cic but there's no harm. + */ -+ if (unlikely(!bfqd) || likely(bic->blkcg_serial_nr == serial_nr)) -+ goto out; ++ if (unlikely(!bfqd) || likely(bic->blkcg_id == id)) ++ return; + -+ bfqg = __bfq_bic_change_cgroup(bfqd, bic, bio_blkcg(bio)); -+ bic->blkcg_serial_nr = serial_nr; -+out: -+ rcu_read_unlock(); ++ bfqg = __bfq_bic_change_cgroup(bfqd, bic, blkcg); ++ BUG_ON(!bfqg); ++ bic->blkcg_id = id; +} + +/** @@ -682,7 +778,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); + + BUG_ON(!bfqq); -+ bfq_bfqq_move(bfqd, bfqq, bfqd->root_group); ++ bfq_bfqq_move(bfqd, bfqq, entity, bfqd->root_group); +} + +/** @@ -713,12 +809,11 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b +} + +/** -+ * bfq_pd_offline - deactivate the entity associated with @pd, -+ * and reparent its children entities. -+ * @pd: descriptor of the policy going offline. ++ * bfq_destroy_group - destroy @bfqg. ++ * @bfqg: the group being destroyed. + * -+ * blkio already grabs the queue_lock for us, so no need to use -+ * RCU-based magic ++ * Destroy @bfqg, making sure that it is not referenced from its parent. ++ * blkio already grabs the queue_lock for us, so no need to use RCU-based magic + */ +static void bfq_pd_offline(struct blkg_policy_data *pd) +{ @@ -777,12 +872,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + bfq_put_async_queues(bfqd, bfqg); + BUG_ON(entity->tree); + -+ /* -+ * @blkg is going offline and will be ignored by -+ * blkg_[rw]stat_recursive_sum(). Transfer stats to the parent so -+ * that they don't get lost. If IOs complete after this point, the -+ * stats for them will be lost. Oh well... -+ */ + bfqg_stats_xfer_dead(bfqg); +} + @@ -792,35 +881,46 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + + list_for_each_entry(blkg, &bfqd->queue->blkg_list, q_node) { + struct bfq_group *bfqg = blkg_to_bfqg(blkg); -+ BUG_ON(!bfqg); + + bfq_end_wr_async_queues(bfqd, bfqg); + } + bfq_end_wr_async_queues(bfqd, bfqd->root_group); +} + -+static int bfq_io_show_weight(struct seq_file *sf, void *v) ++static u64 bfqio_cgroup_weight_read(struct cgroup_subsys_state *css, ++ struct cftype *cftype) ++{ ++ struct blkcg *blkcg = css_to_blkcg(css); ++ struct bfq_group_data *bfqgd = blkcg_to_bfqgd(blkcg); ++ int ret = -EINVAL; ++ ++ spin_lock_irq(&blkcg->lock); ++ ret = bfqgd->weight; ++ spin_unlock_irq(&blkcg->lock); ++ ++ return ret; ++} ++ ++static int bfqio_cgroup_weight_read_dfl(struct seq_file *sf, void *v) +{ + struct blkcg *blkcg = css_to_blkcg(seq_css(sf)); + struct bfq_group_data *bfqgd = blkcg_to_bfqgd(blkcg); -+ unsigned int val = 0; + -+ if (bfqgd) -+ val = bfqgd->weight; -+ -+ seq_printf(sf, "%u\n", val); ++ spin_lock_irq(&blkcg->lock); ++ seq_printf(sf, "%u\n", bfqgd->weight); ++ spin_unlock_irq(&blkcg->lock); + + return 0; +} + -+static int bfq_io_set_weight_legacy(struct cgroup_subsys_state *css, -+ struct cftype *cftype, -+ u64 val) ++static int bfqio_cgroup_weight_write(struct cgroup_subsys_state *css, ++ struct cftype *cftype, ++ u64 val) +{ + struct blkcg *blkcg = css_to_blkcg(css); + struct bfq_group_data *bfqgd = blkcg_to_bfqgd(blkcg); + struct blkcg_gq *blkg; -+ int ret = -ERANGE; ++ int ret = -EINVAL; + + if (val < BFQ_MIN_WEIGHT || val > BFQ_MAX_WEIGHT) + return ret; @@ -865,18 +965,13 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + return ret; +} + -+static ssize_t bfq_io_set_weight(struct kernfs_open_file *of, -+ char *buf, size_t nbytes, -+ loff_t off) ++static ssize_t bfqio_cgroup_weight_write_dfl(struct kernfs_open_file *of, ++ char *buf, size_t nbytes, ++ loff_t off) +{ -+ u64 weight; + /* First unsigned long found in the file is used */ -+ int ret = kstrtoull(strim(buf), 0, &weight); -+ -+ if (ret) -+ return ret; -+ -+ return bfq_io_set_weight_legacy(of_css(of), NULL, weight); ++ return bfqio_cgroup_weight_write(of_css(of), NULL, ++ simple_strtoull(strim(buf), NULL, 0)); +} + +static int bfqg_print_stat(struct seq_file *sf, void *v) @@ -896,17 +991,16 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b +static u64 bfqg_prfill_stat_recursive(struct seq_file *sf, + struct blkg_policy_data *pd, int off) +{ -+ u64 sum = blkg_stat_recursive_sum(pd_to_blkg(pd), -+ &blkcg_policy_bfq, off); ++ u64 sum = bfqg_stat_pd_recursive_sum(pd, off); ++ + return __blkg_prfill_u64(sf, pd, sum); +} + +static u64 bfqg_prfill_rwstat_recursive(struct seq_file *sf, + struct blkg_policy_data *pd, int off) +{ -+ struct blkg_rwstat sum = blkg_rwstat_recursive_sum(pd_to_blkg(pd), -+ &blkcg_policy_bfq, -+ off); ++ struct blkg_rwstat sum = bfqg_rwstat_pd_recursive_sum(pd, off); ++ + return __blkg_prfill_rwstat(sf, pd, &sum); +} + @@ -926,41 +1020,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + return 0; +} + -+static u64 bfqg_prfill_sectors(struct seq_file *sf, struct blkg_policy_data *pd, -+ int off) -+{ -+ u64 sum = blkg_rwstat_total(&pd->blkg->stat_bytes); -+ -+ return __blkg_prfill_u64(sf, pd, sum >> 9); -+} -+ -+static int bfqg_print_stat_sectors(struct seq_file *sf, void *v) -+{ -+ blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), -+ bfqg_prfill_sectors, &blkcg_policy_bfq, 0, false); -+ return 0; -+} -+ -+static u64 bfqg_prfill_sectors_recursive(struct seq_file *sf, -+ struct blkg_policy_data *pd, int off) -+{ -+ struct blkg_rwstat tmp = blkg_rwstat_recursive_sum(pd->blkg, NULL, -+ offsetof(struct blkcg_gq, stat_bytes)); -+ u64 sum = atomic64_read(&tmp.aux_cnt[BLKG_RWSTAT_READ]) + -+ atomic64_read(&tmp.aux_cnt[BLKG_RWSTAT_WRITE]); -+ -+ return __blkg_prfill_u64(sf, pd, sum >> 9); -+} -+ -+static int bfqg_print_stat_sectors_recursive(struct seq_file *sf, void *v) -+{ -+ blkcg_print_blkgs(sf, css_to_blkcg(seq_css(sf)), -+ bfqg_prfill_sectors_recursive, &blkcg_policy_bfq, 0, -+ false); -+ return 0; -+} -+ -+ +static u64 bfqg_prfill_avg_queue_size(struct seq_file *sf, + struct blkg_policy_data *pd, int off) +{ @@ -997,15 +1056,38 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + return blkg_to_bfqg(bfqd->queue->root_blkg); +} + -+static struct cftype bfq_blkcg_legacy_files[] = { ++static struct blkcg_policy_data *bfq_cpd_alloc(gfp_t gfp) ++{ ++ struct bfq_group_data *bgd; ++ ++ bgd = kzalloc(sizeof(*bgd), GFP_KERNEL); ++ if (!bgd) ++ return NULL; ++ return &bgd->pd; ++} ++ ++static void bfq_cpd_free(struct blkcg_policy_data *cpd) ++{ ++ kfree(cpd_to_bfqgd(cpd)); ++} ++ ++static struct cftype bfqio_files_dfl[] = { ++ { ++ .name = "weight", ++ .flags = CFTYPE_NOT_ON_ROOT, ++ .seq_show = bfqio_cgroup_weight_read_dfl, ++ .write = bfqio_cgroup_weight_write_dfl, ++ }, ++ {} /* terminate */ ++}; ++ ++static struct cftype bfqio_files[] = { + { + .name = "bfq.weight", -+ .flags = CFTYPE_NOT_ON_ROOT, -+ .seq_show = bfq_io_show_weight, -+ .write_u64 = bfq_io_set_weight_legacy, ++ .read_u64 = bfqio_cgroup_weight_read, ++ .write_u64 = bfqio_cgroup_weight_write, + }, -+ -+ /* statistics, covers only the tasks in the bfqg */ ++ /* statistics, cover only the tasks in the bfqg */ + { + .name = "bfq.time", + .private = offsetof(struct bfq_group, stats.time), @@ -1013,17 +1095,18 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + }, + { + .name = "bfq.sectors", -+ .seq_show = bfqg_print_stat_sectors, ++ .private = offsetof(struct bfq_group, stats.sectors), ++ .seq_show = bfqg_print_stat, + }, + { + .name = "bfq.io_service_bytes", -+ .private = (unsigned long)&blkcg_policy_bfq, -+ .seq_show = blkg_print_stat_bytes, ++ .private = offsetof(struct bfq_group, stats.service_bytes), ++ .seq_show = bfqg_print_rwstat, + }, + { + .name = "bfq.io_serviced", -+ .private = (unsigned long)&blkcg_policy_bfq, -+ .seq_show = blkg_print_stat_ios, ++ .private = offsetof(struct bfq_group, stats.serviced), ++ .seq_show = bfqg_print_rwstat, + }, + { + .name = "bfq.io_service_time", @@ -1054,17 +1137,18 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + }, + { + .name = "bfq.sectors_recursive", -+ .seq_show = bfqg_print_stat_sectors_recursive, ++ .private = offsetof(struct bfq_group, stats.sectors), ++ .seq_show = bfqg_print_stat_recursive, + }, + { + .name = "bfq.io_service_bytes_recursive", -+ .private = (unsigned long)&blkcg_policy_bfq, -+ .seq_show = blkg_print_stat_bytes_recursive, ++ .private = offsetof(struct bfq_group, stats.service_bytes), ++ .seq_show = bfqg_print_rwstat_recursive, + }, + { + .name = "bfq.io_serviced_recursive", -+ .private = (unsigned long)&blkcg_policy_bfq, -+ .seq_show = blkg_print_stat_ios_recursive, ++ .private = offsetof(struct bfq_group, stats.serviced), ++ .seq_show = bfqg_print_rwstat_recursive, + }, + { + .name = "bfq.io_service_time_recursive", @@ -1110,39 +1194,31 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + .private = offsetof(struct bfq_group, stats.dequeue), + .seq_show = bfqg_print_stat, + }, ++ { ++ .name = "bfq.unaccounted_time", ++ .private = offsetof(struct bfq_group, stats.unaccounted_time), ++ .seq_show = bfqg_print_stat, ++ }, + { } /* terminate */ +}; + -+static struct cftype bfq_blkg_files[] = { -+ { -+ .name = "bfq.weight", -+ .flags = CFTYPE_NOT_ON_ROOT, -+ .seq_show = bfq_io_show_weight, -+ .write = bfq_io_set_weight, -+ }, -+ {} /* terminate */ ++static struct blkcg_policy blkcg_policy_bfq = { ++ .dfl_cftypes = bfqio_files_dfl, ++ .legacy_cftypes = bfqio_files, ++ ++ .pd_alloc_fn = bfq_pd_alloc, ++ .pd_init_fn = bfq_pd_init, ++ .pd_offline_fn = bfq_pd_offline, ++ .pd_free_fn = bfq_pd_free, ++ .pd_reset_stats_fn = bfq_pd_reset_stats, ++ ++ .cpd_alloc_fn = bfq_cpd_alloc, ++ .cpd_init_fn = bfq_cpd_init, ++ .cpd_bind_fn = bfq_cpd_init, ++ .cpd_free_fn = bfq_cpd_free, +}; + -+#else /* CONFIG_BFQ_GROUP_IOSCHED */ -+ -+static inline void bfqg_stats_update_io_add(struct bfq_group *bfqg, -+ struct bfq_queue *bfqq, int op, int op_flags) { } -+static inline void -+bfqg_stats_update_io_remove(struct bfq_group *bfqg, int op, int op_flags) { } -+static inline void -+bfqg_stats_update_io_merged(struct bfq_group *bfqg, int op, int op_flags) { } -+static inline void bfqg_stats_update_completion(struct bfq_group *bfqg, -+ uint64_t start_time, uint64_t io_start_time, int op, -+ int op_flags) { } -+static inline void -+bfqg_stats_set_start_group_wait_time(struct bfq_group *bfqg, -+ struct bfq_group *curr_bfqg) { } -+static inline void bfqg_stats_end_empty_time(struct bfqg_stats *stats) { } -+static inline void bfqg_stats_update_dequeue(struct bfq_group *bfqg) { } -+static inline void bfqg_stats_set_start_empty_time(struct bfq_group *bfqg) { } -+static inline void bfqg_stats_update_idle_time(struct bfq_group *bfqg) { } -+static inline void bfqg_stats_set_start_idle_time(struct bfq_group *bfqg) { } -+static inline void bfqg_stats_update_avg_queue_size(struct bfq_group *bfqg) { } ++#else + +static void bfq_init_entity(struct bfq_entity *entity, + struct bfq_group *bfqg) @@ -1166,20 +1242,27 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + return bfqd->root_group; +} + ++static void bfq_bfqq_move(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq, ++ struct bfq_entity *entity, ++ struct bfq_group *bfqg) ++{ ++} ++ +static void bfq_end_wr_async(struct bfq_data *bfqd) +{ + bfq_end_wr_async_queues(bfqd, bfqd->root_group); +} + -+static struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd, -+ struct blkcg *blkcg) ++static void bfq_disconnect_groups(struct bfq_data *bfqd) +{ -+ return bfqd->root_group; ++ bfq_put_async_queues(bfqd, bfqd->root_group); +} + -+static struct bfq_group *bfqq_group(struct bfq_queue *bfqq) ++static struct bfq_group *bfq_find_alloc_group(struct bfq_data *bfqd, ++ struct blkcg *blkcg) +{ -+ return bfqq->bfqd->root_group; ++ return bfqd->root_group; +} + +static struct bfq_group * @@ -1198,899 +1281,11 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-cgroup.c linux-4.8-bfq/block/b + return bfqg; +} +#endif -diff -w -uNr '--exclude=.git' linux-4.8/block/bfq.h linux-4.8-bfq/block/bfq.h ---- linux-4.8/block/bfq.h 1970-01-01 01:00:00.000000000 +0100 -+++ linux-4.8-bfq/block/bfq.h 2016-10-18 12:57:57.691164881 +0200 -@@ -0,0 +1,886 @@ -+/* -+ * BFQ-v8r4 for 4.8.0: data structures and common functions prototypes. -+ * -+ * Based on ideas and code from CFQ: -+ * Copyright (C) 2003 Jens Axboe -+ * -+ * Copyright (C) 2008 Fabio Checconi -+ * Paolo Valente -+ * -+ * Copyright (C) 2015 Paolo Valente -+ * -+ * Copyright (C) 2016 Paolo Valente -+ */ -+ -+#ifndef _BFQ_H -+#define _BFQ_H -+ -+#include -+#include -+#include -+#include -+#include -+ -+#define BFQ_IOPRIO_CLASSES 3 -+#define BFQ_CL_IDLE_TIMEOUT (HZ/5) -+ -+#define BFQ_MIN_WEIGHT 1 -+#define BFQ_MAX_WEIGHT 1000 -+#define BFQ_WEIGHT_CONVERSION_COEFF 10 -+ -+#define BFQ_DEFAULT_QUEUE_IOPRIO 4 -+ -+#define BFQ_WEIGHT_LEGACY_DFL 100 -+#define BFQ_DEFAULT_GRP_IOPRIO 0 -+#define BFQ_DEFAULT_GRP_CLASS IOPRIO_CLASS_BE -+ -+/* -+ * Soft real-time applications are extremely more latency sensitive -+ * than interactive ones. Over-raise the weight of the former to -+ * privilege them against the latter. -+ */ -+#define BFQ_SOFTRT_WEIGHT_FACTOR 100 -+ -+struct bfq_entity; -+ -+/** -+ * struct bfq_service_tree - per ioprio_class service tree. -+ * -+ * Each service tree represents a B-WF2Q+ scheduler on its own. Each -+ * ioprio_class has its own independent scheduler, and so its own -+ * bfq_service_tree. All the fields are protected by the queue lock -+ * of the containing bfqd. -+ */ -+struct bfq_service_tree { -+ /* tree for active entities (i.e., those backlogged) */ -+ struct rb_root active; -+ /* tree for idle entities (i.e., not backlogged, with V <= F_i)*/ -+ struct rb_root idle; -+ -+ struct bfq_entity *first_idle; /* idle entity with minimum F_i */ -+ struct bfq_entity *last_idle; /* idle entity with maximum F_i */ -+ -+ u64 vtime; /* scheduler virtual time */ -+ /* scheduler weight sum; active and idle entities contribute to it */ -+ unsigned long wsum; -+}; -+ -+/** -+ * struct bfq_sched_data - multi-class scheduler. -+ * -+ * bfq_sched_data is the basic scheduler queue. It supports three -+ * ioprio_classes, and can be used either as a toplevel queue or as an -+ * intermediate queue on a hierarchical setup. @next_in_service -+ * points to the active entity of the sched_data service trees that -+ * will be scheduled next. It is used to reduce the number of steps -+ * needed for each hierarchical-schedule update. -+ * -+ * The supported ioprio_classes are the same as in CFQ, in descending -+ * priority order, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE. -+ * Requests from higher priority queues are served before all the -+ * requests from lower priority queues; among requests of the same -+ * queue requests are served according to B-WF2Q+. -+ * All the fields are protected by the queue lock of the containing bfqd. -+ */ -+struct bfq_sched_data { -+ struct bfq_entity *in_service_entity; /* entity in service */ -+ /* head-of-the-line entity in the scheduler (see comments above) */ -+ struct bfq_entity *next_in_service; -+ /* array of service trees, one per ioprio_class */ -+ struct bfq_service_tree service_tree[BFQ_IOPRIO_CLASSES]; -+}; -+ -+/** -+ * struct bfq_weight_counter - counter of the number of all active entities -+ * with a given weight. -+ */ -+struct bfq_weight_counter { -+ unsigned int weight; /* weight of the entities this counter refers to */ -+ unsigned int num_active; /* nr of active entities with this weight */ -+ /* -+ * Weights tree member (see bfq_data's @queue_weights_tree and -+ * @group_weights_tree) -+ */ -+ struct rb_node weights_node; -+}; -+ -+/** -+ * struct bfq_entity - schedulable entity. -+ * -+ * A bfq_entity is used to represent either a bfq_queue (leaf node in the -+ * cgroup hierarchy) or a bfq_group into the upper level scheduler. Each -+ * entity belongs to the sched_data of the parent group in the cgroup -+ * hierarchy. Non-leaf entities have also their own sched_data, stored -+ * in @my_sched_data. -+ * -+ * Each entity stores independently its priority values; this would -+ * allow different weights on different devices, but this -+ * functionality is not exported to userspace by now. Priorities and -+ * weights are updated lazily, first storing the new values into the -+ * new_* fields, then setting the @prio_changed flag. As soon as -+ * there is a transition in the entity state that allows the priority -+ * update to take place the effective and the requested priority -+ * values are synchronized. -+ * -+ * Unless cgroups are used, the weight value is calculated from the -+ * ioprio to export the same interface as CFQ. When dealing with -+ * ``well-behaved'' queues (i.e., queues that do not spend too much -+ * time to consume their budget and have true sequential behavior, and -+ * when there are no external factors breaking anticipation) the -+ * relative weights at each level of the cgroups hierarchy should be -+ * guaranteed. All the fields are protected by the queue lock of the -+ * containing bfqd. -+ */ -+struct bfq_entity { -+ struct rb_node rb_node; /* service_tree member */ -+ /* pointer to the weight counter associated with this entity */ -+ struct bfq_weight_counter *weight_counter; -+ -+ /* -+ * flag, true if the entity is on a tree (either the active or -+ * the idle one of its service_tree). -+ */ -+ int on_st; -+ -+ u64 finish; /* B-WF2Q+ finish timestamp (aka F_i) */ -+ u64 start; /* B-WF2Q+ start timestamp (aka S_i) */ -+ -+ /* tree the entity is enqueued into; %NULL if not on a tree */ -+ struct rb_root *tree; -+ -+ /* -+ * minimum start time of the (active) subtree rooted at this -+ * entity; used for O(log N) lookups into active trees -+ */ -+ u64 min_start; -+ -+ /* amount of service received during the last service slot */ -+ int service; -+ -+ /* budget, used also to calculate F_i: F_i = S_i + @budget / @weight */ -+ int budget; -+ -+ unsigned int weight; /* weight of the queue */ -+ unsigned int new_weight; /* next weight if a change is in progress */ -+ -+ /* original weight, used to implement weight boosting */ -+ unsigned int orig_weight; -+ -+ /* parent entity, for hierarchical scheduling */ -+ struct bfq_entity *parent; -+ -+ /* -+ * For non-leaf nodes in the hierarchy, the associated -+ * scheduler queue, %NULL on leaf nodes. -+ */ -+ struct bfq_sched_data *my_sched_data; -+ /* the scheduler queue this entity belongs to */ -+ struct bfq_sched_data *sched_data; -+ -+ /* flag, set to request a weight, ioprio or ioprio_class change */ -+ int prio_changed; -+}; -+ -+struct bfq_group; -+ -+/** -+ * struct bfq_queue - leaf schedulable entity. -+ * -+ * A bfq_queue is a leaf request queue; it can be associated with an -+ * io_context or more, if it is async or shared between cooperating -+ * processes. @cgroup holds a reference to the cgroup, to be sure that it -+ * does not disappear while a bfqq still references it (mostly to avoid -+ * races between request issuing and task migration followed by cgroup -+ * destruction). -+ * All the fields are protected by the queue lock of the containing bfqd. -+ */ -+struct bfq_queue { -+ /* reference counter */ -+ int ref; -+ /* parent bfq_data */ -+ struct bfq_data *bfqd; -+ -+ /* current ioprio and ioprio class */ -+ unsigned short ioprio, ioprio_class; -+ /* next ioprio and ioprio class if a change is in progress */ -+ unsigned short new_ioprio, new_ioprio_class; -+ -+ /* -+ * Shared bfq_queue if queue is cooperating with one or more -+ * other queues. -+ */ -+ struct bfq_queue *new_bfqq; -+ /* request-position tree member (see bfq_group's @rq_pos_tree) */ -+ struct rb_node pos_node; -+ /* request-position tree root (see bfq_group's @rq_pos_tree) */ -+ struct rb_root *pos_root; -+ -+ /* sorted list of pending requests */ -+ struct rb_root sort_list; -+ /* if fifo isn't expired, next request to serve */ -+ struct request *next_rq; -+ /* number of sync and async requests queued */ -+ int queued[2]; -+ /* number of sync and async requests currently allocated */ -+ int allocated[2]; -+ /* number of pending metadata requests */ -+ int meta_pending; -+ /* fifo list of requests in sort_list */ -+ struct list_head fifo; -+ -+ /* entity representing this queue in the scheduler */ -+ struct bfq_entity entity; -+ -+ /* maximum budget allowed from the feedback mechanism */ -+ int max_budget; -+ /* budget expiration (in jiffies) */ -+ unsigned long budget_timeout; -+ -+ /* number of requests on the dispatch list or inside driver */ -+ int dispatched; -+ -+ unsigned int flags; /* status flags.*/ -+ -+ /* node for active/idle bfqq list inside parent bfqd */ -+ struct list_head bfqq_list; -+ -+ /* bit vector: a 1 for each seeky requests in history */ -+ u32 seek_history; -+ -+ /* node for the device's burst list */ -+ struct hlist_node burst_list_node; -+ -+ /* position of the last request enqueued */ -+ sector_t last_request_pos; -+ -+ /* Number of consecutive pairs of request completion and -+ * arrival, such that the queue becomes idle after the -+ * completion, but the next request arrives within an idle -+ * time slice; used only if the queue's IO_bound flag has been -+ * cleared. -+ */ -+ unsigned int requests_within_timer; -+ -+ /* pid of the process owning the queue, used for logging purposes */ -+ pid_t pid; -+ -+ /* -+ * Pointer to the bfq_io_cq owning the bfq_queue, set to %NULL -+ * if the queue is shared. -+ */ -+ struct bfq_io_cq *bic; -+ -+ /* current maximum weight-raising time for this queue */ -+ unsigned long wr_cur_max_time; -+ /* -+ * Minimum time instant such that, only if a new request is -+ * enqueued after this time instant in an idle @bfq_queue with -+ * no outstanding requests, then the task associated with the -+ * queue it is deemed as soft real-time (see the comments on -+ * the function bfq_bfqq_softrt_next_start()) -+ */ -+ unsigned long soft_rt_next_start; -+ /* -+ * Start time of the current weight-raising period if -+ * the @bfq-queue is being weight-raised, otherwise -+ * finish time of the last weight-raising period. -+ */ -+ unsigned long last_wr_start_finish; -+ /* factor by which the weight of this queue is multiplied */ -+ unsigned int wr_coeff; -+ /* -+ * Time of the last transition of the @bfq_queue from idle to -+ * backlogged. -+ */ -+ unsigned long last_idle_bklogged; -+ /* -+ * Cumulative service received from the @bfq_queue since the -+ * last transition from idle to backlogged. -+ */ -+ unsigned long service_from_backlogged; -+ /* -+ * Value of wr start time when switching to soft rt -+ */ -+ unsigned long wr_start_at_switch_to_srt; -+ -+ unsigned long split_time; /* time of last split */ -+}; -+ -+/** -+ * struct bfq_ttime - per process thinktime stats. -+ */ -+struct bfq_ttime { -+ u64 last_end_request; /* completion time of last request */ -+ -+ u64 ttime_total; /* total process thinktime */ -+ unsigned long ttime_samples; /* number of thinktime samples */ -+ u64 ttime_mean; /* average process thinktime */ -+ -+}; -+ -+/** -+ * struct bfq_io_cq - per (request_queue, io_context) structure. -+ */ -+struct bfq_io_cq { -+ /* associated io_cq structure */ -+ struct io_cq icq; /* must be the first member */ -+ /* array of two process queues, the sync and the async */ -+ struct bfq_queue *bfqq[2]; -+ /* associated @bfq_ttime struct */ -+ struct bfq_ttime ttime; -+ /* per (request_queue, blkcg) ioprio */ -+ int ioprio; -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ uint64_t blkcg_serial_nr; /* the current blkcg serial */ -+#endif -+ -+ /* -+ * Snapshot of the idle window before merging; taken to -+ * remember this value while the queue is merged, so as to be -+ * able to restore it in case of split. -+ */ -+ bool saved_idle_window; -+ /* -+ * Same purpose as the previous two fields for the I/O bound -+ * classification of a queue. -+ */ -+ bool saved_IO_bound; -+ -+ /* -+ * Same purpose as the previous fields for the value of the -+ * field keeping the queue's belonging to a large burst -+ */ -+ bool saved_in_large_burst; -+ /* -+ * True if the queue belonged to a burst list before its merge -+ * with another cooperating queue. -+ */ -+ bool was_in_burst_list; -+ -+ /* -+ * Similar to previous fields: save wr information. -+ */ -+ unsigned long saved_wr_coeff; -+ unsigned long saved_last_wr_start_finish; -+ unsigned long saved_wr_start_at_switch_to_srt; -+}; -+ -+enum bfq_device_speed { -+ BFQ_BFQD_FAST, -+ BFQ_BFQD_SLOW, -+}; -+ -+/** -+ * struct bfq_data - per-device data structure. -+ * -+ * All the fields are protected by the @queue lock. -+ */ -+struct bfq_data { -+ /* request queue for the device */ -+ struct request_queue *queue; -+ -+ /* root bfq_group for the device */ -+ struct bfq_group *root_group; -+ -+ /* -+ * rbtree of weight counters of @bfq_queues, sorted by -+ * weight. Used to keep track of whether all @bfq_queues have -+ * the same weight. The tree contains one counter for each -+ * distinct weight associated to some active and not -+ * weight-raised @bfq_queue (see the comments to the functions -+ * bfq_weights_tree_[add|remove] for further details). -+ */ -+ struct rb_root queue_weights_tree; -+ /* -+ * rbtree of non-queue @bfq_entity weight counters, sorted by -+ * weight. Used to keep track of whether all @bfq_groups have -+ * the same weight. The tree contains one counter for each -+ * distinct weight associated to some active @bfq_group (see -+ * the comments to the functions bfq_weights_tree_[add|remove] -+ * for further details). -+ */ -+ struct rb_root group_weights_tree; -+ -+ /* -+ * Number of bfq_queues containing requests (including the -+ * queue in service, even if it is idling). -+ */ -+ int busy_queues; -+ /* number of weight-raised busy @bfq_queues */ -+ int wr_busy_queues; -+ /* number of queued requests */ -+ int queued; -+ /* number of requests dispatched and waiting for completion */ -+ int rq_in_driver; -+ -+ /* -+ * Maximum number of requests in driver in the last -+ * @hw_tag_samples completed requests. -+ */ -+ int max_rq_in_driver; -+ /* number of samples used to calculate hw_tag */ -+ int hw_tag_samples; -+ /* flag set to one if the driver is showing a queueing behavior */ -+ int hw_tag; -+ -+ /* number of budgets assigned */ -+ int budgets_assigned; -+ -+ /* -+ * Timer set when idling (waiting) for the next request from -+ * the queue in service. -+ */ -+ struct hrtimer idle_slice_timer; -+ /* delayed work to restart dispatching on the request queue */ -+ struct work_struct unplug_work; -+ -+ /* bfq_queue in service */ -+ struct bfq_queue *in_service_queue; -+ /* bfq_io_cq (bic) associated with the @in_service_queue */ -+ struct bfq_io_cq *in_service_bic; -+ -+ /* on-disk position of the last served request */ -+ sector_t last_position; -+ -+ /* time of last request completion (ns) */ -+ u64 last_completion; -+ -+ /* time of first rq dispatch in current observation interval (ns) */ -+ u64 first_dispatch; -+ /* time of last rq dispatch in current observation interval (ns) */ -+ u64 last_dispatch; -+ -+ /* beginning of the last budget */ -+ ktime_t last_budget_start; -+ /* beginning of the last idle slice */ -+ ktime_t last_idling_start; -+ -+ /* number of samples in current observation interval */ -+ int peak_rate_samples; -+ /* num of samples of seq dispatches in current observation interval */ -+ u32 sequential_samples; -+ /* total num of sectors transferred in current observation interval */ -+ u64 tot_sectors_dispatched; -+ /* max rq size seen during current observation interval (sectors) */ -+ u32 last_rq_max_size; -+ /* time elapsed from first dispatch in current observ. interval (us) */ -+ u64 delta_from_first; -+ /* current estimate of device peak rate */ -+ u32 peak_rate; -+ -+ /* maximum budget allotted to a bfq_queue before rescheduling */ -+ int bfq_max_budget; -+ -+ /* list of all the bfq_queues active on the device */ -+ struct list_head active_list; -+ /* list of all the bfq_queues idle on the device */ -+ struct list_head idle_list; -+ -+ /* -+ * Timeout for async/sync requests; when it fires, requests -+ * are served in fifo order. -+ */ -+ u64 bfq_fifo_expire[2]; -+ /* weight of backward seeks wrt forward ones */ -+ unsigned int bfq_back_penalty; -+ /* maximum allowed backward seek */ -+ unsigned int bfq_back_max; -+ /* maximum idling time */ -+ u32 bfq_slice_idle; -+ /* last time CLASS_IDLE was served */ -+ u64 bfq_class_idle_last_service; -+ -+ /* user-configured max budget value (0 for auto-tuning) */ -+ int bfq_user_max_budget; -+ /* -+ * Timeout for bfq_queues to consume their budget; used to -+ * prevent seeky queues from imposing long latencies to -+ * sequential or quasi-sequential ones (this also implies that -+ * seeky queues cannot receive guarantees in the service -+ * domain; after a timeout they are charged for the time they -+ * have been in service, to preserve fairness among them, but -+ * without service-domain guarantees). -+ */ -+ unsigned int bfq_timeout; -+ -+ /* -+ * Number of consecutive requests that must be issued within -+ * the idle time slice to set again idling to a queue which -+ * was marked as non-I/O-bound (see the definition of the -+ * IO_bound flag for further details). -+ */ -+ unsigned int bfq_requests_within_timer; -+ -+ /* -+ * Force device idling whenever needed to provide accurate -+ * service guarantees, without caring about throughput -+ * issues. CAVEAT: this may even increase latencies, in case -+ * of useless idling for processes that did stop doing I/O. -+ */ -+ bool strict_guarantees; -+ -+ /* -+ * Last time at which a queue entered the current burst of -+ * queues being activated shortly after each other; for more -+ * details about this and the following parameters related to -+ * a burst of activations, see the comments on the function -+ * bfq_handle_burst. -+ */ -+ unsigned long last_ins_in_burst; -+ /* -+ * Reference time interval used to decide whether a queue has -+ * been activated shortly after @last_ins_in_burst. -+ */ -+ unsigned long bfq_burst_interval; -+ /* number of queues in the current burst of queue activations */ -+ int burst_size; -+ -+ /* common parent entity for the queues in the burst */ -+ struct bfq_entity *burst_parent_entity; -+ /* Maximum burst size above which the current queue-activation -+ * burst is deemed as 'large'. -+ */ -+ unsigned long bfq_large_burst_thresh; -+ /* true if a large queue-activation burst is in progress */ -+ bool large_burst; -+ /* -+ * Head of the burst list (as for the above fields, more -+ * details in the comments on the function bfq_handle_burst). -+ */ -+ struct hlist_head burst_list; -+ -+ /* if set to true, low-latency heuristics are enabled */ -+ bool low_latency; -+ /* -+ * Maximum factor by which the weight of a weight-raised queue -+ * is multiplied. -+ */ -+ unsigned int bfq_wr_coeff; -+ /* maximum duration of a weight-raising period (jiffies) */ -+ unsigned int bfq_wr_max_time; -+ -+ /* Maximum weight-raising duration for soft real-time processes */ -+ unsigned int bfq_wr_rt_max_time; -+ /* -+ * Minimum idle period after which weight-raising may be -+ * reactivated for a queue (in jiffies). -+ */ -+ unsigned int bfq_wr_min_idle_time; -+ /* -+ * Minimum period between request arrivals after which -+ * weight-raising may be reactivated for an already busy async -+ * queue (in jiffies). -+ */ -+ unsigned long bfq_wr_min_inter_arr_async; -+ -+ /* Max service-rate for a soft real-time queue, in sectors/sec */ -+ unsigned int bfq_wr_max_softrt_rate; -+ /* -+ * Cached value of the product R*T, used for computing the -+ * maximum duration of weight raising automatically. -+ */ -+ u64 RT_prod; -+ /* device-speed class for the low-latency heuristic */ -+ enum bfq_device_speed device_speed; -+ -+ /* fallback dummy bfqq for extreme OOM conditions */ -+ struct bfq_queue oom_bfqq; -+}; -+ -+enum bfqq_state_flags { -+ BFQ_BFQQ_FLAG_just_created = 0, /* queue just allocated */ -+ BFQ_BFQQ_FLAG_busy, /* has requests or is in service */ -+ BFQ_BFQQ_FLAG_wait_request, /* waiting for a request */ -+ BFQ_BFQQ_FLAG_non_blocking_wait_rq, /* -+ * waiting for a request -+ * without idling the device -+ */ -+ BFQ_BFQQ_FLAG_must_alloc, /* must be allowed rq alloc */ -+ BFQ_BFQQ_FLAG_fifo_expire, /* FIFO checked in this slice */ -+ BFQ_BFQQ_FLAG_idle_window, /* slice idling enabled */ -+ BFQ_BFQQ_FLAG_sync, /* synchronous queue */ -+ BFQ_BFQQ_FLAG_IO_bound, /* -+ * bfqq has timed-out at least once -+ * having consumed at most 2/10 of -+ * its budget -+ */ -+ BFQ_BFQQ_FLAG_in_large_burst, /* -+ * bfqq activated in a large burst, -+ * see comments to bfq_handle_burst. -+ */ -+ BFQ_BFQQ_FLAG_softrt_update, /* -+ * may need softrt-next-start -+ * update -+ */ -+ BFQ_BFQQ_FLAG_coop, /* bfqq is shared */ -+ BFQ_BFQQ_FLAG_split_coop /* shared bfqq will be split */ -+}; -+ -+#define BFQ_BFQQ_FNS(name) \ -+static void bfq_mark_bfqq_##name(struct bfq_queue *bfqq) \ -+{ \ -+ (bfqq)->flags |= (1 << BFQ_BFQQ_FLAG_##name); \ -+} \ -+static void bfq_clear_bfqq_##name(struct bfq_queue *bfqq) \ -+{ \ -+ (bfqq)->flags &= ~(1 << BFQ_BFQQ_FLAG_##name); \ -+} \ -+static int bfq_bfqq_##name(const struct bfq_queue *bfqq) \ -+{ \ -+ return ((bfqq)->flags & (1 << BFQ_BFQQ_FLAG_##name)) != 0; \ -+} -+ -+BFQ_BFQQ_FNS(just_created); -+BFQ_BFQQ_FNS(busy); -+BFQ_BFQQ_FNS(wait_request); -+BFQ_BFQQ_FNS(non_blocking_wait_rq); -+BFQ_BFQQ_FNS(must_alloc); -+BFQ_BFQQ_FNS(fifo_expire); -+BFQ_BFQQ_FNS(idle_window); -+BFQ_BFQQ_FNS(sync); -+BFQ_BFQQ_FNS(IO_bound); -+BFQ_BFQQ_FNS(in_large_burst); -+BFQ_BFQQ_FNS(coop); -+BFQ_BFQQ_FNS(split_coop); -+BFQ_BFQQ_FNS(softrt_update); -+#undef BFQ_BFQQ_FNS -+ -+/* Logging facilities. */ -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+static struct bfq_group *bfqq_group(struct bfq_queue *bfqq); -+static struct blkcg_gq *bfqg_to_blkg(struct bfq_group *bfqg); -+ -+#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) do { \ -+ char __pbuf[128]; \ -+ \ -+ assert_spin_locked((bfqd)->queue->queue_lock); \ -+ blkg_path(bfqg_to_blkg(bfqq_group(bfqq)), __pbuf, sizeof(__pbuf)); \ -+ blk_add_trace_msg((bfqd)->queue, "bfq%d%c %s " fmt, \ -+ (bfqq)->pid, \ -+ bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \ -+ __pbuf, ##args); \ -+} while (0) -+ -+#define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do { \ -+ char __pbuf[128]; \ -+ \ -+ blkg_path(bfqg_to_blkg(bfqg), __pbuf, sizeof(__pbuf)); \ -+ blk_add_trace_msg((bfqd)->queue, "%s " fmt, __pbuf, ##args); \ -+} while (0) -+ -+#else /* CONFIG_BFQ_GROUP_IOSCHED */ -+ -+#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) \ -+ blk_add_trace_msg((bfqd)->queue, "bfq%d%c " fmt, (bfqq)->pid, \ -+ bfq_bfqq_sync((bfqq)) ? 'S' : 'A', \ -+ ##args) -+#define bfq_log_bfqg(bfqd, bfqg, fmt, args...) do {} while (0) -+ -+#endif /* CONFIG_BFQ_GROUP_IOSCHED */ -+ -+#define bfq_log(bfqd, fmt, args...) \ -+ blk_add_trace_msg((bfqd)->queue, "bfq " fmt, ##args) -+ -+/* Expiration reasons. */ -+enum bfqq_expiration { -+ BFQ_BFQQ_TOO_IDLE = 0, /* -+ * queue has been idling for -+ * too long -+ */ -+ BFQ_BFQQ_BUDGET_TIMEOUT, /* budget took too long to be used */ -+ BFQ_BFQQ_BUDGET_EXHAUSTED, /* budget consumed */ -+ BFQ_BFQQ_NO_MORE_REQUESTS, /* the queue has no more requests */ -+ BFQ_BFQQ_PREEMPTED /* preemption in progress */ -+}; -+ -+ -+struct bfqg_stats { -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ /* number of ios merged */ -+ struct blkg_rwstat merged; -+ /* total time spent on device in ns, may not be accurate w/ queueing */ -+ struct blkg_rwstat service_time; -+ /* total time spent waiting in scheduler queue in ns */ -+ struct blkg_rwstat wait_time; -+ /* number of IOs queued up */ -+ struct blkg_rwstat queued; -+ /* total disk time and nr sectors dispatched by this group */ -+ struct blkg_stat time; -+ /* sum of number of ios queued across all samples */ -+ struct blkg_stat avg_queue_size_sum; -+ /* count of samples taken for average */ -+ struct blkg_stat avg_queue_size_samples; -+ /* how many times this group has been removed from service tree */ -+ struct blkg_stat dequeue; -+ /* total time spent waiting for it to be assigned a timeslice. */ -+ struct blkg_stat group_wait_time; -+ /* time spent idling for this blkcg_gq */ -+ struct blkg_stat idle_time; -+ /* total time with empty current active q with other requests queued */ -+ struct blkg_stat empty_time; -+ /* fields after this shouldn't be cleared on stat reset */ -+ uint64_t start_group_wait_time; -+ uint64_t start_idle_time; -+ uint64_t start_empty_time; -+ uint16_t flags; -+#endif -+}; -+ -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+/* -+ * struct bfq_group_data - per-blkcg storage for the blkio subsystem. -+ * -+ * @ps: @blkcg_policy_storage that this structure inherits -+ * @weight: weight of the bfq_group -+ */ -+struct bfq_group_data { -+ /* must be the first member */ -+ struct blkcg_policy_data pd; -+ -+ unsigned int weight; -+}; -+ -+/** -+ * struct bfq_group - per (device, cgroup) data structure. -+ * @entity: schedulable entity to insert into the parent group sched_data. -+ * @sched_data: own sched_data, to contain child entities (they may be -+ * both bfq_queues and bfq_groups). -+ * @bfqd: the bfq_data for the device this group acts upon. -+ * @async_bfqq: array of async queues for all the tasks belonging to -+ * the group, one queue per ioprio value per ioprio_class, -+ * except for the idle class that has only one queue. -+ * @async_idle_bfqq: async queue for the idle class (ioprio is ignored). -+ * @my_entity: pointer to @entity, %NULL for the toplevel group; used -+ * to avoid too many special cases during group creation/ -+ * migration. -+ * @active_entities: number of active entities belonging to the group; -+ * unused for the root group. Used to know whether there -+ * are groups with more than one active @bfq_entity -+ * (see the comments to the function -+ * bfq_bfqq_may_idle()). -+ * @rq_pos_tree: rbtree sorted by next_request position, used when -+ * determining if two or more queues have interleaving -+ * requests (see bfq_find_close_cooperator()). -+ * -+ * Each (device, cgroup) pair has its own bfq_group, i.e., for each cgroup -+ * there is a set of bfq_groups, each one collecting the lower-level -+ * entities belonging to the group that are acting on the same device. -+ * -+ * Locking works as follows: -+ * o @bfqd is protected by the queue lock, RCU is used to access it -+ * from the readers. -+ * o All the other fields are protected by the @bfqd queue lock. -+ */ -+struct bfq_group { -+ /* must be the first member */ -+ struct blkg_policy_data pd; -+ -+ struct bfq_entity entity; -+ struct bfq_sched_data sched_data; -+ -+ void *bfqd; -+ -+ struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; -+ struct bfq_queue *async_idle_bfqq; -+ -+ struct bfq_entity *my_entity; -+ -+ int active_entities; -+ -+ struct rb_root rq_pos_tree; -+ -+ struct bfqg_stats stats; -+}; -+ -+#else -+struct bfq_group { -+ struct bfq_sched_data sched_data; -+ -+ struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; -+ struct bfq_queue *async_idle_bfqq; -+ -+ struct rb_root rq_pos_tree; -+}; -+#endif -+ -+static struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity); -+ -+static struct bfq_service_tree * -+bfq_entity_service_tree(struct bfq_entity *entity) -+{ -+ struct bfq_sched_data *sched_data = entity->sched_data; -+ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); -+ unsigned int idx = bfqq ? bfqq->ioprio_class - 1 : -+ BFQ_DEFAULT_GRP_CLASS - 1; -+ -+ BUG_ON(idx >= BFQ_IOPRIO_CLASSES); -+ BUG_ON(sched_data == NULL); -+ -+ if (bfqq) -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "entity_service_tree %p %d", -+ sched_data->service_tree + idx, idx); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "entity_service_tree %p %d", -+ sched_data->service_tree + idx, idx); -+ } -+#endif -+ return sched_data->service_tree + idx; -+} -+ -+static struct bfq_queue *bic_to_bfqq(struct bfq_io_cq *bic, bool is_sync) -+{ -+ return bic->bfqq[is_sync]; -+} -+ -+static void bic_set_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq, -+ bool is_sync) -+{ -+ bic->bfqq[is_sync] = bfqq; -+} -+ -+static struct bfq_data *bic_to_bfqd(struct bfq_io_cq *bic) -+{ -+ return bic->icq.q->elevator->elevator_data; -+} -+ -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ -+static struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) -+{ -+ struct bfq_entity *group_entity = bfqq->entity.parent; -+ -+ if (!group_entity) -+ group_entity = &bfqq->bfqd->root_group->entity; -+ -+ return container_of(group_entity, struct bfq_group, entity); -+} -+ -+#else -+ -+static struct bfq_group *bfq_bfqq_to_bfqg(struct bfq_queue *bfqq) -+{ -+ return bfqq->bfqd->root_group; -+} -+ -+#endif -+ -+static void bfq_check_ioprio_change(struct bfq_io_cq *bic, struct bio *bio); -+static void bfq_put_queue(struct bfq_queue *bfqq); -+static void bfq_dispatch_insert(struct request_queue *q, struct request *rq); -+static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, -+ struct bio *bio, bool is_sync, -+ struct bfq_io_cq *bic); -+static void bfq_end_wr_async_queues(struct bfq_data *bfqd, -+ struct bfq_group *bfqg); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+static void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg); -+#endif -+static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq); -+ -+#endif /* _BFQ_H */ -diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-ioc.c linux-4.8-bfq/block/bfq-ioc.c ---- linux-4.8/block/bfq-ioc.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux-4.8-bfq/block/bfq-ioc.c 2016-10-18 12:57:57.691164881 +0200 +diff --git a/block/bfq-ioc.c b/block/bfq-ioc.c +new file mode 100644 +index 0000000..fb7bb8f +--- /dev/null ++++ b/block/bfq-ioc.c @@ -0,0 +1,36 @@ +/* + * BFQ: I/O context handling. @@ -2128,10 +1323,12 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-ioc.c linux-4.8-bfq/block/bfq- + return icq_to_bic(ioc_lookup_icq(ioc, bfqd->queue)); + return NULL; +} -diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/bfq-iosched.c ---- linux-4.8/block/bfq-iosched.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux-4.8-bfq/block/bfq-iosched.c 2016-10-18 12:57:57.691164881 +0200 -@@ -0,0 +1,5288 @@ +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c +new file mode 100644 +index 0000000..85e2169 +--- /dev/null ++++ b/block/bfq-iosched.c +@@ -0,0 +1,3763 @@ +/* + * Budget Fair Queueing (BFQ) disk scheduler. + * @@ -2141,28 +1338,25 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * Copyright (C) 2008 Fabio Checconi + * Paolo Valente + * -+ * Copyright (C) 2015 Paolo Valente -+ * -+ * Copyright (C) 2016 Paolo Valente ++ * Copyright (C) 2010 Paolo Valente + * + * Licensed under the GPL-2 as detailed in the accompanying COPYING.BFQ + * file. + * -+ * BFQ is a proportional-share storage-I/O scheduling algorithm based -+ * on the slice-by-slice service scheme of CFQ. But BFQ assigns -+ * budgets, measured in number of sectors, to processes instead of -+ * time slices. The device is not granted to the in-service process -+ * for a given time slice, but until it has exhausted its assigned -+ * budget. This change from the time to the service domain enables BFQ -+ * to distribute the device throughput among processes as desired, -+ * without any distortion due to throughput fluctuations, or to device -+ * internal queueing. BFQ uses an ad hoc internal scheduler, called -+ * B-WF2Q+, to schedule processes according to their budgets. More -+ * precisely, BFQ schedules queues associated with processes. Thanks to -+ * the accurate policy of B-WF2Q+, BFQ can afford to assign high -+ * budgets to I/O-bound processes issuing sequential requests (to -+ * boost the throughput), and yet guarantee a low latency to -+ * interactive and soft real-time applications. ++ * BFQ is a proportional-share storage-I/O scheduling algorithm based on ++ * the slice-by-slice service scheme of CFQ. But BFQ assigns budgets, ++ * measured in number of sectors, to processes instead of time slices. The ++ * device is not granted to the in-service process for a given time slice, ++ * but until it has exhausted its assigned budget. This change from the time ++ * to the service domain allows BFQ to distribute the device throughput ++ * among processes as desired, without any distortion due to ZBR, workload ++ * fluctuations or other factors. BFQ uses an ad hoc internal scheduler, ++ * called B-WF2Q+, to schedule processes according to their budgets. More ++ * precisely, BFQ schedules queues associated to processes. Thanks to the ++ * accurate policy of B-WF2Q+, BFQ can afford to assign high budgets to ++ * I/O-bound processes issuing sequential requests (to boost the ++ * throughput), and yet guarantee a low latency to interactive and soft ++ * real-time applications. + * + * BFQ is described in [1], where also a reference to the initial, more + * theoretical paper on BFQ can be found. The interested reader can find @@ -2207,8 +1401,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +#include "bfq.h" +#include "blk.h" + -+/* Expiration time of sync (0) and async (1) requests, in ns. */ -+static const u64 bfq_fifo_expire[2] = { NSEC_PER_SEC / 4, NSEC_PER_SEC / 8 }; ++/* Expiration time of sync (0) and async (1) requests, in jiffies. */ ++static const int bfq_fifo_expire[2] = { HZ / 4, HZ / 8 }; + +/* Maximum backwards seek, in KiB. */ +static const int bfq_back_max = 16 * 1024; @@ -2216,14 +1410,15 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +/* Penalty of a backwards seek, in number of sectors. */ +static const int bfq_back_penalty = 2; + -+/* Idling period duration, in ns. */ -+static u32 bfq_slice_idle = NSEC_PER_SEC / 125; ++/* Idling period duration, in jiffies. */ ++static int bfq_slice_idle = HZ / 125; + +/* Minimum number of assigned budgets for which stats are safe to compute. */ +static const int bfq_stats_min_budgets = 194; + +/* Default maximum budget values, in sectors and number of requests. */ +static const int bfq_default_max_budget = 16 * 1024; ++static const int bfq_max_budget_async_rq = 4; + +/* + * Async to sync throughput distribution is controlled as follows: @@ -2233,27 +1428,23 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +static const int bfq_async_charge_factor = 10; + +/* Default timeout values, in jiffies, approximating CFQ defaults. */ -+static const int bfq_timeout = HZ / 8; ++static const int bfq_timeout_sync = HZ / 8; ++static int bfq_timeout_async = HZ / 25; + +struct kmem_cache *bfq_pool; + -+/* Below this threshold (in ns), we consider thinktime immediate. */ -+#define BFQ_MIN_TT (2 * NSEC_PER_MSEC) ++/* Below this threshold (in ms), we consider thinktime immediate. */ ++#define BFQ_MIN_TT 2 + +/* hw_tag detection: parallel requests threshold and min samples needed. */ +#define BFQ_HW_QUEUE_THRESHOLD 4 +#define BFQ_HW_QUEUE_SAMPLES 32 + -+#define BFQQ_SEEK_THR (sector_t)(8 * 100) -+#define BFQQ_CLOSE_THR (sector_t)(8 * 1024) -+#define BFQQ_SEEKY(bfqq) (hweight32(bfqq->seek_history) > 32/8) ++#define BFQQ_SEEK_THR (sector_t)(8 * 1024) ++#define BFQQ_SEEKY(bfqq) ((bfqq)->seek_mean > BFQQ_SEEK_THR) + -+/* Min number of samples required to perform peak-rate update */ -+#define BFQ_RATE_MIN_SAMPLES 32 -+/* Min observation time interval required to perform a peak-rate update (ns) */ -+#define BFQ_RATE_MIN_INTERVAL 300*NSEC_PER_MSEC -+/* Target observation time interval for a peak-rate update (ns) */ -+#define BFQ_RATE_REF_INTERVAL NSEC_PER_SEC ++/* Min samples used for peak rate estimation (for autotuning). */ ++#define BFQ_PEAK_RATE_SAMPLES 32 + +/* Shift used for peak rate fixed precision calculations. */ +#define BFQ_RATE_SHIFT 16 @@ -2281,24 +1472,16 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * The device's speed class is dynamically (re)detected in + * bfq_update_peak_rate() every time the estimated peak rate is updated. + * -+ * In the following definitions, R_slow[0]/R_fast[0] and -+ * T_slow[0]/T_fast[0] are the reference values for a slow/fast -+ * rotational device, whereas R_slow[1]/R_fast[1] and -+ * T_slow[1]/T_fast[1] are the reference values for a slow/fast -+ * non-rotational device. Finally, device_speed_thresh are the -+ * thresholds used to switch between speed classes. The reference -+ * rates are not the actual peak rates of the devices used as a -+ * reference, but slightly lower values. The reason for using these -+ * slightly lower values is that the peak-rate estimator tends to -+ * yield slightly lower values than the actual peak rate (it can yield -+ * the actual peak rate only if there is only one process doing I/O, -+ * and the process does sequential I/O). -+ * ++ * In the following definitions, R_slow[0]/R_fast[0] and T_slow[0]/T_fast[0] ++ * are the reference values for a slow/fast rotational device, whereas ++ * R_slow[1]/R_fast[1] and T_slow[1]/T_fast[1] are the reference values for ++ * a slow/fast non-rotational device. Finally, device_speed_thresh are the ++ * thresholds used to switch between speed classes. + * Both the reference peak rates and the thresholds are measured in + * sectors/usec, left-shifted by BFQ_RATE_SHIFT. + */ -+static int R_slow[2] = {1000, 10700}; -+static int R_fast[2] = {14000, 33000}; ++static int R_slow[2] = {1536, 10752}; ++static int R_fast[2] = {17415, 34791}; +/* + * To improve readability, a conversion function is used to initialize the + * following arrays, which entails that they can be initialized only in a @@ -2331,7 +1514,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ +static int bfq_bio_sync(struct bio *bio) +{ -+ return bio_data_dir(bio) == READ || (bio->bi_opf & REQ_SYNC); ++ if (bio_data_dir(bio) == READ || (bio->bi_rw & REQ_SYNC)) ++ return 1; ++ ++ return 0; +} + +/* @@ -2440,72 +1626,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + } +} + -+static struct bfq_queue * -+bfq_rq_pos_tree_lookup(struct bfq_data *bfqd, struct rb_root *root, -+ sector_t sector, struct rb_node **ret_parent, -+ struct rb_node ***rb_link) -+{ -+ struct rb_node **p, *parent; -+ struct bfq_queue *bfqq = NULL; -+ -+ parent = NULL; -+ p = &root->rb_node; -+ while (*p) { -+ struct rb_node **n; -+ -+ parent = *p; -+ bfqq = rb_entry(parent, struct bfq_queue, pos_node); -+ -+ /* -+ * Sort strictly based on sector. Smallest to the left, -+ * largest to the right. -+ */ -+ if (sector > blk_rq_pos(bfqq->next_rq)) -+ n = &(*p)->rb_right; -+ else if (sector < blk_rq_pos(bfqq->next_rq)) -+ n = &(*p)->rb_left; -+ else -+ break; -+ p = n; -+ bfqq = NULL; -+ } -+ -+ *ret_parent = parent; -+ if (rb_link) -+ *rb_link = p; -+ -+ bfq_log(bfqd, "rq_pos_tree_lookup %llu: returning %d", -+ (unsigned long long) sector, -+ bfqq ? bfqq->pid : 0); -+ -+ return bfqq; -+} -+ -+static void bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq) -+{ -+ struct rb_node **p, *parent; -+ struct bfq_queue *__bfqq; -+ -+ if (bfqq->pos_root) { -+ rb_erase(&bfqq->pos_node, bfqq->pos_root); -+ bfqq->pos_root = NULL; -+ } -+ -+ if (bfq_class_idle(bfqq)) -+ return; -+ if (!bfqq->next_rq) -+ return; -+ -+ bfqq->pos_root = &bfq_bfqq_to_bfqg(bfqq)->rq_pos_tree; -+ __bfqq = bfq_rq_pos_tree_lookup(bfqd, bfqq->pos_root, -+ blk_rq_pos(bfqq->next_rq), &parent, &p); -+ if (!__bfqq) { -+ rb_link_node(&bfqq->pos_node, parent, p); -+ rb_insert_color(&bfqq->pos_node, bfqq->pos_root); -+ } else -+ bfqq->pos_root = NULL; -+} -+ +/* + * Tell whether there are active queues or groups with differentiated weights. + */ @@ -2554,7 +1674,11 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ +static bool bfq_symmetric_scenario(struct bfq_data *bfqd) +{ -+ return !bfq_differentiated_weights(bfqd); ++ return ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ !bfqd->active_numerous_groups && ++#endif ++ !bfq_differentiated_weights(bfqd); +} + +/* @@ -2674,19 +1798,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +static unsigned long bfq_serv_to_charge(struct request *rq, + struct bfq_queue *bfqq) +{ -+ if (bfq_bfqq_sync(bfqq) || bfqq->wr_coeff > 1) -+ return blk_rq_sectors(rq); -+ -+ /* -+ * If there are no weight-raised queues, then amplify service -+ * by just the async charge factor; otherwise amplify service -+ * by twice the async charge factor, to further reduce latency -+ * for weight-raised queues. -+ */ -+ if (bfqq->bfqd->wr_busy_queues == 0) -+ return blk_rq_sectors(rq) * bfq_async_charge_factor; -+ -+ return blk_rq_sectors(rq) * 2 * bfq_async_charge_factor; ++ return blk_rq_sectors(rq) * ++ (1 + ((!bfq_bfqq_sync(bfqq)) * (bfqq->wr_coeff == 1) * ++ bfq_async_charge_factor)); +} + +/** @@ -2741,68 +1855,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + dur = bfqd->RT_prod; + do_div(dur, bfqd->peak_rate); + -+ /* -+ * Limit duration between 3 and 13 seconds. Tests show that -+ * higher values than 13 seconds often yield the opposite of -+ * the desired result, i.e., worsen responsiveness by letting -+ * non-interactive and non-soft-real-time applications -+ * preserve weight raising for a too long time interval. -+ * -+ * On the other end, lower values than 3 seconds make it -+ * difficult for most interactive tasks to complete their jobs -+ * before weight-raising finishes. -+ */ -+ if (dur > msecs_to_jiffies(13000)) -+ dur = msecs_to_jiffies(13000); -+ else if (dur < msecs_to_jiffies(3000)) -+ dur = msecs_to_jiffies(3000); -+ + return dur; +} + -+static void -+bfq_bfqq_resume_state(struct bfq_queue *bfqq, struct bfq_io_cq *bic) -+{ -+ if (bic->saved_idle_window) -+ bfq_mark_bfqq_idle_window(bfqq); -+ else -+ bfq_clear_bfqq_idle_window(bfqq); -+ -+ if (bic->saved_IO_bound) -+ bfq_mark_bfqq_IO_bound(bfqq); -+ else -+ bfq_clear_bfqq_IO_bound(bfqq); -+ -+ bfqq->wr_coeff = bic->saved_wr_coeff; -+ bfqq->wr_start_at_switch_to_srt = bic->saved_wr_start_at_switch_to_srt; -+ BUG_ON(time_is_after_jiffies(bfqq->wr_start_at_switch_to_srt)); -+ bfqq->last_wr_start_finish = bic->saved_last_wr_start_finish; -+ BUG_ON(time_is_after_jiffies(bfqq->last_wr_start_finish)); -+ -+ if (bfqq->wr_coeff > 1 && (bfq_bfqq_in_large_burst(bfqq) || -+ time_is_before_jiffies(bfqq->last_wr_start_finish + -+ bfqq->wr_cur_max_time))) { -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "resume state: switching off wr"); -+ -+ bfqq->wr_coeff = 1; -+ } -+ /* make sure weight will be updated, however we got here */ -+ bfqq->entity.prio_changed = 1; -+} -+ -+static int bfqq_process_refs(struct bfq_queue *bfqq) -+{ -+ int process_refs, io_refs; -+ -+ lockdep_assert_held(bfqq->bfqd->queue->queue_lock); -+ -+ io_refs = bfqq->allocated[READ] + bfqq->allocated[WRITE]; -+ process_refs = bfqq->ref - io_refs - bfqq->entity.on_st; -+ BUG_ON(process_refs < 0); -+ return process_refs; -+} -+ +/* Empty burst list and add just bfqq (see comments to bfq_handle_burst) */ +static void bfq_reset_burst_list(struct bfq_data *bfqd, struct bfq_queue *bfqq) +{ @@ -2813,7 +1868,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + hlist_del_init(&item->burst_list_node); + hlist_add_head(&bfqq->burst_list_node, &bfqd->burst_list); + bfqd->burst_size = 1; -+ bfqd->burst_parent_entity = bfqq->entity.parent; +} + +/* Add bfqq to the list of queues in current burst (see bfq_handle_burst) */ @@ -2822,10 +1876,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + /* Increment burst size to take into account also bfqq */ + bfqd->burst_size++; + -+ bfq_log_bfqq(bfqd, bfqq, "add_to_burst %d", bfqd->burst_size); -+ -+ BUG_ON(bfqd->burst_size > bfqd->bfq_large_burst_thresh); -+ + if (bfqd->burst_size == bfqd->bfq_large_burst_thresh) { + struct bfq_queue *pos, *bfqq_item; + struct hlist_node *n; @@ -2835,19 +1885,15 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * other to consider this burst as large. + */ + bfqd->large_burst = true; -+ bfq_log_bfqq(bfqd, bfqq, "add_to_burst: large burst started"); + + /* + * We can now mark all queues in the burst list as + * belonging to a large burst. + */ + hlist_for_each_entry(bfqq_item, &bfqd->burst_list, -+ burst_list_node) { ++ burst_list_node) + bfq_mark_bfqq_in_large_burst(bfqq_item); -+ bfq_log_bfqq(bfqd, bfqq_item, "marked in large burst"); -+ } + bfq_mark_bfqq_in_large_burst(bfqq); -+ bfq_log_bfqq(bfqd, bfqq, "marked in large burst"); + + /* + * From now on, and until the current burst finishes, any @@ -2859,79 +1905,67 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + hlist_for_each_entry_safe(pos, n, &bfqd->burst_list, + burst_list_node) + hlist_del_init(&pos->burst_list_node); -+ } else /* -+ * Burst not yet large: add bfqq to the burst list. Do -+ * not increment the ref counter for bfqq, because bfqq -+ * is removed from the burst list before freeing bfqq -+ * in put_queue. -+ */ ++ } else /* burst not yet large: add bfqq to the burst list */ + hlist_add_head(&bfqq->burst_list_node, &bfqd->burst_list); +} + +/* -+ * If many queues belonging to the same group happen to be created -+ * shortly after each other, then the processes associated with these -+ * queues have typically a common goal. In particular, bursts of queue -+ * creations are usually caused by services or applications that spawn -+ * many parallel threads/processes. Examples are systemd during boot, -+ * or git grep. To help these processes get their job done as soon as -+ * possible, it is usually better to not grant either weight-raising -+ * or device idling to their queues. ++ * If many queues happen to become active shortly after each other, then, ++ * to help the processes associated to these queues get their job done as ++ * soon as possible, it is usually better to not grant either weight-raising ++ * or device idling to these queues. In this comment we describe, firstly, ++ * the reasons why this fact holds, and, secondly, the next function, which ++ * implements the main steps needed to properly mark these queues so that ++ * they can then be treated in a different way. + * -+ * In this comment we describe, firstly, the reasons why this fact -+ * holds, and, secondly, the next function, which implements the main -+ * steps needed to properly mark these queues so that they can then be -+ * treated in a different way. ++ * As for the terminology, we say that a queue becomes active, i.e., ++ * switches from idle to backlogged, either when it is created (as a ++ * consequence of the arrival of an I/O request), or, if already existing, ++ * when a new request for the queue arrives while the queue is idle. ++ * Bursts of activations, i.e., activations of different queues occurring ++ * shortly after each other, are typically caused by services or applications ++ * that spawn or reactivate many parallel threads/processes. Examples are ++ * systemd during boot or git grep. + * -+ * The above services or applications benefit mostly from a high -+ * throughput: the quicker the requests of the activated queues are -+ * cumulatively served, the sooner the target job of these queues gets -+ * completed. As a consequence, weight-raising any of these queues, -+ * which also implies idling the device for it, is almost always -+ * counterproductive. In most cases it just lowers throughput. ++ * These services or applications benefit mostly from a high throughput: ++ * the quicker the requests of the activated queues are cumulatively served, ++ * the sooner the target job of these queues gets completed. As a consequence, ++ * weight-raising any of these queues, which also implies idling the device ++ * for it, is almost always counterproductive: in most cases it just lowers ++ * throughput. + * -+ * On the other hand, a burst of queue creations may be caused also by -+ * the start of an application that does not consist of a lot of -+ * parallel I/O-bound threads. In fact, with a complex application, -+ * several short processes may need to be executed to start-up the -+ * application. In this respect, to start an application as quickly as -+ * possible, the best thing to do is in any case to privilege the I/O -+ * related to the application with respect to all other -+ * I/O. Therefore, the best strategy to start as quickly as possible -+ * an application that causes a burst of queue creations is to -+ * weight-raise all the queues created during the burst. This is the ++ * On the other hand, a burst of activations may be also caused by the start ++ * of an application that does not consist in a lot of parallel I/O-bound ++ * threads. In fact, with a complex application, the burst may be just a ++ * consequence of the fact that several processes need to be executed to ++ * start-up the application. To start an application as quickly as possible, ++ * the best thing to do is to privilege the I/O related to the application ++ * with respect to all other I/O. Therefore, the best strategy to start as ++ * quickly as possible an application that causes a burst of activations is ++ * to weight-raise all the queues activated during the burst. This is the + * exact opposite of the best strategy for the other type of bursts. + * -+ * In the end, to take the best action for each of the two cases, the -+ * two types of bursts need to be distinguished. Fortunately, this -+ * seems relatively easy, by looking at the sizes of the bursts. In -+ * particular, we found a threshold such that only bursts with a -+ * larger size than that threshold are apparently caused by -+ * services or commands such as systemd or git grep. For brevity, -+ * hereafter we call just 'large' these bursts. BFQ *does not* -+ * weight-raise queues whose creation occurs in a large burst. In -+ * addition, for each of these queues BFQ performs or does not perform -+ * idling depending on which choice boosts the throughput more. The -+ * exact choice depends on the device and request pattern at ++ * In the end, to take the best action for each of the two cases, the two ++ * types of bursts need to be distinguished. Fortunately, this seems ++ * relatively easy to do, by looking at the sizes of the bursts. In ++ * particular, we found a threshold such that bursts with a larger size ++ * than that threshold are apparently caused only by services or commands ++ * such as systemd or git grep. For brevity, hereafter we call just 'large' ++ * these bursts. BFQ *does not* weight-raise queues whose activations occur ++ * in a large burst. In addition, for each of these queues BFQ performs or ++ * does not perform idling depending on which choice boosts the throughput ++ * most. The exact choice depends on the device and request pattern at + * hand. + * -+ * Unfortunately, false positives may occur while an interactive task -+ * is starting (e.g., an application is being started). The -+ * consequence is that the queues associated with the task do not -+ * enjoy weight raising as expected. Fortunately these false positives -+ * are very rare. They typically occur if some service happens to -+ * start doing I/O exactly when the interactive task starts. ++ * Turning back to the next function, it implements all the steps needed ++ * to detect the occurrence of a large burst and to properly mark all the ++ * queues belonging to it (so that they can then be treated in a different ++ * way). This goal is achieved by maintaining a special "burst list" that ++ * holds, temporarily, the queues that belong to the burst in progress. The ++ * list is then used to mark these queues as belonging to a large burst if ++ * the burst does become large. The main steps are the following. + * -+ * Turning back to the next function, it implements all the steps -+ * needed to detect the occurrence of a large burst and to properly -+ * mark all the queues belonging to it (so that they can then be -+ * treated in a different way). This goal is achieved by maintaining a -+ * "burst list" that holds, temporarily, the queues that belong to the -+ * burst in progress. The list is then used to mark these queues as -+ * belonging to a large burst if the burst does become large. The main -+ * steps are the following. -+ * -+ * . when the very first queue is created, the queue is inserted into the ++ * . when the very first queue is activated, the queue is inserted into the + * list (as it could be the first queue in a possible burst) + * + * . if the current burst has not yet become large, and a queue Q that does @@ -2952,13 +1986,13 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * + * . the device enters a large-burst mode + * -+ * . if a queue Q that does not belong to the burst is created while ++ * . if a queue Q that does not belong to the burst is activated while + * the device is in large-burst mode and shortly after the last time + * at which a queue either entered the burst list or was marked as + * belonging to the current large burst, then Q is immediately marked + * as belonging to a large burst. + * -+ * . if a queue Q that does not belong to the burst is created a while ++ * . if a queue Q that does not belong to the burst is activated a while + * later, i.e., not shortly after, than the last time at which a queue + * either entered the burst list or was marked as belonging to the + * current large burst, then the current burst is deemed as finished and: @@ -2971,44 +2005,52 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * in a possible new burst (then the burst list contains just Q + * after this step). + */ -+static void bfq_handle_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq) ++static void bfq_handle_burst(struct bfq_data *bfqd, struct bfq_queue *bfqq, ++ bool idle_for_long_time) +{ + /* ++ * If bfqq happened to be activated in a burst, but has been idle ++ * for at least as long as an interactive queue, then we assume ++ * that, in the overall I/O initiated in the burst, the I/O ++ * associated to bfqq is finished. So bfqq does not need to be ++ * treated as a queue belonging to a burst anymore. Accordingly, ++ * we reset bfqq's in_large_burst flag if set, and remove bfqq ++ * from the burst list if it's there. We do not decrement instead ++ * burst_size, because the fact that bfqq does not need to belong ++ * to the burst list any more does not invalidate the fact that ++ * bfqq may have been activated during the current burst. ++ */ ++ if (idle_for_long_time) { ++ hlist_del_init(&bfqq->burst_list_node); ++ bfq_clear_bfqq_in_large_burst(bfqq); ++ } ++ ++ /* + * If bfqq is already in the burst list or is part of a large -+ * burst, or finally has just been split, then there is -+ * nothing else to do. ++ * burst, then there is nothing else to do. + */ + if (!hlist_unhashed(&bfqq->burst_list_node) || -+ bfq_bfqq_in_large_burst(bfqq) || -+ time_is_after_eq_jiffies(bfqq->split_time + -+ msecs_to_jiffies(10))) ++ bfq_bfqq_in_large_burst(bfqq)) + return; + + /* -+ * If bfqq's creation happens late enough, or bfqq belongs to -+ * a different group than the burst group, then the current -+ * burst is finished, and related data structures must be -+ * reset. ++ * If bfqq's activation happens late enough, then the current ++ * burst is finished, and related data structures must be reset. + * -+ * In this respect, consider the special case where bfqq is -+ * the very first queue created after BFQ is selected for this -+ * device. In this case, last_ins_in_burst and -+ * burst_parent_entity are not yet significant when we get -+ * here. But it is easy to verify that, whether or not the -+ * following condition is true, bfqq will end up being -+ * inserted into the burst list. In particular the list will -+ * happen to contain only bfqq. And this is exactly what has -+ * to happen, as bfqq may be the first queue of the first ++ * In this respect, consider the special case where bfqq is the very ++ * first queue being activated. In this case, last_ins_in_burst is ++ * not yet significant when we get here. But it is easy to verify ++ * that, whether or not the following condition is true, bfqq will ++ * end up being inserted into the burst list. In particular the ++ * list will happen to contain only bfqq. And this is exactly what ++ * has to happen, as bfqq may be the first queue in a possible + * burst. + */ + if (time_is_before_jiffies(bfqd->last_ins_in_burst + -+ bfqd->bfq_burst_interval) || -+ bfqq->entity.parent != bfqd->burst_parent_entity) { ++ bfqd->bfq_burst_interval)) { + bfqd->large_burst = false; + bfq_reset_burst_list(bfqd, bfqq); -+ bfq_log_bfqq(bfqd, bfqq, -+ "handle_burst: late activation or different group"); -+ goto end; ++ return; + } + + /* @@ -3017,9 +2059,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * bfqq as belonging to this large burst immediately. + */ + if (bfqd->large_burst) { -+ bfq_log_bfqq(bfqd, bfqq, "handle_burst: marked in burst"); + bfq_mark_bfqq_in_large_burst(bfqq); -+ goto end; ++ return; + } + + /* @@ -3028,507 +2069,180 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * queue. Then we add bfqq to the burst. + */ + bfq_add_to_burst(bfqd, bfqq); -+end: -+ /* -+ * At this point, bfqq either has been added to the current -+ * burst or has caused the current burst to terminate and a -+ * possible new burst to start. In particular, in the second -+ * case, bfqq has become the first queue in the possible new -+ * burst. In both cases last_ins_in_burst needs to be moved -+ * forward. -+ */ -+ bfqd->last_ins_in_burst = jiffies; -+ -+} -+ -+static int bfq_bfqq_budget_left(struct bfq_queue *bfqq) -+{ -+ struct bfq_entity *entity = &bfqq->entity; -+ -+ return entity->budget - entity->service; -+} -+ -+/* -+ * If enough samples have been computed, return the current max budget -+ * stored in bfqd, which is dynamically updated according to the -+ * estimated disk peak rate; otherwise return the default max budget -+ */ -+static int bfq_max_budget(struct bfq_data *bfqd) -+{ -+ if (bfqd->budgets_assigned < bfq_stats_min_budgets) -+ return bfq_default_max_budget; -+ else -+ return bfqd->bfq_max_budget; -+} -+ -+/* -+ * Return min budget, which is a fraction of the current or default -+ * max budget (trying with 1/32) -+ */ -+static int bfq_min_budget(struct bfq_data *bfqd) -+{ -+ if (bfqd->budgets_assigned < bfq_stats_min_budgets) -+ return bfq_default_max_budget / 32; -+ else -+ return bfqd->bfq_max_budget / 32; -+} -+ -+static void bfq_bfqq_expire(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq, -+ bool compensate, -+ enum bfqq_expiration reason); -+ -+/* -+ * The next function, invoked after the input queue bfqq switches from -+ * idle to busy, updates the budget of bfqq. The function also tells -+ * whether the in-service queue should be expired, by returning -+ * true. The purpose of expiring the in-service queue is to give bfqq -+ * the chance to possibly preempt the in-service queue, and the reason -+ * for preempting the in-service queue is to achieve one of the two -+ * goals below. -+ * -+ * 1. Guarantee to bfqq its reserved bandwidth even if bfqq has -+ * expired because it has remained idle. In particular, bfqq may have -+ * expired for one of the following two reasons: -+ * -+ * - BFQ_BFQQ_NO_MORE_REQUEST bfqq did not enjoy any device idling and -+ * did not make it to issue a new request before its last request -+ * was served; -+ * -+ * - BFQ_BFQQ_TOO_IDLE bfqq did enjoy device idling, but did not issue -+ * a new request before the expiration of the idling-time. -+ * -+ * Even if bfqq has expired for one of the above reasons, the process -+ * associated with the queue may be however issuing requests greedily, -+ * and thus be sensitive to the bandwidth it receives (bfqq may have -+ * remained idle for other reasons: CPU high load, bfqq not enjoying -+ * idling, I/O throttling somewhere in the path from the process to -+ * the I/O scheduler, ...). But if, after every expiration for one of -+ * the above two reasons, bfqq has to wait for the service of at least -+ * one full budget of another queue before being served again, then -+ * bfqq is likely to get a much lower bandwidth or resource time than -+ * its reserved ones. To address this issue, two countermeasures need -+ * to be taken. -+ * -+ * First, the budget and the timestamps of bfqq need to be updated in -+ * a special way on bfqq reactivation: they need to be updated as if -+ * bfqq did not remain idle and did not expire. In fact, if they are -+ * computed as if bfqq expired and remained idle until reactivation, -+ * then the process associated with bfqq is treated as if, instead of -+ * being greedy, it stopped issuing requests when bfqq remained idle, -+ * and restarts issuing requests only on this reactivation. In other -+ * words, the scheduler does not help the process recover the "service -+ * hole" between bfqq expiration and reactivation. As a consequence, -+ * the process receives a lower bandwidth than its reserved one. In -+ * contrast, to recover this hole, the budget must be updated as if -+ * bfqq was not expired at all before this reactivation, i.e., it must -+ * be set to the value of the remaining budget when bfqq was -+ * expired. Along the same line, timestamps need to be assigned the -+ * value they had the last time bfqq was selected for service, i.e., -+ * before last expiration. Thus timestamps need to be back-shifted -+ * with respect to their normal computation (see [1] for more details -+ * on this tricky aspect). -+ * -+ * Secondly, to allow the process to recover the hole, the in-service -+ * queue must be expired too, to give bfqq the chance to preempt it -+ * immediately. In fact, if bfqq has to wait for a full budget of the -+ * in-service queue to be completed, then it may become impossible to -+ * let the process recover the hole, even if the back-shifted -+ * timestamps of bfqq are lower than those of the in-service queue. If -+ * this happens for most or all of the holes, then the process may not -+ * receive its reserved bandwidth. In this respect, it is worth noting -+ * that, being the service of outstanding requests unpreemptible, a -+ * little fraction of the holes may however be unrecoverable, thereby -+ * causing a little loss of bandwidth. -+ * -+ * The last important point is detecting whether bfqq does need this -+ * bandwidth recovery. In this respect, the next function deems the -+ * process associated with bfqq greedy, and thus allows it to recover -+ * the hole, if: 1) the process is waiting for the arrival of a new -+ * request (which implies that bfqq expired for one of the above two -+ * reasons), and 2) such a request has arrived soon. The first -+ * condition is controlled through the flag non_blocking_wait_rq, -+ * while the second through the flag arrived_in_time. If both -+ * conditions hold, then the function computes the budget in the -+ * above-described special way, and signals that the in-service queue -+ * should be expired. Timestamp back-shifting is done later in -+ * __bfq_activate_entity. -+ * -+ * 2. Reduce latency. Even if timestamps are not backshifted to let -+ * the process associated with bfqq recover a service hole, bfqq may -+ * however happen to have, after being (re)activated, a lower finish -+ * timestamp than the in-service queue. That is, the next budget of -+ * bfqq may have to be completed before the one of the in-service -+ * queue. If this is the case, then preempting the in-service queue -+ * allows this goal to be achieved, apart from the unpreemptible, -+ * outstanding requests mentioned above. -+ * -+ * Unfortunately, regardless of which of the above two goals one wants -+ * to achieve, service trees need first to be updated to know whether -+ * the in-service queue must be preempted. To have service trees -+ * correctly updated, the in-service queue must be expired and -+ * rescheduled, and bfqq must be scheduled too. This is one of the -+ * most costly operations (in future versions, the scheduling -+ * mechanism may be re-designed in such a way to make it possible to -+ * know whether preemption is needed without needing to update service -+ * trees). In addition, queue preemptions almost always cause random -+ * I/O, and thus loss of throughput. Because of these facts, the next -+ * function adopts the following simple scheme to avoid both costly -+ * operations and too frequent preemptions: it requests the expiration -+ * of the in-service queue (unconditionally) only for queues that need -+ * to recover a hole, or that either are weight-raised or deserve to -+ * be weight-raised. -+ */ -+static bool bfq_bfqq_update_budg_for_activation(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq, -+ bool arrived_in_time, -+ bool wr_or_deserves_wr) -+{ -+ struct bfq_entity *entity = &bfqq->entity; -+ -+ if (bfq_bfqq_non_blocking_wait_rq(bfqq) && arrived_in_time) { -+ /* -+ * We do not clear the flag non_blocking_wait_rq here, as -+ * the latter is used in bfq_activate_bfqq to signal -+ * that timestamps need to be back-shifted (and is -+ * cleared right after). -+ */ -+ -+ /* -+ * In next assignment we rely on that either -+ * entity->service or entity->budget are not updated -+ * on expiration if bfqq is empty (see -+ * __bfq_bfqq_recalc_budget). Thus both quantities -+ * remain unchanged after such an expiration, and the -+ * following statement therefore assigns to -+ * entity->budget the remaining budget on such an -+ * expiration. For clarity, entity->service is not -+ * updated on expiration in any case, and, in normal -+ * operation, is reset only when bfqq is selected for -+ * service (see bfq_get_next_queue). -+ */ -+ BUG_ON(bfqq->max_budget < 0); -+ entity->budget = min_t(unsigned long, -+ bfq_bfqq_budget_left(bfqq), -+ bfqq->max_budget); -+ -+ BUG_ON(entity->budget < 0); -+ return true; -+ } -+ -+ BUG_ON(bfqq->max_budget < 0); -+ entity->budget = max_t(unsigned long, bfqq->max_budget, -+ bfq_serv_to_charge(bfqq->next_rq, bfqq)); -+ BUG_ON(entity->budget < 0); -+ -+ bfq_clear_bfqq_non_blocking_wait_rq(bfqq); -+ return wr_or_deserves_wr; -+} -+ -+static void bfq_update_bfqq_wr_on_rq_arrival(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq, -+ unsigned int old_wr_coeff, -+ bool wr_or_deserves_wr, -+ bool interactive, -+ bool in_burst, -+ bool soft_rt) -+{ -+ if (old_wr_coeff == 1 && wr_or_deserves_wr) { -+ /* start a weight-raising period */ -+ if (interactive) { -+ bfqq->wr_coeff = bfqd->bfq_wr_coeff; -+ bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); -+ } else { -+ bfqq->wr_start_at_switch_to_srt = jiffies; -+ bfqq->wr_coeff = bfqd->bfq_wr_coeff * -+ BFQ_SOFTRT_WEIGHT_FACTOR; -+ bfqq->wr_cur_max_time = -+ bfqd->bfq_wr_rt_max_time; -+ } -+ /* -+ * If needed, further reduce budget to make sure it is -+ * close to bfqq's backlog, so as to reduce the -+ * scheduling-error component due to a too large -+ * budget. Do not care about throughput consequences, -+ * but only about latency. Finally, do not assign a -+ * too small budget either, to avoid increasing -+ * latency by causing too frequent expirations. -+ */ -+ bfqq->entity.budget = min_t(unsigned long, -+ bfqq->entity.budget, -+ 2 * bfq_min_budget(bfqd)); -+ -+ bfq_log_bfqq(bfqd, bfqq, -+ "wrais starting at %lu, rais_max_time %u", -+ jiffies, -+ jiffies_to_msecs(bfqq->wr_cur_max_time)); -+ } else if (old_wr_coeff > 1) { -+ if (interactive) { /* update wr coeff and duration */ -+ bfqq->wr_coeff = bfqd->bfq_wr_coeff; -+ bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); -+ } else if (in_burst) { -+ bfqq->wr_coeff = 1; -+ bfq_log_bfqq(bfqd, bfqq, -+ "wrais ending at %lu, rais_max_time %u", -+ jiffies, -+ jiffies_to_msecs(bfqq-> -+ wr_cur_max_time)); -+ } else if (soft_rt) { -+ /* -+ * The application is now or still meeting the -+ * requirements for being deemed soft rt. We -+ * can then correctly and safely (re)charge -+ * the weight-raising duration for the -+ * application with the weight-raising -+ * duration for soft rt applications. -+ * -+ * In particular, doing this recharge now, i.e., -+ * before the weight-raising period for the -+ * application finishes, reduces the probability -+ * of the following negative scenario: -+ * 1) the weight of a soft rt application is -+ * raised at startup (as for any newly -+ * created application), -+ * 2) since the application is not interactive, -+ * at a certain time weight-raising is -+ * stopped for the application, -+ * 3) at that time the application happens to -+ * still have pending requests, and hence -+ * is destined to not have a chance to be -+ * deemed soft rt before these requests are -+ * completed (see the comments to the -+ * function bfq_bfqq_softrt_next_start() -+ * for details on soft rt detection), -+ * 4) these pending requests experience a high -+ * latency because the application is not -+ * weight-raised while they are pending. -+ */ -+ if (bfqq->wr_cur_max_time != -+ bfqd->bfq_wr_rt_max_time) { -+ bfqq->wr_start_at_switch_to_srt = -+ bfqq->last_wr_start_finish; -+ BUG_ON(time_is_after_jiffies(bfqq->last_wr_start_finish)); -+ -+ bfqq->wr_cur_max_time = -+ bfqd->bfq_wr_rt_max_time; -+ bfqq->wr_coeff = bfqd->bfq_wr_coeff * -+ BFQ_SOFTRT_WEIGHT_FACTOR; -+ bfq_log_bfqq(bfqd, bfqq, -+ "switching to soft_rt wr"); -+ } else -+ bfq_log_bfqq(bfqd, bfqq, -+ "moving forward soft_rt wr duration"); -+ bfqq->last_wr_start_finish = jiffies; -+ } -+ } -+} -+ -+static bool bfq_bfqq_idle_for_long_time(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq) -+{ -+ return bfqq->dispatched == 0 && -+ time_is_before_jiffies( -+ bfqq->budget_timeout + -+ bfqd->bfq_wr_min_idle_time); -+} -+ -+static void bfq_bfqq_handle_idle_busy_switch(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq, -+ int old_wr_coeff, -+ struct request *rq, -+ bool *interactive) -+{ -+ bool soft_rt, in_burst, wr_or_deserves_wr, -+ bfqq_wants_to_preempt, -+ idle_for_long_time = bfq_bfqq_idle_for_long_time(bfqd, bfqq), -+ /* -+ * See the comments on -+ * bfq_bfqq_update_budg_for_activation for -+ * details on the usage of the next variable. -+ */ -+ arrived_in_time = ktime_get_ns() <= -+ RQ_BIC(rq)->ttime.last_end_request + -+ bfqd->bfq_slice_idle * 3; -+ -+ bfq_log_bfqq(bfqd, bfqq, -+ "bfq_add_request non-busy: " -+ "jiffies %lu, in_time %d, idle_long %d busyw %d " -+ "wr_coeff %u", -+ jiffies, arrived_in_time, -+ idle_for_long_time, -+ bfq_bfqq_non_blocking_wait_rq(bfqq), -+ old_wr_coeff); -+ -+ BUG_ON(bfqq->entity.budget < bfqq->entity.service); -+ -+ BUG_ON(bfqq == bfqd->in_service_queue); -+ bfqg_stats_update_io_add(bfqq_group(RQ_BFQQ(rq)), bfqq, -+ req_op(rq), rq->cmd_flags); -+ -+ /* -+ * bfqq deserves to be weight-raised if: -+ * - it is sync, -+ * - it does not belong to a large burst, -+ * - it has been idle for enough time or is soft real-time, -+ * - is linked to a bfq_io_cq (it is not shared in any sense) -+ */ -+ in_burst = bfq_bfqq_in_large_burst(bfqq); -+ soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && -+ !in_burst && -+ time_is_before_jiffies(bfqq->soft_rt_next_start); -+ *interactive = -+ !in_burst && -+ idle_for_long_time; -+ wr_or_deserves_wr = bfqd->low_latency && -+ (bfqq->wr_coeff > 1 || -+ (bfq_bfqq_sync(bfqq) && -+ bfqq->bic && (*interactive || soft_rt))); -+ -+ bfq_log_bfqq(bfqd, bfqq, -+ "bfq_add_request: " -+ "in_burst %d, " -+ "soft_rt %d (next %lu), inter %d, bic %p", -+ bfq_bfqq_in_large_burst(bfqq), soft_rt, -+ bfqq->soft_rt_next_start, -+ *interactive, -+ bfqq->bic); -+ -+ /* -+ * Using the last flag, update budget and check whether bfqq -+ * may want to preempt the in-service queue. -+ */ -+ bfqq_wants_to_preempt = -+ bfq_bfqq_update_budg_for_activation(bfqd, bfqq, -+ arrived_in_time, -+ wr_or_deserves_wr); -+ -+ /* -+ * If bfqq happened to be activated in a burst, but has been -+ * idle for much more than an interactive queue, then we -+ * assume that, in the overall I/O initiated in the burst, the -+ * I/O associated with bfqq is finished. So bfqq does not need -+ * to be treated as a queue belonging to a burst -+ * anymore. Accordingly, we reset bfqq's in_large_burst flag -+ * if set, and remove bfqq from the burst list if it's -+ * there. We do not decrement burst_size, because the fact -+ * that bfqq does not need to belong to the burst list any -+ * more does not invalidate the fact that bfqq was created in -+ * a burst. -+ */ -+ if (likely(!bfq_bfqq_just_created(bfqq)) && -+ idle_for_long_time && -+ time_is_before_jiffies( -+ bfqq->budget_timeout + -+ msecs_to_jiffies(10000))) { -+ hlist_del_init(&bfqq->burst_list_node); -+ bfq_clear_bfqq_in_large_burst(bfqq); -+ } -+ -+ bfq_clear_bfqq_just_created(bfqq); -+ -+ if (!bfq_bfqq_IO_bound(bfqq)) { -+ if (arrived_in_time) { -+ bfqq->requests_within_timer++; -+ if (bfqq->requests_within_timer >= -+ bfqd->bfq_requests_within_timer) -+ bfq_mark_bfqq_IO_bound(bfqq); -+ } else -+ bfqq->requests_within_timer = 0; -+ bfq_log_bfqq(bfqd, bfqq, "requests in time %d", -+ bfqq->requests_within_timer); -+ } -+ -+ if (bfqd->low_latency) { -+ if (unlikely(time_is_after_jiffies(bfqq->split_time))) -+ /* wraparound */ -+ bfqq->split_time = -+ jiffies - bfqd->bfq_wr_min_idle_time - 1; -+ -+ if (time_is_before_jiffies(bfqq->split_time + -+ bfqd->bfq_wr_min_idle_time)) { -+ bfq_update_bfqq_wr_on_rq_arrival(bfqd, bfqq, -+ old_wr_coeff, -+ wr_or_deserves_wr, -+ *interactive, -+ in_burst, -+ soft_rt); -+ -+ if (old_wr_coeff != bfqq->wr_coeff) -+ bfqq->entity.prio_changed = 1; -+ } -+ } -+ -+ bfqq->last_idle_bklogged = jiffies; -+ bfqq->service_from_backlogged = 0; -+ bfq_clear_bfqq_softrt_update(bfqq); -+ -+ bfq_add_bfqq_busy(bfqd, bfqq); -+ -+ /* -+ * Expire in-service queue only if preemption may be needed -+ * for guarantees. In this respect, the function -+ * next_queue_may_preempt just checks a simple, necessary -+ * condition, and not a sufficient condition based on -+ * timestamps. In fact, for the latter condition to be -+ * evaluated, timestamps would need first to be updated, and -+ * this operation is quite costly (see the comments on the -+ * function bfq_bfqq_update_budg_for_activation). -+ */ -+ if (bfqd->in_service_queue && bfqq_wants_to_preempt && -+ bfqd->in_service_queue->wr_coeff < bfqq->wr_coeff && -+ next_queue_may_preempt(bfqd)) { -+ struct bfq_queue *in_serv = -+ bfqd->in_service_queue; -+ BUG_ON(in_serv == bfqq); -+ -+ bfq_bfqq_expire(bfqd, bfqd->in_service_queue, -+ false, BFQ_BFQQ_PREEMPTED); -+ BUG_ON(in_serv->entity.budget < 0); -+ } +} + +static void bfq_add_request(struct request *rq) +{ + struct bfq_queue *bfqq = RQ_BFQQ(rq); ++ struct bfq_entity *entity = &bfqq->entity; + struct bfq_data *bfqd = bfqq->bfqd; + struct request *next_rq, *prev; -+ unsigned int old_wr_coeff = bfqq->wr_coeff; ++ unsigned long old_wr_coeff = bfqq->wr_coeff; + bool interactive = false; + -+ bfq_log_bfqq(bfqd, bfqq, "add_request: size %u %s", -+ blk_rq_sectors(rq), rq_is_sync(rq) ? "S" : "A"); -+ -+ if (bfqq->wr_coeff > 1) /* queue is being weight-raised */ -+ bfq_log_bfqq(bfqd, bfqq, -+ "raising period dur %u/%u msec, old coeff %u, w %d(%d)", -+ jiffies_to_msecs(jiffies - bfqq->last_wr_start_finish), -+ jiffies_to_msecs(bfqq->wr_cur_max_time), -+ bfqq->wr_coeff, -+ bfqq->entity.weight, bfqq->entity.orig_weight); -+ ++ bfq_log_bfqq(bfqd, bfqq, "add_request %d", rq_is_sync(rq)); + bfqq->queued[rq_is_sync(rq)]++; + bfqd->queued++; + + elv_rb_add(&bfqq->sort_list, rq); + + /* -+ * Check if this request is a better next-to-serve candidate. ++ * Check if this request is a better next-serve candidate. + */ + prev = bfqq->next_rq; + next_rq = bfq_choose_req(bfqd, bfqq->next_rq, rq, bfqd->last_position); + BUG_ON(!next_rq); + bfqq->next_rq = next_rq; + -+ /* -+ * Adjust priority tree position, if next_rq changes. -+ */ -+ if (prev != bfqq->next_rq) -+ bfq_pos_tree_add_move(bfqd, bfqq); ++ if (!bfq_bfqq_busy(bfqq)) { ++ bool soft_rt, in_burst, ++ idle_for_long_time = time_is_before_jiffies( ++ bfqq->budget_timeout + ++ bfqd->bfq_wr_min_idle_time); + -+ if (!bfq_bfqq_busy(bfqq)) /* switching to busy ... */ -+ bfq_bfqq_handle_idle_busy_switch(bfqd, bfqq, old_wr_coeff, -+ rq, &interactive); -+ else { ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ bfqg_stats_update_io_add(bfqq_group(RQ_BFQQ(rq)), bfqq, ++ rq->cmd_flags); ++#endif ++ if (bfq_bfqq_sync(bfqq)) { ++ bool already_in_burst = ++ !hlist_unhashed(&bfqq->burst_list_node) || ++ bfq_bfqq_in_large_burst(bfqq); ++ bfq_handle_burst(bfqd, bfqq, idle_for_long_time); ++ /* ++ * If bfqq was not already in the current burst, ++ * then, at this point, bfqq either has been ++ * added to the current burst or has caused the ++ * current burst to terminate. In particular, in ++ * the second case, bfqq has become the first ++ * queue in a possible new burst. ++ * In both cases last_ins_in_burst needs to be ++ * moved forward. ++ */ ++ if (!already_in_burst) ++ bfqd->last_ins_in_burst = jiffies; ++ } ++ ++ in_burst = bfq_bfqq_in_large_burst(bfqq); ++ soft_rt = bfqd->bfq_wr_max_softrt_rate > 0 && ++ !in_burst && ++ time_is_before_jiffies(bfqq->soft_rt_next_start); ++ interactive = !in_burst && idle_for_long_time; ++ entity->budget = max_t(unsigned long, bfqq->max_budget, ++ bfq_serv_to_charge(next_rq, bfqq)); ++ ++ if (!bfq_bfqq_IO_bound(bfqq)) { ++ if (time_before(jiffies, ++ RQ_BIC(rq)->ttime.last_end_request + ++ bfqd->bfq_slice_idle)) { ++ bfqq->requests_within_timer++; ++ if (bfqq->requests_within_timer >= ++ bfqd->bfq_requests_within_timer) ++ bfq_mark_bfqq_IO_bound(bfqq); ++ } else ++ bfqq->requests_within_timer = 0; ++ } ++ ++ if (!bfqd->low_latency) ++ goto add_bfqq_busy; ++ ++ /* ++ * If the queue: ++ * - is not being boosted, ++ * - has been idle for enough time, ++ * - is not a sync queue or is linked to a bfq_io_cq (it is ++ * shared "for its nature" or it is not shared and its ++ * requests have not been redirected to a shared queue) ++ * start a weight-raising period. ++ */ ++ if (old_wr_coeff == 1 && (interactive || soft_rt) && ++ (!bfq_bfqq_sync(bfqq) || bfqq->bic)) { ++ bfqq->wr_coeff = bfqd->bfq_wr_coeff; ++ if (interactive) ++ bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); ++ else ++ bfqq->wr_cur_max_time = ++ bfqd->bfq_wr_rt_max_time; ++ bfq_log_bfqq(bfqd, bfqq, ++ "wrais starting at %lu, rais_max_time %u", ++ jiffies, ++ jiffies_to_msecs(bfqq->wr_cur_max_time)); ++ } else if (old_wr_coeff > 1) { ++ if (interactive) ++ bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); ++ else if (in_burst || ++ (bfqq->wr_cur_max_time == ++ bfqd->bfq_wr_rt_max_time && ++ !soft_rt)) { ++ bfqq->wr_coeff = 1; ++ bfq_log_bfqq(bfqd, bfqq, ++ "wrais ending at %lu, rais_max_time %u", ++ jiffies, ++ jiffies_to_msecs(bfqq-> ++ wr_cur_max_time)); ++ } else if (time_before( ++ bfqq->last_wr_start_finish + ++ bfqq->wr_cur_max_time, ++ jiffies + ++ bfqd->bfq_wr_rt_max_time) && ++ soft_rt) { ++ /* ++ * ++ * The remaining weight-raising time is lower ++ * than bfqd->bfq_wr_rt_max_time, which means ++ * that the application is enjoying weight ++ * raising either because deemed soft-rt in ++ * the near past, or because deemed interactive ++ * a long ago. ++ * In both cases, resetting now the current ++ * remaining weight-raising time for the ++ * application to the weight-raising duration ++ * for soft rt applications would not cause any ++ * latency increase for the application (as the ++ * new duration would be higher than the ++ * remaining time). ++ * ++ * In addition, the application is now meeting ++ * the requirements for being deemed soft rt. ++ * In the end we can correctly and safely ++ * (re)charge the weight-raising duration for ++ * the application with the weight-raising ++ * duration for soft rt applications. ++ * ++ * In particular, doing this recharge now, i.e., ++ * before the weight-raising period for the ++ * application finishes, reduces the probability ++ * of the following negative scenario: ++ * 1) the weight of a soft rt application is ++ * raised at startup (as for any newly ++ * created application), ++ * 2) since the application is not interactive, ++ * at a certain time weight-raising is ++ * stopped for the application, ++ * 3) at that time the application happens to ++ * still have pending requests, and hence ++ * is destined to not have a chance to be ++ * deemed soft rt before these requests are ++ * completed (see the comments to the ++ * function bfq_bfqq_softrt_next_start() ++ * for details on soft rt detection), ++ * 4) these pending requests experience a high ++ * latency because the application is not ++ * weight-raised while they are pending. ++ */ ++ bfqq->last_wr_start_finish = jiffies; ++ bfqq->wr_cur_max_time = ++ bfqd->bfq_wr_rt_max_time; ++ } ++ } ++ if (old_wr_coeff != bfqq->wr_coeff) ++ entity->prio_changed = 1; ++add_bfqq_busy: ++ bfqq->last_idle_bklogged = jiffies; ++ bfqq->service_from_backlogged = 0; ++ bfq_clear_bfqq_softrt_update(bfqq); ++ bfq_add_bfqq_busy(bfqd, bfqq); ++ } else { + if (bfqd->low_latency && old_wr_coeff == 1 && !rq_is_sync(rq) && + time_is_before_jiffies( + bfqq->last_wr_start_finish + @@ -3537,43 +2251,16 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); + + bfqd->wr_busy_queues++; -+ bfqq->entity.prio_changed = 1; ++ entity->prio_changed = 1; + bfq_log_bfqq(bfqd, bfqq, -+ "non-idle wrais starting, " -+ "wr_max_time %u wr_busy %d", -+ jiffies_to_msecs(bfqq->wr_cur_max_time), -+ bfqd->wr_busy_queues); ++ "non-idle wrais starting at %lu, rais_max_time %u", ++ jiffies, ++ jiffies_to_msecs(bfqq->wr_cur_max_time)); + } + if (prev != bfqq->next_rq) + bfq_updated_next_req(bfqd, bfqq); + } + -+ /* -+ * Assign jiffies to last_wr_start_finish in the following -+ * cases: -+ * -+ * . if bfqq is not going to be weight-raised, because, for -+ * non weight-raised queues, last_wr_start_finish stores the -+ * arrival time of the last request; as of now, this piece -+ * of information is used only for deciding whether to -+ * weight-raise async queues -+ * -+ * . if bfqq is not weight-raised, because, if bfqq is now -+ * switching to weight-raised, then last_wr_start_finish -+ * stores the time when weight-raising starts -+ * -+ * . if bfqq is interactive, because, regardless of whether -+ * bfqq is currently weight-raised, the weight-raising -+ * period must start or restart (this case is considered -+ * separately because it is not detected by the above -+ * conditions, if bfqq is already weight-raised) -+ * -+ * last_wr_start_finish has to be updated also if bfqq is soft -+ * real-time, because the weight-raising period is constantly -+ * restarted on idle-to-busy transitions for these queues, but -+ * this is already done in bfq_bfqq_handle_idle_busy_switch if -+ * needed. -+ */ + if (bfqd->low_latency && + (old_wr_coeff == 1 || bfqq->wr_coeff == 1 || interactive)) + bfqq->last_wr_start_finish = jiffies; @@ -3597,24 +2284,14 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + return NULL; +} + -+static sector_t get_sdist(sector_t last_pos, struct request *rq) -+{ -+ sector_t sdist = 0; -+ -+ if (last_pos) { -+ if (last_pos < blk_rq_pos(rq)) -+ sdist = blk_rq_pos(rq) - last_pos; -+ else -+ sdist = last_pos - blk_rq_pos(rq); -+ } -+ -+ return sdist; -+} -+ +static void bfq_activate_request(struct request_queue *q, struct request *rq) +{ + struct bfq_data *bfqd = q->elevator->elevator_data; ++ + bfqd->rq_in_driver++; ++ bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq); ++ bfq_log(bfqd, "activate_request: new bfqd->last_position %llu", ++ (unsigned long long) bfqd->last_position); +} + +static void bfq_deactivate_request(struct request_queue *q, struct request *rq) @@ -3631,9 +2308,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + struct bfq_data *bfqd = bfqq->bfqd; + const int sync = rq_is_sync(rq); + -+ BUG_ON(bfqq->entity.service > bfqq->entity.budget && -+ bfqq == bfqd->in_service_queue); -+ + if (bfqq->next_rq == rq) { + bfqq->next_rq = bfq_find_next_rq(bfqd, bfqq, rq); + bfq_updated_next_req(bfqd, bfqq); @@ -3647,25 +2321,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + elv_rb_del(&bfqq->sort_list, rq); + + if (RB_EMPTY_ROOT(&bfqq->sort_list)) { -+ BUG_ON(bfqq->entity.budget < 0); -+ -+ if (bfq_bfqq_busy(bfqq) && bfqq != bfqd->in_service_queue) { ++ if (bfq_bfqq_busy(bfqq) && bfqq != bfqd->in_service_queue) + bfq_del_bfqq_busy(bfqd, bfqq, 1); -+ -+ /* bfqq emptied. In normal operation, when -+ * bfqq is empty, bfqq->entity.service and -+ * bfqq->entity.budget must contain, -+ * respectively, the service received and the -+ * budget used last time bfqq emptied. These -+ * facts do not hold in this case, as at least -+ * this last removal occurred while bfqq is -+ * not in service. To avoid inconsistencies, -+ * reset both bfqq->entity.service and -+ * bfqq->entity.budget. -+ */ -+ bfqq->entity.budget = bfqq->entity.service = 0; -+ } -+ + /* + * Remove queue from request-position tree as it is empty. + */ @@ -3679,8 +2336,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + BUG_ON(bfqq->meta_pending == 0); + bfqq->meta_pending--; + } -+ bfqg_stats_update_io_remove(bfqq_group(bfqq), req_op(rq), -+ rq->cmd_flags); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ bfqg_stats_update_io_remove(bfqq_group(bfqq), rq->cmd_flags); ++#endif +} + +static int bfq_merge(struct request_queue *q, struct request **req, @@ -3690,7 +2348,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + struct request *__rq; + + __rq = bfq_find_rq_fmerge(bfqd, bio); -+ if (__rq && elv_bio_merge_ok(__rq, bio)) { ++ if (__rq && elv_rq_merge_ok(__rq, bio)) { + *req = __rq; + return ELEVATOR_FRONT_MERGE; + } @@ -3719,15 +2377,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfqd->last_position); + BUG_ON(!next_rq); + bfqq->next_rq = next_rq; -+ /* -+ * If next_rq changes, update both the queue's budget to -+ * fit the new request and the queue's position in its -+ * rq_pos_tree. -+ */ -+ if (prev != bfqq->next_rq) { -+ bfq_updated_next_req(bfqd, bfqq); -+ bfq_pos_tree_add_move(bfqd, bfqq); -+ } + } +} + @@ -3735,8 +2384,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +static void bfq_bio_merged(struct request_queue *q, struct request *req, + struct bio *bio) +{ -+ bfqg_stats_update_io_merged(bfqq_group(RQ_BFQQ(req)), bio_op(bio), -+ bio->bi_opf); ++ bfqg_stats_update_io_merged(bfqq_group(RQ_BFQQ(req)), bio->bi_rw); +} +#endif + @@ -3756,7 +2404,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ + if (bfqq == next_bfqq && + !list_empty(&rq->queuelist) && !list_empty(&next->queuelist) && -+ next->fifo_time < rq->fifo_time) { ++ time_before(next->fifo_time, rq->fifo_time)) { + list_del_init(&rq->queuelist); + list_replace_init(&next->queuelist, &rq->queuelist); + rq->fifo_time = next->fifo_time; @@ -3766,31 +2414,21 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfqq->next_rq = rq; + + bfq_remove_request(next); -+ bfqg_stats_update_io_merged(bfqq_group(bfqq), req_op(next), -+ next->cmd_flags); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ bfqg_stats_update_io_merged(bfqq_group(bfqq), next->cmd_flags); ++#endif +} + +/* Must be called with bfqq != NULL */ +static void bfq_bfqq_end_wr(struct bfq_queue *bfqq) +{ + BUG_ON(!bfqq); -+ + if (bfq_bfqq_busy(bfqq)) + bfqq->bfqd->wr_busy_queues--; + bfqq->wr_coeff = 1; + bfqq->wr_cur_max_time = 0; -+ bfqq->last_wr_start_finish = jiffies; -+ /* -+ * Trigger a weight change on the next invocation of -+ * __bfq_entity_update_weight_prio. -+ */ ++ /* Trigger a weight change on the next activation of the queue */ + bfqq->entity.prio_changed = 1; -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "end_wr: wrais ending at %lu, rais_max_time %u", -+ bfqq->last_wr_start_finish, -+ jiffies_to_msecs(bfqq->wr_cur_max_time)); -+ bfq_log_bfqq(bfqq->bfqd, bfqq, "end_wr: wr_busy %d", -+ bfqq->bfqd->wr_busy_queues); +} + +static void bfq_end_wr_async_queues(struct bfq_data *bfqd, @@ -3821,395 +2459,17 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + spin_unlock_irq(bfqd->queue->queue_lock); +} + -+static sector_t bfq_io_struct_pos(void *io_struct, bool request) -+{ -+ if (request) -+ return blk_rq_pos(io_struct); -+ else -+ return ((struct bio *)io_struct)->bi_iter.bi_sector; -+} -+ -+static int bfq_rq_close_to_sector(void *io_struct, bool request, -+ sector_t sector) -+{ -+ return abs(bfq_io_struct_pos(io_struct, request) - sector) <= -+ BFQQ_CLOSE_THR; -+} -+ -+static struct bfq_queue *bfqq_find_close(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq, -+ sector_t sector) -+{ -+ struct rb_root *root = &bfq_bfqq_to_bfqg(bfqq)->rq_pos_tree; -+ struct rb_node *parent, *node; -+ struct bfq_queue *__bfqq; -+ -+ if (RB_EMPTY_ROOT(root)) -+ return NULL; -+ -+ /* -+ * First, if we find a request starting at the end of the last -+ * request, choose it. -+ */ -+ __bfqq = bfq_rq_pos_tree_lookup(bfqd, root, sector, &parent, NULL); -+ if (__bfqq) -+ return __bfqq; -+ -+ /* -+ * If the exact sector wasn't found, the parent of the NULL leaf -+ * will contain the closest sector (rq_pos_tree sorted by -+ * next_request position). -+ */ -+ __bfqq = rb_entry(parent, struct bfq_queue, pos_node); -+ if (bfq_rq_close_to_sector(__bfqq->next_rq, true, sector)) -+ return __bfqq; -+ -+ if (blk_rq_pos(__bfqq->next_rq) < sector) -+ node = rb_next(&__bfqq->pos_node); -+ else -+ node = rb_prev(&__bfqq->pos_node); -+ if (!node) -+ return NULL; -+ -+ __bfqq = rb_entry(node, struct bfq_queue, pos_node); -+ if (bfq_rq_close_to_sector(__bfqq->next_rq, true, sector)) -+ return __bfqq; -+ -+ return NULL; -+} -+ -+static struct bfq_queue *bfq_find_close_cooperator(struct bfq_data *bfqd, -+ struct bfq_queue *cur_bfqq, -+ sector_t sector) -+{ -+ struct bfq_queue *bfqq; -+ -+ /* -+ * We shall notice if some of the queues are cooperating, -+ * e.g., working closely on the same area of the device. In -+ * that case, we can group them together and: 1) don't waste -+ * time idling, and 2) serve the union of their requests in -+ * the best possible order for throughput. -+ */ -+ bfqq = bfqq_find_close(bfqd, cur_bfqq, sector); -+ if (!bfqq || bfqq == cur_bfqq) -+ return NULL; -+ -+ return bfqq; -+} -+ -+static struct bfq_queue * -+bfq_setup_merge(struct bfq_queue *bfqq, struct bfq_queue *new_bfqq) -+{ -+ int process_refs, new_process_refs; -+ struct bfq_queue *__bfqq; -+ -+ /* -+ * If there are no process references on the new_bfqq, then it is -+ * unsafe to follow the ->new_bfqq chain as other bfqq's in the chain -+ * may have dropped their last reference (not just their last process -+ * reference). -+ */ -+ if (!bfqq_process_refs(new_bfqq)) -+ return NULL; -+ -+ /* Avoid a circular list and skip interim queue merges. */ -+ while ((__bfqq = new_bfqq->new_bfqq)) { -+ if (__bfqq == bfqq) -+ return NULL; -+ new_bfqq = __bfqq; -+ } -+ -+ process_refs = bfqq_process_refs(bfqq); -+ new_process_refs = bfqq_process_refs(new_bfqq); -+ /* -+ * If the process for the bfqq has gone away, there is no -+ * sense in merging the queues. -+ */ -+ if (process_refs == 0 || new_process_refs == 0) -+ return NULL; -+ -+ bfq_log_bfqq(bfqq->bfqd, bfqq, "scheduling merge with queue %d", -+ new_bfqq->pid); -+ -+ /* -+ * Merging is just a redirection: the requests of the process -+ * owning one of the two queues are redirected to the other queue. -+ * The latter queue, in its turn, is set as shared if this is the -+ * first time that the requests of some process are redirected to -+ * it. -+ * -+ * We redirect bfqq to new_bfqq and not the opposite, because we -+ * are in the context of the process owning bfqq, hence we have -+ * the io_cq of this process. So we can immediately configure this -+ * io_cq to redirect the requests of the process to new_bfqq. -+ * -+ * NOTE, even if new_bfqq coincides with the in-service queue, the -+ * io_cq of new_bfqq is not available, because, if the in-service -+ * queue is shared, bfqd->in_service_bic may not point to the -+ * io_cq of the in-service queue. -+ * Redirecting the requests of the process owning bfqq to the -+ * currently in-service queue is in any case the best option, as -+ * we feed the in-service queue with new requests close to the -+ * last request served and, by doing so, hopefully increase the -+ * throughput. -+ */ -+ bfqq->new_bfqq = new_bfqq; -+ new_bfqq->ref += process_refs; -+ return new_bfqq; -+} -+ -+static bool bfq_may_be_close_cooperator(struct bfq_queue *bfqq, -+ struct bfq_queue *new_bfqq) -+{ -+ if (bfq_class_idle(bfqq) || bfq_class_idle(new_bfqq) || -+ (bfqq->ioprio_class != new_bfqq->ioprio_class)) -+ return false; -+ -+ /* -+ * If either of the queues has already been detected as seeky, -+ * then merging it with the other queue is unlikely to lead to -+ * sequential I/O. -+ */ -+ if (BFQQ_SEEKY(bfqq) || BFQQ_SEEKY(new_bfqq)) -+ return false; -+ -+ /* -+ * Interleaved I/O is known to be done by (some) applications -+ * only for reads, so it does not make sense to merge async -+ * queues. -+ */ -+ if (!bfq_bfqq_sync(bfqq) || !bfq_bfqq_sync(new_bfqq)) -+ return false; -+ -+ return true; -+} -+ -+/* -+ * If this function returns true, then bfqq cannot be merged. The idea -+ * is that true cooperation happens very early after processes start -+ * to do I/O. Usually, late cooperations are just accidental false -+ * positives. In case bfqq is weight-raised, such false positives -+ * would evidently degrade latency guarantees for bfqq. -+ */ -+bool wr_from_too_long(struct bfq_queue *bfqq) -+{ -+ return bfqq->wr_coeff > 1 && -+ time_is_before_jiffies(bfqq->last_wr_start_finish + -+ msecs_to_jiffies(100)); -+} -+ -+/* -+ * Attempt to schedule a merge of bfqq with the currently in-service -+ * queue or with a close queue among the scheduled queues. Return -+ * NULL if no merge was scheduled, a pointer to the shared bfq_queue -+ * structure otherwise. -+ * -+ * The OOM queue is not allowed to participate to cooperation: in fact, since -+ * the requests temporarily redirected to the OOM queue could be redirected -+ * again to dedicated queues at any time, the state needed to correctly -+ * handle merging with the OOM queue would be quite complex and expensive -+ * to maintain. Besides, in such a critical condition as an out of memory, -+ * the benefits of queue merging may be little relevant, or even negligible. -+ * -+ * Weight-raised queues can be merged only if their weight-raising -+ * period has just started. In fact cooperating processes are usually -+ * started together. Thus, with this filter we avoid false positives -+ * that would jeopardize low-latency guarantees. -+ * -+ * WARNING: queue merging may impair fairness among non-weight raised -+ * queues, for at least two reasons: 1) the original weight of a -+ * merged queue may change during the merged state, 2) even being the -+ * weight the same, a merged queue may be bloated with many more -+ * requests than the ones produced by its originally-associated -+ * process. -+ */ -+static struct bfq_queue * -+bfq_setup_cooperator(struct bfq_data *bfqd, struct bfq_queue *bfqq, -+ void *io_struct, bool request) -+{ -+ struct bfq_queue *in_service_bfqq, *new_bfqq; -+ -+ if (bfqq->new_bfqq) -+ return bfqq->new_bfqq; -+ -+ if (io_struct && wr_from_too_long(bfqq) && -+ likely(bfqq != &bfqd->oom_bfqq)) -+ bfq_log_bfqq(bfqd, bfqq, -+ "would have looked for coop, but bfq%d wr", -+ bfqq->pid); -+ -+ if (!io_struct || -+ wr_from_too_long(bfqq) || -+ unlikely(bfqq == &bfqd->oom_bfqq)) -+ return NULL; -+ -+ /* If there is only one backlogged queue, don't search. */ -+ if (bfqd->busy_queues == 1) -+ return NULL; -+ -+ in_service_bfqq = bfqd->in_service_queue; -+ -+ if (in_service_bfqq && in_service_bfqq != bfqq && -+ bfqd->in_service_bic && wr_from_too_long(in_service_bfqq) -+ && likely(in_service_bfqq == &bfqd->oom_bfqq)) -+ bfq_log_bfqq(bfqd, bfqq, -+ "would have tried merge with in-service-queue, but wr"); -+ -+ if (!in_service_bfqq || in_service_bfqq == bfqq || -+ !bfqd->in_service_bic || wr_from_too_long(in_service_bfqq) || -+ unlikely(in_service_bfqq == &bfqd->oom_bfqq)) -+ goto check_scheduled; -+ -+ if (bfq_rq_close_to_sector(io_struct, request, bfqd->last_position) && -+ bfqq->entity.parent == in_service_bfqq->entity.parent && -+ bfq_may_be_close_cooperator(bfqq, in_service_bfqq)) { -+ new_bfqq = bfq_setup_merge(bfqq, in_service_bfqq); -+ if (new_bfqq) -+ return new_bfqq; -+ } -+ /* -+ * Check whether there is a cooperator among currently scheduled -+ * queues. The only thing we need is that the bio/request is not -+ * NULL, as we need it to establish whether a cooperator exists. -+ */ -+check_scheduled: -+ new_bfqq = bfq_find_close_cooperator(bfqd, bfqq, -+ bfq_io_struct_pos(io_struct, request)); -+ -+ BUG_ON(new_bfqq && bfqq->entity.parent != new_bfqq->entity.parent); -+ -+ if (new_bfqq && wr_from_too_long(new_bfqq) && -+ likely(new_bfqq != &bfqd->oom_bfqq) && -+ bfq_may_be_close_cooperator(bfqq, new_bfqq)) -+ bfq_log_bfqq(bfqd, bfqq, -+ "would have merged with bfq%d, but wr", -+ new_bfqq->pid); -+ -+ if (new_bfqq && !wr_from_too_long(new_bfqq) && -+ likely(new_bfqq != &bfqd->oom_bfqq) && -+ bfq_may_be_close_cooperator(bfqq, new_bfqq)) -+ return bfq_setup_merge(bfqq, new_bfqq); -+ -+ return NULL; -+} -+ -+static void bfq_bfqq_save_state(struct bfq_queue *bfqq) -+{ -+ struct bfq_io_cq *bic = bfqq->bic; -+ -+ /* -+ * If !bfqq->bic, the queue is already shared or its requests -+ * have already been redirected to a shared queue; both idle window -+ * and weight raising state have already been saved. Do nothing. -+ */ -+ if (!bic) -+ return; -+ -+ bic->saved_idle_window = bfq_bfqq_idle_window(bfqq); -+ bic->saved_IO_bound = bfq_bfqq_IO_bound(bfqq); -+ bic->saved_in_large_burst = bfq_bfqq_in_large_burst(bfqq); -+ bic->was_in_burst_list = !hlist_unhashed(&bfqq->burst_list_node); -+ bic->saved_wr_coeff = bfqq->wr_coeff; -+ bic->saved_wr_start_at_switch_to_srt = bfqq->wr_start_at_switch_to_srt; -+ bic->saved_last_wr_start_finish = bfqq->last_wr_start_finish; -+ BUG_ON(time_is_after_jiffies(bfqq->last_wr_start_finish)); -+} -+ -+static void bfq_get_bic_reference(struct bfq_queue *bfqq) -+{ -+ /* -+ * If bfqq->bic has a non-NULL value, the bic to which it belongs -+ * is about to begin using a shared bfq_queue. -+ */ -+ if (bfqq->bic) -+ atomic_long_inc(&bfqq->bic->icq.ioc->refcount); -+} -+ -+static void -+bfq_merge_bfqqs(struct bfq_data *bfqd, struct bfq_io_cq *bic, -+ struct bfq_queue *bfqq, struct bfq_queue *new_bfqq) -+{ -+ bfq_log_bfqq(bfqd, bfqq, "merging with queue %lu", -+ (unsigned long) new_bfqq->pid); -+ /* Save weight raising and idle window of the merged queues */ -+ bfq_bfqq_save_state(bfqq); -+ bfq_bfqq_save_state(new_bfqq); -+ if (bfq_bfqq_IO_bound(bfqq)) -+ bfq_mark_bfqq_IO_bound(new_bfqq); -+ bfq_clear_bfqq_IO_bound(bfqq); -+ -+ /* -+ * If bfqq is weight-raised, then let new_bfqq inherit -+ * weight-raising. To reduce false positives, neglect the case -+ * where bfqq has just been created, but has not yet made it -+ * to be weight-raised (which may happen because EQM may merge -+ * bfqq even before bfq_add_request is executed for the first -+ * time for bfqq). Handling this case would however be very -+ * easy, thanks to the flag just_created. -+ */ -+ if (new_bfqq->wr_coeff == 1 && bfqq->wr_coeff > 1) { -+ new_bfqq->wr_coeff = bfqq->wr_coeff; -+ new_bfqq->wr_cur_max_time = bfqq->wr_cur_max_time; -+ new_bfqq->last_wr_start_finish = bfqq->last_wr_start_finish; -+ new_bfqq->wr_start_at_switch_to_srt = bfqq->wr_start_at_switch_to_srt; -+ if (bfq_bfqq_busy(new_bfqq)) -+ bfqd->wr_busy_queues++; -+ new_bfqq->entity.prio_changed = 1; -+ bfq_log_bfqq(bfqd, new_bfqq, -+ "wr start after merge with %d, rais_max_time %u", -+ bfqq->pid, -+ jiffies_to_msecs(bfqq->wr_cur_max_time)); -+ } -+ -+ if (bfqq->wr_coeff > 1) { /* bfqq has given its wr to new_bfqq */ -+ bfqq->wr_coeff = 1; -+ bfqq->entity.prio_changed = 1; -+ if (bfq_bfqq_busy(bfqq)) -+ bfqd->wr_busy_queues--; -+ } -+ -+ bfq_log_bfqq(bfqd, new_bfqq, "merge_bfqqs: wr_busy %d", -+ bfqd->wr_busy_queues); -+ -+ /* -+ * Grab a reference to the bic, to prevent it from being destroyed -+ * before being possibly touched by a bfq_split_bfqq(). -+ */ -+ bfq_get_bic_reference(bfqq); -+ bfq_get_bic_reference(new_bfqq); -+ /* -+ * Merge queues (that is, let bic redirect its requests to new_bfqq) -+ */ -+ bic_set_bfqq(bic, new_bfqq, 1); -+ bfq_mark_bfqq_coop(new_bfqq); -+ /* -+ * new_bfqq now belongs to at least two bics (it is a shared queue): -+ * set new_bfqq->bic to NULL. bfqq either: -+ * - does not belong to any bic any more, and hence bfqq->bic must -+ * be set to NULL, or -+ * - is a queue whose owning bics have already been redirected to a -+ * different queue, hence the queue is destined to not belong to -+ * any bic soon and bfqq->bic is already NULL (therefore the next -+ * assignment causes no harm). -+ */ -+ new_bfqq->bic = NULL; -+ bfqq->bic = NULL; -+ bfq_put_queue(bfqq); -+} -+ -+static int bfq_allow_bio_merge(struct request_queue *q, struct request *rq, -+ struct bio *bio) ++static int bfq_allow_merge(struct request_queue *q, struct request *rq, ++ struct bio *bio) +{ + struct bfq_data *bfqd = q->elevator->elevator_data; + struct bfq_io_cq *bic; -+ struct bfq_queue *bfqq, *new_bfqq; + + /* + * Disallow merge of a sync bio into an async request. + */ + if (bfq_bio_sync(bio) && !rq_is_sync(rq)) -+ return false; ++ return 0; + + /* + * Lookup the bfqq that this bio will be queued with. Allow @@ -4218,124 +2478,28 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ + bic = bfq_bic_lookup(bfqd, current->io_context); + if (!bic) -+ return false; ++ return 0; + -+ bfqq = bic_to_bfqq(bic, bfq_bio_sync(bio)); -+ /* -+ * We take advantage of this function to perform an early merge -+ * of the queues of possible cooperating processes. -+ */ -+ if (bfqq) { -+ new_bfqq = bfq_setup_cooperator(bfqd, bfqq, bio, false); -+ if (new_bfqq) { -+ bfq_merge_bfqqs(bfqd, bic, bfqq, new_bfqq); -+ /* -+ * If we get here, the bio will be queued in the -+ * shared queue, i.e., new_bfqq, so use new_bfqq -+ * to decide whether bio and rq can be merged. -+ */ -+ bfqq = new_bfqq; -+ } -+ } -+ -+ return bfqq == RQ_BFQQ(rq); -+} -+ -+static int bfq_allow_rq_merge(struct request_queue *q, struct request *rq, -+ struct request *next) -+{ -+ return RQ_BFQQ(rq) == RQ_BFQQ(next); -+} -+ -+/* -+ * Set the maximum time for the in-service queue to consume its -+ * budget. This prevents seeky processes from lowering the throughput. -+ * In practice, a time-slice service scheme is used with seeky -+ * processes. -+ */ -+static void bfq_set_budget_timeout(struct bfq_data *bfqd, -+ struct bfq_queue *bfqq) -+{ -+ unsigned int timeout_coeff; -+ -+ if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time) -+ timeout_coeff = 1; -+ else -+ timeout_coeff = bfqq->entity.weight / bfqq->entity.orig_weight; -+ -+ bfqd->last_budget_start = ktime_get(); -+ -+ bfqq->budget_timeout = jiffies + -+ bfqd->bfq_timeout * timeout_coeff; -+ -+ bfq_log_bfqq(bfqd, bfqq, "set budget_timeout %u", -+ jiffies_to_msecs(bfqd->bfq_timeout * timeout_coeff)); ++ return bic_to_bfqq(bic, bfq_bio_sync(bio)) == RQ_BFQQ(rq); +} + +static void __bfq_set_in_service_queue(struct bfq_data *bfqd, + struct bfq_queue *bfqq) +{ + if (bfqq) { ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_update_avg_queue_size(bfqq_group(bfqq)); ++#endif + bfq_mark_bfqq_must_alloc(bfqq); ++ bfq_mark_bfqq_budget_new(bfqq); + bfq_clear_bfqq_fifo_expire(bfqq); + + bfqd->budgets_assigned = (bfqd->budgets_assigned*7 + 256) / 8; + -+ BUG_ON(bfqq == bfqd->in_service_queue); -+ BUG_ON(RB_EMPTY_ROOT(&bfqq->sort_list)); -+ -+ if (time_is_before_jiffies(bfqq->last_wr_start_finish) && -+ bfqq->wr_coeff > 1 && -+ bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && -+ time_is_before_jiffies(bfqq->budget_timeout)) { -+ /* -+ * For soft real-time queues, move the start -+ * of the weight-raising period forward by the -+ * time the queue has not received any -+ * service. Otherwise, a relatively long -+ * service delay is likely to cause the -+ * weight-raising period of the queue to end, -+ * because of the short duration of the -+ * weight-raising period of a soft real-time -+ * queue. It is worth noting that this move -+ * is not so dangerous for the other queues, -+ * because soft real-time queues are not -+ * greedy. -+ * -+ * To not add a further variable, we use the -+ * overloaded field budget_timeout to -+ * determine for how long the queue has not -+ * received service, i.e., how much time has -+ * elapsed since the queue expired. However, -+ * this is a little imprecise, because -+ * budget_timeout is set to jiffies if bfqq -+ * not only expires, but also remains with no -+ * request. -+ */ -+ bfqq->last_wr_start_finish += jiffies - -+ max_t(unsigned long, bfqq->last_wr_start_finish, -+ bfqq->budget_timeout); -+ if (time_is_after_jiffies(bfqq->last_wr_start_finish)) { -+ pr_crit( -+ "BFQ WARNING:last %lu budget %lu jiffies %lu", -+ bfqq->last_wr_start_finish, -+ bfqq->budget_timeout, -+ jiffies); -+ pr_crit("diff %lu", jiffies - -+ max_t(unsigned long, -+ bfqq->last_wr_start_finish, -+ bfqq->budget_timeout)); -+ bfqq->last_wr_start_finish = jiffies; -+ } -+ } -+ -+ bfq_set_budget_timeout(bfqd, bfqq); + bfq_log_bfqq(bfqd, bfqq, + "set_in_service_queue, cur-budget = %d", + bfqq->entity.budget); -+ } else -+ bfq_log(bfqd, "set_in_service_queue: NULL"); ++ } + + bfqd->in_service_queue = bfqq; +} @@ -4351,11 +2515,36 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + return bfqq; +} + ++/* ++ * If enough samples have been computed, return the current max budget ++ * stored in bfqd, which is dynamically updated according to the ++ * estimated disk peak rate; otherwise return the default max budget ++ */ ++static int bfq_max_budget(struct bfq_data *bfqd) ++{ ++ if (bfqd->budgets_assigned < bfq_stats_min_budgets) ++ return bfq_default_max_budget; ++ else ++ return bfqd->bfq_max_budget; ++} ++ ++/* ++ * Return min budget, which is a fraction of the current or default ++ * max budget (trying with 1/32) ++ */ ++static int bfq_min_budget(struct bfq_data *bfqd) ++{ ++ if (bfqd->budgets_assigned < bfq_stats_min_budgets) ++ return bfq_default_max_budget / 32; ++ else ++ return bfqd->bfq_max_budget / 32; ++} ++ +static void bfq_arm_slice_timer(struct bfq_data *bfqd) +{ + struct bfq_queue *bfqq = bfqd->in_service_queue; + struct bfq_io_cq *bic; -+ u32 sl; ++ unsigned long sl; + + BUG_ON(!RB_EMPTY_ROOT(&bfqq->sort_list)); + @@ -4379,343 +2568,59 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + sl = bfqd->bfq_slice_idle; + /* + * Unless the queue is being weight-raised or the scenario is -+ * asymmetric, grant only minimum idle time if the queue -+ * is seeky. A long idling is preserved for a weight-raised -+ * queue, or, more in general, in an asymemtric scenario, -+ * because a long idling is needed for guaranteeing to a queue -+ * its reserved share of the throughput (in particular, it is -+ * needed if the queue has a higher weight than some other -+ * queue). ++ * asymmetric, grant only minimum idle time if the queue either ++ * has been seeky for long enough or has already proved to be ++ * constantly seeky. + */ -+ if (BFQQ_SEEKY(bfqq) && bfqq->wr_coeff == 1 && ++ if (bfq_sample_valid(bfqq->seek_samples) && ++ ((BFQQ_SEEKY(bfqq) && bfqq->entity.service > ++ bfq_max_budget(bfqq->bfqd) / 8) || ++ bfq_bfqq_constantly_seeky(bfqq)) && bfqq->wr_coeff == 1 && + bfq_symmetric_scenario(bfqd)) -+ sl = min_t(u32, sl, BFQ_MIN_TT); -+ ++ sl = min(sl, msecs_to_jiffies(BFQ_MIN_TT)); ++ else if (bfqq->wr_coeff > 1) ++ sl = sl * 3; + bfqd->last_idling_start = ktime_get(); -+ hrtimer_start(&bfqd->idle_slice_timer, ns_to_ktime(sl), -+ HRTIMER_MODE_REL); ++ mod_timer(&bfqd->idle_slice_timer, jiffies + sl); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_set_start_idle_time(bfqq_group(bfqq)); -+ bfq_log(bfqd, "arm idle: %ld/%ld ms", -+ sl / NSEC_PER_MSEC, bfqd->bfq_slice_idle / NSEC_PER_MSEC); ++#endif ++ bfq_log(bfqd, "arm idle: %u/%u ms", ++ jiffies_to_msecs(sl), jiffies_to_msecs(bfqd->bfq_slice_idle)); +} + +/* -+ * In autotuning mode, max_budget is dynamically recomputed as the -+ * amount of sectors transferred in timeout at the estimated peak -+ * rate. This enables BFQ to utilize a full timeslice with a full -+ * budget, even if the in-service queue is served at peak rate. And -+ * this maximises throughput with sequential workloads. ++ * Set the maximum time for the in-service queue to consume its ++ * budget. This prevents seeky processes from lowering the disk ++ * throughput (always guaranteed with a time slice scheme as in CFQ). + */ -+static unsigned long bfq_calc_max_budget(struct bfq_data *bfqd) ++static void bfq_set_budget_timeout(struct bfq_data *bfqd) +{ -+ return (u64)bfqd->peak_rate * USEC_PER_MSEC * -+ jiffies_to_msecs(bfqd->bfq_timeout)>>BFQ_RATE_SHIFT; -+} ++ struct bfq_queue *bfqq = bfqd->in_service_queue; ++ unsigned int timeout_coeff; + -+/* -+ * Update parameters related to throughput and responsiveness, as a -+ * function of the estimated peak rate. See comments on -+ * bfq_calc_max_budget(), and on T_slow and T_fast arrays. -+ */ -+void update_thr_responsiveness_params(struct bfq_data *bfqd) -+{ -+ int dev_type = blk_queue_nonrot(bfqd->queue); -+ -+ if (bfqd->bfq_user_max_budget == 0) { -+ bfqd->bfq_max_budget = -+ bfq_calc_max_budget(bfqd); -+ BUG_ON(bfqd->bfq_max_budget < 0); -+ bfq_log(bfqd, "new max_budget = %d", -+ bfqd->bfq_max_budget); -+ } -+ -+ if (bfqd->device_speed == BFQ_BFQD_FAST && -+ bfqd->peak_rate < device_speed_thresh[dev_type]) { -+ bfqd->device_speed = BFQ_BFQD_SLOW; -+ bfqd->RT_prod = R_slow[dev_type] * -+ T_slow[dev_type]; -+ } else if (bfqd->device_speed == BFQ_BFQD_SLOW && -+ bfqd->peak_rate > device_speed_thresh[dev_type]) { -+ bfqd->device_speed = BFQ_BFQD_FAST; -+ bfqd->RT_prod = R_fast[dev_type] * -+ T_fast[dev_type]; -+ } -+ -+ bfq_log(bfqd, -+"dev_type %s dev_speed_class = %s (%llu sects/sec), thresh %llu setcs/sec", -+ dev_type == 0 ? "ROT" : "NONROT", -+ bfqd->device_speed == BFQ_BFQD_FAST ? "FAST" : "SLOW", -+ bfqd->device_speed == BFQ_BFQD_FAST ? -+ (USEC_PER_SEC*(u64)R_fast[dev_type])>>BFQ_RATE_SHIFT : -+ (USEC_PER_SEC*(u64)R_slow[dev_type])>>BFQ_RATE_SHIFT, -+ (USEC_PER_SEC*(u64)device_speed_thresh[dev_type])>> -+ BFQ_RATE_SHIFT); -+} -+ -+void bfq_reset_rate_computation(struct bfq_data *bfqd, struct request *rq) -+{ -+ if (rq != NULL) { /* new rq dispatch now, reset accordingly */ -+ bfqd->last_dispatch = bfqd->first_dispatch = ktime_get_ns() ; -+ bfqd->peak_rate_samples = 1; -+ bfqd->sequential_samples = 0; -+ bfqd->tot_sectors_dispatched = bfqd->last_rq_max_size = -+ blk_rq_sectors(rq); -+ } else /* no new rq dispatched, just reset the number of samples */ -+ bfqd->peak_rate_samples = 0; /* full re-init on next disp. */ -+ -+ bfq_log(bfqd, -+ "reset_rate_computation at end, sample %u/%u tot_sects %llu", -+ bfqd->peak_rate_samples, bfqd->sequential_samples, -+ bfqd->tot_sectors_dispatched); -+} -+ -+void bfq_update_rate_reset(struct bfq_data *bfqd, struct request *rq) -+{ -+ u32 rate, weight, divisor; -+ -+ /* -+ * For the convergence property to hold (see comments on -+ * bfq_update_peak_rate()) and for the assessment to be -+ * reliable, a minimum number of samples must be present, and -+ * a minimum amount of time must have elapsed. If not so, do -+ * not compute new rate. Just reset parameters, to get ready -+ * for a new evaluation attempt. -+ */ -+ if (bfqd->peak_rate_samples < BFQ_RATE_MIN_SAMPLES || -+ bfqd->delta_from_first < BFQ_RATE_MIN_INTERVAL) { -+ bfq_log(bfqd, -+ "update_rate_reset: only resetting, delta_first %lluus samples %d", -+ bfqd->delta_from_first>>10, bfqd->peak_rate_samples); -+ goto reset_computation; -+ } -+ -+ /* -+ * If a new request completion has occurred after last -+ * dispatch, then, to approximate the rate at which requests -+ * have been served by the device, it is more precise to -+ * extend the observation interval to the last completion. -+ */ -+ bfqd->delta_from_first = -+ max_t(u64, bfqd->delta_from_first, -+ bfqd->last_completion - bfqd->first_dispatch); -+ -+ BUG_ON(bfqd->delta_from_first == 0); -+ /* -+ * Rate computed in sects/usec, and not sects/nsec, for -+ * precision issues. -+ */ -+ rate = div64_ul(bfqd->tot_sectors_dispatched<delta_from_first, NSEC_PER_USEC)); -+ -+ bfq_log(bfqd, -+"update_rate_reset: tot_sects %llu delta_first %lluus rate %llu sects/s (%d)", -+ bfqd->tot_sectors_dispatched, bfqd->delta_from_first>>10, -+ ((USEC_PER_SEC*(u64)rate)>>BFQ_RATE_SHIFT), -+ rate > 20< 20M sectors/sec) -+ */ -+ if ((bfqd->peak_rate_samples > (3 * bfqd->sequential_samples)>>2 && -+ rate <= bfqd->peak_rate) || -+ rate > 20<peak_rate_samples, bfqd->sequential_samples, -+ ((USEC_PER_SEC*(u64)rate)>>BFQ_RATE_SHIFT), -+ ((USEC_PER_SEC*(u64)bfqd->peak_rate)>>BFQ_RATE_SHIFT)); -+ goto reset_computation; -+ } else { -+ bfq_log(bfqd, -+ "update_rate_reset: do update, samples %u/%u rate/peak %llu/%llu", -+ bfqd->peak_rate_samples, bfqd->sequential_samples, -+ ((USEC_PER_SEC*(u64)rate)>>BFQ_RATE_SHIFT), -+ ((USEC_PER_SEC*(u64)bfqd->peak_rate)>>BFQ_RATE_SHIFT)); -+ } -+ -+ /* -+ * We have to update the peak rate, at last! To this purpose, -+ * we use a low-pass filter. We compute the smoothing constant -+ * of the filter as a function of the 'weight' of the new -+ * measured rate. -+ * -+ * As can be seen in next formulas, we define this weight as a -+ * quantity proportional to how sequential the workload is, -+ * and to how long the observation time interval is. -+ * -+ * The weight runs from 0 to 8. The maximum value of the -+ * weight, 8, yields the minimum value for the smoothing -+ * constant. At this minimum value for the smoothing constant, -+ * the measured rate contributes for half of the next value of -+ * the estimated peak rate. -+ * -+ * So, the first step is to compute the weight as a function -+ * of how sequential the workload is. Note that the weight -+ * cannot reach 9, because bfqd->sequential_samples cannot -+ * become equal to bfqd->peak_rate_samples, which, in its -+ * turn, holds true because bfqd->sequential_samples is not -+ * incremented for the first sample. -+ */ -+ weight = (9 * bfqd->sequential_samples) / bfqd->peak_rate_samples; -+ -+ /* -+ * Second step: further refine the weight as a function of the -+ * duration of the observation interval. -+ */ -+ weight = min_t(u32, 8, -+ div_u64(weight * bfqd->delta_from_first, -+ BFQ_RATE_REF_INTERVAL)); -+ -+ /* -+ * Divisor ranging from 10, for minimum weight, to 2, for -+ * maximum weight. -+ */ -+ divisor = 10 - weight; -+ BUG_ON(divisor == 0); -+ -+ /* -+ * Finally, update peak rate: -+ * -+ * peak_rate = peak_rate * (divisor-1) / divisor + rate / divisor -+ */ -+ bfqd->peak_rate *= divisor-1; -+ bfqd->peak_rate /= divisor; -+ rate /= divisor; /* smoothing constant alpha = 1/divisor */ -+ -+ bfq_log(bfqd, -+ "update_rate_reset: divisor %d tmp_peak_rate %llu tmp_rate %u", -+ divisor, -+ ((USEC_PER_SEC*(u64)bfqd->peak_rate)>>BFQ_RATE_SHIFT), -+ (u32)((USEC_PER_SEC*(u64)rate)>>BFQ_RATE_SHIFT)); -+ -+ BUG_ON(bfqd->peak_rate == 0); -+ BUG_ON(bfqd->peak_rate > 20<peak_rate += rate; -+ update_thr_responsiveness_params(bfqd); -+ BUG_ON(bfqd->peak_rate > 20<peak_rate_samples == 0) { /* first dispatch */ -+ bfq_log(bfqd, -+ "update_peak_rate: goto reset, samples %d", -+ bfqd->peak_rate_samples) ; -+ bfq_reset_rate_computation(bfqd, rq); -+ goto update_last_values; /* will add one sample */ -+ } -+ -+ /* -+ * Device idle for very long: the observation interval lasting -+ * up to this dispatch cannot be a valid observation interval -+ * for computing a new peak rate (similarly to the late- -+ * completion event in bfq_completed_request()). Go to -+ * update_rate_and_reset to have the following three steps -+ * taken: -+ * - close the observation interval at the last (previous) -+ * request dispatch or completion -+ * - compute rate, if possible, for that observation interval -+ * - start a new observation interval with this dispatch -+ */ -+ if (now_ns - bfqd->last_dispatch > 100*NSEC_PER_MSEC && -+ bfqd->rq_in_driver == 0) { -+ bfq_log(bfqd, -+"update_peak_rate: jumping to updating&resetting delta_last %lluus samples %d", -+ (now_ns - bfqd->last_dispatch)>>10, -+ bfqd->peak_rate_samples) ; -+ goto update_rate_and_reset; -+ } -+ -+ /* Update sampling information */ -+ bfqd->peak_rate_samples++; -+ -+ if ((bfqd->rq_in_driver > 0 || -+ now_ns - bfqd->last_completion < BFQ_MIN_TT) -+ && get_sdist(bfqd->last_position, rq) < BFQQ_SEEK_THR) -+ bfqd->sequential_samples++; -+ -+ bfqd->tot_sectors_dispatched += blk_rq_sectors(rq); -+ -+ /* Reset max observed rq size every 32 dispatches */ -+ if (likely(bfqd->peak_rate_samples % 32)) -+ bfqd->last_rq_max_size = -+ max_t(u32, blk_rq_sectors(rq), bfqd->last_rq_max_size); ++ if (bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time) ++ timeout_coeff = 1; + else -+ bfqd->last_rq_max_size = blk_rq_sectors(rq); ++ timeout_coeff = bfqq->entity.weight / bfqq->entity.orig_weight; + -+ bfqd->delta_from_first = now_ns - bfqd->first_dispatch; ++ bfqd->last_budget_start = ktime_get(); + -+ bfq_log(bfqd, -+ "update_peak_rate: added samples %u/%u tot_sects %llu delta_first %lluus", -+ bfqd->peak_rate_samples, bfqd->sequential_samples, -+ bfqd->tot_sectors_dispatched, -+ bfqd->delta_from_first>>10); ++ bfq_clear_bfqq_budget_new(bfqq); ++ bfqq->budget_timeout = jiffies + ++ bfqd->bfq_timeout[bfq_bfqq_sync(bfqq)] * timeout_coeff; + -+ /* Target observation interval not yet reached, go on sampling */ -+ if (bfqd->delta_from_first < BFQ_RATE_REF_INTERVAL) -+ goto update_last_values; -+ -+update_rate_and_reset: -+ bfq_update_rate_reset(bfqd, rq); -+update_last_values: -+ bfqd->last_position = blk_rq_pos(rq) + blk_rq_sectors(rq); -+ bfqd->last_dispatch = now_ns; -+ -+ bfq_log(bfqd, -+ "update_peak_rate: delta_first %lluus last_pos %llu peak_rate %llu", -+ (now_ns - bfqd->first_dispatch)>>10, -+ (unsigned long long) bfqd->last_position, -+ ((USEC_PER_SEC*(u64)bfqd->peak_rate)>>BFQ_RATE_SHIFT)); -+ bfq_log(bfqd, -+ "update_peak_rate: samples at end %d", bfqd->peak_rate_samples); ++ bfq_log_bfqq(bfqd, bfqq, "set budget_timeout %u", ++ jiffies_to_msecs(bfqd->bfq_timeout[bfq_bfqq_sync(bfqq)] * ++ timeout_coeff)); +} + +/* -+ * Move request from internal lists to the dispatch list of the request queue ++ * Move request from internal lists to the request queue dispatch list. + */ +static void bfq_dispatch_insert(struct request_queue *q, struct request *rq) +{ ++ struct bfq_data *bfqd = q->elevator->elevator_data; + struct bfq_queue *bfqq = RQ_BFQQ(rq); + + /* @@ -4729,10 +2634,15 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * incrementing bfqq->dispatched. + */ + bfqq->dispatched++; -+ bfq_update_peak_rate(q->elevator->elevator_data, rq); -+ + bfq_remove_request(rq); + elv_dispatch_sort(q, rq); ++ ++ if (bfq_bfqq_sync(bfqq)) ++ bfqd->sync_flight++; ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ bfqg_stats_update_dispatch(bfqq_group(bfqq), blk_rq_bytes(rq), ++ rq->cmd_flags); ++#endif +} + +/* @@ -4752,45 +2662,35 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + + rq = rq_entry_fifo(bfqq->fifo.next); + -+ if (ktime_get_ns() < rq->fifo_time) ++ if (time_before(jiffies, rq->fifo_time)) + return NULL; + + return rq; +} + ++static int bfq_bfqq_budget_left(struct bfq_queue *bfqq) ++{ ++ struct bfq_entity *entity = &bfqq->entity; ++ ++ return entity->budget - entity->service; ++} ++ +static void __bfq_bfqq_expire(struct bfq_data *bfqd, struct bfq_queue *bfqq) +{ + BUG_ON(bfqq != bfqd->in_service_queue); + + __bfq_bfqd_reset_in_service(bfqd); + -+ /* -+ * If this bfqq is shared between multiple processes, check -+ * to make sure that those processes are still issuing I/Os -+ * within the mean seek distance. If not, it may be time to -+ * break the queues apart again. -+ */ -+ if (bfq_bfqq_coop(bfqq) && BFQQ_SEEKY(bfqq)) -+ bfq_mark_bfqq_split_coop(bfqq); -+ + if (RB_EMPTY_ROOT(&bfqq->sort_list)) { -+ if (bfqq->dispatched == 0) -+ /* -+ * Overloading budget_timeout field to store -+ * the time at which the queue remains with no -+ * backlog and no outstanding request; used by -+ * the weight-raising mechanism. -+ */ -+ bfqq->budget_timeout = jiffies; -+ -+ bfq_del_bfqq_busy(bfqd, bfqq, 1); -+ } else { -+ bfq_activate_bfqq(bfqd, bfqq); + /* -+ * Resort priority tree of potential close cooperators. ++ * Overloading budget_timeout field to store the time ++ * at which the queue remains with no backlog; used by ++ * the weight-raising mechanism. + */ -+ bfq_pos_tree_add_move(bfqd, bfqq); -+ } ++ bfqq->budget_timeout = jiffies; ++ bfq_del_bfqq_busy(bfqd, bfqq, 1); ++ } else ++ bfq_activate_bfqq(bfqd, bfqq); +} + +/** @@ -4809,19 +2709,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + struct request *next_rq; + int budget, min_budget; + -+ BUG_ON(bfqq != bfqd->in_service_queue); -+ ++ budget = bfqq->max_budget; + min_budget = bfq_min_budget(bfqd); + -+ if (bfqq->wr_coeff == 1) -+ budget = bfqq->max_budget; -+ else /* -+ * Use a constant, low budget for weight-raised queues, -+ * to help achieve a low latency. Keep it slightly higher -+ * than the minimum possible budget, to cause a little -+ * bit fewer expirations. -+ */ -+ budget = 2 * min_budget; ++ BUG_ON(bfqq != bfqd->in_service_queue); + + bfq_log_bfqq(bfqd, bfqq, "recalc_budg: last budg %d, budg left %d", + bfqq->entity.budget, bfq_bfqq_budget_left(bfqq)); @@ -4830,7 +2721,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfq_log_bfqq(bfqd, bfqq, "recalc_budg: sync %d, seeky %d", + bfq_bfqq_sync(bfqq), BFQQ_SEEKY(bfqd->in_service_queue)); + -+ if (bfq_bfqq_sync(bfqq) && bfqq->wr_coeff == 1) { ++ if (bfq_bfqq_sync(bfqq)) { + switch (reason) { + /* + * Caveat: in all the following cases we trade latency @@ -4872,10 +2763,14 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + break; + case BFQ_BFQQ_BUDGET_TIMEOUT: + /* -+ * We double the budget here because it gives -+ * the chance to boost the throughput if this -+ * is not a seeky process (and has bumped into -+ * this timeout because of, e.g., ZBR). ++ * We double the budget here because: 1) it ++ * gives the chance to boost the throughput if ++ * this is not a seeky process (which may have ++ * bumped into this timeout because of, e.g., ++ * ZBR), 2) together with charge_full_budget ++ * it helps give seeky processes higher ++ * timestamps, and hence be served less ++ * frequently. + */ + budget = min(budget * 2, bfqd->bfq_max_budget); + break; @@ -4892,49 +2787,17 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + budget = min(budget * 4, bfqd->bfq_max_budget); + break; + case BFQ_BFQQ_NO_MORE_REQUESTS: -+ /* -+ * For queues that expire for this reason, it -+ * is particularly important to keep the -+ * budget close to the actual service they -+ * need. Doing so reduces the timestamp -+ * misalignment problem described in the -+ * comments in the body of -+ * __bfq_activate_entity. In fact, suppose -+ * that a queue systematically expires for -+ * BFQ_BFQQ_NO_MORE_REQUESTS and presents a -+ * new request in time to enjoy timestamp -+ * back-shifting. The larger the budget of the -+ * queue is with respect to the service the -+ * queue actually requests in each service -+ * slot, the more times the queue can be -+ * reactivated with the same virtual finish -+ * time. It follows that, even if this finish -+ * time is pushed to the system virtual time -+ * to reduce the consequent timestamp -+ * misalignment, the queue unjustly enjoys for -+ * many re-activations a lower finish time -+ * than all newly activated queues. -+ * -+ * The service needed by bfqq is measured -+ * quite precisely by bfqq->entity.service. -+ * Since bfqq does not enjoy device idling, -+ * bfqq->entity.service is equal to the number -+ * of sectors that the process associated with -+ * bfqq requested to read/write before waiting -+ * for request completions, or blocking for -+ * other reasons. -+ */ -+ budget = max_t(int, bfqq->entity.service, min_budget); -+ break; ++ /* ++ * Leave the budget unchanged. ++ */ + default: + return; + } -+ } else if (!bfq_bfqq_sync(bfqq)) ++ } else + /* -+ * Async queues get always the maximum possible -+ * budget, as for them we do not care about latency -+ * (in addition, their ability to dispatch is limited -+ * by the charging factor). ++ * Async queues get always the maximum possible budget ++ * (their ability to dispatch is limited by ++ * @bfqd->bfq_max_budget_async_rq). + */ + budget = bfqd->bfq_max_budget; + @@ -4945,120 +2808,160 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfqq->max_budget = min(bfqq->max_budget, bfqd->bfq_max_budget); + + /* -+ * If there is still backlog, then assign a new budget, making -+ * sure that it is large enough for the next request. Since -+ * the finish time of bfqq must be kept in sync with the -+ * budget, be sure to call __bfq_bfqq_expire() *after* this ++ * Make sure that we have enough budget for the next request. ++ * Since the finish time of the bfqq must be kept in sync with ++ * the budget, be sure to call __bfq_bfqq_expire() after the + * update. -+ * -+ * If there is no backlog, then no need to update the budget; -+ * it will be updated on the arrival of a new request. + */ + next_rq = bfqq->next_rq; -+ if (next_rq) { -+ BUG_ON(reason == BFQ_BFQQ_TOO_IDLE || -+ reason == BFQ_BFQQ_NO_MORE_REQUESTS); ++ if (next_rq) + bfqq->entity.budget = max_t(unsigned long, bfqq->max_budget, + bfq_serv_to_charge(next_rq, bfqq)); -+ BUG_ON(!bfq_bfqq_busy(bfqq)); -+ BUG_ON(RB_EMPTY_ROOT(&bfqq->sort_list)); -+ } ++ else ++ bfqq->entity.budget = bfqq->max_budget; + + bfq_log_bfqq(bfqd, bfqq, "head sect: %u, new budget %d", + next_rq ? blk_rq_sectors(next_rq) : 0, + bfqq->entity.budget); +} + -+/* -+ * Return true if the process associated with bfqq is "slow". The slow -+ * flag is used, in addition to the budget timeout, to reduce the -+ * amount of service provided to seeky processes, and thus reduce -+ * their chances to lower the throughput. More details in the comments -+ * on the function bfq_bfqq_expire(). -+ * -+ * An important observation is in order: as discussed in the comments -+ * on the function bfq_update_peak_rate(), with devices with internal -+ * queues, it is hard if ever possible to know when and for how long -+ * an I/O request is processed by the device (apart from the trivial -+ * I/O pattern where a new request is dispatched only after the -+ * previous one has been completed). This makes it hard to evaluate -+ * the real rate at which the I/O requests of each bfq_queue are -+ * served. In fact, for an I/O scheduler like BFQ, serving a -+ * bfq_queue means just dispatching its requests during its service -+ * slot (i.e., until the budget of the queue is exhausted, or the -+ * queue remains idle, or, finally, a timeout fires). But, during the -+ * service slot of a bfq_queue, around 100 ms at most, the device may -+ * be even still processing requests of bfq_queues served in previous -+ * service slots. On the opposite end, the requests of the in-service -+ * bfq_queue may be completed after the service slot of the queue -+ * finishes. -+ * -+ * Anyway, unless more sophisticated solutions are used -+ * (where possible), the sum of the sizes of the requests dispatched -+ * during the service slot of a bfq_queue is probably the only -+ * approximation available for the service received by the bfq_queue -+ * during its service slot. And this sum is the quantity used in this -+ * function to evaluate the I/O speed of a process. -+ */ -+static bool bfq_bfqq_is_slow(struct bfq_data *bfqd, struct bfq_queue *bfqq, -+ bool compensate, enum bfqq_expiration reason, -+ unsigned long *delta_ms) ++static unsigned long bfq_calc_max_budget(u64 peak_rate, u64 timeout) +{ -+ ktime_t delta_ktime; -+ u32 delta_usecs; -+ bool slow = BFQQ_SEEKY(bfqq); /* if delta too short, use seekyness */ ++ unsigned long max_budget; + -+ if (!bfq_bfqq_sync(bfqq)) ++ /* ++ * The max_budget calculated when autotuning is equal to the ++ * amount of sectors transfered in timeout_sync at the ++ * estimated peak rate. ++ */ ++ max_budget = (unsigned long)(peak_rate * 1000 * ++ timeout >> BFQ_RATE_SHIFT); ++ ++ return max_budget; ++} ++ ++/* ++ * In addition to updating the peak rate, checks whether the process ++ * is "slow", and returns 1 if so. This slow flag is used, in addition ++ * to the budget timeout, to reduce the amount of service provided to ++ * seeky processes, and hence reduce their chances to lower the ++ * throughput. See the code for more details. ++ */ ++static bool bfq_update_peak_rate(struct bfq_data *bfqd, struct bfq_queue *bfqq, ++ bool compensate, enum bfqq_expiration reason) ++{ ++ u64 bw, usecs, expected, timeout; ++ ktime_t delta; ++ int update = 0; ++ ++ if (!bfq_bfqq_sync(bfqq) || bfq_bfqq_budget_new(bfqq)) + return false; + + if (compensate) -+ delta_ktime = bfqd->last_idling_start; ++ delta = bfqd->last_idling_start; + else -+ delta_ktime = ktime_get(); -+ delta_ktime = ktime_sub(delta_ktime, bfqd->last_budget_start); -+ delta_usecs = ktime_to_us(delta_ktime); ++ delta = ktime_get(); ++ delta = ktime_sub(delta, bfqd->last_budget_start); ++ usecs = ktime_to_us(delta); + -+ /* don't trust short/unrealistic values. */ -+ if (delta_usecs < 1000 || delta_usecs >= LONG_MAX) { -+ if (blk_queue_nonrot(bfqd->queue)) -+ /* -+ * give same worst-case guarantees as idling -+ * for seeky -+ */ -+ *delta_ms = BFQ_MIN_TT / NSEC_PER_MSEC; -+ else /* charge at least one seek */ -+ *delta_ms = bfq_slice_idle / NSEC_PER_MSEC; -+ -+ bfq_log(bfqd, "bfq_bfqq_is_slow: unrealistic %u", delta_usecs); -+ -+ return slow; -+ } -+ -+ *delta_ms = delta_usecs / USEC_PER_MSEC; ++ /* Don't trust short/unrealistic values. */ ++ if (usecs < 100 || usecs >= LONG_MAX) ++ return false; + + /* -+ * Use only long (> 20ms) intervals to filter out excessive -+ * spikes in service rate estimation. ++ * Calculate the bandwidth for the last slice. We use a 64 bit ++ * value to store the peak rate, in sectors per usec in fixed ++ * point math. We do so to have enough precision in the estimate ++ * and to avoid overflows. + */ -+ if (delta_usecs > 20000) { -+ /* -+ * Caveat for rotational devices: processes doing I/O -+ * in the slower disk zones tend to be slow(er) even -+ * if not seeky. In this respect, the estimated peak -+ * rate is likely to be an average over the disk -+ * surface. Accordingly, to not be too harsh with -+ * unlucky processes, a process is deemed slow only if -+ * its rate has been lower than half of the estimated -+ * peak rate. -+ */ -+ slow = bfqq->entity.service < bfqd->bfq_max_budget / 2; -+ bfq_log(bfqd, "bfq_bfqq_is_slow: relative rate %d/%d", -+ bfqq->entity.service, bfqd->bfq_max_budget); ++ bw = (u64)bfqq->entity.service << BFQ_RATE_SHIFT; ++ do_div(bw, (unsigned long)usecs); ++ ++ timeout = jiffies_to_msecs(bfqd->bfq_timeout[BLK_RW_SYNC]); ++ ++ /* ++ * Use only long (> 20ms) intervals to filter out spikes for ++ * the peak rate estimation. ++ */ ++ if (usecs > 20000) { ++ if (bw > bfqd->peak_rate || ++ (!BFQQ_SEEKY(bfqq) && ++ reason == BFQ_BFQQ_BUDGET_TIMEOUT)) { ++ bfq_log(bfqd, "measured bw =%llu", bw); ++ /* ++ * To smooth oscillations use a low-pass filter with ++ * alpha=7/8, i.e., ++ * new_rate = (7/8) * old_rate + (1/8) * bw ++ */ ++ do_div(bw, 8); ++ if (bw == 0) ++ return 0; ++ bfqd->peak_rate *= 7; ++ do_div(bfqd->peak_rate, 8); ++ bfqd->peak_rate += bw; ++ update = 1; ++ bfq_log(bfqd, "new peak_rate=%llu", bfqd->peak_rate); ++ } ++ ++ update |= bfqd->peak_rate_samples == BFQ_PEAK_RATE_SAMPLES - 1; ++ ++ if (bfqd->peak_rate_samples < BFQ_PEAK_RATE_SAMPLES) ++ bfqd->peak_rate_samples++; ++ ++ if (bfqd->peak_rate_samples == BFQ_PEAK_RATE_SAMPLES && ++ update) { ++ int dev_type = blk_queue_nonrot(bfqd->queue); ++ ++ if (bfqd->bfq_user_max_budget == 0) { ++ bfqd->bfq_max_budget = ++ bfq_calc_max_budget(bfqd->peak_rate, ++ timeout); ++ bfq_log(bfqd, "new max_budget=%d", ++ bfqd->bfq_max_budget); ++ } ++ if (bfqd->device_speed == BFQ_BFQD_FAST && ++ bfqd->peak_rate < device_speed_thresh[dev_type]) { ++ bfqd->device_speed = BFQ_BFQD_SLOW; ++ bfqd->RT_prod = R_slow[dev_type] * ++ T_slow[dev_type]; ++ } else if (bfqd->device_speed == BFQ_BFQD_SLOW && ++ bfqd->peak_rate > device_speed_thresh[dev_type]) { ++ bfqd->device_speed = BFQ_BFQD_FAST; ++ bfqd->RT_prod = R_fast[dev_type] * ++ T_fast[dev_type]; ++ } ++ } + } + -+ bfq_log_bfqq(bfqd, bfqq, "bfq_bfqq_is_slow: slow %d", slow); ++ /* ++ * If the process has been served for a too short time ++ * interval to let its possible sequential accesses prevail on ++ * the initial seek time needed to move the disk head on the ++ * first sector it requested, then give the process a chance ++ * and for the moment return false. ++ */ ++ if (bfqq->entity.budget <= bfq_max_budget(bfqd) / 8) ++ return false; + -+ return slow; ++ /* ++ * A process is considered ``slow'' (i.e., seeky, so that we ++ * cannot treat it fairly in the service domain, as it would ++ * slow down too much the other processes) if, when a slice ++ * ends for whatever reason, it has received service at a ++ * rate that would not be high enough to complete the budget ++ * before the budget timeout expiration. ++ */ ++ expected = bw * 1000 * timeout >> BFQ_RATE_SHIFT; ++ ++ /* ++ * Caveat: processes doing IO in the slower disk zones will ++ * tend to be slow(er) even if not seeky. And the estimated ++ * peak rate will actually be an average over the disk ++ * surface. Hence, to not be too harsh with unlucky processes, ++ * we keep a budget/3 margin of safety before declaring a ++ * process slow. ++ */ ++ return expected > (4 * bfqq->entity.budget) / 3; +} + +/* @@ -5116,35 +3019,20 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +static unsigned long bfq_bfqq_softrt_next_start(struct bfq_data *bfqd, + struct bfq_queue *bfqq) +{ -+ bfq_log_bfqq(bfqd, bfqq, -+"softrt_next_start: service_blkg %lu soft_rate %u sects/sec interval %u", -+ bfqq->service_from_backlogged, -+ bfqd->bfq_wr_max_softrt_rate, -+ jiffies_to_msecs(HZ * bfqq->service_from_backlogged / -+ bfqd->bfq_wr_max_softrt_rate)); -+ + return max(bfqq->last_idle_bklogged + + HZ * bfqq->service_from_backlogged / + bfqd->bfq_wr_max_softrt_rate, -+ jiffies + nsecs_to_jiffies(bfqq->bfqd->bfq_slice_idle) + 4); ++ jiffies + bfqq->bfqd->bfq_slice_idle + 4); +} + +/* -+ * Return the farthest future time instant according to jiffies -+ * macros. ++ * Return the largest-possible time instant such that, for as long as possible, ++ * the current time will be lower than this time instant according to the macro ++ * time_is_before_jiffies(). + */ -+static unsigned long bfq_greatest_from_now(void) ++static unsigned long bfq_infinity_from_now(unsigned long now) +{ -+ return jiffies + MAX_JIFFY_OFFSET; -+} -+ -+/* -+ * Return the farthest past time instant according to jiffies -+ * macros. -+ */ -+static unsigned long bfq_smallest_from_now(void) -+{ -+ return jiffies - MAX_JIFFY_OFFSET; ++ return now + ULONG_MAX / 2; +} + +/** @@ -5154,24 +3042,28 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * @compensate: if true, compensate for the time spent idling. + * @reason: the reason causing the expiration. + * -+ * If the process associated with bfqq does slow I/O (e.g., because it -+ * issues random requests), we charge bfqq with the time it has been -+ * in service instead of the service it has received (see -+ * bfq_bfqq_charge_time for details on how this goal is achieved). As -+ * a consequence, bfqq will typically get higher timestamps upon -+ * reactivation, and hence it will be rescheduled as if it had -+ * received more service than what it has actually received. In the -+ * end, bfqq receives less service in proportion to how slowly its -+ * associated process consumes its budgets (and hence how seriously it -+ * tends to lower the throughput). In addition, this time-charging -+ * strategy guarantees time fairness among slow processes. In -+ * contrast, if the process associated with bfqq is not slow, we -+ * charge bfqq exactly with the service it has received. + * -+ * Charging time to the first type of queues and the exact service to -+ * the other has the effect of using the WF2Q+ policy to schedule the -+ * former on a timeslice basis, without violating service domain -+ * guarantees among the latter. ++ * If the process associated to the queue is slow (i.e., seeky), or in ++ * case of budget timeout, or, finally, if it is async, we ++ * artificially charge it an entire budget (independently of the ++ * actual service it received). As a consequence, the queue will get ++ * higher timestamps than the correct ones upon reactivation, and ++ * hence it will be rescheduled as if it had received more service ++ * than what it actually received. In the end, this class of processes ++ * will receive less service in proportion to how slowly they consume ++ * their budgets (and hence how seriously they tend to lower the ++ * throughput). ++ * ++ * In contrast, when a queue expires because it has been idling for ++ * too much or because it exhausted its budget, we do not touch the ++ * amount of service it has received. Hence when the queue will be ++ * reactivated and its timestamps updated, the latter will be in sync ++ * with the actual service received by the queue until expiration. ++ * ++ * Charging a full budget to the first type of queues and the exact ++ * service to the others has the effect of using the WF2Q+ policy to ++ * schedule the former on a timeslice basis, without violating the ++ * service domain guarantees of the latter. + */ +static void bfq_bfqq_expire(struct bfq_data *bfqd, + struct bfq_queue *bfqq, @@ -5179,52 +3071,41 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + enum bfqq_expiration reason) +{ + bool slow; -+ unsigned long delta = 0; -+ struct bfq_entity *entity = &bfqq->entity; + + BUG_ON(bfqq != bfqd->in_service_queue); + + /* -+ * Check whether the process is slow (see bfq_bfqq_is_slow). ++ * Update disk peak rate for autotuning and check whether the ++ * process is slow (see bfq_update_peak_rate). + */ -+ slow = bfq_bfqq_is_slow(bfqd, bfqq, compensate, reason, &delta); ++ slow = bfq_update_peak_rate(bfqd, bfqq, compensate, reason); + + /* -+ * Increase service_from_backlogged before next statement, -+ * because the possible next invocation of -+ * bfq_bfqq_charge_time would likely inflate -+ * entity->service. In contrast, service_from_backlogged must -+ * contain real service, to enable the soft real-time -+ * heuristic to correctly compute the bandwidth consumed by -+ * bfqq. -+ */ -+ bfqq->service_from_backlogged += entity->service; -+ -+ /* -+ * As above explained, charge slow (typically seeky) and -+ * timed-out queues with the time and not the service -+ * received, to favor sequential workloads. ++ * As above explained, 'punish' slow (i.e., seeky), timed-out ++ * and async queues, to favor sequential sync workloads. + * -+ * Processes doing I/O in the slower disk zones will tend to -+ * be slow(er) even if not seeky. Therefore, since the -+ * estimated peak rate is actually an average over the disk -+ * surface, these processes may timeout just for bad luck. To -+ * avoid punishing them, do not charge time to processes that -+ * succeeded in consuming at least 2/3 of their budget. This -+ * allows BFQ to preserve enough elasticity to still perform -+ * bandwidth, and not time, distribution with little unlucky -+ * or quasi-sequential processes. ++ * Processes doing I/O in the slower disk zones will tend to be ++ * slow(er) even if not seeky. Hence, since the estimated peak ++ * rate is actually an average over the disk surface, these ++ * processes may timeout just for bad luck. To avoid punishing ++ * them we do not charge a full budget to a process that ++ * succeeded in consuming at least 2/3 of its budget. + */ -+ if (bfqq->wr_coeff == 1 && -+ (slow || -+ (reason == BFQ_BFQQ_BUDGET_TIMEOUT && -+ bfq_bfqq_budget_left(bfqq) >= entity->budget / 3))) -+ bfq_bfqq_charge_time(bfqd, bfqq, delta); ++ if (slow || (reason == BFQ_BFQQ_BUDGET_TIMEOUT && ++ bfq_bfqq_budget_left(bfqq) >= bfqq->entity.budget / 3)) ++ bfq_bfqq_charge_full_budget(bfqq); + -+ BUG_ON(bfqq->entity.budget < bfqq->entity.service); ++ bfqq->service_from_backlogged += bfqq->entity.service; ++ ++ if (BFQQ_SEEKY(bfqq) && reason == BFQ_BFQQ_BUDGET_TIMEOUT && ++ !bfq_bfqq_constantly_seeky(bfqq)) { ++ bfq_mark_bfqq_constantly_seeky(bfqq); ++ if (!blk_queue_nonrot(bfqd->queue)) ++ bfqd->const_seeky_busy_in_flight_queues++; ++ } + + if (reason == BFQ_BFQQ_TOO_IDLE && -+ entity->service <= 2 * entity->budget / 10) ++ bfqq->entity.service <= 2 * bfqq->entity.budget / 10) + bfq_clear_bfqq_IO_bound(bfqq); + + if (bfqd->low_latency && bfqq->wr_coeff == 1) @@ -5233,23 +3114,19 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + if (bfqd->low_latency && bfqd->bfq_wr_max_softrt_rate > 0 && + RB_EMPTY_ROOT(&bfqq->sort_list)) { + /* -+ * If we get here, and there are no outstanding -+ * requests, then the request pattern is isochronous -+ * (see the comments on the function -+ * bfq_bfqq_softrt_next_start()). Thus we can compute -+ * soft_rt_next_start. If, instead, the queue still -+ * has outstanding requests, then we have to wait for -+ * the completion of all the outstanding requests to ++ * If we get here, and there are no outstanding requests, ++ * then the request pattern is isochronous (see the comments ++ * to the function bfq_bfqq_softrt_next_start()). Hence we ++ * can compute soft_rt_next_start. If, instead, the queue ++ * still has outstanding requests, then we have to wait ++ * for the completion of all the outstanding requests to + * discover whether the request pattern is actually + * isochronous. + */ -+ BUG_ON(bfqd->busy_queues < 1); -+ if (bfqq->dispatched == 0) { ++ if (bfqq->dispatched == 0) + bfqq->soft_rt_next_start = + bfq_bfqq_softrt_next_start(bfqd, bfqq); -+ bfq_log_bfqq(bfqd, bfqq, "new soft_rt_next %lu", -+ bfqq->soft_rt_next_start); -+ } else { ++ else { + /* + * The application is still waiting for the + * completion of one or more requests: @@ -5266,7 +3143,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * happened to be in the past. + */ + bfqq->soft_rt_next_start = -+ bfq_greatest_from_now(); ++ bfq_infinity_from_now(jiffies); + /* + * Schedule an update of soft_rt_next_start to when + * the task may be discovered to be isochronous. @@ -5276,27 +3153,15 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + } + + bfq_log_bfqq(bfqd, bfqq, -+ "expire (%d, slow %d, num_disp %d, idle_win %d, weight %d)", -+ reason, slow, bfqq->dispatched, -+ bfq_bfqq_idle_window(bfqq), entity->weight); ++ "expire (%d, slow %d, num_disp %d, idle_win %d)", reason, ++ slow, bfqq->dispatched, bfq_bfqq_idle_window(bfqq)); + + /* + * Increase, decrease or leave budget unchanged according to + * reason. + */ -+ BUG_ON(bfqq->entity.budget < bfqq->entity.service); + __bfq_bfqq_recalc_budget(bfqd, bfqq, reason); -+ BUG_ON(bfqq->next_rq == NULL && -+ bfqq->entity.budget < bfqq->entity.service); + __bfq_bfqq_expire(bfqd, bfqq); -+ -+ BUG_ON(!bfq_bfqq_busy(bfqq) && reason == BFQ_BFQQ_BUDGET_EXHAUSTED && -+ !bfq_class_idle(bfqq)); -+ -+ if (!bfq_bfqq_busy(bfqq) && -+ reason != BFQ_BFQQ_BUDGET_TIMEOUT && -+ reason != BFQ_BFQQ_BUDGET_EXHAUSTED) -+ bfq_mark_bfqq_non_blocking_wait_rq(bfqq); +} + +/* @@ -5306,17 +3171,20 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ +static bool bfq_bfqq_budget_timeout(struct bfq_queue *bfqq) +{ -+ return time_is_before_eq_jiffies(bfqq->budget_timeout); ++ if (bfq_bfqq_budget_new(bfqq) || ++ time_before(jiffies, bfqq->budget_timeout)) ++ return false; ++ return true; +} + +/* -+ * If we expire a queue that is actively waiting (i.e., with the -+ * device idled) for the arrival of a new request, then we may incur -+ * the timestamp misalignment problem described in the body of the -+ * function __bfq_activate_entity. Hence we return true only if this -+ * condition does not hold, or if the queue is slow enough to deserve -+ * only to be kicked off for preserving a high throughput. -+ */ ++ * If we expire a queue that is waiting for the arrival of a new ++ * request, we may prevent the fictitious timestamp back-shifting that ++ * allows the guarantees of the queue to be preserved (see [1] for ++ * this tricky aspect). Hence we return true only if this condition ++ * does not hold, or if the queue is slow enough to deserve only to be ++ * kicked off for preserving a high throughput. ++*/ +static bool bfq_may_expire_for_budg_timeout(struct bfq_queue *bfqq) +{ + bfq_log_bfqq(bfqq->bfqd, bfqq, @@ -5358,12 +3226,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +{ + struct bfq_data *bfqd = bfqq->bfqd; + bool idling_boosts_thr, idling_boosts_thr_without_issues, ++ all_queues_seeky, on_hdd_and_not_all_queues_seeky, + idling_needed_for_service_guarantees, + asymmetric_scenario; + -+ if (bfqd->strict_guarantees) -+ return true; -+ + /* + * The next variable takes into account the cases where idling + * boosts the throughput. @@ -5426,27 +3292,74 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfqd->wr_busy_queues == 0; + + /* -+ * There is then a case where idling must be performed not ++ * There are then two cases where idling must be performed not + * for throughput concerns, but to preserve service -+ * guarantees. ++ * guarantees. In the description of these cases, we say, for ++ * short, that a queue is sequential/random if the process ++ * associated to the queue issues sequential/random requests ++ * (in the second case the queue may be tagged as seeky or ++ * even constantly_seeky). + * -+ * To introduce this case, we can note that allowing the drive -+ * to enqueue more than one request at a time, and hence -+ * delegating de facto final scheduling decisions to the -+ * drive's internal scheduler, entails loss of control on the -+ * actual request service order. In particular, the critical -+ * situation is when requests from different processes happen -+ * to be present, at the same time, in the internal queue(s) -+ * of the drive. In such a situation, the drive, by deciding -+ * the service order of the internally-queued requests, does -+ * determine also the actual throughput distribution among -+ * these processes. But the drive typically has no notion or -+ * concern about per-process throughput distribution, and -+ * makes its decisions only on a per-request basis. Therefore, -+ * the service distribution enforced by the drive's internal -+ * scheduler is likely to coincide with the desired -+ * device-throughput distribution only in a completely -+ * symmetric scenario where: ++ * To introduce the first case, we note that, since ++ * bfq_bfqq_idle_window(bfqq) is false if the device is ++ * NCQ-capable and bfqq is random (see ++ * bfq_update_idle_window()), then, from the above two ++ * assignments it follows that ++ * idling_boosts_thr_without_issues is false if the device is ++ * NCQ-capable and bfqq is random. Therefore, for this case, ++ * device idling would never be allowed if we used just ++ * idling_boosts_thr_without_issues to decide whether to allow ++ * it. And, beneficially, this would imply that throughput ++ * would always be boosted also with random I/O on NCQ-capable ++ * HDDs. ++ * ++ * But we must be careful on this point, to avoid an unfair ++ * treatment for bfqq. In fact, because of the same above ++ * assignments, idling_boosts_thr_without_issues is, on the ++ * other hand, true if 1) the device is an HDD and bfqq is ++ * sequential, and 2) there are no busy weight-raised ++ * queues. As a consequence, if we used just ++ * idling_boosts_thr_without_issues to decide whether to idle ++ * the device, then with an HDD we might easily bump into a ++ * scenario where queues that are sequential and I/O-bound ++ * would enjoy idling, whereas random queues would not. The ++ * latter might then get a low share of the device throughput, ++ * simply because the former would get many requests served ++ * after being set as in service, while the latter would not. ++ * ++ * To address this issue, we start by setting to true a ++ * sentinel variable, on_hdd_and_not_all_queues_seeky, if the ++ * device is rotational and not all queues with pending or ++ * in-flight requests are constantly seeky (i.e., there are ++ * active sequential queues, and bfqq might then be mistreated ++ * if it does not enjoy idling because it is random). ++ */ ++ all_queues_seeky = bfq_bfqq_constantly_seeky(bfqq) && ++ bfqd->busy_in_flight_queues == ++ bfqd->const_seeky_busy_in_flight_queues; ++ ++ on_hdd_and_not_all_queues_seeky = ++ !blk_queue_nonrot(bfqd->queue) && !all_queues_seeky; ++ ++ /* ++ * To introduce the second case where idling needs to be ++ * performed to preserve service guarantees, we can note that ++ * allowing the drive to enqueue more than one request at a ++ * time, and hence delegating de facto final scheduling ++ * decisions to the drive's internal scheduler, causes loss of ++ * control on the actual request service order. In particular, ++ * the critical situation is when requests from different ++ * processes happens to be present, at the same time, in the ++ * internal queue(s) of the drive. In such a situation, the ++ * drive, by deciding the service order of the ++ * internally-queued requests, does determine also the actual ++ * throughput distribution among these processes. But the ++ * drive typically has no notion or concern about per-process ++ * throughput distribution, and makes its decisions only on a ++ * per-request basis. Therefore, the service distribution ++ * enforced by the drive's internal scheduler is likely to ++ * coincide with the desired device-throughput distribution ++ * only in a completely symmetric scenario where: + * (i) each of these processes must get the same throughput as + * the others; + * (ii) all these processes have the same I/O pattern @@ -5468,53 +3381,26 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * words, only if sub-condition (i) holds, then idling is + * allowed, and the device tends to be prevented from queueing + * many requests, possibly of several processes. The reason -+ * for not controlling also sub-condition (ii) is that we -+ * exploit preemption to preserve guarantees in case of -+ * symmetric scenarios, even if (ii) does not hold, as -+ * explained in the next two paragraphs. -+ * -+ * Even if a queue, say Q, is expired when it remains idle, Q -+ * can still preempt the new in-service queue if the next -+ * request of Q arrives soon (see the comments on -+ * bfq_bfqq_update_budg_for_activation). If all queues and -+ * groups have the same weight, this form of preemption, -+ * combined with the hole-recovery heuristic described in the -+ * comments on function bfq_bfqq_update_budg_for_activation, -+ * are enough to preserve a correct bandwidth distribution in -+ * the mid term, even without idling. In fact, even if not -+ * idling allows the internal queues of the device to contain -+ * many requests, and thus to reorder requests, we can rather -+ * safely assume that the internal scheduler still preserves a -+ * minimum of mid-term fairness. The motivation for using -+ * preemption instead of idling is that, by not idling, -+ * service guarantees are preserved without minimally -+ * sacrificing throughput. In other words, both a high -+ * throughput and its desired distribution are obtained. -+ * -+ * More precisely, this preemption-based, idleless approach -+ * provides fairness in terms of IOPS, and not sectors per -+ * second. This can be seen with a simple example. Suppose -+ * that there are two queues with the same weight, but that -+ * the first queue receives requests of 8 sectors, while the -+ * second queue receives requests of 1024 sectors. In -+ * addition, suppose that each of the two queues contains at -+ * most one request at a time, which implies that each queue -+ * always remains idle after it is served. Finally, after -+ * remaining idle, each queue receives very quickly a new -+ * request. It follows that the two queues are served -+ * alternatively, preempting each other if needed. This -+ * implies that, although both queues have the same weight, -+ * the queue with large requests receives a service that is -+ * 1024/8 times as high as the service received by the other -+ * queue. -+ * -+ * On the other hand, device idling is performed, and thus -+ * pure sector-domain guarantees are provided, for the -+ * following queues, which are likely to need stronger -+ * throughput guarantees: weight-raised queues, and queues -+ * with a higher weight than other queues. When such queues -+ * are active, sub-condition (i) is false, which triggers -+ * device idling. ++ * for not controlling also sub-condition (ii) is that, first, ++ * in the case of an HDD, the asymmetry in terms of types of ++ * I/O patterns is already taken in to account in the above ++ * sentinel variable ++ * on_hdd_and_not_all_queues_seeky. Secondly, in the case of a ++ * flash-based device, we prefer however to privilege ++ * throughput (and idling lowers throughput for this type of ++ * devices), for the following reasons: ++ * 1) differently from HDDs, the service time of random ++ * requests is not orders of magnitudes lower than the service ++ * time of sequential requests; thus, even if processes doing ++ * sequential I/O get a preferential treatment with respect to ++ * others doing random I/O, the consequences are not as ++ * dramatic as with HDDs; ++ * 2) if a process doing random I/O does need strong ++ * throughput guarantees, it is hopefully already being ++ * weight-raised, or the user is likely to have assigned it a ++ * higher weight than the other processes (and thus ++ * sub-condition (i) is likely to be false, which triggers ++ * idling). + * + * According to the above considerations, the next variable is + * true (only) if sub-condition (i) holds. To compute the @@ -5522,7 +3408,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * the function bfq_symmetric_scenario(), but also check + * whether bfqq is being weight-raised, because + * bfq_symmetric_scenario() does not take into account also -+ * weight-raised queues (see comments on ++ * weight-raised queues (see comments to + * bfq_weights_tree_add()). + * + * As a side note, it is worth considering that the above @@ -5544,16 +3430,17 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * bfqq. Such a case is when bfqq became active in a burst of + * queue activations. Queues that became active during a large + * burst benefit only from throughput, as discussed in the -+ * comments on bfq_handle_burst. Thus, if bfqq became active ++ * comments to bfq_handle_burst. Thus, if bfqq became active + * in a burst and not idling the device maximizes throughput, + * then the device must no be idled, because not idling the + * device provides bfqq and all other queues in the burst with -+ * maximum benefit. Combining this and the above case, we can -+ * now establish when idling is actually needed to preserve -+ * service guarantees. ++ * maximum benefit. Combining this and the two cases above, we ++ * can now establish when idling is actually needed to ++ * preserve service guarantees. + */ + idling_needed_for_service_guarantees = -+ asymmetric_scenario && !bfq_bfqq_in_large_burst(bfqq); ++ (on_hdd_and_not_all_queues_seeky || asymmetric_scenario) && ++ !bfq_bfqq_in_large_burst(bfqq); + + /* + * We have now all the components we need to compute the return @@ -5563,16 +3450,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * 2) idling either boosts the throughput (without issues), or + * is necessary to preserve service guarantees. + */ -+ bfq_log_bfqq(bfqd, bfqq, "may_idle: sync %d idling_boosts_thr %d", -+ bfq_bfqq_sync(bfqq), idling_boosts_thr); -+ -+ bfq_log_bfqq(bfqd, bfqq, -+ "may_idle: wr_busy %d boosts %d IO-bound %d guar %d", -+ bfqd->wr_busy_queues, -+ idling_boosts_thr_without_issues, -+ bfq_bfqq_IO_bound(bfqq), -+ idling_needed_for_service_guarantees); -+ + return bfq_bfqq_sync(bfqq) && + (idling_boosts_thr_without_issues || + idling_needed_for_service_guarantees); @@ -5584,7 +3461,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * 1) the queue must remain in service and cannot be expired, and + * 2) the device must be idled to wait for the possible arrival of a new + * request for the queue. -+ * See the comments on the function bfq_bfqq_may_idle for the reasons ++ * See the comments to the function bfq_bfqq_may_idle for the reasons + * why performing device idling is the best choice to boost the throughput + * and preserve service guarantees when bfq_bfqq_may_idle itself + * returns true. @@ -5614,7 +3491,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfq_log_bfqq(bfqd, bfqq, "select_queue: already in-service queue"); + + if (bfq_may_expire_for_budg_timeout(bfqq) && -+ !hrtimer_active(&bfqd->idle_slice_timer) && ++ !timer_pending(&bfqd->idle_slice_timer) && + !bfq_bfqq_must_idle(bfqq)) + goto expire; + @@ -5634,8 +3511,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * not disable disk idling even when a new request + * arrives. + */ -+ if (bfq_bfqq_wait_request(bfqq)) { -+ BUG_ON(!hrtimer_active(&bfqd->idle_slice_timer)); ++ if (timer_pending(&bfqd->idle_slice_timer)) { + /* + * If we get here: 1) at least a new request + * has arrived but we have not disabled the @@ -5650,8 +3526,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * So we disable idling. + */ + bfq_clear_bfqq_wait_request(bfqq); -+ hrtimer_try_to_cancel(&bfqd->idle_slice_timer); ++ del_timer(&bfqd->idle_slice_timer); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_update_idle_time(bfqq_group(bfqq)); ++#endif + } + goto keep_queue; + } @@ -5662,7 +3540,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * for a new request, or has requests waiting for a completion and + * may idle after their completion, then keep it anyway. + */ -+ if (hrtimer_active(&bfqd->idle_slice_timer) || ++ if (timer_pending(&bfqd->idle_slice_timer) || + (bfqq->dispatched != 0 && bfq_bfqq_may_idle(bfqq))) { + bfqq = NULL; + goto keep_queue; @@ -5684,9 +3562,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + struct bfq_entity *entity = &bfqq->entity; + + if (bfqq->wr_coeff > 1) { /* queue is being weight-raised */ -+ BUG_ON(bfqq->wr_cur_max_time == bfqd->bfq_wr_rt_max_time && -+ time_is_after_jiffies(bfqq->last_wr_start_finish)); -+ + bfq_log_bfqq(bfqd, bfqq, + "raising period dur %u/%u msec, old coeff %u, w %d(%d)", + jiffies_to_msecs(jiffies - bfqq->last_wr_start_finish), @@ -5700,30 +3575,20 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfq_log_bfqq(bfqd, bfqq, "WARN: pending prio change"); + + /* -+ * If the queue was activated in a burst, or too much -+ * time has elapsed from the beginning of this -+ * weight-raising period, then end weight raising. ++ * If the queue was activated in a burst, or ++ * too much time has elapsed from the beginning ++ * of this weight-raising period, then end weight ++ * raising. + */ -+ if (bfq_bfqq_in_large_burst(bfqq)) -+ bfq_bfqq_end_wr(bfqq); -+ else if (time_is_before_jiffies(bfqq->last_wr_start_finish + ++ if (bfq_bfqq_in_large_burst(bfqq) || ++ time_is_before_jiffies(bfqq->last_wr_start_finish + + bfqq->wr_cur_max_time)) { -+ if (bfqq->wr_cur_max_time != bfqd->bfq_wr_rt_max_time || -+ time_is_before_jiffies(bfqq->wr_start_at_switch_to_srt + -+ bfq_wr_duration(bfqd))) -+ bfq_bfqq_end_wr(bfqq); -+ else { -+ /* switch back to interactive wr */ -+ bfqq->wr_coeff = bfqd->bfq_wr_coeff; -+ bfqq->wr_cur_max_time = bfq_wr_duration(bfqd); -+ bfqq->last_wr_start_finish = -+ bfqq->wr_start_at_switch_to_srt; -+ BUG_ON(time_is_after_jiffies( -+ bfqq->last_wr_start_finish)); -+ bfqq->entity.prio_changed = 1; -+ bfq_log_bfqq(bfqd, bfqq, -+ "back to interactive wr"); -+ } ++ bfqq->last_wr_start_finish = jiffies; ++ bfq_log_bfqq(bfqd, bfqq, ++ "wrais ending at %lu, rais_max_time %u", ++ bfqq->last_wr_start_finish, ++ jiffies_to_msecs(bfqq->wr_cur_max_time)); ++ bfq_bfqq_end_wr(bfqq); + } + } + /* Update weight both if it must be raised and if it must be lowered */ @@ -5774,29 +3639,13 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ + if (!bfqd->rq_in_driver) + bfq_schedule_dispatch(bfqd); -+ BUG_ON(bfqq->entity.budget < bfqq->entity.service); + goto expire; + } + -+ BUG_ON(bfqq->entity.budget < bfqq->entity.service); + /* Finally, insert request into driver dispatch list. */ + bfq_bfqq_served(bfqq, service_to_charge); -+ -+ BUG_ON(bfqq->entity.budget < bfqq->entity.service); -+ + bfq_dispatch_insert(bfqd->queue, rq); + -+ /* -+ * If weight raising has to terminate for bfqq, then next -+ * function causes an immediate update of bfqq's weight, -+ * without waiting for next activation. As a consequence, on -+ * expiration, bfqq will be timestamped as if has never been -+ * weight-raised during this service slot, even if it has -+ * received part or even most of the service as a -+ * weight-raised queue. This inflates bfqq's timestamps, which -+ * is beneficial, as bfqq is then more willing to leave the -+ * device immediately to possible other weight-raised queues. -+ */ + bfq_update_wr_data(bfqd, bfqq); + + bfq_log_bfqq(bfqd, bfqq, @@ -5812,7 +3661,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfqd->in_service_bic = RQ_BIC(rq); + } + -+ if (bfqd->busy_queues > 1 && bfq_class_idle(bfqq)) ++ if (bfqd->busy_queues > 1 && ((!bfq_bfqq_sync(bfqq) && ++ dispatched >= bfqd->bfq_max_budget_async_rq) || ++ bfq_class_idle(bfqq))) + goto expire; + + return dispatched; @@ -5858,8 +3709,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + st = bfq_entity_service_tree(&bfqq->entity); + + dispatched += __bfq_forced_dispatch_bfqq(bfqq); -+ + bfqq->max_budget = bfq_max_budget(bfqd); ++ + bfq_forget_idle(st); + } + @@ -5872,37 +3723,37 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +{ + struct bfq_data *bfqd = q->elevator->elevator_data; + struct bfq_queue *bfqq; ++ int max_dispatch; + + bfq_log(bfqd, "dispatch requests: %d busy queues", bfqd->busy_queues); -+ + if (bfqd->busy_queues == 0) + return 0; + + if (unlikely(force)) + return bfq_forced_dispatch(bfqd); + -+ /* -+ * Force device to serve one request at a time if -+ * strict_guarantees is true. Forcing this service scheme is -+ * currently the ONLY way to guarantee that the request -+ * service order enforced by the scheduler is respected by a -+ * queueing device. Otherwise the device is free even to make -+ * some unlucky request wait for as long as the device -+ * wishes. -+ * -+ * Of course, serving one request at at time may cause loss of -+ * throughput. -+ */ -+ if (bfqd->strict_guarantees && bfqd->rq_in_driver > 0) -+ return 0; -+ + bfqq = bfq_select_queue(bfqd); + if (!bfqq) + return 0; + -+ BUG_ON(bfqq->entity.budget < bfqq->entity.service); ++ if (bfq_class_idle(bfqq)) ++ max_dispatch = 1; + -+ BUG_ON(bfq_bfqq_wait_request(bfqq)); ++ if (!bfq_bfqq_sync(bfqq)) ++ max_dispatch = bfqd->bfq_max_budget_async_rq; ++ ++ if (!bfq_bfqq_sync(bfqq) && bfqq->dispatched >= max_dispatch) { ++ if (bfqd->busy_queues > 1) ++ return 0; ++ if (bfqq->dispatched >= 4 * max_dispatch) ++ return 0; ++ } ++ ++ if (bfqd->sync_flight != 0 && !bfq_bfqq_sync(bfqq)) ++ return 0; ++ ++ bfq_clear_bfqq_wait_request(bfqq); ++ BUG_ON(timer_pending(&bfqd->idle_slice_timer)); + + if (!bfq_dispatch_request(bfqd, bfqq)) + return 0; @@ -5910,8 +3761,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfq_log_bfqq(bfqd, bfqq, "dispatched %s request", + bfq_bfqq_sync(bfqq) ? "sync" : "async"); + -+ BUG_ON(bfqq->next_rq == NULL && -+ bfqq->entity.budget < bfqq->entity.service); + return 1; +} + @@ -5923,22 +3772,23 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ +static void bfq_put_queue(struct bfq_queue *bfqq) +{ ++ struct bfq_data *bfqd = bfqq->bfqd; +#ifdef CONFIG_BFQ_GROUP_IOSCHED + struct bfq_group *bfqg = bfqq_group(bfqq); +#endif + -+ BUG_ON(bfqq->ref <= 0); ++ BUG_ON(atomic_read(&bfqq->ref) <= 0); + -+ bfq_log_bfqq(bfqq->bfqd, bfqq, "put_queue: %p %d", bfqq, bfqq->ref); -+ bfqq->ref--; -+ if (bfqq->ref) ++ bfq_log_bfqq(bfqd, bfqq, "put_queue: %p %d", bfqq, ++ atomic_read(&bfqq->ref)); ++ if (!atomic_dec_and_test(&bfqq->ref)) + return; + + BUG_ON(rb_first(&bfqq->sort_list)); + BUG_ON(bfqq->allocated[READ] + bfqq->allocated[WRITE] != 0); + BUG_ON(bfqq->entity.tree); + BUG_ON(bfq_bfqq_busy(bfqq)); -+ BUG_ON(bfqq->bfqd->in_service_queue == bfqq); ++ BUG_ON(bfqd->in_service_queue == bfqq); + + if (bfq_bfqq_sync(bfqq)) + /* @@ -5951,7 +3801,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ + hlist_del_init(&bfqq->burst_list_node); + -+ bfq_log_bfqq(bfqq->bfqd, bfqq, "put_queue: %p freed", bfqq); ++ bfq_log_bfqq(bfqd, bfqq, "put_queue: %p freed", bfqq); + + kmem_cache_free(bfq_pool, bfqq); +#ifdef CONFIG_BFQ_GROUP_IOSCHED @@ -5959,25 +3809,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +#endif +} + -+static void bfq_put_cooperator(struct bfq_queue *bfqq) -+{ -+ struct bfq_queue *__bfqq, *next; -+ -+ /* -+ * If this queue was scheduled to merge with another queue, be -+ * sure to drop the reference taken on that queue (and others in -+ * the merge chain). See bfq_setup_merge and bfq_merge_bfqqs. -+ */ -+ __bfqq = bfqq->new_bfqq; -+ while (__bfqq) { -+ if (__bfqq == bfqq) -+ break; -+ next = __bfqq->new_bfqq; -+ bfq_put_queue(__bfqq); -+ __bfqq = next; -+ } -+} -+ +static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq) +{ + if (bfqq == bfqd->in_service_queue) { @@ -5985,16 +3816,17 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfq_schedule_dispatch(bfqd); + } + -+ bfq_log_bfqq(bfqd, bfqq, "exit_bfqq: %p, %d", bfqq, bfqq->ref); -+ -+ bfq_put_cooperator(bfqq); ++ bfq_log_bfqq(bfqd, bfqq, "exit_bfqq: %p, %d", bfqq, ++ atomic_read(&bfqq->ref)); + + bfq_put_queue(bfqq); +} + +static void bfq_init_icq(struct io_cq *icq) +{ -+ icq_to_bic(icq)->ttime.last_end_request = ktime_get_ns() - (1ULL<<32); ++ struct bfq_io_cq *bic = icq_to_bic(icq); ++ ++ bic->ttime.last_end_request = jiffies; +} + +static void bfq_exit_icq(struct io_cq *icq) @@ -6002,21 +3834,14 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + struct bfq_io_cq *bic = icq_to_bic(icq); + struct bfq_data *bfqd = bic_to_bfqd(bic); + -+ if (bic_to_bfqq(bic, false)) { -+ bfq_exit_bfqq(bfqd, bic_to_bfqq(bic, false)); -+ bic_set_bfqq(bic, NULL, false); ++ if (bic->bfqq[BLK_RW_ASYNC]) { ++ bfq_exit_bfqq(bfqd, bic->bfqq[BLK_RW_ASYNC]); ++ bic->bfqq[BLK_RW_ASYNC] = NULL; + } + -+ if (bic_to_bfqq(bic, true)) { -+ /* -+ * If the bic is using a shared queue, put the reference -+ * taken on the io_context when the bic started using a -+ * shared bfq_queue. -+ */ -+ if (bfq_bfqq_coop(bic_to_bfqq(bic, true))) -+ put_io_context(icq->ioc); -+ bfq_exit_bfqq(bfqd, bic_to_bfqq(bic, true)); -+ bic_set_bfqq(bic, NULL, true); ++ if (bic->bfqq[BLK_RW_SYNC]) { ++ bfq_exit_bfqq(bfqd, bic->bfqq[BLK_RW_SYNC]); ++ bic->bfqq[BLK_RW_SYNC] = NULL; + } +} + @@ -6024,8 +3849,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * Update the entity prio values; note that the new values will not + * be used until the next (re)activation. + */ -+static void bfq_set_next_ioprio_data(struct bfq_queue *bfqq, -+ struct bfq_io_cq *bic) ++static void ++bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) +{ + struct task_struct *tsk = current; + int ioprio_class; @@ -6057,7 +3882,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + break; + } + -+ if (bfqq->new_ioprio >= IOPRIO_BE_NR) { ++ if (bfqq->new_ioprio < 0 || bfqq->new_ioprio >= IOPRIO_BE_NR) { + pr_crit("bfq_set_next_ioprio_data: new_ioprio %d\n", + bfqq->new_ioprio); + BUG(); @@ -6065,40 +3890,45 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + + bfqq->entity.new_weight = bfq_ioprio_to_weight(bfqq->new_ioprio); + bfqq->entity.prio_changed = 1; -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "set_next_ioprio_data: bic_class %d prio %d class %d", -+ ioprio_class, bfqq->new_ioprio, bfqq->new_ioprio_class); +} + +static void bfq_check_ioprio_change(struct bfq_io_cq *bic, struct bio *bio) +{ -+ struct bfq_data *bfqd = bic_to_bfqd(bic); -+ struct bfq_queue *bfqq; ++ struct bfq_data *bfqd; ++ struct bfq_queue *bfqq, *new_bfqq; + unsigned long uninitialized_var(flags); + int ioprio = bic->icq.ioc->ioprio; + ++ bfqd = bfq_get_bfqd_locked(&(bic->icq.q->elevator->elevator_data), ++ &flags); + /* + * This condition may trigger on a newly created bic, be sure to + * drop the lock before returning. + */ + if (unlikely(!bfqd) || likely(bic->ioprio == ioprio)) -+ return; ++ goto out; + + bic->ioprio = ioprio; + -+ bfqq = bic_to_bfqq(bic, false); ++ bfqq = bic->bfqq[BLK_RW_ASYNC]; + if (bfqq) { -+ bfq_put_queue(bfqq); -+ bfqq = bfq_get_queue(bfqd, bio, BLK_RW_ASYNC, bic); -+ bic_set_bfqq(bic, bfqq, false); -+ bfq_log_bfqq(bfqd, bfqq, -+ "check_ioprio_change: bfqq %p %d", -+ bfqq, bfqq->ref); ++ new_bfqq = bfq_get_queue(bfqd, bio, BLK_RW_ASYNC, bic, ++ GFP_ATOMIC); ++ if (new_bfqq) { ++ bic->bfqq[BLK_RW_ASYNC] = new_bfqq; ++ bfq_log_bfqq(bfqd, bfqq, ++ "check_ioprio_change: bfqq %p %d", ++ bfqq, atomic_read(&bfqq->ref)); ++ bfq_put_queue(bfqq); ++ } + } + -+ bfqq = bic_to_bfqq(bic, true); ++ bfqq = bic->bfqq[BLK_RW_SYNC]; + if (bfqq) + bfq_set_next_ioprio_data(bfqq, bic); ++ ++out: ++ bfq_put_bfqd_unlock(bfqd, &flags); +} + +static void bfq_init_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, @@ -6107,9 +3937,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + RB_CLEAR_NODE(&bfqq->entity.rb_node); + INIT_LIST_HEAD(&bfqq->fifo); + INIT_HLIST_NODE(&bfqq->burst_list_node); -+ BUG_ON(!hlist_unhashed(&bfqq->burst_list_node)); + -+ bfqq->ref = 0; ++ atomic_set(&bfqq->ref, 0); + bfqq->bfqd = bfqd; + + if (bic) @@ -6119,7 +3948,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + if (!bfq_class_idle(bfqq)) + bfq_mark_bfqq_idle_window(bfqq); + bfq_mark_bfqq_sync(bfqq); -+ bfq_mark_bfqq_just_created(bfqq); + } else + bfq_clear_bfqq_sync(bfqq); + bfq_mark_bfqq_IO_bound(bfqq); @@ -6129,19 +3957,72 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfqq->pid = pid; + + bfqq->wr_coeff = 1; -+ bfqq->last_wr_start_finish = jiffies; -+ bfqq->wr_start_at_switch_to_srt = bfq_smallest_from_now(); -+ bfqq->budget_timeout = bfq_smallest_from_now(); -+ bfqq->split_time = bfq_smallest_from_now(); -+ ++ bfqq->last_wr_start_finish = 0; + /* + * Set to the value for which bfqq will not be deemed as + * soft rt when it becomes backlogged. + */ -+ bfqq->soft_rt_next_start = bfq_greatest_from_now(); ++ bfqq->soft_rt_next_start = bfq_infinity_from_now(jiffies); ++} + -+ /* first request is almost certainly seeky */ -+ bfqq->seek_history = 1; ++static struct bfq_queue *bfq_find_alloc_queue(struct bfq_data *bfqd, ++ struct bio *bio, int is_sync, ++ struct bfq_io_cq *bic, ++ gfp_t gfp_mask) ++{ ++ struct bfq_group *bfqg; ++ struct bfq_queue *bfqq, *new_bfqq = NULL; ++ struct blkcg *blkcg; ++ ++retry: ++ rcu_read_lock(); ++ ++ blkcg = bio_blkcg(bio); ++ bfqg = bfq_find_alloc_group(bfqd, blkcg); ++ /* bic always exists here */ ++ bfqq = bic_to_bfqq(bic, is_sync); ++ ++ /* ++ * Always try a new alloc if we fall back to the OOM bfqq ++ * originally, since it should just be a temporary situation. ++ */ ++ if (!bfqq || bfqq == &bfqd->oom_bfqq) { ++ bfqq = NULL; ++ if (new_bfqq) { ++ bfqq = new_bfqq; ++ new_bfqq = NULL; ++ } else if (gfpflags_allow_blocking(gfp_mask)) { ++ rcu_read_unlock(); ++ spin_unlock_irq(bfqd->queue->queue_lock); ++ new_bfqq = kmem_cache_alloc_node(bfq_pool, ++ gfp_mask | __GFP_ZERO, ++ bfqd->queue->node); ++ spin_lock_irq(bfqd->queue->queue_lock); ++ if (new_bfqq) ++ goto retry; ++ } else { ++ bfqq = kmem_cache_alloc_node(bfq_pool, ++ gfp_mask | __GFP_ZERO, ++ bfqd->queue->node); ++ } ++ ++ if (bfqq) { ++ bfq_init_bfqq(bfqd, bfqq, bic, current->pid, ++ is_sync); ++ bfq_init_entity(&bfqq->entity, bfqg); ++ bfq_log_bfqq(bfqd, bfqq, "allocated"); ++ } else { ++ bfqq = &bfqd->oom_bfqq; ++ bfq_log_bfqq(bfqd, bfqq, "using oom bfqq"); ++ } ++ } ++ ++ if (new_bfqq) ++ kmem_cache_free(bfq_pool, new_bfqq); ++ ++ rcu_read_unlock(); ++ ++ return bfqq; +} + +static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, @@ -6164,84 +4045,90 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +} + +static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, -+ struct bio *bio, bool is_sync, -+ struct bfq_io_cq *bic) ++ struct bio *bio, int is_sync, ++ struct bfq_io_cq *bic, gfp_t gfp_mask) +{ + const int ioprio = IOPRIO_PRIO_DATA(bic->ioprio); + const int ioprio_class = IOPRIO_PRIO_CLASS(bic->ioprio); + struct bfq_queue **async_bfqq = NULL; -+ struct bfq_queue *bfqq; -+ struct bfq_group *bfqg; -+ -+ rcu_read_lock(); -+ -+ bfqg = bfq_find_set_group(bfqd, bio_blkcg(bio)); -+ if (!bfqg) { -+ bfqq = &bfqd->oom_bfqq; -+ goto out; -+ } ++ struct bfq_queue *bfqq = NULL; + + if (!is_sync) { ++ struct blkcg *blkcg; ++ struct bfq_group *bfqg; ++ ++ rcu_read_lock(); ++ blkcg = bio_blkcg(bio); ++ rcu_read_unlock(); ++ bfqg = bfq_find_alloc_group(bfqd, blkcg); + async_bfqq = bfq_async_queue_prio(bfqd, bfqg, ioprio_class, + ioprio); + bfqq = *async_bfqq; -+ if (bfqq) -+ goto out; + } + -+ bfqq = kmem_cache_alloc_node(bfq_pool, GFP_NOWAIT | __GFP_ZERO, -+ bfqd->queue->node); -+ -+ if (bfqq) { -+ bfq_init_bfqq(bfqd, bfqq, bic, current->pid, -+ is_sync); -+ bfq_init_entity(&bfqq->entity, bfqg); -+ bfq_log_bfqq(bfqd, bfqq, "allocated"); -+ } else { -+ bfqq = &bfqd->oom_bfqq; -+ bfq_log_bfqq(bfqd, bfqq, "using oom bfqq"); -+ goto out; -+ } ++ if (!bfqq) ++ bfqq = bfq_find_alloc_queue(bfqd, bio, is_sync, bic, gfp_mask); + + /* + * Pin the queue now that it's allocated, scheduler exit will + * prune it. + */ -+ if (async_bfqq) { -+ bfqq->ref++; ++ if (!is_sync && !(*async_bfqq)) { ++ atomic_inc(&bfqq->ref); + bfq_log_bfqq(bfqd, bfqq, "get_queue, bfqq not in async: %p, %d", -+ bfqq, bfqq->ref); ++ bfqq, atomic_read(&bfqq->ref)); + *async_bfqq = bfqq; + } + -+out: -+ bfqq->ref++; -+ bfq_log_bfqq(bfqd, bfqq, "get_queue, at end: %p, %d", bfqq, bfqq->ref); -+ rcu_read_unlock(); ++ atomic_inc(&bfqq->ref); ++ bfq_log_bfqq(bfqd, bfqq, "get_queue, at end: %p, %d", bfqq, ++ atomic_read(&bfqq->ref)); + return bfqq; +} + +static void bfq_update_io_thinktime(struct bfq_data *bfqd, + struct bfq_io_cq *bic) +{ -+ struct bfq_ttime *ttime = &bic->ttime; -+ u64 elapsed = ktime_get_ns() - bic->ttime.last_end_request; ++ unsigned long elapsed = jiffies - bic->ttime.last_end_request; ++ unsigned long ttime = min(elapsed, 2UL * bfqd->bfq_slice_idle); + -+ elapsed = min_t(u64, elapsed, 2 * bfqd->bfq_slice_idle); -+ -+ ttime->ttime_samples = (7*bic->ttime.ttime_samples + 256) / 8; -+ ttime->ttime_total = div_u64(7*ttime->ttime_total + 256*elapsed, 8); -+ ttime->ttime_mean = div64_ul(ttime->ttime_total + 128, -+ ttime->ttime_samples); ++ bic->ttime.ttime_samples = (7*bic->ttime.ttime_samples + 256) / 8; ++ bic->ttime.ttime_total = (7*bic->ttime.ttime_total + 256*ttime) / 8; ++ bic->ttime.ttime_mean = (bic->ttime.ttime_total + 128) / ++ bic->ttime.ttime_samples; +} + -+static void -+bfq_update_io_seektime(struct bfq_data *bfqd, struct bfq_queue *bfqq, -+ struct request *rq) ++static void bfq_update_io_seektime(struct bfq_data *bfqd, ++ struct bfq_queue *bfqq, ++ struct request *rq) +{ -+ bfqq->seek_history <<= 1; -+ bfqq->seek_history |= -+ get_sdist(bfqq->last_request_pos, rq) > BFQQ_SEEK_THR; ++ sector_t sdist; ++ u64 total; ++ ++ if (bfqq->last_request_pos < blk_rq_pos(rq)) ++ sdist = blk_rq_pos(rq) - bfqq->last_request_pos; ++ else ++ sdist = bfqq->last_request_pos - blk_rq_pos(rq); ++ ++ /* ++ * Don't allow the seek distance to get too large from the ++ * odd fragment, pagein, etc. ++ */ ++ if (bfqq->seek_samples == 0) /* first request, not really a seek */ ++ sdist = 0; ++ else if (bfqq->seek_samples <= 60) /* second & third seek */ ++ sdist = min(sdist, (bfqq->seek_mean * 4) + 2*1024*1024); ++ else ++ sdist = min(sdist, (bfqq->seek_mean * 4) + 2*1024*64); ++ ++ bfqq->seek_samples = (7*bfqq->seek_samples + 256) / 8; ++ bfqq->seek_total = (7*bfqq->seek_total + (u64)256*sdist) / 8; ++ total = bfqq->seek_total + (bfqq->seek_samples/2); ++ do_div(total, bfqq->seek_samples); ++ bfqq->seek_mean = (sector_t)total; ++ ++ bfq_log_bfqq(bfqd, bfqq, "dist=%llu mean=%llu", (u64)sdist, ++ (u64)bfqq->seek_mean); +} + +/* @@ -6258,11 +4145,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + if (!bfq_bfqq_sync(bfqq) || bfq_class_idle(bfqq)) + return; + -+ /* Idle window just restored, statistics are meaningless. */ -+ if (time_is_after_eq_jiffies(bfqq->split_time + -+ bfqd->bfq_wr_min_idle_time)) -+ return; -+ + enable_idle = bfq_bfqq_idle_window(bfqq); + + if (atomic_read(&bic->icq.ioc->active_ref) == 0 || @@ -6300,13 +4182,21 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + + bfq_update_io_thinktime(bfqd, bic); + bfq_update_io_seektime(bfqd, bfqq, rq); ++ if (!BFQQ_SEEKY(bfqq) && bfq_bfqq_constantly_seeky(bfqq)) { ++ bfq_clear_bfqq_constantly_seeky(bfqq); ++ if (!blk_queue_nonrot(bfqd->queue)) { ++ BUG_ON(!bfqd->const_seeky_busy_in_flight_queues); ++ bfqd->const_seeky_busy_in_flight_queues--; ++ } ++ } + if (bfqq->entity.service > bfq_max_budget(bfqd) / 8 || + !BFQQ_SEEKY(bfqq)) + bfq_update_idle_window(bfqd, bfqq, bic); + + bfq_log_bfqq(bfqd, bfqq, -+ "rq_enqueued: idle_window=%d (seeky %d)", -+ bfq_bfqq_idle_window(bfqq), BFQQ_SEEKY(bfqq)); ++ "rq_enqueued: idle_window=%d (seeky %d, mean %llu)", ++ bfq_bfqq_idle_window(bfqq), BFQQ_SEEKY(bfqq), ++ (unsigned long long) bfqq->seek_mean); + + bfqq->last_request_pos = blk_rq_pos(rq) + blk_rq_sectors(rq); + @@ -6320,15 +4210,14 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * is small and the queue is not to be expired, then + * just exit. + * -+ * In this way, if the device is being idled to wait -+ * for a new request from the in-service queue, we -+ * avoid unplugging the device and committing the -+ * device to serve just a small request. On the -+ * contrary, we wait for the block layer to decide -+ * when to unplug the device: hopefully, new requests -+ * will be merged to this one quickly, then the device -+ * will be unplugged and larger requests will be -+ * dispatched. ++ * In this way, if the disk is being idled to wait for ++ * a new request from the in-service queue, we avoid ++ * unplugging the device and committing the disk to serve ++ * just a small request. On the contrary, we wait for ++ * the block layer to decide when to unplug the device: ++ * hopefully, new requests will be merged to this one ++ * quickly, then the device will be unplugged and ++ * larger requests will be dispatched. + */ + if (small_req && !budget_timeout) + return; @@ -6340,8 +4229,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * timer. + */ + bfq_clear_bfqq_wait_request(bfqq); -+ hrtimer_try_to_cancel(&bfqd->idle_slice_timer); ++ del_timer(&bfqd->idle_slice_timer); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_update_idle_time(bfqq_group(bfqq)); ++#endif + + /* + * The queue is not empty, because a new request just @@ -6365,41 +4256,13 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +static void bfq_insert_request(struct request_queue *q, struct request *rq) +{ + struct bfq_data *bfqd = q->elevator->elevator_data; -+ struct bfq_queue *bfqq = RQ_BFQQ(rq), *new_bfqq; ++ struct bfq_queue *bfqq = RQ_BFQQ(rq); + + assert_spin_locked(bfqd->queue->queue_lock); + -+ /* -+ * An unplug may trigger a requeue of a request from the device -+ * driver: make sure we are in process context while trying to -+ * merge two bfq_queues. -+ */ -+ if (!in_interrupt()) { -+ new_bfqq = bfq_setup_cooperator(bfqd, bfqq, rq, true); -+ if (new_bfqq) { -+ if (bic_to_bfqq(RQ_BIC(rq), 1) != bfqq) -+ new_bfqq = bic_to_bfqq(RQ_BIC(rq), 1); -+ /* -+ * Release the request's reference to the old bfqq -+ * and make sure one is taken to the shared queue. -+ */ -+ new_bfqq->allocated[rq_data_dir(rq)]++; -+ bfqq->allocated[rq_data_dir(rq)]--; -+ new_bfqq->ref++; -+ bfq_clear_bfqq_just_created(bfqq); -+ bfq_put_queue(bfqq); -+ if (bic_to_bfqq(RQ_BIC(rq), 1) == bfqq) -+ bfq_merge_bfqqs(bfqd, RQ_BIC(rq), -+ bfqq, new_bfqq); -+ rq->elv.priv[1] = new_bfqq; -+ bfqq = new_bfqq; -+ } -+ } -+ + bfq_add_request(rq); + -+ rq->fifo_time = ktime_get_ns() + -+ jiffies_to_nsecs(bfqd->bfq_fifo_expire[rq_is_sync(rq)]); ++ rq->fifo_time = jiffies + bfqd->bfq_fifo_expire[rq_is_sync(rq)]; + list_add_tail(&rq->queuelist, &bfqq->fifo); + + bfq_rq_enqueued(bfqd, bfqq, rq); @@ -6407,8 +4270,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + +static void bfq_update_hw_tag(struct bfq_data *bfqd) +{ -+ bfqd->max_rq_in_driver = max_t(int, bfqd->max_rq_in_driver, -+ bfqd->rq_in_driver); ++ bfqd->max_rq_in_driver = max(bfqd->max_rq_in_driver, ++ bfqd->rq_in_driver); + + if (bfqd->hw_tag == 1) + return; @@ -6434,85 +4297,48 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +{ + struct bfq_queue *bfqq = RQ_BFQQ(rq); + struct bfq_data *bfqd = bfqq->bfqd; -+ u64 now_ns; -+ u32 delta_us; ++ bool sync = bfq_bfqq_sync(bfqq); + -+ bfq_log_bfqq(bfqd, bfqq, "completed one req with %u sects left", -+ blk_rq_sectors(rq)); ++ bfq_log_bfqq(bfqd, bfqq, "completed one req with %u sects left (%d)", ++ blk_rq_sectors(rq), sync); + -+ assert_spin_locked(bfqd->queue->queue_lock); + bfq_update_hw_tag(bfqd); + + BUG_ON(!bfqd->rq_in_driver); + BUG_ON(!bfqq->dispatched); + bfqd->rq_in_driver--; + bfqq->dispatched--; ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_update_completion(bfqq_group(bfqq), + rq_start_time_ns(rq), -+ rq_io_start_time_ns(rq), req_op(rq), -+ rq->cmd_flags); ++ rq_io_start_time_ns(rq), rq->cmd_flags); ++#endif + + if (!bfqq->dispatched && !bfq_bfqq_busy(bfqq)) { -+ BUG_ON(!RB_EMPTY_ROOT(&bfqq->sort_list)); -+ /* -+ * Set budget_timeout (which we overload to store the -+ * time at which the queue remains with no backlog and -+ * no outstanding request; used by the weight-raising -+ * mechanism). -+ */ -+ bfqq->budget_timeout = jiffies; -+ + bfq_weights_tree_remove(bfqd, &bfqq->entity, + &bfqd->queue_weights_tree); ++ if (!blk_queue_nonrot(bfqd->queue)) { ++ BUG_ON(!bfqd->busy_in_flight_queues); ++ bfqd->busy_in_flight_queues--; ++ if (bfq_bfqq_constantly_seeky(bfqq)) { ++ BUG_ON(!bfqd-> ++ const_seeky_busy_in_flight_queues); ++ bfqd->const_seeky_busy_in_flight_queues--; ++ } ++ } + } + -+ now_ns = ktime_get_ns(); -+ -+ RQ_BIC(rq)->ttime.last_end_request = now_ns; ++ if (sync) { ++ bfqd->sync_flight--; ++ RQ_BIC(rq)->ttime.last_end_request = jiffies; ++ } + + /* -+ * Using us instead of ns, to get a reasonable precision in -+ * computing rate in next check. -+ */ -+ delta_us = div_u64(now_ns - bfqd->last_completion, NSEC_PER_USEC); -+ -+ bfq_log(bfqd, "rq_completed: delta %uus/%luus max_size %u rate %llu/%llu", -+ delta_us, BFQ_MIN_TT/NSEC_PER_USEC, bfqd->last_rq_max_size, -+ (USEC_PER_SEC* -+ (u64)((bfqd->last_rq_max_size<>BFQ_RATE_SHIFT, -+ (USEC_PER_SEC*(u64)(1UL<<(BFQ_RATE_SHIFT-10)))>>BFQ_RATE_SHIFT); -+ -+ /* -+ * If the request took rather long to complete, and, according -+ * to the maximum request size recorded, this completion latency -+ * implies that the request was certainly served at a very low -+ * rate (less than 1M sectors/sec), then the whole observation -+ * interval that lasts up to this time instant cannot be a -+ * valid time interval for computing a new peak rate. Invoke -+ * bfq_update_rate_reset to have the following three steps -+ * taken: -+ * - close the observation interval at the last (previous) -+ * request dispatch or completion -+ * - compute rate, if possible, for that observation interval -+ * - reset to zero samples, which will trigger a proper -+ * re-initialization of the observation interval on next -+ * dispatch -+ */ -+ if (delta_us > BFQ_MIN_TT/NSEC_PER_USEC && -+ (bfqd->last_rq_max_size<last_completion = now_ns; -+ -+ /* -+ * If we are waiting to discover whether the request pattern -+ * of the task associated with the queue is actually -+ * isochronous, and both requisites for this condition to hold -+ * are now satisfied, then compute soft_rt_next_start (see the -+ * comments on the function bfq_bfqq_softrt_next_start()). We -+ * schedule this delayed check when bfqq expires, if it still -+ * has in-flight requests. ++ * If we are waiting to discover whether the request pattern of the ++ * task associated with the queue is actually isochronous, and ++ * both requisites for this condition to hold are satisfied, then ++ * compute soft_rt_next_start (see the comments to the function ++ * bfq_bfqq_softrt_next_start()). + */ + if (bfq_bfqq_softrt_update(bfqq) && bfqq->dispatched == 0 && + RB_EMPTY_ROOT(&bfqq->sort_list)) @@ -6524,7 +4350,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * or if we want to idle in case it has no pending requests. + */ + if (bfqd->in_service_queue == bfqq) { -+ if (bfqq->dispatched == 0 && bfq_bfqq_must_idle(bfqq)) { ++ if (bfq_bfqq_budget_new(bfqq)) ++ bfq_set_budget_timeout(bfqd); ++ ++ if (bfq_bfqq_must_idle(bfqq)) { + bfq_arm_slice_timer(bfqd); + goto out; + } else if (bfq_may_expire_for_budg_timeout(bfqq)) @@ -6554,7 +4383,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + return ELV_MQUEUE_MAY; +} + -+static int bfq_may_queue(struct request_queue *q, int op, int op_flags) ++static int bfq_may_queue(struct request_queue *q, int rw) +{ + struct bfq_data *bfqd = q->elevator->elevator_data; + struct task_struct *tsk = current; @@ -6571,7 +4400,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + if (!bic) + return ELV_MQUEUE_MAY; + -+ bfqq = bic_to_bfqq(bic, rw_is_sync(op, op_flags)); ++ bfqq = bic_to_bfqq(bic, rw_is_sync(rw)); + if (bfqq) + return __bfq_may_queue(bfqq); + @@ -6595,38 +4424,12 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + rq->elv.priv[1] = NULL; + + bfq_log_bfqq(bfqq->bfqd, bfqq, "put_request %p, %d", -+ bfqq, bfqq->ref); ++ bfqq, atomic_read(&bfqq->ref)); + bfq_put_queue(bfqq); + } +} + +/* -+ * Returns NULL if a new bfqq should be allocated, or the old bfqq if this -+ * was the last process referring to that bfqq. -+ */ -+static struct bfq_queue * -+bfq_split_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq) -+{ -+ bfq_log_bfqq(bfqq->bfqd, bfqq, "splitting queue"); -+ -+ put_io_context(bic->icq.ioc); -+ -+ if (bfqq_process_refs(bfqq) == 1) { -+ bfqq->pid = current->pid; -+ bfq_clear_bfqq_coop(bfqq); -+ bfq_clear_bfqq_split_coop(bfqq); -+ return bfqq; -+ } -+ -+ bic_set_bfqq(bic, NULL, 1); -+ -+ bfq_put_cooperator(bfqq); -+ -+ bfq_put_queue(bfqq); -+ return NULL; -+} -+ -+/* + * Allocate bfq data structures associated with this request. + */ +static int bfq_set_request(struct request_queue *q, struct request *rq, @@ -6638,96 +4441,38 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + const int is_sync = rq_is_sync(rq); + struct bfq_queue *bfqq; + unsigned long flags; -+ bool split = false; ++ ++ might_sleep_if(gfpflags_allow_blocking(gfp_mask)); ++ ++ bfq_check_ioprio_change(bic, bio); + + spin_lock_irqsave(q->queue_lock, flags); -+ bfq_check_ioprio_change(bic, bio); + + if (!bic) + goto queue_fail; + + bfq_bic_update_cgroup(bic, bio); + -+new_queue: + bfqq = bic_to_bfqq(bic, is_sync); + if (!bfqq || bfqq == &bfqd->oom_bfqq) { -+ if (bfqq) -+ bfq_put_queue(bfqq); -+ bfqq = bfq_get_queue(bfqd, bio, is_sync, bic); -+ BUG_ON(!hlist_unhashed(&bfqq->burst_list_node)); -+ ++ bfqq = bfq_get_queue(bfqd, bio, is_sync, bic, gfp_mask); + bic_set_bfqq(bic, bfqq, is_sync); -+ if (split && is_sync) { -+ bfq_log_bfqq(bfqd, bfqq, -+ "set_request: was_in_list %d " -+ "was_in_large_burst %d " -+ "large burst in progress %d", -+ bic->was_in_burst_list, -+ bic->saved_in_large_burst, -+ bfqd->large_burst); -+ -+ if ((bic->was_in_burst_list && bfqd->large_burst) || -+ bic->saved_in_large_burst) { -+ bfq_log_bfqq(bfqd, bfqq, -+ "set_request: marking in " -+ "large burst"); ++ if (is_sync) { ++ if (bfqd->large_burst) + bfq_mark_bfqq_in_large_burst(bfqq); -+ } else { -+ bfq_log_bfqq(bfqd, bfqq, -+ "set_request: clearing in " -+ "large burst"); ++ else + bfq_clear_bfqq_in_large_burst(bfqq); -+ if (bic->was_in_burst_list) -+ hlist_add_head(&bfqq->burst_list_node, -+ &bfqd->burst_list); -+ } -+ bfqq->split_time = jiffies; -+ } -+ } else { -+ /* If the queue was seeky for too long, break it apart. */ -+ if (bfq_bfqq_coop(bfqq) && bfq_bfqq_split_coop(bfqq)) { -+ bfq_log_bfqq(bfqd, bfqq, "breaking apart bfqq"); -+ -+ /* Update bic before losing reference to bfqq */ -+ if (bfq_bfqq_in_large_burst(bfqq)) -+ bic->saved_in_large_burst = true; -+ -+ bfqq = bfq_split_bfqq(bic, bfqq); -+ split = true; -+ if (!bfqq) -+ goto new_queue; + } + } + + bfqq->allocated[rw]++; -+ bfqq->ref++; -+ bfq_log_bfqq(bfqd, bfqq, "set_request: bfqq %p, %d", bfqq, bfqq->ref); ++ atomic_inc(&bfqq->ref); ++ bfq_log_bfqq(bfqd, bfqq, "set_request: bfqq %p, %d", bfqq, ++ atomic_read(&bfqq->ref)); + + rq->elv.priv[0] = bic; + rq->elv.priv[1] = bfqq; + -+ /* -+ * If a bfq_queue has only one process reference, it is owned -+ * by only one bfq_io_cq: we can set the bic field of the -+ * bfq_queue to the address of that structure. Also, if the -+ * queue has just been split, mark a flag so that the -+ * information is available to the other scheduler hooks. -+ */ -+ if (likely(bfqq != &bfqd->oom_bfqq) && bfqq_process_refs(bfqq) == 1) { -+ bfqq->bic = bic; -+ if (split) { -+ /* -+ * If the queue has just been split from a shared -+ * queue, restore the idle window and the possible -+ * weight raising period. -+ */ -+ bfq_bfqq_resume_state(bfqq, bic); -+ } -+ } -+ -+ if (unlikely(bfq_bfqq_just_created(bfqq))) -+ bfq_handle_burst(bfqd, bfqq); -+ + spin_unlock_irqrestore(q->queue_lock, flags); + + return 0; @@ -6754,10 +4499,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * Handler of the expiration of the timer running if the in-service queue + * is idling inside its time slice. + */ -+static enum hrtimer_restart bfq_idle_slice_timer(struct hrtimer *timer) ++static void bfq_idle_slice_timer(unsigned long data) +{ -+ struct bfq_data *bfqd = container_of(timer, struct bfq_data, -+ idle_slice_timer); ++ struct bfq_data *bfqd = (struct bfq_data *)data; + struct bfq_queue *bfqq; + unsigned long flags; + enum bfqq_expiration reason; @@ -6775,8 +4519,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + */ + if (bfqq) { + bfq_log_bfqq(bfqd, bfqq, "slice_timer expired"); -+ bfq_clear_bfqq_wait_request(bfqq); -+ + if (bfq_bfqq_budget_timeout(bfqq)) + /* + * Also here the queue can be safely expired @@ -6802,16 +4544,14 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfq_schedule_dispatch(bfqd); + + spin_unlock_irqrestore(bfqd->queue->queue_lock, flags); -+ return HRTIMER_NORESTART; +} + +static void bfq_shutdown_timer_wq(struct bfq_data *bfqd) +{ -+ hrtimer_cancel(&bfqd->idle_slice_timer); ++ del_timer_sync(&bfqd->idle_slice_timer); + cancel_work_sync(&bfqd->unplug_work); +} + -+#ifdef CONFIG_BFQ_GROUP_IOSCHED +static void __bfq_put_async_bfqq(struct bfq_data *bfqd, + struct bfq_queue **bfqq_ptr) +{ @@ -6820,9 +4560,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + + bfq_log(bfqd, "put_async_bfqq: %p", bfqq); + if (bfqq) { -+ bfq_bfqq_move(bfqd, bfqq, root_group); ++ bfq_bfqq_move(bfqd, bfqq, &bfqq->entity, root_group); + bfq_log_bfqq(bfqd, bfqq, "put_async_bfqq: putting %p, %d", -+ bfqq, bfqq->ref); ++ bfqq, atomic_read(&bfqq->ref)); + bfq_put_queue(bfqq); + *bfqq_ptr = NULL; + } @@ -6844,7 +4584,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + + __bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq); +} -+#endif + +static void bfq_exit_queue(struct elevator_queue *e) +{ @@ -6864,7 +4603,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + + bfq_shutdown_timer_wq(bfqd); + -+ BUG_ON(hrtimer_active(&bfqd->idle_slice_timer)); ++ synchronize_rcu(); ++ ++ BUG_ON(timer_pending(&bfqd->idle_slice_timer)); + +#ifdef CONFIG_BFQ_GROUP_IOSCHED + blkcg_deactivate_policy(q, &blkcg_policy_bfq); @@ -6885,7 +4626,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + root_group->my_entity = NULL; + root_group->bfqd = bfqd; +#endif -+ root_group->rq_pos_tree = RB_ROOT; + for (i = 0; i < BFQ_IOPRIO_CLASSES; i++) + root_group->sched_data.service_tree[i] = BFQ_SERVICE_TREE_INIT; +} @@ -6912,14 +4652,11 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * will not attempt to free it. + */ + bfq_init_bfqq(bfqd, &bfqd->oom_bfqq, NULL, 1, 0); -+ bfqd->oom_bfqq.ref++; ++ atomic_inc(&bfqd->oom_bfqq.ref); + bfqd->oom_bfqq.new_ioprio = BFQ_DEFAULT_QUEUE_IOPRIO; + bfqd->oom_bfqq.new_ioprio_class = IOPRIO_CLASS_BE; + bfqd->oom_bfqq.entity.new_weight = + bfq_ioprio_to_weight(bfqd->oom_bfqq.new_ioprio); -+ -+ /* oom_bfqq does not participate to bursts */ -+ bfq_clear_bfqq_just_created(&bfqd->oom_bfqq); + /* + * Trigger weight initialization, according to ioprio, at the + * oom_bfqq's first activation. The oom_bfqq's ioprio and ioprio @@ -6938,10 +4675,13 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + goto out_free; + bfq_init_root_group(bfqd->root_group, bfqd); + bfq_init_entity(&bfqd->oom_bfqq.entity, bfqd->root_group); ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ bfqd->active_numerous_groups = 0; ++#endif + -+ hrtimer_init(&bfqd->idle_slice_timer, CLOCK_MONOTONIC, -+ HRTIMER_MODE_REL); ++ init_timer(&bfqd->idle_slice_timer); + bfqd->idle_slice_timer.function = bfq_idle_slice_timer; ++ bfqd->idle_slice_timer.data = (unsigned long)bfqd; + + bfqd->queue_weights_tree = RB_ROOT; + bfqd->group_weights_tree = RB_ROOT; @@ -6962,19 +4702,18 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + bfqd->bfq_back_penalty = bfq_back_penalty; + bfqd->bfq_slice_idle = bfq_slice_idle; + bfqd->bfq_class_idle_last_service = 0; -+ bfqd->bfq_timeout = bfq_timeout; ++ bfqd->bfq_max_budget_async_rq = bfq_max_budget_async_rq; ++ bfqd->bfq_timeout[BLK_RW_ASYNC] = bfq_timeout_async; ++ bfqd->bfq_timeout[BLK_RW_SYNC] = bfq_timeout_sync; + + bfqd->bfq_requests_within_timer = 120; + -+ bfqd->bfq_large_burst_thresh = 8; -+ bfqd->bfq_burst_interval = msecs_to_jiffies(180); ++ bfqd->bfq_large_burst_thresh = 11; ++ bfqd->bfq_burst_interval = msecs_to_jiffies(500); + + bfqd->low_latency = true; + -+ /* -+ * Trade-off between responsiveness and fairness. -+ */ -+ bfqd->bfq_wr_coeff = 30; ++ bfqd->bfq_wr_coeff = 20; + bfqd->bfq_wr_rt_max_time = msecs_to_jiffies(300); + bfqd->bfq_wr_max_time = 0; + bfqd->bfq_wr_min_idle_time = msecs_to_jiffies(2000); @@ -6986,15 +4725,16 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + * video. + */ + bfqd->wr_busy_queues = 0; ++ bfqd->busy_in_flight_queues = 0; ++ bfqd->const_seeky_busy_in_flight_queues = 0; + + /* -+ * Begin by assuming, optimistically, that the device is a -+ * high-speed one, and that its peak rate is equal to 2/3 of -+ * the highest reference rate. ++ * Begin by assuming, optimistically, that the device peak rate is ++ * equal to the highest reference rate. + */ + bfqd->RT_prod = R_fast[blk_queue_nonrot(bfqd->queue)] * + T_fast[blk_queue_nonrot(bfqd->queue)]; -+ bfqd->peak_rate = R_fast[blk_queue_nonrot(bfqd->queue)] * 2 / 3; ++ bfqd->peak_rate = R_fast[blk_queue_nonrot(bfqd->queue)]; + bfqd->device_speed = BFQ_BFQD_FAST; + + return 0; @@ -7020,7 +4760,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + +static ssize_t bfq_var_show(unsigned int var, char *page) +{ -+ return sprintf(page, "%u\n", var); ++ return sprintf(page, "%d\n", var); +} + +static ssize_t bfq_var_store(unsigned long *var, const char *page, @@ -7091,21 +4831,21 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +static ssize_t __FUNC(struct elevator_queue *e, char *page) \ +{ \ + struct bfq_data *bfqd = e->elevator_data; \ -+ u64 __data = __VAR; \ -+ if (__CONV == 1) \ ++ unsigned int __data = __VAR; \ ++ if (__CONV) \ + __data = jiffies_to_msecs(__data); \ -+ else if (__CONV == 2) \ -+ __data = div_u64(__data, NSEC_PER_MSEC); \ + return bfq_var_show(__data, (page)); \ +} -+SHOW_FUNCTION(bfq_fifo_expire_sync_show, bfqd->bfq_fifo_expire[1], 2); -+SHOW_FUNCTION(bfq_fifo_expire_async_show, bfqd->bfq_fifo_expire[0], 2); ++SHOW_FUNCTION(bfq_fifo_expire_sync_show, bfqd->bfq_fifo_expire[1], 1); ++SHOW_FUNCTION(bfq_fifo_expire_async_show, bfqd->bfq_fifo_expire[0], 1); +SHOW_FUNCTION(bfq_back_seek_max_show, bfqd->bfq_back_max, 0); +SHOW_FUNCTION(bfq_back_seek_penalty_show, bfqd->bfq_back_penalty, 0); -+SHOW_FUNCTION(bfq_slice_idle_show, bfqd->bfq_slice_idle, 2); ++SHOW_FUNCTION(bfq_slice_idle_show, bfqd->bfq_slice_idle, 1); +SHOW_FUNCTION(bfq_max_budget_show, bfqd->bfq_user_max_budget, 0); -+SHOW_FUNCTION(bfq_timeout_sync_show, bfqd->bfq_timeout, 1); -+SHOW_FUNCTION(bfq_strict_guarantees_show, bfqd->strict_guarantees, 0); ++SHOW_FUNCTION(bfq_max_budget_async_rq_show, ++ bfqd->bfq_max_budget_async_rq, 0); ++SHOW_FUNCTION(bfq_timeout_sync_show, bfqd->bfq_timeout[BLK_RW_SYNC], 1); ++SHOW_FUNCTION(bfq_timeout_async_show, bfqd->bfq_timeout[BLK_RW_ASYNC], 1); +SHOW_FUNCTION(bfq_low_latency_show, bfqd->low_latency, 0); +SHOW_FUNCTION(bfq_wr_coeff_show, bfqd->bfq_wr_coeff, 0); +SHOW_FUNCTION(bfq_wr_rt_max_time_show, bfqd->bfq_wr_rt_max_time, 1); @@ -7115,17 +4855,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +SHOW_FUNCTION(bfq_wr_max_softrt_rate_show, bfqd->bfq_wr_max_softrt_rate, 0); +#undef SHOW_FUNCTION + -+#define USEC_SHOW_FUNCTION(__FUNC, __VAR) \ -+static ssize_t __FUNC(struct elevator_queue *e, char *page) \ -+{ \ -+ struct bfq_data *bfqd = e->elevator_data; \ -+ u64 __data = __VAR; \ -+ __data = div_u64(__data, NSEC_PER_USEC); \ -+ return bfq_var_show(__data, (page)); \ -+} -+USEC_SHOW_FUNCTION(bfq_slice_idle_us_show, bfqd->bfq_slice_idle); -+#undef USEC_SHOW_FUNCTION -+ +#define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV) \ +static ssize_t \ +__FUNC(struct elevator_queue *e, const char *page, size_t count) \ @@ -7137,22 +4866,24 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + __data = (MIN); \ + else if (__data > (MAX)) \ + __data = (MAX); \ -+ if (__CONV == 1) \ ++ if (__CONV) \ + *(__PTR) = msecs_to_jiffies(__data); \ -+ else if (__CONV == 2) \ -+ *(__PTR) = (u64)__data * NSEC_PER_MSEC; \ + else \ + *(__PTR) = __data; \ + return ret; \ +} +STORE_FUNCTION(bfq_fifo_expire_sync_store, &bfqd->bfq_fifo_expire[1], 1, -+ INT_MAX, 2); ++ INT_MAX, 1); +STORE_FUNCTION(bfq_fifo_expire_async_store, &bfqd->bfq_fifo_expire[0], 1, -+ INT_MAX, 2); ++ INT_MAX, 1); +STORE_FUNCTION(bfq_back_seek_max_store, &bfqd->bfq_back_max, 0, INT_MAX, 0); +STORE_FUNCTION(bfq_back_seek_penalty_store, &bfqd->bfq_back_penalty, 1, + INT_MAX, 0); -+STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2); ++STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 1); ++STORE_FUNCTION(bfq_max_budget_async_rq_store, &bfqd->bfq_max_budget_async_rq, ++ 1, INT_MAX, 0); ++STORE_FUNCTION(bfq_timeout_async_store, &bfqd->bfq_timeout[BLK_RW_ASYNC], 0, ++ INT_MAX, 1); +STORE_FUNCTION(bfq_wr_coeff_store, &bfqd->bfq_wr_coeff, 1, INT_MAX, 0); +STORE_FUNCTION(bfq_wr_max_time_store, &bfqd->bfq_wr_max_time, 0, INT_MAX, 1); +STORE_FUNCTION(bfq_wr_rt_max_time_store, &bfqd->bfq_wr_rt_max_time, 0, INT_MAX, @@ -7165,23 +4896,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + INT_MAX, 0); +#undef STORE_FUNCTION + -+#define USEC_STORE_FUNCTION(__FUNC, __PTR, MIN, MAX) \ -+static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)\ -+{ \ -+ struct bfq_data *bfqd = e->elevator_data; \ -+ unsigned long __data; \ -+ int ret = bfq_var_store(&__data, (page), count); \ -+ if (__data < (MIN)) \ -+ __data = (MIN); \ -+ else if (__data > (MAX)) \ -+ __data = (MAX); \ -+ *(__PTR) = (u64)__data * NSEC_PER_USEC; \ -+ return ret; \ -+} -+USEC_STORE_FUNCTION(bfq_slice_idle_us_store, &bfqd->bfq_slice_idle, 0, -+ UINT_MAX); -+#undef USEC_STORE_FUNCTION -+ +/* do nothing for the moment */ +static ssize_t bfq_weights_store(struct elevator_queue *e, + const char *page, size_t count) @@ -7189,6 +4903,16 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + return count; +} + ++static unsigned long bfq_estimated_max_budget(struct bfq_data *bfqd) ++{ ++ u64 timeout = jiffies_to_msecs(bfqd->bfq_timeout[BLK_RW_SYNC]); ++ ++ if (bfqd->peak_rate_samples >= BFQ_PEAK_RATE_SAMPLES) ++ return bfq_calc_max_budget(bfqd->peak_rate, timeout); ++ else ++ return bfq_default_max_budget; ++} ++ +static ssize_t bfq_max_budget_store(struct elevator_queue *e, + const char *page, size_t count) +{ @@ -7197,7 +4921,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + int ret = bfq_var_store(&__data, (page), count); + + if (__data == 0) -+ bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); ++ bfqd->bfq_max_budget = bfq_estimated_max_budget(bfqd); + else { + if (__data > INT_MAX) + __data = INT_MAX; @@ -7209,10 +4933,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + return ret; +} + -+/* -+ * Leaving this name to preserve name compatibility with cfq -+ * parameters, but this timeout is used for both sync and async. -+ */ +static ssize_t bfq_timeout_sync_store(struct elevator_queue *e, + const char *page, size_t count) +{ @@ -7225,27 +4945,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + else if (__data > INT_MAX) + __data = INT_MAX; + -+ bfqd->bfq_timeout = msecs_to_jiffies(__data); ++ bfqd->bfq_timeout[BLK_RW_SYNC] = msecs_to_jiffies(__data); + if (bfqd->bfq_user_max_budget == 0) -+ bfqd->bfq_max_budget = bfq_calc_max_budget(bfqd); -+ -+ return ret; -+} -+ -+static ssize_t bfq_strict_guarantees_store(struct elevator_queue *e, -+ const char *page, size_t count) -+{ -+ struct bfq_data *bfqd = e->elevator_data; -+ unsigned long uninitialized_var(__data); -+ int ret = bfq_var_store(&__data, (page), count); -+ -+ if (__data > 1) -+ __data = 1; -+ if (!bfqd->strict_guarantees && __data == 1 -+ && bfqd->bfq_slice_idle < 8 * NSEC_PER_MSEC) -+ bfqd->bfq_slice_idle = 8 * NSEC_PER_MSEC; -+ -+ bfqd->strict_guarantees = __data; ++ bfqd->bfq_max_budget = bfq_estimated_max_budget(bfqd); + + return ret; +} @@ -7275,10 +4977,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + BFQ_ATTR(back_seek_max), + BFQ_ATTR(back_seek_penalty), + BFQ_ATTR(slice_idle), -+ BFQ_ATTR(slice_idle_us), + BFQ_ATTR(max_budget), ++ BFQ_ATTR(max_budget_async_rq), + BFQ_ATTR(timeout_sync), -+ BFQ_ATTR(strict_guarantees), ++ BFQ_ATTR(timeout_async), + BFQ_ATTR(low_latency), + BFQ_ATTR(wr_coeff), + BFQ_ATTR(wr_max_time), @@ -7298,8 +5000,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ +#ifdef CONFIG_BFQ_GROUP_IOSCHED + .elevator_bio_merged_fn = bfq_bio_merged, +#endif -+ .elevator_allow_bio_merge_fn = bfq_allow_bio_merge, -+ .elevator_allow_rq_merge_fn = bfq_allow_rq_merge, ++ .elevator_allow_merge_fn = bfq_allow_merge, + .elevator_dispatch_fn = bfq_dispatch_requests, + .elevator_add_req_fn = bfq_insert_request, + .elevator_activate_req_fn = bfq_activate_request, @@ -7322,28 +5023,18 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + .elevator_owner = THIS_MODULE, +}; + -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+static struct blkcg_policy blkcg_policy_bfq = { -+ .dfl_cftypes = bfq_blkg_files, -+ .legacy_cftypes = bfq_blkcg_legacy_files, -+ -+ .cpd_alloc_fn = bfq_cpd_alloc, -+ .cpd_init_fn = bfq_cpd_init, -+ .cpd_bind_fn = bfq_cpd_init, -+ .cpd_free_fn = bfq_cpd_free, -+ -+ .pd_alloc_fn = bfq_pd_alloc, -+ .pd_init_fn = bfq_pd_init, -+ .pd_offline_fn = bfq_pd_offline, -+ .pd_free_fn = bfq_pd_free, -+ .pd_reset_stats_fn = bfq_pd_reset_stats, -+}; -+#endif -+ +static int __init bfq_init(void) +{ + int ret; -+ char msg[50] = "BFQ I/O-scheduler: v8r4"; ++ ++ /* ++ * Can be 0 on HZ < 1000 setups. ++ */ ++ if (bfq_slice_idle == 0) ++ bfq_slice_idle = 1; ++ ++ if (bfq_timeout_async == 0) ++ bfq_timeout_async = 1; + +#ifdef CONFIG_BFQ_GROUP_IOSCHED + ret = blkcg_policy_register(&blkcg_policy_bfq); @@ -7356,46 +5047,27 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + goto err_pol_unreg; + + /* -+ * Times to load large popular applications for the typical -+ * systems installed on the reference devices (see the -+ * comments before the definitions of the next two -+ * arrays). Actually, we use slightly slower values, as the -+ * estimated peak rate tends to be smaller than the actual -+ * peak rate. The reason for this last fact is that estimates -+ * are computed over much shorter time intervals than the long -+ * intervals typically used for benchmarking. Why? First, to -+ * adapt more quickly to variations. Second, because an I/O -+ * scheduler cannot rely on a peak-rate-evaluation workload to -+ * be run for a long time. ++ * Times to load large popular applications for the typical systems ++ * installed on the reference devices (see the comments before the ++ * definitions of the two arrays). + */ -+ T_slow[0] = msecs_to_jiffies(3500); /* actually 4 sec */ -+ T_slow[1] = msecs_to_jiffies(1000); /* actually 1.5 sec */ -+ T_fast[0] = msecs_to_jiffies(7000); /* actually 8 sec */ -+ T_fast[1] = msecs_to_jiffies(2500); /* actually 3 sec */ ++ T_slow[0] = msecs_to_jiffies(2600); ++ T_slow[1] = msecs_to_jiffies(1000); ++ T_fast[0] = msecs_to_jiffies(5500); ++ T_fast[1] = msecs_to_jiffies(2000); + + /* -+ * Thresholds that determine the switch between speed classes -+ * (see the comments before the definition of the array -+ * device_speed_thresh). These thresholds are biased towards -+ * transitions to the fast class. This is safer than the -+ * opposite bias. In fact, a wrong transition to the slow -+ * class results in short weight-raising periods, because the -+ * speed of the device then tends to be higher that the -+ * reference peak rate. On the opposite end, a wrong -+ * transition to the fast class tends to increase -+ * weight-raising periods, because of the opposite reason. ++ * Thresholds that determine the switch between speed classes (see ++ * the comments before the definition of the array). + */ -+ device_speed_thresh[0] = (4 * R_slow[0]) / 3; -+ device_speed_thresh[1] = (4 * R_slow[1]) / 3; ++ device_speed_thresh[0] = (R_fast[0] + R_slow[0]) / 2; ++ device_speed_thresh[1] = (R_fast[1] + R_slow[1]) / 2; + + ret = elv_register(&iosched_bfq); + if (ret) + goto err_pol_unreg; + -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ strcat(msg, " (with cgroups support)"); -+#endif -+ pr_info("%s", msg); ++ pr_info("BFQ I/O-scheduler: v7r11"); + + return 0; + @@ -7420,10 +5092,12 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-iosched.c linux-4.8-bfq/block/ + +MODULE_AUTHOR("Arianna Avanzini, Fabio Checconi, Paolo Valente"); +MODULE_LICENSE("GPL"); -diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bfq-sched.c ---- linux-4.8/block/bfq-sched.c 1970-01-01 01:00:00.000000000 +0100 -+++ linux-4.8-bfq/block/bfq-sched.c 2016-10-18 12:57:57.691164881 +0200 -@@ -0,0 +1,1501 @@ +diff --git a/block/bfq-sched.c b/block/bfq-sched.c +new file mode 100644 +index 0000000..a5ed694 +--- /dev/null ++++ b/block/bfq-sched.c +@@ -0,0 +1,1199 @@ +/* + * BFQ: Hierarchical B-WF2Q+ scheduler. + * @@ -7433,13 +5107,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + * Copyright (C) 2008 Fabio Checconi + * Paolo Valente + * -+ * Copyright (C) 2015 Paolo Valente -+ * -+ * Copyright (C) 2016 Paolo Valente ++ * Copyright (C) 2010 Paolo Valente + */ + -+static struct bfq_group *bfqq_group(struct bfq_queue *bfqq); -+ +#ifdef CONFIG_BFQ_GROUP_IOSCHED +#define for_each_entity(entity) \ + for (; entity ; entity = entity->parent) @@ -7452,6 +5122,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + int extract, + struct bfq_data *bfqd); + ++static struct bfq_group *bfqq_group(struct bfq_queue *bfqq); ++ +static void bfq_update_budget(struct bfq_entity *next_in_service) +{ + struct bfq_entity *bfqg_entity; @@ -7476,7 +5148,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +static int bfq_update_next_in_service(struct bfq_sched_data *sd) +{ + struct bfq_entity *next_in_service; -+ struct bfq_queue *bfqq; + + if (sd->in_service_entity) + /* will update/requeue at the end of service */ @@ -7494,29 +5165,14 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + + if (next_in_service) + bfq_update_budget(next_in_service); -+ else -+ goto exit; + -+ bfqq = bfq_entity_to_bfqq(next_in_service); -+ if (bfqq) -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "update_next_in_service: chosen this queue"); -+ else { -+ struct bfq_group *bfqg = -+ container_of(next_in_service, -+ struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "update_next_in_service: chosen this entity"); -+ } -+exit: + return 1; +} + +static void bfq_check_next_in_service(struct bfq_sched_data *sd, + struct bfq_entity *entity) +{ -+ WARN_ON(sd->next_in_service != entity); ++ BUG_ON(sd->next_in_service != entity); +} +#else +#define for_each_entity(entity) \ @@ -7595,36 +5251,20 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +static void bfq_calc_finish(struct bfq_entity *entity, unsigned long service) +{ + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); -+ unsigned long long start, finish, delta; + + BUG_ON(entity->weight == 0); + + entity->finish = entity->start + + bfq_delta(service, entity->weight); + -+ start = ((entity->start>>10)*1000)>>12; -+ finish = ((entity->finish>>10)*1000)>>12; -+ delta = ((bfq_delta(service, entity->weight)>>10)*1000)>>12; -+ + if (bfqq) { + bfq_log_bfqq(bfqq->bfqd, bfqq, + "calc_finish: serv %lu, w %d", + service, entity->weight); + bfq_log_bfqq(bfqq->bfqd, bfqq, + "calc_finish: start %llu, finish %llu, delta %llu", -+ start, finish, delta); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ } else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "calc_finish group: serv %lu, w %d", -+ service, entity->weight); -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "calc_finish group: start %llu, finish %llu, delta %llu", -+ start, finish, delta); -+#endif ++ entity->start, entity->finish, ++ bfq_delta(service, entity->weight)); + } +} + @@ -7753,26 +5393,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +static void bfq_update_active_node(struct rb_node *node) +{ + struct bfq_entity *entity = rb_entry(node, struct bfq_entity, rb_node); -+ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); + + entity->min_start = entity->start; + bfq_update_min(entity, node->rb_right); + bfq_update_min(entity, node->rb_left); -+ -+ if (bfqq) { -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "update_active_node: new min_start %llu", -+ ((entity->min_start>>10)*1000)>>12); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ } else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "update_active_node: new min_start %llu", -+ ((entity->min_start>>10)*1000)>>12); -+#endif -+ } +} + +/** @@ -7862,6 +5486,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + BUG_ON(!bfqg); + BUG_ON(!bfqd); + bfqg->active_entities++; ++ if (bfqg->active_entities == 2) ++ bfqd->active_numerous_groups++; + } +#endif +} @@ -7873,7 +5499,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +static unsigned short bfq_ioprio_to_weight(int ioprio) +{ + BUG_ON(ioprio < 0 || ioprio >= IOPRIO_BE_NR); -+ return (IOPRIO_BE_NR - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF; ++ return IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF - ioprio; +} + +/** @@ -7896,9 +5522,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); + + if (bfqq) { -+ bfqq->ref++; ++ atomic_inc(&bfqq->ref); + bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d", -+ bfqq, bfqq->ref); ++ bfqq, atomic_read(&bfqq->ref)); + } +} + @@ -7973,6 +5599,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + BUG_ON(!bfqd); + BUG_ON(!bfqg->active_entities); + bfqg->active_entities--; ++ if (bfqg->active_entities == 1) { ++ BUG_ON(!bfqd->active_numerous_groups); ++ bfqd->active_numerous_groups--; ++ } + } +#endif +} @@ -8022,7 +5652,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + if (bfqq) { + sd = entity->sched_data; + bfq_log_bfqq(bfqq->bfqd, bfqq, "forget_entity: %p %d", -+ bfqq, bfqq->ref); ++ bfqq, atomic_read(&bfqq->ref)); + bfq_put_queue(bfqq); + } +} @@ -8072,7 +5702,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + + if (entity->prio_changed) { + struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); -+ unsigned int prev_weight, new_weight; ++ unsigned short prev_weight, new_weight; + struct bfq_data *bfqd = NULL; + struct rb_root *root; +#ifdef CONFIG_BFQ_GROUP_IOSCHED @@ -8100,10 +5730,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + entity->new_weight > BFQ_MAX_WEIGHT) { + pr_crit("update_weight_prio: new_weight %d\n", + entity->new_weight); -+ if (entity->new_weight < BFQ_MIN_WEIGHT) -+ entity->new_weight = BFQ_MIN_WEIGHT; -+ else -+ entity->new_weight = BFQ_MAX_WEIGHT; ++ BUG(); + } + entity->orig_weight = entity->new_weight; + if (bfqq) @@ -8134,13 +5761,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + * associated with its new weight. + */ + if (prev_weight != new_weight) { -+ if (bfqq) -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "weight changed %d %d(%d %d)", -+ prev_weight, new_weight, -+ entity->orig_weight, -+ bfqq->wr_coeff); -+ + root = bfqq ? &bfqd->queue_weights_tree : + &bfqd->group_weights_tree; + bfq_weights_tree_remove(bfqd, entity, root); @@ -8187,7 +5807,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + st = bfq_entity_service_tree(entity); + + entity->service += served; -+ ++ BUG_ON(entity->service > entity->budget); + BUG_ON(st->wsum == 0); + + st->vtime += bfq_delta(served, st->wsum); @@ -8196,69 +5816,31 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_set_start_empty_time(bfqq_group(bfqq)); +#endif -+ st = bfq_entity_service_tree(&bfqq->entity); -+ bfq_log_bfqq(bfqq->bfqd, bfqq, "bfqq_served %d secs, vtime %llu on %p", -+ served, ((st->vtime>>10)*1000)>>12, st); ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "bfqq_served %d secs", served); +} + +/** -+ * bfq_bfqq_charge_time - charge an amount of service equivalent to the length -+ * of the time interval during which bfqq has been in -+ * service. -+ * @bfqd: the device ++ * bfq_bfqq_charge_full_budget - set the service to the entity budget. + * @bfqq: the queue that needs a service update. -+ * @time_ms: the amount of time during which the queue has received service + * -+ * If a queue does not consume its budget fast enough, then providing -+ * the queue with service fairness may impair throughput, more or less -+ * severely. For this reason, queues that consume their budget slowly -+ * are provided with time fairness instead of service fairness. This -+ * goal is achieved through the BFQ scheduling engine, even if such an -+ * engine works in the service, and not in the time domain. The trick -+ * is charging these queues with an inflated amount of service, equal -+ * to the amount of service that they would have received during their -+ * service slot if they had been fast, i.e., if their requests had -+ * been dispatched at a rate equal to the estimated peak rate. -+ * -+ * It is worth noting that time fairness can cause important -+ * distortions in terms of bandwidth distribution, on devices with -+ * internal queueing. The reason is that I/O requests dispatched -+ * during the service slot of a queue may be served after that service -+ * slot is finished, and may have a total processing time loosely -+ * correlated with the duration of the service slot. This is -+ * especially true for short service slots. ++ * When it's not possible to be fair in the service domain, because ++ * a queue is not consuming its budget fast enough (the meaning of ++ * fast depends on the timeout parameter), we charge it a full ++ * budget. In this way we should obtain a sort of time-domain ++ * fairness among all the seeky/slow queues. + */ -+static void bfq_bfqq_charge_time(struct bfq_data *bfqd, struct bfq_queue *bfqq, -+ unsigned long time_ms) ++static void bfq_bfqq_charge_full_budget(struct bfq_queue *bfqq) +{ + struct bfq_entity *entity = &bfqq->entity; -+ int tot_serv_to_charge = entity->service; -+ unsigned int timeout_ms = jiffies_to_msecs(bfq_timeout); + -+ if (time_ms > 0 && time_ms < timeout_ms) -+ tot_serv_to_charge = -+ (bfqd->bfq_max_budget * time_ms) / timeout_ms; ++ bfq_log_bfqq(bfqq->bfqd, bfqq, "charge_full_budget"); + -+ if (tot_serv_to_charge < entity->service) -+ tot_serv_to_charge = entity->service; -+ -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "charge_time: %lu/%u ms, %d/%d/%d sectors", -+ time_ms, timeout_ms, entity->service, -+ tot_serv_to_charge, entity->budget); -+ -+ /* Increase budget to avoid inconsistencies */ -+ if (tot_serv_to_charge > entity->budget) -+ entity->budget = tot_serv_to_charge; -+ -+ bfq_bfqq_served(bfqq, -+ max_t(int, 0, tot_serv_to_charge - entity->service)); ++ bfq_bfqq_served(bfqq, entity->budget - entity->service); +} + +/** + * __bfq_activate_entity - activate an entity. + * @entity: the entity being activated. -+ * @non_blocking_wait_rq: true if this entity was waiting for a request + * + * Called whenever an entity is activated, i.e., it is not active and one + * of its children receives a new request, or has to be reactivated due to @@ -8266,16 +5848,11 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + * service received if @entity is active) of the queue to calculate its + * timestamps. + */ -+static void __bfq_activate_entity(struct bfq_entity *entity, -+ bool non_blocking_wait_rq) ++static void __bfq_activate_entity(struct bfq_entity *entity) +{ + struct bfq_sched_data *sd = entity->sched_data; + struct bfq_service_tree *st = bfq_entity_service_tree(entity); -+ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); -+ bool backshifted = false; + -+ BUG_ON(!sd); -+ BUG_ON(!st); + if (entity == sd->in_service_entity) { + BUG_ON(entity->tree); + /* @@ -8293,133 +5870,45 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + * old start time. + */ + bfq_active_extract(st, entity); ++ } else if (entity->tree == &st->idle) { ++ /* ++ * Must be on the idle tree, bfq_idle_extract() will ++ * check for that. ++ */ ++ bfq_idle_extract(st, entity); ++ entity->start = bfq_gt(st->vtime, entity->finish) ? ++ st->vtime : entity->finish; + } else { -+ unsigned long long min_vstart; ++ /* ++ * The finish time of the entity may be invalid, and ++ * it is in the past for sure, otherwise the queue ++ * would have been on the idle tree. ++ */ ++ entity->start = st->vtime; ++ st->wsum += entity->weight; ++ bfq_get_entity(entity); + -+ /* See comments on bfq_fqq_update_budg_for_activation */ -+ if (non_blocking_wait_rq && bfq_gt(st->vtime, entity->finish)) { -+ backshifted = true; -+ min_vstart = entity->finish; -+ } else -+ min_vstart = st->vtime; -+ -+ if (entity->tree == &st->idle) { -+ /* -+ * Must be on the idle tree, bfq_idle_extract() will -+ * check for that. -+ */ -+ bfq_idle_extract(st, entity); -+ entity->start = bfq_gt(min_vstart, entity->finish) ? -+ min_vstart : entity->finish; -+ } else { -+ /* -+ * The finish time of the entity may be invalid, and -+ * it is in the past for sure, otherwise the queue -+ * would have been on the idle tree. -+ */ -+ entity->start = min_vstart; -+ st->wsum += entity->weight; -+ bfq_get_entity(entity); -+ -+ BUG_ON(entity->on_st); -+ entity->on_st = 1; -+ } ++ BUG_ON(entity->on_st); ++ entity->on_st = 1; + } + + st = __bfq_entity_update_weight_prio(st, entity); + bfq_calc_finish(entity, entity->budget); -+ -+ /* -+ * If some queues enjoy backshifting for a while, then their -+ * (virtual) finish timestamps may happen to become lower and -+ * lower than the system virtual time. In particular, if -+ * these queues often happen to be idle for short time -+ * periods, and during such time periods other queues with -+ * higher timestamps happen to be busy, then the backshifted -+ * timestamps of the former queues can become much lower than -+ * the system virtual time. In fact, to serve the queues with -+ * higher timestamps while the ones with lower timestamps are -+ * idle, the system virtual time may be pushed-up to much -+ * higher values than the finish timestamps of the idle -+ * queues. As a consequence, the finish timestamps of all new -+ * or newly activated queues may end up being much larger than -+ * those of lucky queues with backshifted timestamps. The -+ * latter queues may then monopolize the device for a lot of -+ * time. This would simply break service guarantees. -+ * -+ * To reduce this problem, push up a little bit the -+ * backshifted timestamps of the queue associated with this -+ * entity (only a queue can happen to have the backshifted -+ * flag set): just enough to let the finish timestamp of the -+ * queue be equal to the current value of the system virtual -+ * time. This may introduce a little unfairness among queues -+ * with backshifted timestamps, but it does not break -+ * worst-case fairness guarantees. -+ * -+ * As a special case, if bfqq is weight-raised, push up -+ * timestamps much less, to keep very low the probability that -+ * this push up causes the backshifted finish timestamps of -+ * weight-raised queues to become higher than the backshifted -+ * finish timestamps of non weight-raised queues. -+ */ -+ if (backshifted && bfq_gt(st->vtime, entity->finish)) { -+ unsigned long delta = st->vtime - entity->finish; -+ -+ if (bfqq) -+ delta /= bfqq->wr_coeff; -+ -+ entity->start += delta; -+ entity->finish += delta; -+ -+ if (bfqq) { -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "__activate_entity: new queue finish %llu", -+ ((entity->finish>>10)*1000)>>12); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ } else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "__activate_entity: new group finish %llu", -+ ((entity->finish>>10)*1000)>>12); -+#endif -+ } -+ } -+ + bfq_active_insert(st, entity); -+ -+ if (bfqq) { -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "__activate_entity: queue %seligible in st %p", -+ entity->start <= st->vtime ? "" : "non ", st); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ } else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "__activate_entity: group %seligible in st %p", -+ entity->start <= st->vtime ? "" : "non ", st); -+#endif -+ } +} + +/** + * bfq_activate_entity - activate an entity and its ancestors if necessary. + * @entity: the entity to activate. -+ * @non_blocking_wait_rq: true if this entity was waiting for a request + * + * Activate @entity and all the entities on the path from it to the root. + */ -+static void bfq_activate_entity(struct bfq_entity *entity, -+ bool non_blocking_wait_rq) ++static void bfq_activate_entity(struct bfq_entity *entity) +{ + struct bfq_sched_data *sd; + + for_each_entity(entity) { -+ BUG_ON(!entity); -+ __bfq_activate_entity(entity, non_blocking_wait_rq); ++ __bfq_activate_entity(entity); + + sd = entity->sched_data; + if (!bfq_update_next_in_service(sd)) @@ -8500,24 +5989,23 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + + if (!__bfq_deactivate_entity(entity, requeue)) + /* -+ * next_in_service has not been changed, so -+ * no upwards update is needed ++ * The parent entity is still backlogged, and ++ * we don't need to update it as it is still ++ * in service. + */ + break; + + if (sd->next_in_service) + /* -+ * The parent entity is still backlogged, -+ * because next_in_service is not NULL, and -+ * next_in_service has been updated (see -+ * comment on the body of the above if): -+ * upwards update of the schedule is needed. ++ * The parent entity is still backlogged and ++ * the budgets on the path towards the root ++ * need to be updated. + */ + goto update; + + /* -+ * If we get here, then the parent is no more backlogged and -+ * we want to propagate the deactivation upwards. ++ * If we reach there the parent is no more backlogged and ++ * we want to propagate the dequeue upwards. + */ + requeue = 1; + } @@ -8527,23 +6015,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +update: + entity = parent; + for_each_entity(entity) { -+ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); -+ __bfq_activate_entity(entity, false); ++ __bfq_activate_entity(entity); + + sd = entity->sched_data; -+ if (bfqq) -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "invoking udpdate_next for this queue"); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ else { -+ struct bfq_group *bfqg = -+ container_of(entity, -+ struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "invoking udpdate_next for this entity"); -+ } -+#endif + if (!bfq_update_next_in_service(sd)) + break; + } @@ -8569,23 +6043,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + + entry = rb_entry(node, struct bfq_entity, rb_node); + if (bfq_gt(entry->min_start, st->vtime)) { -+ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entry); + st->vtime = entry->min_start; -+ -+ if (bfqq) -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "update_vtime: new vtime %llu %p", -+ ((st->vtime>>10)*1000)>>12, st); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ else { -+ struct bfq_group *bfqg = -+ container_of(entry, struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "update_vtime: new vtime %llu %p", -+ ((st->vtime>>10)*1000)>>12, st); -+ } -+#endif + bfq_forget_idle(st); + } +} @@ -8638,11 +6096,10 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + * Update the virtual time in @st and return the first eligible entity + * it contains. + */ -+static struct bfq_entity * -+__bfq_lookup_next_entity(struct bfq_service_tree *st, bool force) ++static struct bfq_entity *__bfq_lookup_next_entity(struct bfq_service_tree *st, ++ bool force) +{ + struct bfq_entity *entity, *new_next_in_service = NULL; -+ struct bfq_queue *bfqq; + + if (RB_EMPTY_ROOT(&st->active)) + return NULL; @@ -8651,24 +6108,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + entity = bfq_first_active_entity(st); + BUG_ON(bfq_gt(entity->start, st->vtime)); + -+ bfqq = bfq_entity_to_bfqq(entity); -+ if (bfqq) -+ bfq_log_bfqq(bfqq->bfqd, bfqq, -+ "__lookup_next: start %llu vtime %llu st %p", -+ ((entity->start>>10)*1000)>>12, -+ ((st->vtime>>10)*1000)>>12, st); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg((struct bfq_data *)bfqg->bfqd, bfqg, -+ "__lookup_next: start %llu vtime %llu st %p", -+ ((entity->start>>10)*1000)>>12, -+ ((st->vtime>>10)*1000)>>12, st); -+ } -+#endif -+ + /* + * If the chosen entity does not match with the sched_data's + * next_in_service and we are forcedly serving the IDLE priority @@ -8704,36 +6143,11 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + + BUG_ON(sd->in_service_entity); + -+ /* -+ * Choose from idle class, if needed to guarantee a minimum -+ * bandwidth to this class. This should also mitigate -+ * priority-inversion problems in case a low priority task is -+ * holding file system resources. -+ */ + if (bfqd && -+ jiffies - bfqd->bfq_class_idle_last_service > -+ BFQ_CL_IDLE_TIMEOUT) { ++ jiffies - bfqd->bfq_class_idle_last_service > BFQ_CL_IDLE_TIMEOUT) { + entity = __bfq_lookup_next_entity(st + BFQ_IOPRIO_CLASSES - 1, + true); + if (entity) { -+ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); -+ -+ if (bfqq) -+ bfq_log_bfqq(bfqd, bfqq, -+ "idle chosen from st %p %d", -+ st + BFQ_IOPRIO_CLASSES - 1, -+ BFQ_IOPRIO_CLASSES - 1); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg(bfqd, bfqg, -+ "idle chosen from st %p %d", -+ st + BFQ_IOPRIO_CLASSES - 1, -+ BFQ_IOPRIO_CLASSES - 1); -+ } -+#endif + i = BFQ_IOPRIO_CLASSES - 1; + bfqd->bfq_class_idle_last_service = jiffies; + sd->next_in_service = entity; @@ -8742,25 +6156,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + for (; i < BFQ_IOPRIO_CLASSES; i++) { + entity = __bfq_lookup_next_entity(st + i, false); + if (entity) { -+ if (bfqd != NULL) { -+ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); -+ -+ if (bfqq) -+ bfq_log_bfqq(bfqd, bfqq, -+ "chosen from st %p %d", -+ st + i, i); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg(bfqd, bfqg, -+ "chosen from st %p %d", -+ st + i, i); -+ } -+#endif -+ } -+ + if (extract) { + bfq_check_next_in_service(sd, entity); + bfq_active_extract(st + i, entity); @@ -8774,13 +6169,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + return entity; +} + -+static bool next_queue_may_preempt(struct bfq_data *bfqd) -+{ -+ struct bfq_sched_data *sd = &bfqd->root_group->sched_data; -+ -+ return sd->next_in_service != sd->in_service_entity; -+} -+ +/* + * Get next queue for service. + */ @@ -8797,36 +6185,7 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + + sd = &bfqd->root_group->sched_data; + for (; sd ; sd = entity->my_sched_data) { -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ if (entity) { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg(bfqd, bfqg, -+ "get_next_queue: lookup in this group"); -+ } else -+ bfq_log_bfqg(bfqd, bfqd->root_group, -+ "get_next_queue: lookup in root group"); -+#endif -+ + entity = bfq_lookup_next_entity(sd, 1, bfqd); -+ -+ bfqq = bfq_entity_to_bfqq(entity); -+ if (bfqq) -+ bfq_log_bfqq(bfqd, bfqq, -+ "get_next_queue: this queue, finish %llu", -+ (((entity->finish>>10)*1000)>>10)>>2); -+#ifdef CONFIG_BFQ_GROUP_IOSCHED -+ else { -+ struct bfq_group *bfqg = -+ container_of(entity, struct bfq_group, entity); -+ -+ bfq_log_bfqg(bfqd, bfqg, -+ "get_next_queue: this entity, finish %llu", -+ (((entity->finish>>10)*1000)>>10)>>2); -+ } -+#endif -+ + BUG_ON(!entity); + entity->service = 0; + } @@ -8844,9 +6203,8 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + bfqd->in_service_bic = NULL; + } + -+ bfq_clear_bfqq_wait_request(bfqd->in_service_queue); -+ hrtimer_try_to_cancel(&bfqd->idle_slice_timer); + bfqd->in_service_queue = NULL; ++ del_timer(&bfqd->idle_slice_timer); +} + +static void bfq_deactivate_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq, @@ -8854,7 +6212,9 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +{ + struct bfq_entity *entity = &bfqq->entity; + -+ BUG_ON(bfqq == bfqd->in_service_queue); ++ if (bfqq == bfqd->in_service_queue) ++ __bfq_bfqd_reset_in_service(bfqd); ++ + bfq_deactivate_entity(entity, requeue); +} + @@ -8862,11 +6222,12 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +{ + struct bfq_entity *entity = &bfqq->entity; + -+ bfq_activate_entity(entity, bfq_bfqq_non_blocking_wait_rq(bfqq)); -+ bfq_clear_bfqq_non_blocking_wait_rq(bfqq); ++ bfq_activate_entity(entity); +} + ++#ifdef CONFIG_BFQ_GROUP_IOSCHED +static void bfqg_stats_update_dequeue(struct bfq_group *bfqg); ++#endif + +/* + * Called when the bfqq no longer has requests pending, remove it from @@ -8877,7 +6238,6 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf +{ + BUG_ON(!bfq_bfqq_busy(bfqq)); + BUG_ON(!RB_EMPTY_ROOT(&bfqq->sort_list)); -+ BUG_ON(bfqq == bfqd->in_service_queue); + + bfq_log_bfqq(bfqd, bfqq, "del from busy"); + @@ -8886,20 +6246,27 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + BUG_ON(bfqd->busy_queues == 0); + bfqd->busy_queues--; + -+ if (!bfqq->dispatched) ++ if (!bfqq->dispatched) { + bfq_weights_tree_remove(bfqd, &bfqq->entity, + &bfqd->queue_weights_tree); -+ ++ if (!blk_queue_nonrot(bfqd->queue)) { ++ BUG_ON(!bfqd->busy_in_flight_queues); ++ bfqd->busy_in_flight_queues--; ++ if (bfq_bfqq_constantly_seeky(bfqq)) { ++ BUG_ON(!bfqd-> ++ const_seeky_busy_in_flight_queues); ++ bfqd->const_seeky_busy_in_flight_queues--; ++ } ++ } ++ } + if (bfqq->wr_coeff > 1) + bfqd->wr_busy_queues--; + ++#ifdef CONFIG_BFQ_GROUP_IOSCHED + bfqg_stats_update_dequeue(bfqq_group(bfqq)); -+ -+ BUG_ON(bfqq->entity.budget < 0); ++#endif + + bfq_deactivate_bfqq(bfqd, bfqq, requeue); -+ -+ BUG_ON(bfqq->entity.budget < 0); +} + +/* @@ -8917,88 +6284,826 @@ diff -w -uNr '--exclude=.git' linux-4.8/block/bfq-sched.c linux-4.8-bfq/block/bf + bfq_mark_bfqq_busy(bfqq); + bfqd->busy_queues++; + -+ if (!bfqq->dispatched) ++ if (!bfqq->dispatched) { + if (bfqq->wr_coeff == 1) + bfq_weights_tree_add(bfqd, &bfqq->entity, + &bfqd->queue_weights_tree); -+ ++ if (!blk_queue_nonrot(bfqd->queue)) { ++ bfqd->busy_in_flight_queues++; ++ if (bfq_bfqq_constantly_seeky(bfqq)) ++ bfqd->const_seeky_busy_in_flight_queues++; ++ } ++ } + if (bfqq->wr_coeff > 1) + bfqd->wr_busy_queues++; +} -diff -w -uNr '--exclude=.git' linux-4.8/block/Kconfig.iosched linux-4.8-bfq/block/Kconfig.iosched ---- linux-4.8/block/Kconfig.iosched 2016-10-03 01:24:33.000000000 +0200 -+++ linux-4.8-bfq/block/Kconfig.iosched 2016-10-18 12:57:57.691164881 +0200 -@@ -39,6 +39,25 @@ - ---help--- - Enable group IO scheduling in CFQ. - -+config IOSCHED_BFQ -+ tristate "BFQ I/O scheduler" -+ default n -+ ---help--- -+ The BFQ I/O scheduler tries to distribute bandwidth among -+ all processes according to their weights. -+ It aims at distributing the bandwidth as desired, independently of -+ the disk parameters and with any workload. It also tries to -+ guarantee low latency to interactive and soft real-time -+ applications. If compiled built-in (saying Y here), BFQ can -+ be configured to support hierarchical scheduling. +diff --git a/block/bfq.h b/block/bfq.h +new file mode 100644 +index 0000000..2bf54ae +--- /dev/null ++++ b/block/bfq.h +@@ -0,0 +1,801 @@ ++/* ++ * BFQ-v7r11 for 4.5.0: data structures and common functions prototypes. ++ * ++ * Based on ideas and code from CFQ: ++ * Copyright (C) 2003 Jens Axboe ++ * ++ * Copyright (C) 2008 Fabio Checconi ++ * Paolo Valente ++ * ++ * Copyright (C) 2010 Paolo Valente ++ */ + -+config BFQ_GROUP_IOSCHED -+ bool "BFQ hierarchical scheduling support" -+ depends on IOSCHED_BFQ && BLK_CGROUP -+ default n -+ ---help--- -+ Enable hierarchical scheduling in BFQ, using the blkio controller. ++#ifndef _BFQ_H ++#define _BFQ_H + - choice - prompt "Default I/O scheduler" - default DEFAULT_CFQ -@@ -52,6 +71,16 @@ - config DEFAULT_CFQ - bool "CFQ" if IOSCHED_CFQ=y - -+ config DEFAULT_BFQ -+ bool "BFQ" if IOSCHED_BFQ=y -+ help -+ Selects BFQ as the default I/O scheduler which will be -+ used by default for all block devices. -+ The BFQ I/O scheduler aims at distributing the bandwidth -+ as desired, independently of the disk parameters and with -+ any workload. It also tries to guarantee low latency to -+ interactive and soft real-time applications. ++#include ++#include ++#include ++#include ++#include + - config DEFAULT_NOOP - bool "No-op" - -@@ -61,6 +90,7 @@ - string - default "deadline" if DEFAULT_DEADLINE - default "cfq" if DEFAULT_CFQ -+ default "bfq" if DEFAULT_BFQ - default "noop" if DEFAULT_NOOP - - endmenu -diff -w -uNr '--exclude=.git' linux-4.8/block/Makefile linux-4.8-bfq/block/Makefile ---- linux-4.8/block/Makefile 2016-10-03 01:24:33.000000000 +0200 -+++ linux-4.8-bfq/block/Makefile 2016-10-18 12:57:57.691164881 +0200 -@@ -18,6 +18,7 @@ - obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o - obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o - obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o -+obj-$(CONFIG_IOSCHED_BFQ) += bfq-iosched.o - - obj-$(CONFIG_BLOCK_COMPAT) += compat_ioctl.o - obj-$(CONFIG_BLK_CMDLINE_PARSER) += cmdline-parser.o -diff -w -uNr '--exclude=.git' linux-4.8/include/linux/blkdev.h linux-4.8-bfq/include/linux/blkdev.h ---- linux-4.8/include/linux/blkdev.h 2016-10-03 01:24:33.000000000 +0200 -+++ linux-4.8-bfq/include/linux/blkdev.h 2016-10-18 12:57:59.951179412 +0200 -@@ -45,7 +45,7 @@ - * Maximum number of blkcg policies allowed to be registered concurrently. - * Defined here to simplify include dependency. - */ --#define BLKCG_MAX_POLS 2 -+#define BLKCG_MAX_POLS 3 - - typedef void (rq_end_io_fn)(struct request *, int); - ++#define BFQ_IOPRIO_CLASSES 3 ++#define BFQ_CL_IDLE_TIMEOUT (HZ/5) ++ ++#define BFQ_MIN_WEIGHT 1 ++#define BFQ_MAX_WEIGHT 1000 ++#define BFQ_WEIGHT_CONVERSION_COEFF 10 ++ ++#define BFQ_DEFAULT_QUEUE_IOPRIO 4 ++ ++#define BFQ_DEFAULT_GRP_WEIGHT 10 ++#define BFQ_DEFAULT_GRP_IOPRIO 0 ++#define BFQ_DEFAULT_GRP_CLASS IOPRIO_CLASS_BE ++ ++struct bfq_entity; ++ ++/** ++ * struct bfq_service_tree - per ioprio_class service tree. ++ * @active: tree for active entities (i.e., those backlogged). ++ * @idle: tree for idle entities (i.e., those not backlogged, with V <= F_i). ++ * @first_idle: idle entity with minimum F_i. ++ * @last_idle: idle entity with maximum F_i. ++ * @vtime: scheduler virtual time. ++ * @wsum: scheduler weight sum; active and idle entities contribute to it. ++ * ++ * Each service tree represents a B-WF2Q+ scheduler on its own. Each ++ * ioprio_class has its own independent scheduler, and so its own ++ * bfq_service_tree. All the fields are protected by the queue lock ++ * of the containing bfqd. ++ */ ++struct bfq_service_tree { ++ struct rb_root active; ++ struct rb_root idle; ++ ++ struct bfq_entity *first_idle; ++ struct bfq_entity *last_idle; ++ ++ u64 vtime; ++ unsigned long wsum; ++}; ++ ++/** ++ * struct bfq_sched_data - multi-class scheduler. ++ * @in_service_entity: entity in service. ++ * @next_in_service: head-of-the-line entity in the scheduler. ++ * @service_tree: array of service trees, one per ioprio_class. ++ * ++ * bfq_sched_data is the basic scheduler queue. It supports three ++ * ioprio_classes, and can be used either as a toplevel queue or as ++ * an intermediate queue on a hierarchical setup. ++ * @next_in_service points to the active entity of the sched_data ++ * service trees that will be scheduled next. ++ * ++ * The supported ioprio_classes are the same as in CFQ, in descending ++ * priority order, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE. ++ * Requests from higher priority queues are served before all the ++ * requests from lower priority queues; among requests of the same ++ * queue requests are served according to B-WF2Q+. ++ * All the fields are protected by the queue lock of the containing bfqd. ++ */ ++struct bfq_sched_data { ++ struct bfq_entity *in_service_entity; ++ struct bfq_entity *next_in_service; ++ struct bfq_service_tree service_tree[BFQ_IOPRIO_CLASSES]; ++}; ++ ++/** ++ * struct bfq_weight_counter - counter of the number of all active entities ++ * with a given weight. ++ * @weight: weight of the entities that this counter refers to. ++ * @num_active: number of active entities with this weight. ++ * @weights_node: weights tree member (see bfq_data's @queue_weights_tree ++ * and @group_weights_tree). ++ */ ++struct bfq_weight_counter { ++ short int weight; ++ unsigned int num_active; ++ struct rb_node weights_node; ++}; ++ ++/** ++ * struct bfq_entity - schedulable entity. ++ * @rb_node: service_tree member. ++ * @weight_counter: pointer to the weight counter associated with this entity. ++ * @on_st: flag, true if the entity is on a tree (either the active or ++ * the idle one of its service_tree). ++ * @finish: B-WF2Q+ finish timestamp (aka F_i). ++ * @start: B-WF2Q+ start timestamp (aka S_i). ++ * @tree: tree the entity is enqueued into; %NULL if not on a tree. ++ * @min_start: minimum start time of the (active) subtree rooted at ++ * this entity; used for O(log N) lookups into active trees. ++ * @service: service received during the last round of service. ++ * @budget: budget used to calculate F_i; F_i = S_i + @budget / @weight. ++ * @weight: weight of the queue ++ * @parent: parent entity, for hierarchical scheduling. ++ * @my_sched_data: for non-leaf nodes in the cgroup hierarchy, the ++ * associated scheduler queue, %NULL on leaf nodes. ++ * @sched_data: the scheduler queue this entity belongs to. ++ * @ioprio: the ioprio in use. ++ * @new_weight: when a weight change is requested, the new weight value. ++ * @orig_weight: original weight, used to implement weight boosting ++ * @prio_changed: flag, true when the user requested a weight, ioprio or ++ * ioprio_class change. ++ * ++ * A bfq_entity is used to represent either a bfq_queue (leaf node in the ++ * cgroup hierarchy) or a bfq_group into the upper level scheduler. Each ++ * entity belongs to the sched_data of the parent group in the cgroup ++ * hierarchy. Non-leaf entities have also their own sched_data, stored ++ * in @my_sched_data. ++ * ++ * Each entity stores independently its priority values; this would ++ * allow different weights on different devices, but this ++ * functionality is not exported to userspace by now. Priorities and ++ * weights are updated lazily, first storing the new values into the ++ * new_* fields, then setting the @prio_changed flag. As soon as ++ * there is a transition in the entity state that allows the priority ++ * update to take place the effective and the requested priority ++ * values are synchronized. ++ * ++ * Unless cgroups are used, the weight value is calculated from the ++ * ioprio to export the same interface as CFQ. When dealing with ++ * ``well-behaved'' queues (i.e., queues that do not spend too much ++ * time to consume their budget and have true sequential behavior, and ++ * when there are no external factors breaking anticipation) the ++ * relative weights at each level of the cgroups hierarchy should be ++ * guaranteed. All the fields are protected by the queue lock of the ++ * containing bfqd. ++ */ ++struct bfq_entity { ++ struct rb_node rb_node; ++ struct bfq_weight_counter *weight_counter; ++ ++ int on_st; ++ ++ u64 finish; ++ u64 start; ++ ++ struct rb_root *tree; ++ ++ u64 min_start; ++ ++ int service, budget; ++ unsigned short weight, new_weight; ++ unsigned short orig_weight; ++ ++ struct bfq_entity *parent; ++ ++ struct bfq_sched_data *my_sched_data; ++ struct bfq_sched_data *sched_data; ++ ++ int prio_changed; ++}; ++ ++struct bfq_group; ++ ++/** ++ * struct bfq_queue - leaf schedulable entity. ++ * @ref: reference counter. ++ * @bfqd: parent bfq_data. ++ * @new_ioprio: when an ioprio change is requested, the new ioprio value. ++ * @ioprio_class: the ioprio_class in use. ++ * @new_ioprio_class: when an ioprio_class change is requested, the new ++ * ioprio_class value. ++ * @new_bfqq: shared bfq_queue if queue is cooperating with ++ * one or more other queues. ++ * @sort_list: sorted list of pending requests. ++ * @next_rq: if fifo isn't expired, next request to serve. ++ * @queued: nr of requests queued in @sort_list. ++ * @allocated: currently allocated requests. ++ * @meta_pending: pending metadata requests. ++ * @fifo: fifo list of requests in sort_list. ++ * @entity: entity representing this queue in the scheduler. ++ * @max_budget: maximum budget allowed from the feedback mechanism. ++ * @budget_timeout: budget expiration (in jiffies). ++ * @dispatched: number of requests on the dispatch list or inside driver. ++ * @flags: status flags. ++ * @bfqq_list: node for active/idle bfqq list inside our bfqd. ++ * @burst_list_node: node for the device's burst list. ++ * @seek_samples: number of seeks sampled ++ * @seek_total: sum of the distances of the seeks sampled ++ * @seek_mean: mean seek distance ++ * @last_request_pos: position of the last request enqueued ++ * @requests_within_timer: number of consecutive pairs of request completion ++ * and arrival, such that the queue becomes idle ++ * after the completion, but the next request arrives ++ * within an idle time slice; used only if the queue's ++ * IO_bound has been cleared. ++ * @pid: pid of the process owning the queue, used for logging purposes. ++ * @last_wr_start_finish: start time of the current weight-raising period if ++ * the @bfq-queue is being weight-raised, otherwise ++ * finish time of the last weight-raising period ++ * @wr_cur_max_time: current max raising time for this queue ++ * @soft_rt_next_start: minimum time instant such that, only if a new ++ * request is enqueued after this time instant in an ++ * idle @bfq_queue with no outstanding requests, then ++ * the task associated with the queue it is deemed as ++ * soft real-time (see the comments to the function ++ * bfq_bfqq_softrt_next_start()) ++ * @last_idle_bklogged: time of the last transition of the @bfq_queue from ++ * idle to backlogged ++ * @service_from_backlogged: cumulative service received from the @bfq_queue ++ * since the last transition from idle to ++ * backlogged ++ * @bic: pointer to the bfq_io_cq owning the bfq_queue, set to %NULL if the ++ * queue is shared ++ * ++ * A bfq_queue is a leaf request queue; it can be associated with an ++ * io_context or more, if it is async or shared between cooperating ++ * processes. @cgroup holds a reference to the cgroup, to be sure that it ++ * does not disappear while a bfqq still references it (mostly to avoid ++ * races between request issuing and task migration followed by cgroup ++ * destruction). ++ * All the fields are protected by the queue lock of the containing bfqd. ++ */ ++struct bfq_queue { ++ atomic_t ref; ++ struct bfq_data *bfqd; ++ ++ unsigned short ioprio, new_ioprio; ++ unsigned short ioprio_class, new_ioprio_class; ++ ++ /* fields for cooperating queues handling */ ++ struct bfq_queue *new_bfqq; ++ struct rb_node pos_node; ++ struct rb_root *pos_root; ++ ++ struct rb_root sort_list; ++ struct request *next_rq; ++ int queued[2]; ++ int allocated[2]; ++ int meta_pending; ++ struct list_head fifo; ++ ++ struct bfq_entity entity; ++ ++ int max_budget; ++ unsigned long budget_timeout; ++ ++ int dispatched; ++ ++ unsigned int flags; ++ ++ struct list_head bfqq_list; ++ ++ struct hlist_node burst_list_node; ++ ++ unsigned int seek_samples; ++ u64 seek_total; ++ sector_t seek_mean; ++ sector_t last_request_pos; ++ ++ unsigned int requests_within_timer; ++ ++ pid_t pid; ++ struct bfq_io_cq *bic; ++ ++ /* weight-raising fields */ ++ unsigned long wr_cur_max_time; ++ unsigned long soft_rt_next_start; ++ unsigned long last_wr_start_finish; ++ unsigned int wr_coeff; ++ unsigned long last_idle_bklogged; ++ unsigned long service_from_backlogged; ++}; ++ ++/** ++ * struct bfq_ttime - per process thinktime stats. ++ * @ttime_total: total process thinktime ++ * @ttime_samples: number of thinktime samples ++ * @ttime_mean: average process thinktime ++ */ ++struct bfq_ttime { ++ unsigned long last_end_request; ++ ++ unsigned long ttime_total; ++ unsigned long ttime_samples; ++ unsigned long ttime_mean; ++}; ++ ++/** ++ * struct bfq_io_cq - per (request_queue, io_context) structure. ++ * @icq: associated io_cq structure ++ * @bfqq: array of two process queues, the sync and the async ++ * @ttime: associated @bfq_ttime struct ++ * @ioprio: per (request_queue, blkcg) ioprio. ++ * @blkcg_id: id of the blkcg the related io_cq belongs to. ++ */ ++struct bfq_io_cq { ++ struct io_cq icq; /* must be the first member */ ++ struct bfq_queue *bfqq[2]; ++ struct bfq_ttime ttime; ++ int ioprio; ++ ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ uint64_t blkcg_id; /* the current blkcg ID */ ++#endif ++}; ++ ++enum bfq_device_speed { ++ BFQ_BFQD_FAST, ++ BFQ_BFQD_SLOW, ++}; ++ ++/** ++ * struct bfq_data - per device data structure. ++ * @queue: request queue for the managed device. ++ * @root_group: root bfq_group for the device. ++ * @active_numerous_groups: number of bfq_groups containing more than one ++ * active @bfq_entity. ++ * @queue_weights_tree: rbtree of weight counters of @bfq_queues, sorted by ++ * weight. Used to keep track of whether all @bfq_queues ++ * have the same weight. The tree contains one counter ++ * for each distinct weight associated to some active ++ * and not weight-raised @bfq_queue (see the comments to ++ * the functions bfq_weights_tree_[add|remove] for ++ * further details). ++ * @group_weights_tree: rbtree of non-queue @bfq_entity weight counters, sorted ++ * by weight. Used to keep track of whether all ++ * @bfq_groups have the same weight. The tree contains ++ * one counter for each distinct weight associated to ++ * some active @bfq_group (see the comments to the ++ * functions bfq_weights_tree_[add|remove] for further ++ * details). ++ * @busy_queues: number of bfq_queues containing requests (including the ++ * queue in service, even if it is idling). ++ * @busy_in_flight_queues: number of @bfq_queues containing pending or ++ * in-flight requests, plus the @bfq_queue in ++ * service, even if idle but waiting for the ++ * possible arrival of its next sync request. This ++ * field is updated only if the device is rotational, ++ * but used only if the device is also NCQ-capable. ++ * The reason why the field is updated also for non- ++ * NCQ-capable rotational devices is related to the ++ * fact that the value of @hw_tag may be set also ++ * later than when busy_in_flight_queues may need to ++ * be incremented for the first time(s). Taking also ++ * this possibility into account, to avoid unbalanced ++ * increments/decrements, would imply more overhead ++ * than just updating busy_in_flight_queues ++ * regardless of the value of @hw_tag. ++ * @const_seeky_busy_in_flight_queues: number of constantly-seeky @bfq_queues ++ * (that is, seeky queues that expired ++ * for budget timeout at least once) ++ * containing pending or in-flight ++ * requests, including the in-service ++ * @bfq_queue if constantly seeky. This ++ * field is updated only if the device ++ * is rotational, but used only if the ++ * device is also NCQ-capable (see the ++ * comments to @busy_in_flight_queues). ++ * @wr_busy_queues: number of weight-raised busy @bfq_queues. ++ * @queued: number of queued requests. ++ * @rq_in_driver: number of requests dispatched and waiting for completion. ++ * @sync_flight: number of sync requests in the driver. ++ * @max_rq_in_driver: max number of reqs in driver in the last ++ * @hw_tag_samples completed requests. ++ * @hw_tag_samples: nr of samples used to calculate hw_tag. ++ * @hw_tag: flag set to one if the driver is showing a queueing behavior. ++ * @budgets_assigned: number of budgets assigned. ++ * @idle_slice_timer: timer set when idling for the next sequential request ++ * from the queue in service. ++ * @unplug_work: delayed work to restart dispatching on the request queue. ++ * @in_service_queue: bfq_queue in service. ++ * @in_service_bic: bfq_io_cq (bic) associated with the @in_service_queue. ++ * @last_position: on-disk position of the last served request. ++ * @last_budget_start: beginning of the last budget. ++ * @last_idling_start: beginning of the last idle slice. ++ * @peak_rate: peak transfer rate observed for a budget. ++ * @peak_rate_samples: number of samples used to calculate @peak_rate. ++ * @bfq_max_budget: maximum budget allotted to a bfq_queue before ++ * rescheduling. ++ * @active_list: list of all the bfq_queues active on the device. ++ * @idle_list: list of all the bfq_queues idle on the device. ++ * @bfq_fifo_expire: timeout for async/sync requests; when it expires ++ * requests are served in fifo order. ++ * @bfq_back_penalty: weight of backward seeks wrt forward ones. ++ * @bfq_back_max: maximum allowed backward seek. ++ * @bfq_slice_idle: maximum idling time. ++ * @bfq_user_max_budget: user-configured max budget value ++ * (0 for auto-tuning). ++ * @bfq_max_budget_async_rq: maximum budget (in nr of requests) allotted to ++ * async queues. ++ * @bfq_timeout: timeout for bfq_queues to consume their budget; used to ++ * to prevent seeky queues to impose long latencies to well ++ * behaved ones (this also implies that seeky queues cannot ++ * receive guarantees in the service domain; after a timeout ++ * they are charged for the whole allocated budget, to try ++ * to preserve a behavior reasonably fair among them, but ++ * without service-domain guarantees). ++ * @bfq_coop_thresh: number of queue merges after which a @bfq_queue is ++ * no more granted any weight-raising. ++ * @bfq_failed_cooperations: number of consecutive failed cooperation ++ * chances after which weight-raising is restored ++ * to a queue subject to more than bfq_coop_thresh ++ * queue merges. ++ * @bfq_requests_within_timer: number of consecutive requests that must be ++ * issued within the idle time slice to set ++ * again idling to a queue which was marked as ++ * non-I/O-bound (see the definition of the ++ * IO_bound flag for further details). ++ * @last_ins_in_burst: last time at which a queue entered the current ++ * burst of queues being activated shortly after ++ * each other; for more details about this and the ++ * following parameters related to a burst of ++ * activations, see the comments to the function ++ * @bfq_handle_burst. ++ * @bfq_burst_interval: reference time interval used to decide whether a ++ * queue has been activated shortly after ++ * @last_ins_in_burst. ++ * @burst_size: number of queues in the current burst of queue activations. ++ * @bfq_large_burst_thresh: maximum burst size above which the current ++ * queue-activation burst is deemed as 'large'. ++ * @large_burst: true if a large queue-activation burst is in progress. ++ * @burst_list: head of the burst list (as for the above fields, more details ++ * in the comments to the function bfq_handle_burst). ++ * @low_latency: if set to true, low-latency heuristics are enabled. ++ * @bfq_wr_coeff: maximum factor by which the weight of a weight-raised ++ * queue is multiplied. ++ * @bfq_wr_max_time: maximum duration of a weight-raising period (jiffies). ++ * @bfq_wr_rt_max_time: maximum duration for soft real-time processes. ++ * @bfq_wr_min_idle_time: minimum idle period after which weight-raising ++ * may be reactivated for a queue (in jiffies). ++ * @bfq_wr_min_inter_arr_async: minimum period between request arrivals ++ * after which weight-raising may be ++ * reactivated for an already busy queue ++ * (in jiffies). ++ * @bfq_wr_max_softrt_rate: max service-rate for a soft real-time queue, ++ * sectors per seconds. ++ * @RT_prod: cached value of the product R*T used for computing the maximum ++ * duration of the weight raising automatically. ++ * @device_speed: device-speed class for the low-latency heuristic. ++ * @oom_bfqq: fallback dummy bfqq for extreme OOM conditions. ++ * ++ * All the fields are protected by the @queue lock. ++ */ ++struct bfq_data { ++ struct request_queue *queue; ++ ++ struct bfq_group *root_group; ++ ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ int active_numerous_groups; ++#endif ++ ++ struct rb_root queue_weights_tree; ++ struct rb_root group_weights_tree; ++ ++ int busy_queues; ++ int busy_in_flight_queues; ++ int const_seeky_busy_in_flight_queues; ++ int wr_busy_queues; ++ int queued; ++ int rq_in_driver; ++ int sync_flight; ++ ++ int max_rq_in_driver; ++ int hw_tag_samples; ++ int hw_tag; ++ ++ int budgets_assigned; ++ ++ struct timer_list idle_slice_timer; ++ struct work_struct unplug_work; ++ ++ struct bfq_queue *in_service_queue; ++ struct bfq_io_cq *in_service_bic; ++ ++ sector_t last_position; ++ ++ ktime_t last_budget_start; ++ ktime_t last_idling_start; ++ int peak_rate_samples; ++ u64 peak_rate; ++ int bfq_max_budget; ++ ++ struct list_head active_list; ++ struct list_head idle_list; ++ ++ unsigned int bfq_fifo_expire[2]; ++ unsigned int bfq_back_penalty; ++ unsigned int bfq_back_max; ++ unsigned int bfq_slice_idle; ++ u64 bfq_class_idle_last_service; ++ ++ int bfq_user_max_budget; ++ int bfq_max_budget_async_rq; ++ unsigned int bfq_timeout[2]; ++ ++ unsigned int bfq_coop_thresh; ++ unsigned int bfq_failed_cooperations; ++ unsigned int bfq_requests_within_timer; ++ ++ unsigned long last_ins_in_burst; ++ unsigned long bfq_burst_interval; ++ int burst_size; ++ unsigned long bfq_large_burst_thresh; ++ bool large_burst; ++ struct hlist_head burst_list; ++ ++ bool low_latency; ++ ++ /* parameters of the low_latency heuristics */ ++ unsigned int bfq_wr_coeff; ++ unsigned int bfq_wr_max_time; ++ unsigned int bfq_wr_rt_max_time; ++ unsigned int bfq_wr_min_idle_time; ++ unsigned long bfq_wr_min_inter_arr_async; ++ unsigned int bfq_wr_max_softrt_rate; ++ u64 RT_prod; ++ enum bfq_device_speed device_speed; ++ ++ struct bfq_queue oom_bfqq; ++}; ++ ++enum bfqq_state_flags { ++ BFQ_BFQQ_FLAG_busy = 0, /* has requests or is in service */ ++ BFQ_BFQQ_FLAG_wait_request, /* waiting for a request */ ++ BFQ_BFQQ_FLAG_must_alloc, /* must be allowed rq alloc */ ++ BFQ_BFQQ_FLAG_fifo_expire, /* FIFO checked in this slice */ ++ BFQ_BFQQ_FLAG_idle_window, /* slice idling enabled */ ++ BFQ_BFQQ_FLAG_sync, /* synchronous queue */ ++ BFQ_BFQQ_FLAG_budget_new, /* no completion with this budget */ ++ BFQ_BFQQ_FLAG_IO_bound, /* ++ * bfqq has timed-out at least once ++ * having consumed at most 2/10 of ++ * its budget ++ */ ++ BFQ_BFQQ_FLAG_in_large_burst, /* ++ * bfqq activated in a large burst, ++ * see comments to bfq_handle_burst. ++ */ ++ BFQ_BFQQ_FLAG_constantly_seeky, /* ++ * bfqq has proved to be slow and ++ * seeky until budget timeout ++ */ ++ BFQ_BFQQ_FLAG_softrt_update, /* ++ * may need softrt-next-start ++ * update ++ */ ++}; ++ ++#define BFQ_BFQQ_FNS(name) \ ++static void bfq_mark_bfqq_##name(struct bfq_queue *bfqq) \ ++{ \ ++ (bfqq)->flags |= (1 << BFQ_BFQQ_FLAG_##name); \ ++} \ ++static void bfq_clear_bfqq_##name(struct bfq_queue *bfqq) \ ++{ \ ++ (bfqq)->flags &= ~(1 << BFQ_BFQQ_FLAG_##name); \ ++} \ ++static int bfq_bfqq_##name(const struct bfq_queue *bfqq) \ ++{ \ ++ return ((bfqq)->flags & (1 << BFQ_BFQQ_FLAG_##name)) != 0; \ ++} ++ ++BFQ_BFQQ_FNS(busy); ++BFQ_BFQQ_FNS(wait_request); ++BFQ_BFQQ_FNS(must_alloc); ++BFQ_BFQQ_FNS(fifo_expire); ++BFQ_BFQQ_FNS(idle_window); ++BFQ_BFQQ_FNS(sync); ++BFQ_BFQQ_FNS(budget_new); ++BFQ_BFQQ_FNS(IO_bound); ++BFQ_BFQQ_FNS(in_large_burst); ++BFQ_BFQQ_FNS(constantly_seeky); ++BFQ_BFQQ_FNS(softrt_update); ++#undef BFQ_BFQQ_FNS ++ ++/* Logging facilities. */ ++#define bfq_log_bfqq(bfqd, bfqq, fmt, args...) \ ++ blk_add_trace_msg((bfqd)->queue, "bfq%d " fmt, (bfqq)->pid, ##args) ++ ++#define bfq_log(bfqd, fmt, args...) \ ++ blk_add_trace_msg((bfqd)->queue, "bfq " fmt, ##args) ++ ++/* Expiration reasons. */ ++enum bfqq_expiration { ++ BFQ_BFQQ_TOO_IDLE = 0, /* ++ * queue has been idling for ++ * too long ++ */ ++ BFQ_BFQQ_BUDGET_TIMEOUT, /* budget took too long to be used */ ++ BFQ_BFQQ_BUDGET_EXHAUSTED, /* budget consumed */ ++ BFQ_BFQQ_NO_MORE_REQUESTS, /* the queue has no more requests */ ++}; ++ ++#ifdef CONFIG_BFQ_GROUP_IOSCHED ++ ++struct bfqg_stats { ++ /* total bytes transferred */ ++ struct blkg_rwstat service_bytes; ++ /* total IOs serviced, post merge */ ++ struct blkg_rwstat serviced; ++ /* number of ios merged */ ++ struct blkg_rwstat merged; ++ /* total time spent on device in ns, may not be accurate w/ queueing */ ++ struct blkg_rwstat service_time; ++ /* total time spent waiting in scheduler queue in ns */ ++ struct blkg_rwstat wait_time; ++ /* number of IOs queued up */ ++ struct blkg_rwstat queued; ++ /* total sectors transferred */ ++ struct blkg_stat sectors; ++ /* total disk time and nr sectors dispatched by this group */ ++ struct blkg_stat time; ++ /* time not charged to this cgroup */ ++ struct blkg_stat unaccounted_time; ++ /* sum of number of ios queued across all samples */ ++ struct blkg_stat avg_queue_size_sum; ++ /* count of samples taken for average */ ++ struct blkg_stat avg_queue_size_samples; ++ /* how many times this group has been removed from service tree */ ++ struct blkg_stat dequeue; ++ /* total time spent waiting for it to be assigned a timeslice. */ ++ struct blkg_stat group_wait_time; ++ /* time spent idling for this blkcg_gq */ ++ struct blkg_stat idle_time; ++ /* total time with empty current active q with other requests queued */ ++ struct blkg_stat empty_time; ++ /* fields after this shouldn't be cleared on stat reset */ ++ uint64_t start_group_wait_time; ++ uint64_t start_idle_time; ++ uint64_t start_empty_time; ++ uint16_t flags; ++}; ++ ++/* ++ * struct bfq_group_data - per-blkcg storage for the blkio subsystem. ++ * ++ * @ps: @blkcg_policy_storage that this structure inherits ++ * @weight: weight of the bfq_group ++ */ ++struct bfq_group_data { ++ /* must be the first member */ ++ struct blkcg_policy_data pd; ++ ++ unsigned short weight; ++}; ++ ++/** ++ * struct bfq_group - per (device, cgroup) data structure. ++ * @entity: schedulable entity to insert into the parent group sched_data. ++ * @sched_data: own sched_data, to contain child entities (they may be ++ * both bfq_queues and bfq_groups). ++ * @bfqd: the bfq_data for the device this group acts upon. ++ * @async_bfqq: array of async queues for all the tasks belonging to ++ * the group, one queue per ioprio value per ioprio_class, ++ * except for the idle class that has only one queue. ++ * @async_idle_bfqq: async queue for the idle class (ioprio is ignored). ++ * @my_entity: pointer to @entity, %NULL for the toplevel group; used ++ * to avoid too many special cases during group creation/ ++ * migration. ++ * @active_entities: number of active entities belonging to the group; ++ * unused for the root group. Used to know whether there ++ * are groups with more than one active @bfq_entity ++ * (see the comments to the function ++ * bfq_bfqq_must_not_expire()). ++ * ++ * Each (device, cgroup) pair has its own bfq_group, i.e., for each cgroup ++ * there is a set of bfq_groups, each one collecting the lower-level ++ * entities belonging to the group that are acting on the same device. ++ * ++ * Locking works as follows: ++ * o @bfqd is protected by the queue lock, RCU is used to access it ++ * from the readers. ++ * o All the other fields are protected by the @bfqd queue lock. ++ */ ++struct bfq_group { ++ /* must be the first member */ ++ struct blkg_policy_data pd; ++ ++ struct bfq_entity entity; ++ struct bfq_sched_data sched_data; ++ ++ void *bfqd; ++ ++ struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; ++ struct bfq_queue *async_idle_bfqq; ++ ++ struct bfq_entity *my_entity; ++ ++ int active_entities; ++ ++ struct bfqg_stats stats; ++ struct bfqg_stats dead_stats; /* stats pushed from dead children */ ++}; ++ ++#else ++struct bfq_group { ++ struct bfq_sched_data sched_data; ++ ++ struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; ++ struct bfq_queue *async_idle_bfqq; ++}; ++#endif ++ ++static struct bfq_queue *bfq_entity_to_bfqq(struct bfq_entity *entity); ++ ++static struct bfq_service_tree * ++bfq_entity_service_tree(struct bfq_entity *entity) ++{ ++ struct bfq_sched_data *sched_data = entity->sched_data; ++ struct bfq_queue *bfqq = bfq_entity_to_bfqq(entity); ++ unsigned int idx = bfqq ? bfqq->ioprio_class - 1 : ++ BFQ_DEFAULT_GRP_CLASS; ++ ++ BUG_ON(idx >= BFQ_IOPRIO_CLASSES); ++ BUG_ON(sched_data == NULL); ++ ++ return sched_data->service_tree + idx; ++} ++ ++static struct bfq_queue *bic_to_bfqq(struct bfq_io_cq *bic, bool is_sync) ++{ ++ return bic->bfqq[is_sync]; ++} ++ ++static void bic_set_bfqq(struct bfq_io_cq *bic, struct bfq_queue *bfqq, ++ bool is_sync) ++{ ++ bic->bfqq[is_sync] = bfqq; ++} ++ ++static struct bfq_data *bic_to_bfqd(struct bfq_io_cq *bic) ++{ ++ return bic->icq.q->elevator->elevator_data; ++} ++ ++/** ++ * bfq_get_bfqd_locked - get a lock to a bfqd using a RCU protected pointer. ++ * @ptr: a pointer to a bfqd. ++ * @flags: storage for the flags to be saved. ++ * ++ * This function allows bfqg->bfqd to be protected by the ++ * queue lock of the bfqd they reference; the pointer is dereferenced ++ * under RCU, so the storage for bfqd is assured to be safe as long ++ * as the RCU read side critical section does not end. After the ++ * bfqd->queue->queue_lock is taken the pointer is rechecked, to be ++ * sure that no other writer accessed it. If we raced with a writer, ++ * the function returns NULL, with the queue unlocked, otherwise it ++ * returns the dereferenced pointer, with the queue locked. ++ */ ++static struct bfq_data *bfq_get_bfqd_locked(void **ptr, unsigned long *flags) ++{ ++ struct bfq_data *bfqd; ++ ++ rcu_read_lock(); ++ bfqd = rcu_dereference(*(struct bfq_data **)ptr); ++ ++ if (bfqd != NULL) { ++ spin_lock_irqsave(bfqd->queue->queue_lock, *flags); ++ if (ptr == NULL) ++ printk(KERN_CRIT "get_bfqd_locked pointer NULL\n"); ++ else if (*ptr == bfqd) ++ goto out; ++ spin_unlock_irqrestore(bfqd->queue->queue_lock, *flags); ++ } ++ ++ bfqd = NULL; ++out: ++ rcu_read_unlock(); ++ return bfqd; ++} ++ ++static void bfq_put_bfqd_unlock(struct bfq_data *bfqd, unsigned long *flags) ++{ ++ spin_unlock_irqrestore(bfqd->queue->queue_lock, *flags); ++} ++ ++static void bfq_check_ioprio_change(struct bfq_io_cq *bic, struct bio *bio); ++static void bfq_put_queue(struct bfq_queue *bfqq); ++static void bfq_dispatch_insert(struct request_queue *q, struct request *rq); ++static struct bfq_queue *bfq_get_queue(struct bfq_data *bfqd, ++ struct bio *bio, int is_sync, ++ struct bfq_io_cq *bic, gfp_t gfp_mask); ++static void bfq_end_wr_async_queues(struct bfq_data *bfqd, ++ struct bfq_group *bfqg); ++static void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg); ++static void bfq_exit_bfqq(struct bfq_data *bfqd, struct bfq_queue *bfqq); ++ ++#endif /* _BFQ_H */ +-- +2.10.0 + diff --git a/kernel/kernel/files/patches/mageia/char-tmp-tpm_crb-fix-Intel-PTT-hw-bug-during-idle-state.patch b/kernel/kernel/files/patches/mageia/char-tmp-tpm_crb-fix-Intel-PTT-hw-bug-during-idle-state.patch new file mode 100644 index 00000000..767ccd9a --- /dev/null +++ b/kernel/kernel/files/patches/mageia/char-tmp-tpm_crb-fix-Intel-PTT-hw-bug-during-idle-state.patch @@ -0,0 +1,115 @@ +From bc33c5df710c0aae6db396146194108634ef6f60 Mon Sep 17 00:00:00 2001 +From: "Winkler, Tomas" +Date: Mon, 12 Sep 2016 16:04:19 +0300 +Subject: [PATCH] tmp/tpm_crb: fix Intel PTT hw bug during idle state + +There is a HW bug in Skylake, and Broxton PCH Intel PTT device, where +most of the registers in the control area except START, REQUEST, CANCEL, +and LOC_CTRL lost retention when the device is in the idle state. Hence +we need to bring the device to ready state before accessing the other +registers. The fix brings device to ready state before trying to read +command and response buffer addresses in order to remap the for access. + +Signed-off-by: Tomas Winkler +Tested-by: Jarkko Sakkinen +Reviewed-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +--- + drivers/char/tpm/tpm_crb.c | 47 ++++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 39 insertions(+), 8 deletions(-) + +diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c +index 8dd0f20..ff0d505 100644 +--- a/drivers/char/tpm/tpm_crb.c ++++ b/drivers/char/tpm/tpm_crb.c +@@ -315,6 +315,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, + struct list_head resources; + struct resource io_res; + struct device *dev = &device->dev; ++ u32 pa_high, pa_low; + u64 cmd_pa; + u32 cmd_size; + u64 rsp_pa; +@@ -342,12 +343,27 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, + if (IS_ERR(priv->cca)) + return PTR_ERR(priv->cca); + +- cmd_pa = ((u64) ioread32(&priv->cca->cmd_pa_high) << 32) | +- (u64) ioread32(&priv->cca->cmd_pa_low); ++ /* ++ * PTT HW bug w/a: wake up the device to access ++ * possibly not retained registers. ++ */ ++ ret = crb_cmd_ready(dev, priv); ++ if (ret) ++ return ret; ++ ++ pa_high = ioread32(&priv->cca->cmd_pa_high); ++ pa_low = ioread32(&priv->cca->cmd_pa_low); ++ cmd_pa = ((u64)pa_high << 32) | pa_low; + cmd_size = ioread32(&priv->cca->cmd_size); ++ ++ dev_dbg(dev, "cmd_hi = %X cmd_low = %X cmd_size %X\n", ++ pa_high, pa_low, cmd_size); ++ + priv->cmd = crb_map_res(dev, priv, &io_res, cmd_pa, cmd_size); +- if (IS_ERR(priv->cmd)) +- return PTR_ERR(priv->cmd); ++ if (IS_ERR(priv->cmd)) { ++ ret = PTR_ERR(priv->cmd); ++ goto out; ++ } + + memcpy_fromio(&rsp_pa, &priv->cca->rsp_pa, 8); + rsp_pa = le64_to_cpu(rsp_pa); +@@ -355,7 +371,8 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, + + if (cmd_pa != rsp_pa) { + priv->rsp = crb_map_res(dev, priv, &io_res, rsp_pa, rsp_size); +- return PTR_ERR_OR_ZERO(priv->rsp); ++ ret = PTR_ERR_OR_ZERO(priv->rsp); ++ goto out; + } + + /* According to the PTP specification, overlapping command and response +@@ -363,12 +380,18 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, + */ + if (cmd_size != rsp_size) { + dev_err(dev, FW_BUG "overlapping command and response buffer sizes are not identical"); +- return -EINVAL; ++ ret = -EINVAL; ++ goto out; + } ++ + priv->cmd_size = cmd_size; + + priv->rsp = priv->cmd; +- return 0; ++ ++out: ++ crb_go_idle(dev, priv); ++ ++ return ret; + } + + static int crb_acpi_add(struct acpi_device *device) +@@ -412,7 +435,15 @@ static int crb_acpi_add(struct acpi_device *device) + if (rc) + return rc; + +- return crb_init(device, priv); ++ rc = crb_cmd_ready(dev, priv); ++ if (rc) ++ return rc; ++ ++ rc = crb_init(device, priv); ++ if (rc) ++ crb_go_idle(dev, priv); ++ ++ return rc; + } + + static int crb_acpi_remove(struct acpi_device *device) +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/char-tmp-tpm_crb-implement-runtime-pm-for-tpm_crb.patch b/kernel/kernel/files/patches/mageia/char-tmp-tpm_crb-implement-runtime-pm-for-tpm_crb.patch new file mode 100644 index 00000000..c4953345 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/char-tmp-tpm_crb-implement-runtime-pm-for-tpm_crb.patch @@ -0,0 +1,134 @@ +From e74f2f76c13770bb8e004475a933923e9c92723d Mon Sep 17 00:00:00 2001 +From: "Winkler, Tomas" +Date: Sat, 8 Oct 2016 14:59:39 +0300 +Subject: [PATCH] tmp/tpm_crb: implement runtime pm for tpm_crb + +Utilize runtime_pm for driving tpm crb idle states. +The framework calls cmd_ready from the pm_runtime_resume handler +and go idle from the pm_runtime_suspend handler. +The TPM framework should wake the device before transmit and receive. +In case the runtime_pm framework is not compiled in or enabled, the device +will be in the permanent ready state. + +Signed-off-by: Tomas Winkler +Reviewed-by: Jarkko Sakkinen +Tested-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +--- + drivers/char/tpm/tpm-interface.c | 5 +++++ + drivers/char/tpm/tpm_crb.c | 42 ++++++++++++++++++++++++++++++++++++---- + 2 files changed, 43 insertions(+), 4 deletions(-) + +diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c +index 3a9149c..cb0e57e 100644 +--- a/drivers/char/tpm/tpm-interface.c ++++ b/drivers/char/tpm/tpm-interface.c +@@ -29,6 +29,7 @@ + #include + #include + #include ++#include + + #include "tpm.h" + #include "tpm_eventlog.h" +@@ -356,6 +357,8 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz, + if (!(flags & TPM_TRANSMIT_UNLOCKED)) + mutex_lock(&chip->tpm_mutex); + ++ pm_runtime_get_sync(chip->dev.parent); ++ + rc = chip->ops->send(chip, (u8 *) buf, count); + if (rc < 0) { + dev_err(&chip->dev, +@@ -397,6 +400,8 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz, + dev_err(&chip->dev, + "tpm_transmit: tpm_recv: error %zd\n", rc); + out: ++ pm_runtime_put_sync(chip->dev.parent); ++ + if (!(flags & TPM_TRANSMIT_UNLOCKED)) + mutex_unlock(&chip->tpm_mutex); + return rc; +diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c +index f579f1a..717b6b4 100644 +--- a/drivers/char/tpm/tpm_crb.c ++++ b/drivers/char/tpm/tpm_crb.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include "tpm.h" + + #define ACPI_SIG_TPM2 "TPM2" +@@ -149,8 +150,6 @@ static int __maybe_unused crb_cmd_ready(struct device *dev, + return 0; + } + +-static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume); +- + static u8 crb_status(struct tpm_chip *chip) + { + struct crb_priv *priv = dev_get_drvdata(&chip->dev); +@@ -433,11 +432,21 @@ static int crb_acpi_add(struct acpi_device *device) + if (rc) + return rc; + ++ pm_runtime_get_noresume(dev); ++ pm_runtime_set_active(dev); ++ pm_runtime_enable(dev); ++ + rc = tpm_chip_register(chip); +- if (rc) ++ if (rc) { + crb_go_idle(dev, priv); ++ pm_runtime_put_noidle(dev); ++ pm_runtime_disable(dev); ++ return rc; ++ } + +- return rc; ++ pm_runtime_put(dev); ++ ++ return 0; + } + + static int crb_acpi_remove(struct acpi_device *device) +@@ -447,9 +456,34 @@ static int crb_acpi_remove(struct acpi_device *device) + + tpm_chip_unregister(chip); + ++ pm_runtime_disable(dev); ++ + return 0; + } + ++#ifdef CONFIG_PM ++static int crb_pm_runtime_suspend(struct device *dev) ++{ ++ struct tpm_chip *chip = dev_get_drvdata(dev); ++ struct crb_priv *priv = dev_get_drvdata(&chip->dev); ++ ++ return crb_go_idle(dev, priv); ++} ++ ++static int crb_pm_runtime_resume(struct device *dev) ++{ ++ struct tpm_chip *chip = dev_get_drvdata(dev); ++ struct crb_priv *priv = dev_get_drvdata(&chip->dev); ++ ++ return crb_cmd_ready(dev, priv); ++} ++#endif /* CONFIG_PM */ ++ ++static const struct dev_pm_ops crb_pm = { ++ SET_SYSTEM_SLEEP_PM_OPS(tpm_pm_suspend, tpm_pm_resume) ++ SET_RUNTIME_PM_OPS(crb_pm_runtime_suspend, crb_pm_runtime_resume, NULL) ++}; ++ + static struct acpi_device_id crb_device_ids[] = { + {"MSFT0101", 0}, + {"", 0}, +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/char-tpm-tpm_crb-implement-tpm-crb-idle-state.patch b/kernel/kernel/files/patches/mageia/char-tpm-tpm_crb-implement-tpm-crb-idle-state.patch new file mode 100644 index 00000000..5ba21308 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/char-tpm-tpm_crb-implement-tpm-crb-idle-state.patch @@ -0,0 +1,111 @@ +From ba5287b6ef6a2ee91dc6cc0829649cecf7b70253 Mon Sep 17 00:00:00 2001 +From: "Winkler, Tomas" +Date: Thu, 15 Sep 2016 10:27:38 +0300 +Subject: [PATCH] tpm/tpm_crb: implement tpm crb idle state + +The register TPM_CRB_CTRL_REQ_x contains bits goIdle and cmdReady for +SW to indicate that the device can enter or should exit the idle state. + +The legacy ACPI-start (SMI + DMA) based devices do not support these +bits and the idle state management is not exposed to the host SW. +Thus, this functionality only is enabled only for a CRB start (MMIO) +based devices. + +Based on Jarkko Sakkinen +original patch: +'tpm_crb: implement power tpm crb power management' + +To keep the implementation local to the hw we don't use wait_for_tpm_stat +for polling the TPM_CRB_CTRL_REQ. + +[jarkko.sakkinen@linux.intel.com: removed cmdReady debug trace on a + success case due the heavy amount of log traffic it causes.] + +Signed-off-by: Tomas Winkler +Reviewed-by: Jarkko Sakkinen +Tested-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +--- + drivers/char/tpm/tpm_crb.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 66 insertions(+) + +diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c +index a7c870a..8dd0f20 100644 +--- a/drivers/char/tpm/tpm_crb.c ++++ b/drivers/char/tpm/tpm_crb.c +@@ -83,6 +83,72 @@ struct crb_priv { + u32 cmd_size; + }; + ++/** ++ * crb_go_idle - request tpm crb device to go the idle state ++ * ++ * @dev: crb device ++ * @priv: crb private data ++ * ++ * Write CRB_CTRL_REQ_GO_IDLE to TPM_CRB_CTRL_REQ ++ * The device should respond within TIMEOUT_C by clearing the bit. ++ * Anyhow, we do not wait here as a consequent CMD_READY request ++ * will be handled correctly even if idle was not completed. ++ * ++ * The function does nothing for devices with ACPI-start method. ++ * ++ * Return: 0 always ++ */ ++static int __maybe_unused crb_go_idle(struct device *dev, struct crb_priv *priv) ++{ ++ if (priv->flags & CRB_FL_ACPI_START) ++ return 0; ++ ++ iowrite32(CRB_CTRL_REQ_GO_IDLE, &priv->cca->req); ++ /* we don't really care when this settles */ ++ ++ return 0; ++} ++ ++/** ++ * crb_cmd_ready - request tpm crb device to enter ready state ++ * ++ * @dev: crb device ++ * @priv: crb private data ++ * ++ * Write CRB_CTRL_REQ_CMD_READY to TPM_CRB_CTRL_REQ ++ * and poll till the device acknowledge it by clearing the bit. ++ * The device should respond within TIMEOUT_C. ++ * ++ * The function does nothing for devices with ACPI-start method ++ * ++ * Return: 0 on success -ETIME on timeout; ++ */ ++static int __maybe_unused crb_cmd_ready(struct device *dev, ++ struct crb_priv *priv) ++{ ++ ktime_t stop, start; ++ ++ if (priv->flags & CRB_FL_ACPI_START) ++ return 0; ++ ++ iowrite32(CRB_CTRL_REQ_CMD_READY, &priv->cca->req); ++ ++ start = ktime_get(); ++ stop = ktime_add(start, ms_to_ktime(TPM2_TIMEOUT_C)); ++ do { ++ if (!(ioread32(&priv->cca->req) & CRB_CTRL_REQ_CMD_READY)) ++ return 0; ++ usleep_range(50, 100); ++ } while (ktime_before(ktime_get(), stop)); ++ ++ if (ioread32(&priv->cca->req) & CRB_CTRL_REQ_CMD_READY) { ++ dev_warn(dev, "cmdReady timed out\n"); ++ return -ETIME; ++ } ++ ++ return 0; ++} ++ + static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume); + + static u8 crb_status(struct tpm_chip *chip) +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/char-tpm-tpm_crb-open-code-the-crb_init-into-acpi_add.patch b/kernel/kernel/files/patches/mageia/char-tpm-tpm_crb-open-code-the-crb_init-into-acpi_add.patch new file mode 100644 index 00000000..b4e47ae1 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/char-tpm-tpm_crb-open-code-the-crb_init-into-acpi_add.patch @@ -0,0 +1,75 @@ +From c58bd34cec4c05f8e3362a79ae94de9f405c39b5 Mon Sep 17 00:00:00 2001 +From: "Winkler, Tomas" +Date: Mon, 12 Sep 2016 16:04:20 +0300 +Subject: [PATCH] tpm/tpm_crb: open code the crb_init into acpi_add + +This is preparation step for implementing tpm crb +runtime pm. We need to have tpm chip allocated +and populated before we access the runtime handlers. + +Signed-off-by: Tomas Winkler +Reviewed-by: Jarkko Sakkinen +Tested-by: Jarkko Sakkinen +Signed-off-by: Jarkko Sakkinen +--- + drivers/char/tpm/tpm_crb.c | 26 ++++++++++---------------- + 1 file changed, 10 insertions(+), 16 deletions(-) + +diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c +index ff0d505..f579f1a 100644 +--- a/drivers/char/tpm/tpm_crb.c ++++ b/drivers/char/tpm/tpm_crb.c +@@ -262,21 +262,6 @@ static const struct tpm_class_ops tpm_crb = { + .req_complete_val = CRB_DRV_STS_COMPLETE, + }; + +-static int crb_init(struct acpi_device *device, struct crb_priv *priv) +-{ +- struct tpm_chip *chip; +- +- chip = tpmm_chip_alloc(&device->dev, &tpm_crb); +- if (IS_ERR(chip)) +- return PTR_ERR(chip); +- +- dev_set_drvdata(&chip->dev, priv); +- chip->acpi_dev_handle = device->handle; +- chip->flags = TPM_CHIP_FLAG_TPM2; +- +- return tpm_chip_register(chip); +-} +- + static int crb_check_resource(struct acpi_resource *ares, void *data) + { + struct resource *io_res = data; +@@ -398,6 +383,7 @@ static int crb_acpi_add(struct acpi_device *device) + { + struct acpi_table_tpm2 *buf; + struct crb_priv *priv; ++ struct tpm_chip *chip; + struct device *dev = &device->dev; + acpi_status status; + u32 sm; +@@ -435,11 +421,19 @@ static int crb_acpi_add(struct acpi_device *device) + if (rc) + return rc; + ++ chip = tpmm_chip_alloc(dev, &tpm_crb); ++ if (IS_ERR(chip)) ++ return PTR_ERR(chip); ++ ++ dev_set_drvdata(&chip->dev, priv); ++ chip->acpi_dev_handle = device->handle; ++ chip->flags = TPM_CHIP_FLAG_TPM2; ++ + rc = crb_cmd_ready(dev, priv); + if (rc) + return rc; + +- rc = crb_init(device, priv); ++ rc = tpm_chip_register(chip); + if (rc) + crb_go_idle(dev, priv); + +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/fs-aufs-4.8-modular.patch b/kernel/kernel/files/patches/mageia/fs-aufs-4.9-modular.patch similarity index 61% rename from kernel/kernel/files/patches/mageia/fs-aufs-4.8-modular.patch rename to kernel/kernel/files/patches/mageia/fs-aufs-4.9-modular.patch index 62a3b4f0..f0a84fef 100644 --- a/kernel/kernel/files/patches/mageia/fs-aufs-4.8-modular.patch +++ b/kernel/kernel/files/patches/mageia/fs-aufs-4.9-modular.patch @@ -1,6 +1,6 @@ fs/aufs/Kconfig | 2 +- - fs/dcache.c | 1 + + fs/dcache.c | 2 ++ fs/exec.c | 1 + fs/fcntl.c | 1 + fs/file_table.c | 4 ++++ @@ -16,11 +16,11 @@ security/commoncap.c | 2 ++ security/device_cgroup.c | 2 ++ security/security.c | 10 ++++++++++ - 17 files changed, 41 insertions(+), 1 deletion(-) + 17 files changed, 42 insertions(+), 1 deletion(-) -diff -Nurp linux-4.8-aufs/fs/aufs/Kconfig linux-4.8-aufs-mod/fs/aufs/Kconfig ---- linux-4.8-aufs/fs/aufs/Kconfig 2016-07-04 19:02:29.246286120 +0300 -+++ linux-4.8-aufs-mod/fs/aufs/Kconfig 2016-07-04 19:03:53.653714965 +0300 +diff -Nurp linux-4.9-aufs/fs/aufs/Kconfig linux-4.9-aufs-mod/fs/aufs/Kconfig +--- linux-4.9-aufs/fs/aufs/Kconfig 2016-12-31 00:31:52.367789380 +0200 ++++ linux-4.9-aufs-mod/fs/aufs/Kconfig 2016-12-31 00:32:35.153785422 +0200 @@ -1,5 +1,5 @@ config AUFS_FS - bool "Aufs (Advanced multi layered unification filesystem) support" @@ -28,10 +28,10 @@ diff -Nurp linux-4.8-aufs/fs/aufs/Kconfig linux-4.8-aufs-mod/fs/aufs/Kconfig help Aufs is a stackable unification filesystem such as Unionfs, which unifies several directories and provides a merged single -diff -Nurp linux-4.8-aufs/fs/dcache.c linux-4.8-aufs-mod/fs/dcache.c ---- linux-4.8-aufs/fs/dcache.c 2016-07-04 19:02:29.260286196 +0300 -+++ linux-4.8-aufs-mod/fs/dcache.c 2016-07-04 19:03:53.653714965 +0300 -@@ -1310,6 +1310,7 @@ rename_retry: +diff -Nurp linux-4.9-aufs/fs/dcache.c linux-4.9-aufs-mod/fs/dcache.c +--- linux-4.9-aufs/fs/dcache.c 2016-12-31 00:31:52.379789379 +0200 ++++ linux-4.9-aufs-mod/fs/dcache.c 2016-12-31 01:49:12.324360147 +0200 +@@ -1272,6 +1272,7 @@ rename_retry: seq = 1; goto again; } @@ -39,9 +39,17 @@ diff -Nurp linux-4.8-aufs/fs/dcache.c linux-4.8-aufs-mod/fs/dcache.c /* * Search for at least 1 mount point in the dentry's subdirs. -diff -Nurp linux-4.8-aufs/fs/exec.c linux-4.8-aufs-mod/fs/exec.c ---- linux-4.8-aufs/fs/exec.c 2016-07-04 17:58:15.707773651 +0300 -+++ linux-4.8-aufs-mod/fs/exec.c 2016-07-04 19:03:53.654714970 +0300 +@@ -2855,6 +2856,7 @@ void d_exchange(struct dentry *dentry1, + + write_sequnlock(&rename_lock); + } ++EXPORT_SYMBOL_GPL(d_exchange); + + /** + * d_ancestor - search for an ancestor +diff -Nurp linux-4.9-aufs/fs/exec.c linux-4.9-aufs-mod/fs/exec.c +--- linux-4.9-aufs/fs/exec.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/fs/exec.c 2016-12-31 00:32:35.153785422 +0200 @@ -104,6 +104,7 @@ bool path_noexec(const struct path *path return (path->mnt->mnt_flags & MNT_NOEXEC) || (path->mnt->mnt_sb->s_iflags & SB_I_NOEXEC); @@ -50,9 +58,9 @@ diff -Nurp linux-4.8-aufs/fs/exec.c linux-4.8-aufs-mod/fs/exec.c #ifdef CONFIG_USELIB /* -diff -Nurp linux-4.8-aufs/fs/fcntl.c linux-4.8-aufs-mod/fs/fcntl.c ---- linux-4.8-aufs/fs/fcntl.c 2016-07-04 19:02:29.260286196 +0300 -+++ linux-4.8-aufs-mod/fs/fcntl.c 2016-07-04 19:03:53.654714970 +0300 +diff -Nurp linux-4.9-aufs/fs/fcntl.c linux-4.9-aufs-mod/fs/fcntl.c +--- linux-4.9-aufs/fs/fcntl.c 2016-12-31 00:31:52.379789379 +0200 ++++ linux-4.9-aufs-mod/fs/fcntl.c 2016-12-31 00:32:35.154785422 +0200 @@ -82,6 +82,7 @@ int setfl(int fd, struct file * filp, un out: return error; @@ -61,9 +69,9 @@ diff -Nurp linux-4.8-aufs/fs/fcntl.c linux-4.8-aufs-mod/fs/fcntl.c static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, int force) -diff -Nurp linux-4.8-aufs/fs/file_table.c linux-4.8-aufs-mod/fs/file_table.c ---- linux-4.8-aufs/fs/file_table.c 2016-05-16 01:43:13.000000000 +0300 -+++ linux-4.8-aufs-mod/fs/file_table.c 2016-07-04 19:03:53.654714970 +0300 +diff -Nurp linux-4.9-aufs/fs/file_table.c linux-4.9-aufs-mod/fs/file_table.c +--- linux-4.9-aufs/fs/file_table.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/fs/file_table.c 2016-12-31 00:32:35.154785422 +0200 @@ -147,6 +147,7 @@ over: } return ERR_PTR(-ENFILE); @@ -96,10 +104,10 @@ diff -Nurp linux-4.8-aufs/fs/file_table.c linux-4.8-aufs-mod/fs/file_table.c void __init files_init(void) { -diff -Nurp linux-4.8-aufs/fs/inode.c linux-4.8-aufs-mod/fs/inode.c ---- linux-4.8-aufs/fs/inode.c 2016-07-04 19:02:29.261286202 +0300 -+++ linux-4.8-aufs-mod/fs/inode.c 2016-07-04 20:51:39.805168596 +0300 -@@ -1600,6 +1600,7 @@ int update_time(struct inode *inode, str +diff -Nurp linux-4.9-aufs/fs/inode.c linux-4.9-aufs-mod/fs/inode.c +--- linux-4.9-aufs/fs/inode.c 2016-12-31 00:31:52.379789379 +0200 ++++ linux-4.9-aufs-mod/fs/inode.c 2016-12-31 00:32:35.154785422 +0200 +@@ -1651,6 +1651,7 @@ int update_time(struct inode *inode, str return update_time(inode, time, flags); } @@ -107,10 +115,10 @@ diff -Nurp linux-4.8-aufs/fs/inode.c linux-4.8-aufs-mod/fs/inode.c /** * touch_atime - update the access time -diff -Nurp linux-4.8-aufs/fs/namespace.c linux-4.8-aufs-mod/fs/namespace.c ---- linux-4.8-aufs/fs/namespace.c 2016-07-04 17:58:15.729773645 +0300 -+++ linux-4.8-aufs-mod/fs/namespace.c 2016-07-04 19:03:53.654714970 +0300 -@@ -463,6 +463,7 @@ void __mnt_drop_write(struct vfsmount *m +diff -Nurp linux-4.9-aufs/fs/namespace.c linux-4.9-aufs-mod/fs/namespace.c +--- linux-4.9-aufs/fs/namespace.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/fs/namespace.c 2016-12-31 00:32:35.154785422 +0200 +@@ -466,6 +466,7 @@ void __mnt_drop_write(struct vfsmount *m mnt_dec_writers(real_mount(mnt)); preempt_enable(); } @@ -118,7 +126,7 @@ diff -Nurp linux-4.8-aufs/fs/namespace.c linux-4.8-aufs-mod/fs/namespace.c /** * mnt_drop_write - give up write access to a mount -@@ -1812,6 +1813,7 @@ int iterate_mounts(int (*f)(struct vfsmo +@@ -1823,6 +1824,7 @@ int iterate_mounts(int (*f)(struct vfsmo } return 0; } @@ -126,9 +134,9 @@ diff -Nurp linux-4.8-aufs/fs/namespace.c linux-4.8-aufs-mod/fs/namespace.c static void cleanup_group_ids(struct mount *mnt, struct mount *end) { -diff -Nurp linux-4.8-aufs/fs/notify/group.c linux-4.8-aufs-mod/fs/notify/group.c ---- linux-4.8-aufs/fs/notify/group.c 2016-07-04 17:58:15.742773641 +0300 -+++ linux-4.8-aufs-mod/fs/notify/group.c 2016-07-04 19:03:53.655714975 +0300 +diff -Nurp linux-4.9-aufs/fs/notify/group.c linux-4.9-aufs-mod/fs/notify/group.c +--- linux-4.9-aufs/fs/notify/group.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/fs/notify/group.c 2016-12-31 00:32:35.155785422 +0200 @@ -22,6 +22,7 @@ #include #include @@ -137,7 +145,7 @@ diff -Nurp linux-4.8-aufs/fs/notify/group.c linux-4.8-aufs-mod/fs/notify/group.c #include #include "fsnotify.h" -@@ -81,6 +82,7 @@ void fsnotify_get_group(struct fsnotify_ +@@ -100,6 +101,7 @@ void fsnotify_get_group(struct fsnotify_ { atomic_inc(&group->refcnt); } @@ -145,7 +153,7 @@ diff -Nurp linux-4.8-aufs/fs/notify/group.c linux-4.8-aufs-mod/fs/notify/group.c /* * Drop a reference to a group. Free it if it's through. -@@ -90,6 +92,7 @@ void fsnotify_put_group(struct fsnotify_ +@@ -109,6 +111,7 @@ void fsnotify_put_group(struct fsnotify_ if (atomic_dec_and_test(&group->refcnt)) fsnotify_final_destroy_group(group); } @@ -153,7 +161,7 @@ diff -Nurp linux-4.8-aufs/fs/notify/group.c linux-4.8-aufs-mod/fs/notify/group.c /* * Create a new fsnotify_group and hold a reference for the group returned. -@@ -118,6 +121,7 @@ struct fsnotify_group *fsnotify_alloc_gr +@@ -137,6 +140,7 @@ struct fsnotify_group *fsnotify_alloc_gr return group; } @@ -161,9 +169,9 @@ diff -Nurp linux-4.8-aufs/fs/notify/group.c linux-4.8-aufs-mod/fs/notify/group.c int fsnotify_fasync(int fd, struct file *file, int on) { -diff -Nurp linux-4.8-aufs/fs/notify/mark.c linux-4.8-aufs-mod/fs/notify/mark.c ---- linux-4.8-aufs/fs/notify/mark.c 2016-07-04 17:58:15.742773641 +0300 -+++ linux-4.8-aufs-mod/fs/notify/mark.c 2016-07-04 19:03:53.655714975 +0300 +diff -Nurp linux-4.9-aufs/fs/notify/mark.c linux-4.9-aufs-mod/fs/notify/mark.c +--- linux-4.9-aufs/fs/notify/mark.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/fs/notify/mark.c 2016-12-31 00:32:35.155785422 +0200 @@ -113,6 +113,7 @@ void fsnotify_put_mark(struct fsnotify_m mark->free_mark(mark); } @@ -196,9 +204,9 @@ diff -Nurp linux-4.8-aufs/fs/notify/mark.c linux-4.8-aufs-mod/fs/notify/mark.c /* * Nothing fancy, just initialize lists and locks and counters. -diff -Nurp linux-4.8-aufs/fs/open.c linux-4.8-aufs-mod/fs/open.c ---- linux-4.8-aufs/fs/open.c 2016-07-04 17:58:15.746773640 +0300 -+++ linux-4.8-aufs-mod/fs/open.c 2016-07-04 19:03:53.655714975 +0300 +diff -Nurp linux-4.9-aufs/fs/open.c linux-4.9-aufs-mod/fs/open.c +--- linux-4.9-aufs/fs/open.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/fs/open.c 2016-12-31 00:32:35.155785422 +0200 @@ -64,6 +64,7 @@ int do_truncate(struct dentry *dentry, l inode_unlock(dentry->d_inode); return ret; @@ -207,7 +215,7 @@ diff -Nurp linux-4.8-aufs/fs/open.c linux-4.8-aufs-mod/fs/open.c long vfs_truncate(const struct path *path, loff_t length) { -@@ -678,6 +679,7 @@ int open_check_o_direct(struct file *f) +@@ -695,6 +696,7 @@ int open_check_o_direct(struct file *f) } return 0; } @@ -215,9 +223,9 @@ diff -Nurp linux-4.8-aufs/fs/open.c linux-4.8-aufs-mod/fs/open.c static int do_dentry_open(struct file *f, struct inode *inode, -diff -Nurp linux-4.8-aufs/fs/read_write.c linux-4.8-aufs-mod/fs/read_write.c ---- linux-4.8-aufs/fs/read_write.c 2016-07-04 19:02:29.262286207 +0300 -+++ linux-4.8-aufs-mod/fs/read_write.c 2016-07-04 19:03:53.655714975 +0300 +diff -Nurp linux-4.9-aufs/fs/read_write.c linux-4.9-aufs-mod/fs/read_write.c +--- linux-4.9-aufs/fs/read_write.c 2016-12-31 00:31:52.380789379 +0200 ++++ linux-4.9-aufs-mod/fs/read_write.c 2016-12-31 00:32:35.155785422 +0200 @@ -525,6 +525,7 @@ vfs_readf_t vfs_readf(struct file *file) return new_sync_read; return ERR_PTR(-ENOSYS); @@ -234,10 +242,10 @@ diff -Nurp linux-4.8-aufs/fs/read_write.c linux-4.8-aufs-mod/fs/read_write.c ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t *pos) { -diff -Nurp linux-4.8-aufs/fs/splice.c linux-4.8-aufs-mod/fs/splice.c ---- linux-4.8-aufs/fs/splice.c 2016-07-04 19:02:29.262286207 +0300 -+++ linux-4.8-aufs-mod/fs/splice.c 2016-07-04 19:03:53.656714979 +0300 -@@ -1124,6 +1124,7 @@ long do_splice_from(struct pipe_inode_in +diff -Nurp linux-4.9-aufs/fs/splice.c linux-4.9-aufs-mod/fs/splice.c +--- linux-4.9-aufs/fs/splice.c 2016-12-31 00:31:52.380789379 +0200 ++++ linux-4.9-aufs-mod/fs/splice.c 2016-12-31 00:32:35.156785422 +0200 +@@ -868,6 +868,7 @@ long do_splice_from(struct pipe_inode_in return splice_write(pipe, out, ppos, len, flags); } @@ -245,7 +253,7 @@ diff -Nurp linux-4.8-aufs/fs/splice.c linux-4.8-aufs-mod/fs/splice.c /* * Attempt to initiate a splice from a file to a pipe. -@@ -1153,6 +1154,7 @@ long do_splice_to(struct file *in, loff_ +@@ -897,6 +898,7 @@ long do_splice_to(struct file *in, loff_ return splice_read(in, ppos, pipe, len, flags); } @@ -253,29 +261,29 @@ diff -Nurp linux-4.8-aufs/fs/splice.c linux-4.8-aufs-mod/fs/splice.c /** * splice_direct_to_actor - splices data directly between two non-pipes -diff -Nurp linux-4.8-aufs/fs/xattr.c linux-4.8-aufs-mod/fs/xattr.c ---- linux-4.8-aufs/fs/xattr.c 2016-07-04 17:58:15.754773638 +0300 -+++ linux-4.8-aufs-mod/fs/xattr.c 2016-07-04 19:03:53.656714979 +0300 -@@ -207,6 +207,7 @@ vfs_getxattr_alloc(struct dentry *dentry +diff -Nurp linux-4.9-aufs/fs/xattr.c linux-4.9-aufs-mod/fs/xattr.c +--- linux-4.9-aufs/fs/xattr.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/fs/xattr.c 2016-12-31 00:32:35.156785422 +0200 +@@ -296,6 +296,7 @@ vfs_getxattr_alloc(struct dentry *dentry *xattr_value = value; return error; } +EXPORT_SYMBOL_GPL(vfs_getxattr_alloc); ssize_t - vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) -diff -Nurp linux-4.8-aufs/kernel/task_work.c linux-4.8-aufs-mod/kernel/task_work.c ---- linux-4.8-aufs/kernel/task_work.c 2016-05-16 01:43:13.000000000 +0300 -+++ linux-4.8-aufs-mod/kernel/task_work.c 2016-07-04 19:03:53.656714979 +0300 -@@ -118,3 +118,4 @@ void task_work_run(void) + __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name, +diff -Nurp linux-4.9-aufs/kernel/task_work.c linux-4.9-aufs-mod/kernel/task_work.c +--- linux-4.9-aufs/kernel/task_work.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/kernel/task_work.c 2016-12-31 00:32:35.156785422 +0200 +@@ -119,3 +119,4 @@ void task_work_run(void) } while (work); } } +EXPORT_SYMBOL_GPL(task_work_run); -diff -Nurp linux-4.8-aufs/security/commoncap.c linux-4.8-aufs-mod/security/commoncap.c ---- linux-4.8-aufs/security/commoncap.c 2016-07-04 17:58:15.945773585 +0300 -+++ linux-4.8-aufs-mod/security/commoncap.c 2016-07-04 19:03:53.656714979 +0300 -@@ -1058,12 +1058,14 @@ int cap_mmap_addr(unsigned long addr) +diff -Nurp linux-4.9-aufs/security/commoncap.c linux-4.9-aufs-mod/security/commoncap.c +--- linux-4.9-aufs/security/commoncap.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/security/commoncap.c 2016-12-31 00:32:35.156785422 +0200 +@@ -1061,12 +1061,14 @@ int cap_mmap_addr(unsigned long addr) } return ret; } @@ -290,9 +298,9 @@ diff -Nurp linux-4.8-aufs/security/commoncap.c linux-4.8-aufs-mod/security/commo #ifdef CONFIG_SECURITY -diff -Nurp linux-4.8-aufs/security/device_cgroup.c linux-4.8-aufs-mod/security/device_cgroup.c ---- linux-4.8-aufs/security/device_cgroup.c 2016-05-16 01:43:13.000000000 +0300 -+++ linux-4.8-aufs-mod/security/device_cgroup.c 2016-07-04 19:03:53.656714979 +0300 +diff -Nurp linux-4.9-aufs/security/device_cgroup.c linux-4.9-aufs-mod/security/device_cgroup.c +--- linux-4.9-aufs/security/device_cgroup.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/security/device_cgroup.c 2016-12-31 00:32:35.156785422 +0200 @@ -7,6 +7,7 @@ #include #include @@ -309,10 +317,10 @@ diff -Nurp linux-4.8-aufs/security/device_cgroup.c linux-4.8-aufs-mod/security/d int devcgroup_inode_mknod(int mode, dev_t dev) { -diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/security.c ---- linux-4.8-aufs/security/security.c 2016-07-04 17:58:15.948773584 +0300 -+++ linux-4.8-aufs-mod/security/security.c 2016-07-04 19:03:53.657714984 +0300 -@@ -434,6 +434,7 @@ int security_path_rmdir(const struct pat +diff -Nurp linux-4.9-aufs/security/security.c linux-4.9-aufs-mod/security/security.c +--- linux-4.9-aufs/security/security.c 2016-12-11 21:17:54.000000000 +0200 ++++ linux-4.9-aufs-mod/security/security.c 2016-12-31 00:32:35.157785422 +0200 +@@ -443,6 +443,7 @@ int security_path_rmdir(const struct pat return 0; return call_int_hook(path_rmdir, 0, dir, dentry); } @@ -320,7 +328,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_path_unlink(const struct path *dir, struct dentry *dentry) { -@@ -450,6 +451,7 @@ int security_path_symlink(const struct p +@@ -459,6 +460,7 @@ int security_path_symlink(const struct p return 0; return call_int_hook(path_symlink, 0, dir, dentry, old_name); } @@ -328,7 +336,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_path_link(struct dentry *old_dentry, const struct path *new_dir, struct dentry *new_dentry) -@@ -458,6 +460,7 @@ int security_path_link(struct dentry *ol +@@ -467,6 +469,7 @@ int security_path_link(struct dentry *ol return 0; return call_int_hook(path_link, 0, old_dentry, new_dir, new_dentry); } @@ -336,7 +344,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_path_rename(const struct path *old_dir, struct dentry *old_dentry, const struct path *new_dir, struct dentry *new_dentry, -@@ -485,6 +488,7 @@ int security_path_truncate(const struct +@@ -494,6 +497,7 @@ int security_path_truncate(const struct return 0; return call_int_hook(path_truncate, 0, path); } @@ -344,7 +352,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_path_chmod(const struct path *path, umode_t mode) { -@@ -492,6 +496,7 @@ int security_path_chmod(const struct pat +@@ -501,6 +505,7 @@ int security_path_chmod(const struct pat return 0; return call_int_hook(path_chmod, 0, path, mode); } @@ -352,7 +360,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid) { -@@ -499,6 +504,7 @@ int security_path_chown(const struct pat +@@ -508,6 +513,7 @@ int security_path_chown(const struct pat return 0; return call_int_hook(path_chown, 0, path, uid, gid); } @@ -360,7 +368,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_path_chroot(const struct path *path) { -@@ -584,6 +590,7 @@ int security_inode_readlink(struct dentr +@@ -593,6 +599,7 @@ int security_inode_readlink(struct dentr return 0; return call_int_hook(inode_readlink, 0, dentry); } @@ -368,7 +376,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_inode_follow_link(struct dentry *dentry, struct inode *inode, bool rcu) -@@ -599,6 +606,7 @@ int security_inode_permission(struct ino +@@ -608,6 +615,7 @@ int security_inode_permission(struct ino return 0; return call_int_hook(inode_permission, 0, inode, mask); } @@ -376,7 +384,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_inode_setattr(struct dentry *dentry, struct iattr *attr) { -@@ -737,6 +745,7 @@ int security_file_permission(struct file +@@ -779,6 +787,7 @@ int security_file_permission(struct file return fsnotify_perm(file, mask); } @@ -384,7 +392,7 @@ diff -Nurp linux-4.8-aufs/security/security.c linux-4.8-aufs-mod/security/securi int security_file_alloc(struct file *file) { -@@ -796,6 +805,7 @@ int security_mmap_file(struct file *file +@@ -838,6 +847,7 @@ int security_mmap_file(struct file *file return ret; return ima_file_mmap(file, prot); } diff --git a/kernel/kernel/files/patches/mageia/fs-aufs-4.8.patch b/kernel/kernel/files/patches/mageia/fs-aufs-4.9.patch similarity index 97% rename from kernel/kernel/files/patches/mageia/fs-aufs-4.8.patch rename to kernel/kernel/files/patches/mageia/fs-aufs-4.9.patch index 1efb3528..9b0feefe 100644 --- a/kernel/kernel/files/patches/mageia/fs-aufs-4.8.patch +++ b/kernel/kernel/files/patches/mageia/fs-aufs-4.9.patch @@ -1,120 +1,7 @@ - Documentation/ABI/testing/debugfs-aufs | 50 - Documentation/ABI/testing/sysfs-aufs | 31 - Documentation/filesystems/aufs/README | 392 +++ - Documentation/filesystems/aufs/design/01intro.txt | 157 + - Documentation/filesystems/aufs/design/02struct.txt | 245 ++ - Documentation/filesystems/aufs/design/03atomic_open.txt | 72 - Documentation/filesystems/aufs/design/03lookup.txt | 100 - Documentation/filesystems/aufs/design/04branch.txt | 61 - Documentation/filesystems/aufs/design/05wbr_policy.txt | 51 - Documentation/filesystems/aufs/design/06fhsm.txt | 105 - Documentation/filesystems/aufs/design/06mmap.txt | 59 - Documentation/filesystems/aufs/design/06xattr.txt | 81 - Documentation/filesystems/aufs/design/07export.txt | 45 - Documentation/filesystems/aufs/design/08shwh.txt | 39 - Documentation/filesystems/aufs/design/10dynop.txt | 34 - MAINTAINERS | 13 - drivers/block/loop.c | 18 - fs/Kconfig | 1 - fs/Makefile | 1 - fs/aufs/Kconfig | 185 + - fs/aufs/Makefile | 36 - fs/aufs/aufs.h | 46 - fs/aufs/branch.c | 1399 ++++++++++++ - fs/aufs/branch.h | 296 ++ - fs/aufs/cpup.c | 1378 +++++++++++ - fs/aufs/cpup.h | 81 - fs/aufs/dbgaufs.c | 425 +++ - fs/aufs/dbgaufs.h | 35 - fs/aufs/dcsub.c | 212 + - fs/aufs/dcsub.h | 123 + - fs/aufs/debug.c | 427 +++ - fs/aufs/debug.h | 212 + - fs/aufs/dentry.c | 1117 +++++++++ - fs/aufs/dentry.h | 242 ++ - fs/aufs/dinfo.c | 540 ++++ - fs/aufs/dir.c | 749 ++++++ - fs/aufs/dir.h | 124 + - fs/aufs/dynop.c | 358 +++ - fs/aufs/dynop.h | 61 - fs/aufs/export.c | 824 +++++++ - fs/aufs/f_op.c | 759 ++++++ - fs/aufs/fhsm.c | 412 +++ - fs/aufs/file.c | 844 +++++++ - fs/aufs/file.h | 281 ++ - fs/aufs/finfo.c | 138 + - fs/aufs/fstype.h | 387 +++ - fs/aufs/hfsnotify.c | 274 ++ - fs/aufs/hfsplus.c | 43 - fs/aufs/hnotify.c | 710 ++++++ - fs/aufs/i_op.c | 1438 ++++++++++++ - fs/aufs/i_op_add.c | 911 +++++++ - fs/aufs/i_op_del.c | 498 ++++ - fs/aufs/i_op_ren.c | 1002 ++++++++ - fs/aufs/iinfo.c | 272 ++ - fs/aufs/inode.c | 506 ++++ - fs/aufs/inode.h | 687 +++++ - fs/aufs/ioctl.c | 206 + - fs/aufs/loop.c | 134 + - fs/aufs/loop.h | 39 - fs/aufs/magic.mk | 30 - fs/aufs/module.c | 319 ++ - fs/aufs/module.h | 143 + - fs/aufs/mvdown.c | 691 +++++ - fs/aufs/opts.c | 1847 ++++++++++++++++ - fs/aufs/opts.h | 198 + - fs/aufs/plink.c | 501 ++++ - fs/aufs/poll.c | 39 - fs/aufs/posix_acl.c | 85 - fs/aufs/procfs.c | 156 + - fs/aufs/rdu.c | 368 +++ - fs/aufs/rwsem.h | 185 + - fs/aufs/sbinfo.c | 342 ++ - fs/aufs/spl.h | 100 - fs/aufs/super.c | 1025 ++++++++ - fs/aufs/super.h | 625 +++++ - fs/aufs/sysaufs.c | 91 - fs/aufs/sysaufs.h | 88 - fs/aufs/sysfs.c | 340 ++ - fs/aufs/sysrq.c | 144 + - fs/aufs/vdir.c | 887 +++++++ - fs/aufs/vfsub.c | 871 +++++++ - fs/aufs/vfsub.h | 303 ++ - fs/aufs/wbr_policy.c | 752 ++++++ - fs/aufs/whout.c | 1047 +++++++++ - fs/aufs/whout.h | 72 - fs/aufs/wkq.c | 200 + - fs/aufs/wkq.h | 80 - fs/aufs/xattr.c | 334 ++ - fs/aufs/xino.c | 1305 +++++++++++ - fs/dcache.c | 2 - fs/fcntl.c | 4 - fs/inode.c | 2 - fs/proc/base.c | 2 - fs/proc/nommu.c | 5 - fs/proc/task_mmu.c | 7 - fs/proc/task_nommu.c | 5 - fs/read_write.c | 22 - fs/splice.c | 10 - include/linux/file.h | 1 - include/linux/fs.h | 9 - include/linux/mm.h | 22 - include/linux/mm_types.h | 2 - include/linux/splice.h | 6 - include/uapi/linux/Kbuild | 1 - include/uapi/linux/aufs_type.h | 406 +++ - kernel/fork.c | 2 - mm/Makefile | 2 - mm/filemap.c | 2 - mm/memory.c | 2 - mm/mmap.c | 33 - mm/nommu.c | 10 - mm/prfile.c | 86 - 112 files changed, 33747 insertions(+), 30 deletions(-) Documentation/ABI/testing/debugfs-aufs | 50 + Documentation/ABI/testing/sysfs-aufs | 31 + - Documentation/filesystems/aufs/README | 392 +++++ + Documentation/filesystems/aufs/README | 393 +++++ Documentation/filesystems/aufs/design/01intro.txt | 157 ++ Documentation/filesystems/aufs/design/02struct.txt | 245 +++ .../filesystems/aufs/design/03atomic_open.txt | 72 + @@ -136,7 +23,7 @@ fs/aufs/aufs.h | 46 + fs/aufs/branch.c | 1399 +++++++++++++++ fs/aufs/branch.h | 296 ++++ - fs/aufs/cpup.c | 1378 +++++++++++++++ + fs/aufs/cpup.c | 1381 +++++++++++++++ fs/aufs/cpup.h | 81 + fs/aufs/dbgaufs.c | 425 +++++ fs/aufs/dbgaufs.h | 35 + @@ -151,8 +38,8 @@ fs/aufs/dir.h | 124 ++ fs/aufs/dynop.c | 358 ++++ fs/aufs/dynop.h | 61 + - fs/aufs/export.c | 824 +++++++++ - fs/aufs/f_op.c | 759 ++++++++ + fs/aufs/export.c | 823 +++++++++ + fs/aufs/f_op.c | 710 ++++++++ fs/aufs/fhsm.c | 412 +++++ fs/aufs/file.c | 844 +++++++++ fs/aufs/file.h | 281 +++ @@ -161,13 +48,13 @@ fs/aufs/hfsnotify.c | 274 +++ fs/aufs/hfsplus.c | 43 + fs/aufs/hnotify.c | 710 ++++++++ - fs/aufs/i_op.c | 1438 +++++++++++++++ - fs/aufs/i_op_add.c | 911 ++++++++++ + fs/aufs/i_op.c | 1431 +++++++++++++++ + fs/aufs/i_op_add.c | 915 ++++++++++ fs/aufs/i_op_del.c | 498 ++++++ - fs/aufs/i_op_ren.c | 1002 +++++++++++ + fs/aufs/i_op_ren.c | 1152 ++++++++++++ fs/aufs/iinfo.c | 272 +++ fs/aufs/inode.c | 506 ++++++ - fs/aufs/inode.h | 687 ++++++++ + fs/aufs/inode.h | 678 +++++++ fs/aufs/ioctl.c | 206 +++ fs/aufs/loop.c | 134 ++ fs/aufs/loop.h | 39 + @@ -175,8 +62,8 @@ fs/aufs/module.c | 319 ++++ fs/aufs/module.h | 143 ++ fs/aufs/mvdown.c | 691 ++++++++ - fs/aufs/opts.c | 1847 ++++++++++++++++++++ - fs/aufs/opts.h | 198 +++ + fs/aufs/opts.c | 1857 ++++++++++++++++++++ + fs/aufs/opts.h | 200 +++ fs/aufs/plink.c | 501 ++++++ fs/aufs/poll.c | 39 + fs/aufs/posix_acl.c | 85 + @@ -185,21 +72,21 @@ fs/aufs/rwsem.h | 185 ++ fs/aufs/sbinfo.c | 342 ++++ fs/aufs/spl.h | 100 ++ - fs/aufs/super.c | 1025 +++++++++++ - fs/aufs/super.h | 625 +++++++ + fs/aufs/super.c | 1033 +++++++++++ + fs/aufs/super.h | 626 +++++++ fs/aufs/sysaufs.c | 91 + fs/aufs/sysaufs.h | 88 + fs/aufs/sysfs.c | 340 ++++ fs/aufs/sysrq.c | 144 ++ fs/aufs/vdir.c | 887 ++++++++++ - fs/aufs/vfsub.c | 871 +++++++++ + fs/aufs/vfsub.c | 873 +++++++++ fs/aufs/vfsub.h | 303 ++++ - fs/aufs/wbr_policy.c | 752 ++++++++ - fs/aufs/whout.c | 1047 +++++++++++ + fs/aufs/wbr_policy.c | 817 +++++++++ + fs/aufs/whout.c | 1048 +++++++++++ fs/aufs/whout.h | 72 + fs/aufs/wkq.c | 200 +++ fs/aufs/wkq.h | 80 + - fs/aufs/xattr.c | 334 ++++ + fs/aufs/xattr.c | 319 ++++ fs/aufs/xino.c | 1305 ++++++++++++++ fs/dcache.c | 2 +- fs/fcntl.c | 4 +- @@ -224,7 +111,7 @@ mm/mmap.c | 33 +- mm/nommu.c | 10 +- mm/prfile.c | 86 + - 112 files changed, 33747 insertions(+), 30 deletions(-) + 112 files changed, 33913 insertions(+), 30 deletions(-) diff --git a/Documentation/ABI/testing/debugfs-aufs b/Documentation/ABI/testing/debugfs-aufs new file mode 100644 @@ -321,10 +208,10 @@ index 0000000..82f9518 + will be empty. About XINO files, see the aufs manual. diff --git a/Documentation/filesystems/aufs/README b/Documentation/filesystems/aufs/README new file mode 100644 -index 0000000..36df674 +index 0000000..fa82b63 --- /dev/null +++ b/Documentation/filesystems/aufs/README -@@ -0,0 +1,392 @@ +@@ -0,0 +1,393 @@ + +Aufs4 -- advanced multi layered unification filesystem version 4.x +http://aufs.sf.net @@ -700,6 +587,7 @@ index 0000000..36df674 +Daniel Epellei made a donation (2015/1). +OmegaPhil made a donation (2016/1). +Tomasz Szewczyk made a donation (2016/4). ++James Burry made a donation (2016/12). + +Thank you very much. +Donations are always, including future donations, very important and @@ -1839,10 +1727,10 @@ index 0000000..49afc58 +Currently this approach is applied to address_space_operations for +regular files only. diff --git a/MAINTAINERS b/MAINTAINERS -index f593300..8a17054 100644 +index 63cefa6..d78b954 100644 --- a/MAINTAINERS +++ b/MAINTAINERS -@@ -2256,6 +2256,19 @@ F: include/linux/audit.h +@@ -2293,6 +2293,19 @@ F: include/linux/audit.h F: include/uapi/linux/audit.h F: kernel/audit* @@ -1863,7 +1751,7 @@ index f593300..8a17054 100644 M: Miguel Ojeda Sandonis W: http://miguelojeda.es/auxdisplay.htm diff --git a/drivers/block/loop.c b/drivers/block/loop.c -index c9f2107..005e292 100644 +index fa1b7a9..6ee9235 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -701,6 +701,24 @@ static inline int is_loop_device(struct file *file) @@ -1892,10 +1780,10 @@ index c9f2107..005e292 100644 static ssize_t loop_attr_show(struct device *dev, char *page, diff --git a/fs/Kconfig b/fs/Kconfig -index 2bc7ad7..3049386 100644 +index 4bd03a2..620e01b 100644 --- a/fs/Kconfig +++ b/fs/Kconfig -@@ -245,6 +245,7 @@ source "fs/pstore/Kconfig" +@@ -249,6 +249,7 @@ source "fs/pstore/Kconfig" source "fs/sysv/Kconfig" source "fs/ufs/Kconfig" source "fs/exofs/Kconfig" @@ -3906,10 +3794,10 @@ index 0000000..32a4d8f +#endif /* __AUFS_BRANCH_H__ */ diff --git a/fs/aufs/cpup.c b/fs/aufs/cpup.c new file mode 100644 -index 0000000..598a4d6 +index 0000000..5b050ec --- /dev/null +++ b/fs/aufs/cpup.c -@@ -0,0 +1,1378 @@ +@@ -0,0 +1,1381 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -4618,7 +4506,8 @@ index 0000000..598a4d6 + IMustLock(h_dir); + AuDbg("%pd %pd\n", h_dentry, h_path->dentry); + /* no delegation since it is just created */ -+ err = vfsub_rename(h_dir, h_dentry, h_dir, h_path, /*delegated*/NULL); ++ err = vfsub_rename(h_dir, h_dentry, h_dir, h_path, /*delegated*/NULL, ++ /*flags*/0); + dput(h_path->dentry); + +out: @@ -4631,6 +4520,8 @@ index 0000000..598a4d6 + * @len is for truncating when it is -1 copyup the entire file. + * in link/rename cases, @dst_parent may be different from the real one. + * basic->bsrc can be larger than basic->bdst. ++ * aufs doesn't touch the credential so ++ * security_inode_copy_up{,_xattr}() are unnecrssary. + */ +static int au_cpup_single(struct au_cp_generic *cpg, struct dentry *dst_parent) +{ @@ -10080,10 +9971,10 @@ index 0000000..5db2da2 +#endif /* __AUFS_DYNOP_H__ */ diff --git a/fs/aufs/export.c b/fs/aufs/export.c new file mode 100644 -index 0000000..6b5a7be +index 0000000..203f58b --- /dev/null +++ b/fs/aufs/export.c -@@ -0,0 +1,824 @@ +@@ -0,0 +1,823 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -10098,7 +9989,6 @@ index 0000000..6b5a7be +#include +#include +#include -+#include "../fs/mount.h" +#include "aufs.h" + +union conv { @@ -10910,10 +10800,10 @@ index 0000000..6b5a7be +} diff --git a/fs/aufs/f_op.c b/fs/aufs/f_op.c new file mode 100644 -index 0000000..00475fb +index 0000000..139240a --- /dev/null +++ b/fs/aufs/f_op.c -@@ -0,0 +1,759 @@ +@@ -0,0 +1,710 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -11533,54 +11423,6 @@ index 0000000..00475fb + return err; +} + -+/* no one supports this operation, currently */ -+#if 0 -+static int aufs_aio_fsync_nondir(struct kiocb *kio, int datasync) -+{ -+ int err; -+ struct au_write_pre wpre; -+ struct inode *inode, *h_inode; -+ struct file *file, *h_file; -+ -+ err = 0; /* -EBADF; */ /* posix? */ -+ if (unlikely(!(file->f_mode & FMODE_WRITE))) -+ goto out; -+ -+ file = kio->ki_filp; -+ inode = file_inode(file); -+ au_mtx_and_read_lock(inode); -+ -+ h_file = au_write_pre(file, /*do_ready*/1, &wpre); -+ err = PTR_ERR(h_file); -+ if (IS_ERR(h_file)) -+ goto out_unlock; -+ -+ err = -ENOSYS; -+ h_file = au_hf_top(file); -+ if (h_file->f_op->aio_fsync) { -+ h_inode = file_inode(h_file); -+ if (!is_sync_kiocb(kio)) { -+ get_file(h_file); -+ fput(file); -+ } -+ kio->ki_filp = h_file; -+ err = h_file->f_op->aio_fsync(kio, datasync); -+ inode_lock_nested(h_inode, AuLsc_I_CHILD); -+ if (!err) -+ vfsub_update_h_iattr(&h_file->f_path, /*did*/NULL); -+ /*ignore*/ -+ inode_unlock(h_inode); -+ } -+ au_write_post(inode, h_file, &wpre, /*written*/0); -+ -+out_unlock: -+ si_read_unlock(inode->sb); -+ inode_unlock(inode); -+out: -+ return err; -+} -+#endif -+ +static int aufs_fasync(int fd, struct file *file, int flag) +{ + int err; @@ -11661,7 +11503,6 @@ index 0000000..00475fb + .flush = aufs_flush_nondir, + .release = aufs_release_nondir, + .fsync = aufs_fsync_nondir, -+ /* .aio_fsync = aufs_aio_fsync_nondir, */ + .fasync = aufs_fasync, + /* .sendpage = aufs_sendpage, */ + .setfl = aufs_setfl, @@ -14812,10 +14653,10 @@ index 0000000..a05aed8 +} diff --git a/fs/aufs/i_op.c b/fs/aufs/i_op.c new file mode 100644 -index 0000000..c730ec7 +index 0000000..444be461 --- /dev/null +++ b/fs/aufs/i_op.c -@@ -0,0 +1,1438 @@ +@@ -0,0 +1,1431 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -15693,6 +15534,10 @@ index 0000000..c730ec7 + inode = d_inode(dentry); + IMustLock(inode); + ++ err = setattr_prepare(dentry, ia); ++ if (unlikely(err)) ++ goto out; ++ + err = -ENOMEM; + a = kzalloc(sizeof(*a), GFP_NOFS); + if (unlikely(!a)) @@ -15836,8 +15681,8 @@ index 0000000..c730ec7 + return err; +} + -+ssize_t au_srxattr(struct dentry *dentry, struct inode *inode, -+ struct au_srxattr *arg) ++ssize_t au_sxattr(struct dentry *dentry, struct inode *inode, ++ struct au_sxattr *arg) +{ + int err; + struct path h_path; @@ -15871,13 +15716,11 @@ index 0000000..c730ec7 + arg->u.set.name, arg->u.set.value, + arg->u.set.size, arg->u.set.flags); + break; -+ case AU_XATTR_REMOVE: -+ err = vfsub_removexattr(h_path.dentry, arg->u.remove.name); -+ break; + case AU_ACL_SET: + err = -EOPNOTSUPP; + h_inode = d_inode(h_path.dentry); + if (h_inode->i_op->set_acl) ++ /* this will call posix_acl_update_mode */ + err = h_inode->i_op->set_acl(h_inode, + arg->u.acl_set.acl, + arg->u.acl_set.type); @@ -15931,7 +15774,7 @@ index 0000000..c730ec7 +} + +/* -+ * common routine for aufs_getattr() and aufs_getxattr(). ++ * common routine for aufs_getattr() and au_getxattr(). + * returns zero or negative (an error). + * @dentry will be read-locked in success. + */ @@ -16098,7 +15941,7 @@ index 0000000..c730ec7 + err = 0; + AuDbg("%pf\n", h_inode->i_op->get_link); + AuDbgDentry(h_dentry); -+ ret = h_inode->i_op->get_link(h_dentry, h_inode, done); ++ ret = vfs_get_link(h_dentry, done); + dput(h_dentry); + if (IS_ERR(ret)) + err = PTR_ERR(ret); @@ -16192,10 +16035,7 @@ index 0000000..c730ec7 + .getattr = aufs_getattr, + +#ifdef CONFIG_AUFS_XATTR -+ .setxattr = aufs_setxattr, -+ .getxattr = aufs_getxattr, + .listxattr = aufs_listxattr, -+ .removexattr = aufs_removexattr, +#endif + + .readlink = generic_readlink, @@ -16224,10 +16064,7 @@ index 0000000..c730ec7 + .getattr = aufs_getattr, + +#ifdef CONFIG_AUFS_XATTR -+ .setxattr = aufs_setxattr, -+ .getxattr = aufs_getxattr, + .listxattr = aufs_listxattr, -+ .removexattr = aufs_removexattr, +#endif + + .update_time = aufs_update_time, @@ -16245,10 +16082,7 @@ index 0000000..c730ec7 + .getattr = aufs_getattr, + +#ifdef CONFIG_AUFS_XATTR -+ .setxattr = aufs_setxattr, -+ .getxattr = aufs_getxattr, + .listxattr = aufs_listxattr, -+ .removexattr = aufs_removexattr, +#endif + + .update_time = aufs_update_time @@ -16256,10 +16090,10 @@ index 0000000..c730ec7 +}; diff --git a/fs/aufs/i_op_add.c b/fs/aufs/i_op_add.c new file mode 100644 -index 0000000..2a9aa09 +index 0000000..680cd89 --- /dev/null +++ b/fs/aufs/i_op_add.c -@@ -0,0 +1,911 @@ +@@ -0,0 +1,915 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -16961,6 +16795,10 @@ index 0000000..2a9aa09 + goto out_parent; + } + ++ /* ++ * aufs doesn't touch the credential so ++ * security_dentry_create_files_as() is unnecrssary. ++ */ + if (au_opt_test(au_mntflags(sb), PLINK)) { + if (a->bdst < a->bsrc + /* && h_src_dentry->d_sb != a->h_path.dentry->d_sb */) @@ -17677,10 +17515,10 @@ index 0000000..2fe8f07 +} diff --git a/fs/aufs/i_op_ren.c b/fs/aufs/i_op_ren.c new file mode 100644 -index 0000000..43a0909 +index 0000000..dd47c44 --- /dev/null +++ b/fs/aufs/i_op_ren.c -@@ -0,0 +1,1002 @@ +@@ -0,0 +1,1152 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -17695,13 +17533,15 @@ index 0000000..43a0909 +enum { AuSRC, AuDST, AuSrcDst }; +enum { AuPARENT, AuCHILD, AuParentChild }; + -+#define AuRen_ISDIR 1 -+#define AuRen_ISSAMEDIR (1 << 1) -+#define AuRen_WHSRC (1 << 2) -+#define AuRen_WHDST (1 << 3) -+#define AuRen_MNT_WRITE (1 << 4) -+#define AuRen_DT_DSTDIR (1 << 5) -+#define AuRen_DIROPQ (1 << 6) ++#define AuRen_ISDIR_SRC 1 ++#define AuRen_ISDIR_DST (1 << 1) ++#define AuRen_ISSAMEDIR (1 << 2) ++#define AuRen_WHSRC (1 << 3) ++#define AuRen_WHDST (1 << 4) ++#define AuRen_MNT_WRITE (1 << 5) ++#define AuRen_DT_DSTDIR (1 << 6) ++#define AuRen_DIROPQ_SRC (1 << 7) ++#define AuRen_DIROPQ_DST (1 << 8) +#define au_ftest_ren(flags, name) ((flags) & AuRen_##name) +#define au_fset_ren(flags, name) \ + do { (flags) |= AuRen_##name; } while (0) @@ -17713,9 +17553,9 @@ index 0000000..43a0909 + struct dentry *dentry, *h_dentry, *parent, *h_parent, + *wh_dentry; + struct inode *dir, *inode; -+ struct au_hinode *hdir; ++ struct au_hinode *hdir, *hinode; + struct au_dtime dt[AuParentChild]; -+ aufs_bindex_t btop; ++ aufs_bindex_t btop, bdiropq; + } sd[AuSrcDst]; + +#define src_dentry sd[AuSRC].dentry @@ -17726,9 +17566,11 @@ index 0000000..43a0909 +#define src_h_parent sd[AuSRC].h_parent +#define src_wh_dentry sd[AuSRC].wh_dentry +#define src_hdir sd[AuSRC].hdir ++#define src_hinode sd[AuSRC].hinode +#define src_h_dir sd[AuSRC].hdir->hi_inode +#define src_dt sd[AuSRC].dt +#define src_btop sd[AuSRC].btop ++#define src_bdiropq sd[AuSRC].bdiropq + +#define dst_dentry sd[AuDST].dentry +#define dst_dir sd[AuDST].dir @@ -17738,18 +17580,23 @@ index 0000000..43a0909 +#define dst_h_parent sd[AuDST].h_parent +#define dst_wh_dentry sd[AuDST].wh_dentry +#define dst_hdir sd[AuDST].hdir ++#define dst_hinode sd[AuDST].hinode +#define dst_h_dir sd[AuDST].hdir->hi_inode +#define dst_dt sd[AuDST].dt +#define dst_btop sd[AuDST].btop ++#define dst_bdiropq sd[AuDST].bdiropq + + struct dentry *h_trap; + struct au_branch *br; -+ struct au_hinode *src_hinode; + struct path h_path; + struct au_nhash whlist; -+ aufs_bindex_t btgt, src_bwh, src_bdiropq; ++ aufs_bindex_t btgt, src_bwh; + -+ unsigned int flags; ++ struct { ++ unsigned short auren_flags; ++ unsigned char flags; /* syscall parameter */ ++ unsigned char exchange; ++ } __packed; + + struct au_whtmp_rmdir *thargs; + struct dentry *h_dst; @@ -17771,16 +17618,29 @@ index 0000000..43a0909 + err = -EIO; \ +} while (0) + -+static void au_ren_rev_diropq(int err, struct au_ren_args *a) ++static void au_ren_do_rev_diropq(int err, struct au_ren_args *a, int idx) +{ + int rerr; ++ struct dentry *d; ++#define src_or_dst(member) a->sd[idx].member + -+ au_hn_inode_lock_nested(a->src_hinode, AuLsc_I_CHILD); -+ rerr = au_diropq_remove(a->src_dentry, a->btgt); -+ au_hn_inode_unlock(a->src_hinode); -+ au_set_dbdiropq(a->src_dentry, a->src_bdiropq); ++ d = src_or_dst(dentry); /* {src,dst}_dentry */ ++ au_hn_inode_lock_nested(src_or_dst(hinode), AuLsc_I_CHILD); ++ rerr = au_diropq_remove(d, a->btgt); ++ au_hn_inode_unlock(src_or_dst(hinode)); ++ au_set_dbdiropq(d, src_or_dst(bdiropq)); + if (rerr) -+ RevertFailure("remove diropq %pd", a->src_dentry); ++ RevertFailure("remove diropq %pd", d); ++ ++#undef src_or_dst_ ++} ++ ++static void au_ren_rev_diropq(int err, struct au_ren_args *a) ++{ ++ if (au_ftest_ren(a->auren_flags, DIROPQ_SRC)) ++ au_ren_do_rev_diropq(err, a, AuSRC); ++ if (au_ftest_ren(a->auren_flags, DIROPQ_DST)) ++ au_ren_do_rev_diropq(err, a, AuDST); +} + +static void au_ren_rev_rename(int err, struct au_ren_args *a) @@ -17799,7 +17659,7 @@ index 0000000..43a0909 + delegated = NULL; + rerr = vfsub_rename(a->dst_h_dir, + au_h_dptr(a->src_dentry, a->btgt), -+ a->src_h_dir, &a->h_path, &delegated); ++ a->src_h_dir, &a->h_path, &delegated, a->flags); + if (unlikely(rerr == -EWOULDBLOCK)) { + pr_warn("cannot retry for NFSv4 delegation" + " for an internal rename\n"); @@ -17832,7 +17692,7 @@ index 0000000..43a0909 + + delegated = NULL; + rerr = vfsub_rename(a->dst_h_dir, a->h_dst, a->dst_h_dir, &a->h_path, -+ &delegated); ++ &delegated, a->flags); + if (unlikely(rerr == -EWOULDBLOCK)) { + pr_warn("cannot retry for NFSv4 delegation" + " for an internal rename\n"); @@ -17874,13 +17734,11 @@ index 0000000..43a0909 + d = a->src_dentry; + if (au_dbtop(d) == a->btgt) { + a->h_path.dentry = a->dst_h_dentry; -+ if (au_ftest_ren(a->flags, DIROPQ) -+ && au_dbdiropq(d) == a->btgt) -+ au_fclr_ren(a->flags, DIROPQ); + AuDebugOn(au_dbtop(d) != a->btgt); + delegated = NULL; + err = vfsub_rename(a->src_h_dir, au_h_dptr(d, a->btgt), -+ a->dst_h_dir, &a->h_path, &delegated); ++ a->dst_h_dir, &a->h_path, &delegated, ++ a->flags); + if (unlikely(err == -EWOULDBLOCK)) { + pr_warn("cannot retry for NFSv4 delegation" + " for an internal rename\n"); @@ -17924,22 +17782,73 @@ index 0000000..43a0909 +} + +/* make it 'opaque' dir. */ -+static int au_ren_diropq(struct au_ren_args *a) ++static int au_ren_do_diropq(struct au_ren_args *a, int idx) +{ + int err; -+ struct dentry *diropq; ++ struct dentry *d, *diropq; ++#define src_or_dst(member) a->sd[idx].member + + err = 0; -+ a->src_bdiropq = au_dbdiropq(a->src_dentry); -+ a->src_hinode = au_hi(a->src_inode, a->btgt); -+ au_hn_inode_lock_nested(a->src_hinode, AuLsc_I_CHILD); -+ diropq = au_diropq_create(a->src_dentry, a->btgt); -+ au_hn_inode_unlock(a->src_hinode); ++ d = src_or_dst(dentry); /* {src,dst}_dentry */ ++ src_or_dst(bdiropq) = au_dbdiropq(d); ++ src_or_dst(hinode) = au_hi(src_or_dst(inode), a->btgt); ++ au_hn_inode_lock_nested(src_or_dst(hinode), AuLsc_I_CHILD); ++ diropq = au_diropq_create(d, a->btgt); ++ au_hn_inode_unlock(src_or_dst(hinode)); + if (IS_ERR(diropq)) + err = PTR_ERR(diropq); + else + dput(diropq); + ++#undef src_or_dst_ ++ return err; ++} ++ ++static int au_ren_diropq(struct au_ren_args *a) ++{ ++ int err; ++ unsigned char always; ++ struct dentry *d; ++ ++ err = 0; ++ d = a->dst_dentry; /* already renamed on the branch */ ++ always = !!au_opt_test(au_mntflags(d->d_sb), ALWAYS_DIROPQ); ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC) ++ && a->btgt != au_dbdiropq(a->src_dentry) ++ && (a->dst_wh_dentry ++ || a->btgt <= au_dbdiropq(d) ++ /* hide the lower to keep xino */ ++ /* the lowers may not be a dir, but we hide them anyway */ ++ || a->btgt < au_dbbot(d) ++ || always)) { ++ AuDbg("here\n"); ++ err = au_ren_do_diropq(a, AuSRC); ++ if (unlikely(err)) ++ goto out; ++ au_fset_ren(a->auren_flags, DIROPQ_SRC); ++ } ++ if (!a->exchange) ++ goto out; /* success */ ++ ++ d = a->src_dentry; /* already renamed on the branch */ ++ if (au_ftest_ren(a->auren_flags, ISDIR_DST) ++ && a->btgt != au_dbdiropq(a->dst_dentry) ++ && (a->btgt < au_dbdiropq(d) ++ || a->btgt < au_dbbot(d) ++ || always)) { ++ AuDbgDentry(a->src_dentry); ++ AuDbgDentry(a->dst_dentry); ++ err = au_ren_do_diropq(a, AuDST); ++ if (unlikely(err)) ++ goto out_rev_src; ++ au_fset_ren(a->auren_flags, DIROPQ_DST); ++ } ++ goto out; /* success */ ++ ++out_rev_src: ++ AuDbg("err %d, reverting src\n", err); ++ au_ren_rev_diropq(err, a); ++out: + return err; +} + @@ -17948,103 +17857,104 @@ index 0000000..43a0909 + int err; + struct dentry *d, *h_d; + -+ /* prepare workqueue args for asynchronous rmdir */ -+ h_d = a->dst_h_dentry; -+ if (au_ftest_ren(a->flags, ISDIR) && d_is_positive(h_d)) { -+ err = -ENOMEM; -+ a->thargs = au_whtmp_rmdir_alloc(a->src_dentry->d_sb, GFP_NOFS); -+ if (unlikely(!a->thargs)) -+ goto out; -+ a->h_dst = dget(h_d); -+ } ++ if (!a->exchange) { ++ /* prepare workqueue args for asynchronous rmdir */ ++ h_d = a->dst_h_dentry; ++ if (au_ftest_ren(a->auren_flags, ISDIR_DST) ++ && d_is_positive(h_d)) { ++ err = -ENOMEM; ++ a->thargs = au_whtmp_rmdir_alloc(a->src_dentry->d_sb, ++ GFP_NOFS); ++ if (unlikely(!a->thargs)) ++ goto out; ++ a->h_dst = dget(h_d); ++ } + -+ /* create whiteout for src_dentry */ -+ if (au_ftest_ren(a->flags, WHSRC)) { -+ a->src_bwh = au_dbwh(a->src_dentry); -+ AuDebugOn(a->src_bwh >= 0); -+ a->src_wh_dentry -+ = au_wh_create(a->src_dentry, a->btgt, a->src_h_parent); -+ err = PTR_ERR(a->src_wh_dentry); -+ if (IS_ERR(a->src_wh_dentry)) -+ goto out_thargs; -+ } ++ /* create whiteout for src_dentry */ ++ if (au_ftest_ren(a->auren_flags, WHSRC)) { ++ a->src_bwh = au_dbwh(a->src_dentry); ++ AuDebugOn(a->src_bwh >= 0); ++ a->src_wh_dentry = au_wh_create(a->src_dentry, a->btgt, ++ a->src_h_parent); ++ err = PTR_ERR(a->src_wh_dentry); ++ if (IS_ERR(a->src_wh_dentry)) ++ goto out_thargs; ++ } + -+ /* lookup whiteout for dentry */ -+ if (au_ftest_ren(a->flags, WHDST)) { -+ h_d = au_wh_lkup(a->dst_h_parent, &a->dst_dentry->d_name, -+ a->br); -+ err = PTR_ERR(h_d); -+ if (IS_ERR(h_d)) -+ goto out_whsrc; -+ if (d_is_negative(h_d)) -+ dput(h_d); -+ else -+ a->dst_wh_dentry = h_d; -+ } ++ /* lookup whiteout for dentry */ ++ if (au_ftest_ren(a->auren_flags, WHDST)) { ++ h_d = au_wh_lkup(a->dst_h_parent, ++ &a->dst_dentry->d_name, a->br); ++ err = PTR_ERR(h_d); ++ if (IS_ERR(h_d)) ++ goto out_whsrc; ++ if (d_is_negative(h_d)) ++ dput(h_d); ++ else ++ a->dst_wh_dentry = h_d; ++ } + -+ /* rename dentry to tmpwh */ -+ if (a->thargs) { -+ err = au_whtmp_ren(a->dst_h_dentry, a->br); -+ if (unlikely(err)) -+ goto out_whdst; ++ /* rename dentry to tmpwh */ ++ if (a->thargs) { ++ err = au_whtmp_ren(a->dst_h_dentry, a->br); ++ if (unlikely(err)) ++ goto out_whdst; + -+ d = a->dst_dentry; -+ au_set_h_dptr(d, a->btgt, NULL); -+ err = au_lkup_neg(d, a->btgt, /*wh*/0); -+ if (unlikely(err)) -+ goto out_whtmp; -+ a->dst_h_dentry = au_h_dptr(d, a->btgt); ++ d = a->dst_dentry; ++ au_set_h_dptr(d, a->btgt, NULL); ++ err = au_lkup_neg(d, a->btgt, /*wh*/0); ++ if (unlikely(err)) ++ goto out_whtmp; ++ a->dst_h_dentry = au_h_dptr(d, a->btgt); ++ } + } + + BUG_ON(d_is_positive(a->dst_h_dentry) && a->src_btop != a->btgt); + + /* rename by vfs_rename or cpup */ -+ d = a->dst_dentry; -+ if (au_ftest_ren(a->flags, ISDIR) -+ && (a->dst_wh_dentry -+ || au_dbdiropq(d) == a->btgt -+ /* hide the lower to keep xino */ -+ || a->btgt < au_dbbot(d) -+ || au_opt_test(au_mntflags(d->d_sb), ALWAYS_DIROPQ))) -+ au_fset_ren(a->flags, DIROPQ); + err = au_ren_or_cpup(a); + if (unlikely(err)) + /* leave the copied-up one */ + goto out_whtmp; + + /* make dir opaque */ -+ if (au_ftest_ren(a->flags, DIROPQ)) { -+ err = au_ren_diropq(a); -+ if (unlikely(err)) -+ goto out_rename; -+ } ++ err = au_ren_diropq(a); ++ if (unlikely(err)) ++ goto out_rename; + + /* update target timestamps */ ++ if (a->exchange) { ++ AuDebugOn(au_dbtop(a->dst_dentry) != a->btgt); ++ a->h_path.dentry = au_h_dptr(a->dst_dentry, a->btgt); ++ vfsub_update_h_iattr(&a->h_path, /*did*/NULL); /*ignore*/ ++ a->dst_inode->i_ctime = d_inode(a->h_path.dentry)->i_ctime; ++ } + AuDebugOn(au_dbtop(a->src_dentry) != a->btgt); + a->h_path.dentry = au_h_dptr(a->src_dentry, a->btgt); + vfsub_update_h_iattr(&a->h_path, /*did*/NULL); /*ignore*/ + a->src_inode->i_ctime = d_inode(a->h_path.dentry)->i_ctime; + -+ /* remove whiteout for dentry */ -+ if (a->dst_wh_dentry) { -+ a->h_path.dentry = a->dst_wh_dentry; -+ err = au_wh_unlink_dentry(a->dst_h_dir, &a->h_path, -+ a->dst_dentry); -+ if (unlikely(err)) -+ goto out_diropq; ++ if (!a->exchange) { ++ /* remove whiteout for dentry */ ++ if (a->dst_wh_dentry) { ++ a->h_path.dentry = a->dst_wh_dentry; ++ err = au_wh_unlink_dentry(a->dst_h_dir, &a->h_path, ++ a->dst_dentry); ++ if (unlikely(err)) ++ goto out_diropq; ++ } ++ ++ /* remove whtmp */ ++ if (a->thargs) ++ au_ren_del_whtmp(a); /* ignore this error */ ++ ++ au_fhsm_wrote(a->src_dentry->d_sb, a->btgt, /*force*/0); + } -+ -+ /* remove whtmp */ -+ if (a->thargs) -+ au_ren_del_whtmp(a); /* ignore this error */ -+ -+ au_fhsm_wrote(a->src_dentry->d_sb, a->btgt, /*force*/0); + err = 0; + goto out_success; + +out_diropq: -+ if (au_ftest_ren(a->flags, DIROPQ)) -+ au_ren_rev_diropq(err, a); ++ au_ren_rev_diropq(err, a); +out_rename: + au_ren_rev_rename(err, a); + dput(a->h_dst); @@ -18137,7 +18047,7 @@ index 0000000..43a0909 + SiMustAnyLock(d->d_sb); + + err = 0; -+ if (au_ftest_ren(a->flags, ISDIR) && a->dst_inode) { ++ if (au_ftest_ren(a->auren_flags, ISDIR_DST) && a->dst_inode) { + rdhash = au_sbi(d->d_sb)->si_rdhash; + if (!rdhash) + rdhash = au_rdhash_est(au_dir_size(/*file*/NULL, d)); @@ -18145,9 +18055,12 @@ index 0000000..43a0909 + if (unlikely(err)) + goto out; + -+ au_set_dbtop(d, a->dst_btop); -+ err = may_rename_dstdir(d, &a->whlist); -+ au_set_dbtop(d, a->btgt); ++ if (!a->exchange) { ++ au_set_dbtop(d, a->dst_btop); ++ err = may_rename_dstdir(d, &a->whlist); ++ au_set_dbtop(d, a->btgt); ++ } else ++ err = may_rename_srcdir(d, a->btgt); + } + a->dst_h_dentry = au_h_dptr(d, au_dbtop(d)); + if (unlikely(err)) @@ -18155,7 +18068,7 @@ index 0000000..43a0909 + + d = a->src_dentry; + a->src_h_dentry = au_h_dptr(d, au_dbtop(d)); -+ if (au_ftest_ren(a->flags, ISDIR)) { ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC)) { + err = may_rename_srcdir(d, a->btgt); + if (unlikely(err)) { + au_nhash_wh_free(&a->whlist); @@ -18179,7 +18092,7 @@ index 0000000..43a0909 + + if (a->src_btop == a->btgt) { + err = au_may_del(a->src_dentry, a->btgt, a->src_h_parent, -+ au_ftest_ren(a->flags, ISDIR)); ++ au_ftest_ren(a->auren_flags, ISDIR_SRC)); + if (unlikely(err)) + goto out; + err = -EINVAL; @@ -18196,7 +18109,7 @@ index 0000000..43a0909 + goto out; + + err = -EIO; -+ isdir = !!au_ftest_ren(a->flags, ISDIR); ++ isdir = !!au_ftest_ren(a->auren_flags, ISDIR_DST); + if (d_really_is_negative(a->dst_dentry)) { + if (d_is_negative(a->dst_h_dentry)) + err = au_may_add(a->dst_dentry, a->btgt, @@ -18246,7 +18159,7 @@ index 0000000..43a0909 +{ + vfsub_unlock_rename(a->src_h_parent, a->src_hdir, + a->dst_h_parent, a->dst_hdir); -+ if (au_ftest_ren(a->flags, MNT_WRITE)) ++ if (au_ftest_ren(a->auren_flags, MNT_WRITE)) + vfsub_mnt_drop_write(au_br_mnt(a->br)); +} + @@ -18264,7 +18177,7 @@ index 0000000..43a0909 + err = vfsub_mnt_want_write(au_br_mnt(a->br)); + if (unlikely(err)) + goto out; -+ au_fset_ren(a->flags, MNT_WRITE); ++ au_fset_ren(a->auren_flags, MNT_WRITE); + a->h_trap = vfsub_lock_rename(a->src_h_parent, a->src_hdir, + a->dst_h_parent, a->dst_hdir); + udba = au_opt_udba(a->src_dentry->d_sb); @@ -18297,20 +18210,30 @@ index 0000000..43a0909 + + dir = a->dst_dir; + dir->i_version++; -+ if (au_ftest_ren(a->flags, ISDIR)) { ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC)) { + /* is this updating defined in POSIX? */ + au_cpup_attr_timesizes(a->src_inode); + au_cpup_attr_nlink(dir, /*force*/1); + } -+ + au_dir_ts(dir, a->btgt); + -+ if (au_ftest_ren(a->flags, ISSAMEDIR)) ++ if (a->exchange) { ++ dir = a->src_dir; ++ dir->i_version++; ++ if (au_ftest_ren(a->auren_flags, ISDIR_DST)) { ++ /* is this updating defined in POSIX? */ ++ au_cpup_attr_timesizes(a->dst_inode); ++ au_cpup_attr_nlink(dir, /*force*/1); ++ } ++ au_dir_ts(dir, a->btgt); ++ } ++ ++ if (au_ftest_ren(a->auren_flags, ISSAMEDIR)) + return; + + dir = a->src_dir; + dir->i_version++; -+ if (au_ftest_ren(a->flags, ISDIR)) ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC)) + au_cpup_attr_nlink(dir, /*force*/1); + au_dir_ts(dir, a->btgt); +} @@ -18330,13 +18253,16 @@ index 0000000..43a0909 + + i = a->dst_inode; + if (i) { -+ if (!au_ftest_ren(a->flags, ISDIR)) -+ vfsub_drop_nlink(i); -+ else { -+ vfsub_dead_dir(i); -+ au_cpup_attr_timesizes(i); -+ } -+ au_update_dbrange(d, /*do_put_zero*/1); ++ if (!a->exchange) { ++ if (!au_ftest_ren(a->auren_flags, ISDIR_DST)) ++ vfsub_drop_nlink(i); ++ else { ++ vfsub_dead_dir(i); ++ au_cpup_attr_timesizes(i); ++ } ++ au_update_dbrange(d, /*do_put_zero*/1); ++ } else ++ au_cpup_attr_nlink(i, /*force*/1); + } else { + bbot = a->btgt; + for (bindex = au_dbtop(d); bindex < bbot; bindex++) @@ -18348,30 +18274,33 @@ index 0000000..43a0909 + } + + d = a->src_dentry; -+ au_set_dbwh(d, -1); -+ bbot = au_dbbot(d); -+ for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { -+ h_d = au_h_dptr(d, bindex); -+ if (h_d) -+ au_set_h_dptr(d, bindex, NULL); -+ } -+ au_set_dbbot(d, a->btgt); -+ -+ sb = d->d_sb; -+ i = a->src_inode; -+ if (au_opt_test(au_mntflags(sb), PLINK) && au_plink_test(i)) -+ return; /* success */ -+ -+ bbot = au_ibbot(i); -+ for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { -+ h_i = au_h_iptr(i, bindex); -+ if (h_i) { -+ au_xino_write(sb, bindex, h_i->i_ino, /*ino*/0); -+ /* ignore this error */ -+ au_set_h_iptr(i, bindex, NULL, 0); ++ if (!a->exchange) { ++ au_set_dbwh(d, -1); ++ bbot = au_dbbot(d); ++ for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { ++ h_d = au_h_dptr(d, bindex); ++ if (h_d) ++ au_set_h_dptr(d, bindex, NULL); + } ++ au_set_dbbot(d, a->btgt); ++ ++ sb = d->d_sb; ++ i = a->src_inode; ++ if (au_opt_test(au_mntflags(sb), PLINK) && au_plink_test(i)) ++ return; /* success */ ++ ++ bbot = au_ibbot(i); ++ for (bindex = a->btgt + 1; bindex <= bbot; bindex++) { ++ h_i = au_h_iptr(i, bindex); ++ if (h_i) { ++ au_xino_write(sb, bindex, h_i->i_ino, /*ino*/0); ++ /* ignore this error */ ++ au_set_h_iptr(i, bindex, NULL, 0); ++ } ++ } ++ au_set_ibbot(i, a->btgt); + } -+ au_set_ibbot(i, a->btgt); ++ d_drop(a->src_dentry); +} + +/* ---------------------------------------------------------------------- */ @@ -18409,7 +18338,8 @@ index 0000000..43a0909 + + a->src_btop = au_dbtop(a->src_dentry); + a->dst_btop = au_dbtop(a->dst_dentry); -+ if (au_ftest_ren(a->flags, ISDIR)) ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC) ++ || au_ftest_ren(a->auren_flags, ISDIR_DST)) + au_fset_wrdir(wr_dir_args.flags, ISDIR); + wr_dir_args.force_btgt = a->src_btop; + if (a->dst_inode && a->dst_btop < a->src_btop) @@ -18417,6 +18347,8 @@ index 0000000..43a0909 + wr_dir_args.force_btgt = au_wbr(a->dst_dentry, wr_dir_args.force_btgt); + err = au_wr_dir(a->dst_dentry, a->src_dentry, &wr_dir_args); + a->btgt = err; ++ if (a->exchange) ++ au_update_dbtop(a->dst_dentry); + + return err; +} @@ -18425,19 +18357,20 @@ index 0000000..43a0909 +{ + a->h_path.dentry = a->src_h_parent; + au_dtime_store(a->src_dt + AuPARENT, a->src_parent, &a->h_path); -+ if (!au_ftest_ren(a->flags, ISSAMEDIR)) { ++ if (!au_ftest_ren(a->auren_flags, ISSAMEDIR)) { + a->h_path.dentry = a->dst_h_parent; + au_dtime_store(a->dst_dt + AuPARENT, a->dst_parent, &a->h_path); + } + -+ au_fclr_ren(a->flags, DT_DSTDIR); -+ if (!au_ftest_ren(a->flags, ISDIR)) ++ au_fclr_ren(a->auren_flags, DT_DSTDIR); ++ if (!au_ftest_ren(a->auren_flags, ISDIR_SRC) ++ && !a->exchange) + return; + + a->h_path.dentry = a->src_h_dentry; + au_dtime_store(a->src_dt + AuCHILD, a->src_dentry, &a->h_path); + if (d_is_positive(a->dst_h_dentry)) { -+ au_fset_ren(a->flags, DT_DSTDIR); ++ au_fset_ren(a->auren_flags, DT_DSTDIR); + a->h_path.dentry = a->dst_h_dentry; + au_dtime_store(a->dst_dt + AuCHILD, a->dst_dentry, &a->h_path); + } @@ -18449,17 +18382,17 @@ index 0000000..43a0909 + struct inode *h_inode; + + au_dtime_revert(a->src_dt + AuPARENT); -+ if (!au_ftest_ren(a->flags, ISSAMEDIR)) ++ if (!au_ftest_ren(a->auren_flags, ISSAMEDIR)) + au_dtime_revert(a->dst_dt + AuPARENT); + -+ if (au_ftest_ren(a->flags, ISDIR) && err != -EIO) { ++ if (au_ftest_ren(a->auren_flags, ISDIR_SRC) && err != -EIO) { + h_d = a->src_dt[AuCHILD].dt_h_path.dentry; + h_inode = d_inode(h_d); + inode_lock_nested(h_inode, AuLsc_I_CHILD); + au_dtime_revert(a->src_dt + AuCHILD); + inode_unlock(h_inode); + -+ if (au_ftest_ren(a->flags, DT_DSTDIR)) { ++ if (au_ftest_ren(a->auren_flags, DT_DSTDIR)) { + h_d = a->dst_dt[AuCHILD].dt_h_path.dentry; + h_inode = d_inode(h_d); + inode_lock_nested(h_inode, AuLsc_I_CHILD); @@ -18472,22 +18405,30 @@ index 0000000..43a0909 +/* ---------------------------------------------------------------------- */ + +int aufs_rename(struct inode *_src_dir, struct dentry *_src_dentry, -+ struct inode *_dst_dir, struct dentry *_dst_dentry) ++ struct inode *_dst_dir, struct dentry *_dst_dentry, ++ unsigned int _flags) +{ -+ int err, flags; ++ int err, lock_flags; + /* reduce stack space */ + struct au_ren_args *a; ++ struct au_pin pin; + -+ AuDbg("%pd, %pd\n", _src_dentry, _dst_dentry); ++ AuDbg("%pd, %pd, 0x%x\n", _src_dentry, _dst_dentry, _flags); + IMustLock(_src_dir); + IMustLock(_dst_dir); + ++ err = -EINVAL; ++ if (unlikely(_flags & RENAME_WHITEOUT)) ++ goto out; ++ + err = -ENOMEM; + BUILD_BUG_ON(sizeof(*a) > PAGE_SIZE); + a = kzalloc(sizeof(*a), GFP_NOFS); + if (unlikely(!a)) + goto out; + ++ a->flags = _flags; ++ a->exchange = _flags & RENAME_EXCHANGE; + a->src_dir = _src_dir; + a->src_dentry = _src_dentry; + a->src_inode = NULL; @@ -18501,20 +18442,33 @@ index 0000000..43a0909 + a->dst_inode = d_inode(a->dst_dentry); + a->dst_parent = a->dst_dentry->d_parent; /* dir inode is locked */ + if (a->dst_inode) { -+ IMustLock(a->dst_inode); ++ /* ++ * if EXCHANGE && src is non-dir && dst is dir, ++ * dst is not locked. ++ */ ++ /* IMustLock(a->dst_inode); */ + au_igrab(a->dst_inode); + } + + err = -ENOTDIR; -+ flags = AuLock_FLUSH | AuLock_NOPLM | AuLock_GEN; ++ lock_flags = AuLock_FLUSH | AuLock_NOPLM | AuLock_GEN; + if (d_is_dir(a->src_dentry)) { -+ au_fset_ren(a->flags, ISDIR); -+ if (unlikely(d_really_is_positive(a->dst_dentry) ++ au_fset_ren(a->auren_flags, ISDIR_SRC); ++ if (unlikely(!a->exchange ++ && d_really_is_positive(a->dst_dentry) + && !d_is_dir(a->dst_dentry))) + goto out_free; -+ flags |= AuLock_DIRS; ++ lock_flags |= AuLock_DIRS; + } -+ err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry, flags); ++ if (a->dst_inode && d_is_dir(a->dst_dentry)) { ++ au_fset_ren(a->auren_flags, ISDIR_DST); ++ if (unlikely(!a->exchange ++ && d_really_is_positive(a->src_dentry) ++ && !d_is_dir(a->src_dentry))) ++ goto out_free; ++ lock_flags |= AuLock_DIRS; ++ } ++ err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry, lock_flags); + if (unlikely(err)) + goto out_free; + @@ -18524,14 +18478,14 @@ index 0000000..43a0909 + err = -ENOENT; + if (a->dst_inode) { + /* -+ * If it is a dir, VFS unhash dst_dentry before this ++ * If it is a dir, VFS unhash it before this + * function. It means we cannot rely upon d_unhashed(). + */ + if (unlikely(!a->dst_inode->i_nlink)) + goto out_unlock; -+ if (!S_ISDIR(a->dst_inode->i_mode)) { ++ if (!au_ftest_ren(a->auren_flags, ISDIR_DST)) { + err = au_d_hashed_positive(a->dst_dentry); -+ if (unlikely(err)) ++ if (unlikely(err && !a->exchange)) + goto out_unlock; + } else if (unlikely(IS_DEADDIR(a->dst_inode))) + goto out_unlock; @@ -18547,7 +18501,7 @@ index 0000000..43a0909 + if (unlikely(d_inode(a->dst_parent) == d_inode(a->src_dentry))) + goto out_unlock; + -+ au_fset_ren(a->flags, ISSAMEDIR); /* temporary */ ++ au_fset_ren(a->auren_flags, ISSAMEDIR); /* temporary */ + di_write_lock_parent(a->dst_parent); + + /* which branch we process */ @@ -18564,39 +18518,43 @@ index 0000000..43a0909 + + /* prepare the writable parent dir on the same branch */ + if (a->dst_btop == a->btgt) { -+ au_fset_ren(a->flags, WHDST); ++ au_fset_ren(a->auren_flags, WHDST); + } else { + err = au_cpup_dirs(a->dst_dentry, a->btgt); + if (unlikely(err)) + goto out_children; + } + -+ if (a->src_dir != a->dst_dir) { -+ /* -+ * this temporary unlock is safe, -+ * because both dir->i_mutex are locked. -+ */ -+ di_write_unlock(a->dst_parent); -+ di_write_lock_parent(a->src_parent); -+ err = au_wr_dir_need_wh(a->src_dentry, -+ au_ftest_ren(a->flags, ISDIR), -+ &a->btgt); -+ di_write_unlock(a->src_parent); -+ di_write_lock2_parent(a->src_parent, a->dst_parent, /*isdir*/1); -+ au_fclr_ren(a->flags, ISSAMEDIR); -+ } else -+ err = au_wr_dir_need_wh(a->src_dentry, -+ au_ftest_ren(a->flags, ISDIR), -+ &a->btgt); ++ err = 0; ++ if (!a->exchange) { ++ if (a->src_dir != a->dst_dir) { ++ /* ++ * this temporary unlock is safe, ++ * because both dir->i_mutex are locked. ++ */ ++ di_write_unlock(a->dst_parent); ++ di_write_lock_parent(a->src_parent); ++ err = au_wr_dir_need_wh(a->src_dentry, ++ au_ftest_ren(a->auren_flags, ++ ISDIR_SRC), ++ &a->btgt); ++ di_write_unlock(a->src_parent); ++ di_write_lock2_parent(a->src_parent, a->dst_parent, ++ /*isdir*/1); ++ au_fclr_ren(a->auren_flags, ISSAMEDIR); ++ } else ++ err = au_wr_dir_need_wh(a->src_dentry, ++ au_ftest_ren(a->auren_flags, ++ ISDIR_SRC), ++ &a->btgt); ++ } + if (unlikely(err < 0)) + goto out_children; + if (err) -+ au_fset_ren(a->flags, WHSRC); ++ au_fset_ren(a->auren_flags, WHSRC); + + /* cpup src */ + if (a->src_btop != a->btgt) { -+ struct au_pin pin; -+ + err = au_pin(&pin, a->src_dentry, a->btgt, + au_opt_udba(a->src_dentry->d_sb), + AuPin_DI_LOCKED | AuPin_MNT_WRITE); @@ -18617,7 +18575,32 @@ index 0000000..43a0909 + goto out_children; + a->src_btop = a->btgt; + a->src_h_dentry = au_h_dptr(a->src_dentry, a->btgt); -+ au_fset_ren(a->flags, WHSRC); ++ if (!a->exchange) ++ au_fset_ren(a->auren_flags, WHSRC); ++ } ++ ++ /* cpup dst */ ++ if (a->exchange && a->dst_inode ++ && a->dst_btop != a->btgt) { ++ err = au_pin(&pin, a->dst_dentry, a->btgt, ++ au_opt_udba(a->dst_dentry->d_sb), ++ AuPin_DI_LOCKED | AuPin_MNT_WRITE); ++ if (!err) { ++ struct au_cp_generic cpg = { ++ .dentry = a->dst_dentry, ++ .bdst = a->btgt, ++ .bsrc = a->dst_btop, ++ .len = -1, ++ .pin = &pin, ++ .flags = AuCpup_DTIME | AuCpup_HOPEN ++ }; ++ err = au_sio_cpup_simple(&cpg); ++ au_unpin(&pin); ++ } ++ if (unlikely(err)) ++ goto out_children; ++ a->dst_btop = a->btgt; ++ a->dst_h_dentry = au_h_dptr(a->dst_dentry, a->btgt); + } + + /* lock them all */ @@ -18626,12 +18609,14 @@ index 0000000..43a0909 + /* leave the copied-up one */ + goto out_children; + -+ if (!au_opt_test(au_mntflags(a->dst_dir->i_sb), UDBA_NONE)) -+ err = au_may_ren(a); -+ else if (unlikely(a->dst_dentry->d_name.len > AUFS_MAX_NAMELEN)) -+ err = -ENAMETOOLONG; -+ if (unlikely(err)) -+ goto out_hdir; ++ if (!a->exchange) { ++ if (!au_opt_test(au_mntflags(a->dst_dir->i_sb), UDBA_NONE)) ++ err = au_may_ren(a); ++ else if (unlikely(a->dst_dentry->d_name.len > AUFS_MAX_NAMELEN)) ++ err = -ENAMETOOLONG; ++ if (unlikely(err)) ++ goto out_hdir; ++ } + + /* store timestamps to be revertible */ + au_ren_dt(a); @@ -18661,14 +18646,17 @@ index 0000000..43a0909 + au_set_dbtop(a->dst_dentry, a->dst_btop); + } +out_parent: -+ if (!err) -+ d_move(a->src_dentry, a->dst_dentry); -+ else { ++ if (!err) { ++ if (!a->exchange) ++ d_move(a->src_dentry, a->dst_dentry); ++ else ++ d_exchange(a->src_dentry, a->dst_dentry); ++ } else { + au_update_dbtop(a->dst_dentry); + if (!a->dst_inode) + d_drop(a->dst_dentry); + } -+ if (au_ftest_ren(a->flags, ISSAMEDIR)) ++ if (au_ftest_ren(a->auren_flags, ISSAMEDIR)) + di_write_unlock(a->dst_parent); + else + di_write_unlock2(a->src_parent, a->dst_parent); @@ -19475,10 +19463,10 @@ index 0000000..8f7446d +} diff --git a/fs/aufs/inode.h b/fs/aufs/inode.h new file mode 100644 -index 0000000..33d9f5e +index 0000000..b9e3039 --- /dev/null +++ b/fs/aufs/inode.h -@@ -0,0 +1,687 @@ +@@ -0,0 +1,678 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -19706,7 +19694,8 @@ index 0000000..33d9f5e +/* i_op_ren.c */ +int au_wbr(struct dentry *dentry, aufs_bindex_t btgt); +int aufs_rename(struct inode *src_dir, struct dentry *src_dentry, -+ struct inode *dir, struct dentry *dentry); ++ struct inode *dir, struct dentry *dentry, ++ unsigned int flags); + +/* iinfo.c */ +struct inode *au_h_iptr(struct inode *inode, aufs_bindex_t bindex); @@ -19779,17 +19768,11 @@ index 0000000..33d9f5e +int au_cpup_xattr(struct dentry *h_dst, struct dentry *h_src, int ignore_flags, + unsigned int verbose); +ssize_t aufs_listxattr(struct dentry *dentry, char *list, size_t size); -+ssize_t aufs_getxattr(struct dentry *dentry, struct inode *inode, -+ const char *name, void *value, size_t size); -+int aufs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, -+ const void *value, size_t size, int flags); -+int aufs_removexattr(struct dentry *dentry, const char *name); -+ -+/* void au_xattr_init(struct super_block *sb); */ ++void au_xattr_init(struct super_block *sb); +#else +AuStubInt0(au_cpup_xattr, struct dentry *h_dst, struct dentry *h_src, + int ignore_flags, unsigned int verbose); -+/* AuStubVoid(au_xattr_init, struct super_block *sb); */ ++AuStubVoid(au_xattr_init, struct super_block *sb); +#endif + +#ifdef CONFIG_FS_POSIX_ACL @@ -19800,11 +19783,10 @@ index 0000000..33d9f5e +#if IS_ENABLED(CONFIG_AUFS_XATTR) || IS_ENABLED(CONFIG_FS_POSIX_ACL) +enum { + AU_XATTR_SET, -+ AU_XATTR_REMOVE, + AU_ACL_SET +}; + -+struct au_srxattr { ++struct au_sxattr { + int type; + union { + struct { @@ -19814,16 +19796,13 @@ index 0000000..33d9f5e + int flags; + } set; + struct { -+ const char *name; -+ } remove; -+ struct { + struct posix_acl *acl; + int type; + } acl_set; + } u; +}; -+ssize_t au_srxattr(struct dentry *dentry, struct inode *inode, -+ struct au_srxattr *arg); ++ssize_t au_sxattr(struct dentry *dentry, struct inode *inode, ++ struct au_sxattr *arg); +#endif + +/* ---------------------------------------------------------------------- */ @@ -21772,10 +21751,10 @@ index 0000000..b0e5b84 +} diff --git a/fs/aufs/opts.c b/fs/aufs/opts.c new file mode 100644 -index 0000000..1d21f0d +index 0000000..8d9461d --- /dev/null +++ b/fs/aufs/opts.c -@@ -0,0 +1,1847 @@ +@@ -0,0 +1,1857 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -22189,6 +22168,10 @@ index 0000000..1d21f0d + {AuWbrCreate_MFSV, "mfs:%d"}, + {AuWbrCreate_MFSV, "most-free-space:%d"}, + ++ /* top-down regardless the parent, and then mfs */ ++ {AuWbrCreate_TDMFS, "tdmfs:%d"}, ++ {AuWbrCreate_TDMFSV, "tdmfs:%d:%d"}, ++ + {AuWbrCreate_MFSRR, "mfsrr:%d"}, + {AuWbrCreate_MFSRRV, "mfsrr:%d:%d"}, + {AuWbrCreate_PMFS, "pmfs"}, @@ -22264,6 +22247,7 @@ index 0000000..1d21f0d + create->wbr_create = err; + switch (err) { + case AuWbrCreate_MFSRRV: ++ case AuWbrCreate_TDMFSV: + case AuWbrCreate_PMFSRRV: + e = au_wbr_mfs_wmark(&args[0], str, create); + if (!e) @@ -22272,6 +22256,7 @@ index 0000000..1d21f0d + err = e; + break; + case AuWbrCreate_MFSRR: ++ case AuWbrCreate_TDMFS: + case AuWbrCreate_PMFSRR: + e = au_wbr_mfs_wmark(&args[0], str, create); + if (unlikely(e)) { @@ -22482,10 +22467,12 @@ index 0000000..1d21f0d + AuDbg("%d sec\n", u.create->mfs_second); + break; + case AuWbrCreate_MFSRR: ++ case AuWbrCreate_TDMFS: + AuDbg("%llu watermark\n", + u.create->mfsrr_watermark); + break; + case AuWbrCreate_MFSRRV: ++ case AuWbrCreate_TDMFSV: + case AuWbrCreate_PMFSRRV: + AuDbg("%llu watermark, %d sec\n", + u.create->mfsrr_watermark, @@ -23051,6 +23038,8 @@ index 0000000..1d21f0d + switch (create->wbr_create) { + case AuWbrCreate_MFSRRV: + case AuWbrCreate_MFSRR: ++ case AuWbrCreate_TDMFS: ++ case AuWbrCreate_TDMFSV: + case AuWbrCreate_PMFSRR: + case AuWbrCreate_PMFSRRV: + sbinfo->si_wbr_mfs.mfsrr_watermark = create->mfsrr_watermark; @@ -23625,10 +23614,10 @@ index 0000000..1d21f0d +} diff --git a/fs/aufs/opts.h b/fs/aufs/opts.h new file mode 100644 -index 0000000..0d6c2e1 +index 0000000..c7323ee --- /dev/null +++ b/fs/aufs/opts.h -@@ -0,0 +1,198 @@ +@@ -0,0 +1,200 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -23717,6 +23706,8 @@ index 0000000..0d6c2e1 + AuWbrCreate_MFSV, /* mfs with seconds */ + AuWbrCreate_MFSRR, /* mfs then rr */ + AuWbrCreate_MFSRRV, /* mfs then rr with seconds */ ++ AuWbrCreate_TDMFS, /* top down regardless parent and mfs */ ++ AuWbrCreate_TDMFSV, /* top down regardless parent and mfs */ + AuWbrCreate_PMFS, /* parent and mfs */ + AuWbrCreate_PMFSV, /* parent and mfs with seconds */ + AuWbrCreate_PMFSRR, /* parent, mfs and round-robin */ @@ -24381,7 +24372,7 @@ index 0000000..dd2baf5 +} diff --git a/fs/aufs/posix_acl.c b/fs/aufs/posix_acl.c new file mode 100644 -index 0000000..1ee17ee +index 0000000..81510b9 --- /dev/null +++ b/fs/aufs/posix_acl.c @@ -0,0 +1,85 @@ @@ -24437,7 +24428,7 @@ index 0000000..1ee17ee + int err; + ssize_t ssz; + struct dentry *dentry; -+ struct au_srxattr arg = { ++ struct au_sxattr arg = { + .type = AU_ACL_SET, + .u.acl_set = { + .acl = acl, @@ -24461,7 +24452,7 @@ index 0000000..1ee17ee + } + } + -+ ssz = au_srxattr(dentry, inode, &arg); ++ ssz = au_sxattr(dentry, inode, &arg); + dput(dentry); + err = ssz; + if (ssz >= 0) @@ -25653,10 +25644,10 @@ index 0000000..8f519db3 +#endif /* __AUFS_SPL_H__ */ diff --git a/fs/aufs/super.c b/fs/aufs/super.c new file mode 100644 -index 0000000..58a773c +index 0000000..0082ce4 --- /dev/null +++ b/fs/aufs/super.c -@@ -0,0 +1,1025 @@ +@@ -0,0 +1,1033 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -25764,15 +25755,31 @@ index 0000000..58a773c + return err; +} + ++static void au_gen_fmt(char *fmt, int len __maybe_unused, const char *pat, ++ const char *append) ++{ ++ char *p; ++ ++ p = fmt; ++ while (*pat != ':') ++ *p++ = *pat++; ++ *p++ = *pat++; ++ strcpy(p, append); ++ AuDebugOn(strlen(fmt) >= len); ++} ++ +static void au_show_wbr_create(struct seq_file *m, int v, + struct au_sbinfo *sbinfo) +{ + const char *pat; ++ char fmt[32]; ++ struct au_wbr_mfs *mfs; + + AuRwMustAnyLock(&sbinfo->si_rwsem); + + seq_puts(m, ",create="); + pat = au_optstr_wbr_create(v); ++ mfs = &sbinfo->si_wbr_mfs; + switch (v) { + case AuWbrCreate_TDP: + case AuWbrCreate_RR: @@ -25780,36 +25787,28 @@ index 0000000..58a773c + case AuWbrCreate_PMFS: + seq_puts(m, pat); + break; -+ case AuWbrCreate_MFSV: -+ seq_printf(m, /*pat*/"mfs:%lu", -+ jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire) -+ / MSEC_PER_SEC); -+ break; -+ case AuWbrCreate_PMFSV: -+ seq_printf(m, /*pat*/"pmfs:%lu", -+ jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire) -+ / MSEC_PER_SEC); -+ break; + case AuWbrCreate_MFSRR: -+ seq_printf(m, /*pat*/"mfsrr:%llu", -+ sbinfo->si_wbr_mfs.mfsrr_watermark); ++ case AuWbrCreate_TDMFS: ++ case AuWbrCreate_PMFSRR: ++ au_gen_fmt(fmt, sizeof(fmt), pat, "%llu"); ++ seq_printf(m, fmt, mfs->mfsrr_watermark); ++ break; ++ case AuWbrCreate_MFSV: ++ case AuWbrCreate_PMFSV: ++ au_gen_fmt(fmt, sizeof(fmt), pat, "%lu"); ++ seq_printf(m, fmt, ++ jiffies_to_msecs(mfs->mfs_expire) ++ / MSEC_PER_SEC); + break; + case AuWbrCreate_MFSRRV: -+ seq_printf(m, /*pat*/"mfsrr:%llu:%lu", -+ sbinfo->si_wbr_mfs.mfsrr_watermark, -+ jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire) -+ / MSEC_PER_SEC); -+ break; -+ case AuWbrCreate_PMFSRR: -+ seq_printf(m, /*pat*/"pmfsrr:%llu", -+ sbinfo->si_wbr_mfs.mfsrr_watermark); -+ break; ++ case AuWbrCreate_TDMFSV: + case AuWbrCreate_PMFSRRV: -+ seq_printf(m, /*pat*/"pmfsrr:%llu:%lu", -+ sbinfo->si_wbr_mfs.mfsrr_watermark, -+ jiffies_to_msecs(sbinfo->si_wbr_mfs.mfs_expire) -+ / MSEC_PER_SEC); ++ au_gen_fmt(fmt, sizeof(fmt), pat, "%llu:%lu"); ++ seq_printf(m, fmt, mfs->mfsrr_watermark, ++ jiffies_to_msecs(mfs->mfs_expire) / MSEC_PER_SEC); + break; ++ default: ++ BUG(); + } +} + @@ -26569,7 +26568,7 @@ index 0000000..58a773c + sb->s_maxbytes = 0; + sb->s_stack_depth = 1; + au_export_init(sb); -+ /* au_xattr_init(sb); */ ++ au_xattr_init(sb); + + err = alloc_root(sb); + if (unlikely(err)) { @@ -26684,10 +26683,10 @@ index 0000000..58a773c +}; diff --git a/fs/aufs/super.h b/fs/aufs/super.h new file mode 100644 -index 0000000..e4ac866 +index 0000000..ba614b3 --- /dev/null +++ b/fs/aufs/super.h -@@ -0,0 +1,625 @@ +@@ -0,0 +1,626 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -26932,6 +26931,7 @@ index 0000000..e4ac866 +#define AuLock_IW (1 << 2) /* write-lock inode */ +#define AuLock_FLUSH (1 << 3) /* wait for 'nowait' tasks */ +#define AuLock_DIRS (1 << 4) /* target is a pair of dirs */ ++ /* except RENAME_EXCHANGE */ +#define AuLock_NOPLM (1 << 5) /* return err in plm mode */ +#define AuLock_NOPLMW (1 << 6) /* wait for plm mode ends */ +#define AuLock_GEN (1 << 7) /* test digen/iigen */ @@ -28895,10 +28895,10 @@ index 0000000..b2eb4c0 +} diff --git a/fs/aufs/vfsub.c b/fs/aufs/vfsub.c new file mode 100644 -index 0000000..2e54bad +index 0000000..f2c500b --- /dev/null +++ b/fs/aufs/vfsub.c -@@ -0,0 +1,871 @@ +@@ -0,0 +1,873 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -28911,7 +28911,9 @@ index 0000000..2e54bad +#include +#include +#include ++#ifdef CONFIG_AUFS_BR_FUSE +#include "../fs/mount.h" ++#endif +#include "aufs.h" + +#ifdef CONFIG_AUFS_BR_FUSE @@ -29271,7 +29273,7 @@ index 0000000..2e54bad + +int vfsub_rename(struct inode *src_dir, struct dentry *src_dentry, + struct inode *dir, struct path *path, -+ struct inode **delegated_inode) ++ struct inode **delegated_inode, unsigned int flags) +{ + int err; + struct path tmp = { @@ -29292,7 +29294,7 @@ index 0000000..2e54bad + + lockdep_off(); + err = vfs_rename(src_dir, src_dentry, dir, path->dentry, -+ delegated_inode, /*flags*/0); ++ delegated_inode, flags); + lockdep_on(); + if (!err) { + int did; @@ -29772,7 +29774,7 @@ index 0000000..2e54bad +} diff --git a/fs/aufs/vfsub.h b/fs/aufs/vfsub.h new file mode 100644 -index 0000000..64fff0f +index 0000000..c9df32c --- /dev/null +++ b/fs/aufs/vfsub.h @@ -0,0 +1,303 @@ @@ -29928,7 +29930,7 @@ index 0000000..64fff0f + struct path *path, struct inode **delegated_inode); +int vfsub_rename(struct inode *src_hdir, struct dentry *src_dentry, + struct inode *hdir, struct path *path, -+ struct inode **delegated_inode); ++ struct inode **delegated_inode, unsigned int flags); +int vfsub_mkdir(struct inode *dir, struct path *path, int mode); +int vfsub_rmdir(struct inode *dir, struct path *path); + @@ -30081,10 +30083,10 @@ index 0000000..64fff0f +#endif /* __AUFS_VFSUB_H__ */ diff --git a/fs/aufs/wbr_policy.c b/fs/aufs/wbr_policy.c new file mode 100644 -index 0000000..79eb9b4 +index 0000000..438a8da --- /dev/null +++ b/fs/aufs/wbr_policy.c -@@ -0,0 +1,752 @@ +@@ -0,0 +1,817 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -30591,6 +30593,61 @@ index 0000000..79eb9b4 + +/* ---------------------------------------------------------------------- */ + ++/* top down regardless parent, and then mfs */ ++static int au_wbr_create_tdmfs(struct dentry *dentry, ++ unsigned int flags __maybe_unused) ++{ ++ int err; ++ aufs_bindex_t bwh, btail, bindex, bfound, bmfs; ++ unsigned long long watermark; ++ struct super_block *sb; ++ struct au_wbr_mfs *mfs; ++ struct au_branch *br; ++ struct dentry *parent; ++ ++ sb = dentry->d_sb; ++ mfs = &au_sbi(sb)->si_wbr_mfs; ++ mutex_lock(&mfs->mfs_lock); ++ if (time_after(jiffies, mfs->mfs_jiffy + mfs->mfs_expire) ++ || mfs->mfs_bindex < 0) ++ au_mfs(dentry, /*parent*/NULL); ++ watermark = mfs->mfsrr_watermark; ++ bmfs = mfs->mfs_bindex; ++ mutex_unlock(&mfs->mfs_lock); ++ ++ /* another style of au_wbr_create_exp() */ ++ bwh = au_dbwh(dentry); ++ parent = dget_parent(dentry); ++ btail = au_dbtaildir(parent); ++ if (bwh >= 0 && bwh < btail) ++ btail = bwh; ++ ++ err = au_wbr_nonopq(dentry, btail); ++ if (unlikely(err < 0)) ++ goto out; ++ btail = err; ++ bfound = -1; ++ for (bindex = 0; bindex <= btail; bindex++) { ++ br = au_sbr(sb, bindex); ++ if (au_br_rdonly(br)) ++ continue; ++ if (br->br_wbr->wbr_bytes > watermark) { ++ bfound = bindex; ++ break; ++ } ++ } ++ err = bfound; ++ if (err < 0) ++ err = bmfs; ++ ++out: ++ dput(parent); ++ AuDbg("b%d\n", err); ++ return err; ++} ++ ++/* ---------------------------------------------------------------------- */ ++ +/* most free space and then round robin */ +static int au_wbr_create_mfsrr(struct dentry *dentry, unsigned int flags) +{ @@ -30816,6 +30873,16 @@ index 0000000..79eb9b4 + .init = au_wbr_create_init_mfsrr, + .fin = au_wbr_create_fin_mfs + }, ++ [AuWbrCreate_TDMFS] = { ++ .create = au_wbr_create_tdmfs, ++ .init = au_wbr_create_init_mfs, ++ .fin = au_wbr_create_fin_mfs ++ }, ++ [AuWbrCreate_TDMFSV] = { ++ .create = au_wbr_create_tdmfs, ++ .init = au_wbr_create_init_mfs, ++ .fin = au_wbr_create_fin_mfs ++ }, + [AuWbrCreate_PMFS] = { + .create = au_wbr_create_pmfs, + .init = au_wbr_create_init_mfs, @@ -30839,10 +30906,10 @@ index 0000000..79eb9b4 +}; diff --git a/fs/aufs/whout.c b/fs/aufs/whout.c new file mode 100644 -index 0000000..54feb08 +index 0000000..2fa8627 --- /dev/null +++ b/fs/aufs/whout.c -@@ -0,0 +1,1047 @@ +@@ -0,0 +1,1048 @@ +/* + * Copyright (C) 2005-2016 Junjiro R. Okajima + */ @@ -31023,7 +31090,8 @@ index 0000000..54feb08 + + /* under the same dir, no need to lock_rename() */ + delegated = NULL; -+ err = vfsub_rename(h_dir, h_dentry, h_dir, &h_path, &delegated); ++ err = vfsub_rename(h_dir, h_dentry, h_dir, &h_path, &delegated, ++ /*flags*/0); + AuTraceErr(err); + if (unlikely(err == -EWOULDBLOCK)) { + pr_warn("cannot retry for NFSv4 delegation" @@ -32262,10 +32330,10 @@ index 0000000..6d63f74 +#endif /* __AUFS_WKQ_H__ */ diff --git a/fs/aufs/xattr.c b/fs/aufs/xattr.c new file mode 100644 -index 0000000..2a148c9 +index 0000000..1daba20 --- /dev/null +++ b/fs/aufs/xattr.c -@@ -0,0 +1,334 @@ +@@ -0,0 +1,319 @@ +/* + * Copyright (C) 2014-2016 Junjiro R. Okajima + */ @@ -32519,8 +32587,9 @@ index 0000000..2a148c9 + return au_lgxattr(dentry, &arg); +} + -+ssize_t aufs_getxattr(struct dentry *dentry, struct inode *inode __maybe_unused, -+ const char *name, void *value, size_t size) ++static ssize_t au_getxattr(struct dentry *dentry, ++ struct inode *inode __maybe_unused, ++ const char *name, void *value, size_t size) +{ + struct au_lgxattr arg = { + .type = AU_XATTR_GET, @@ -32534,10 +32603,11 @@ index 0000000..2a148c9 + return au_lgxattr(dentry, &arg); +} + -+int aufs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, -+ const void *value, size_t size, int flags) ++static int au_setxattr(struct dentry *dentry, struct inode *inode, ++ const char *name, const void *value, size_t size, ++ int flags) +{ -+ struct au_srxattr arg = { ++ struct au_sxattr arg = { + .type = AU_XATTR_SET, + .u.set = { + .name = name, @@ -32547,59 +32617,42 @@ index 0000000..2a148c9 + }, + }; + -+ return au_srxattr(dentry, inode, &arg); -+} -+ -+int aufs_removexattr(struct dentry *dentry, const char *name) -+{ -+ struct au_srxattr arg = { -+ .type = AU_XATTR_REMOVE, -+ .u.remove = { -+ .name = name -+ }, -+ }; -+ -+ return au_srxattr(dentry, d_inode(dentry), &arg); ++ return au_sxattr(dentry, inode, &arg); +} + +/* ---------------------------------------------------------------------- */ + -+#if 0 -+static size_t au_xattr_list(struct dentry *dentry, char *list, size_t list_size, -+ const char *name, size_t name_len, int type) ++static int au_xattr_get(const struct xattr_handler *handler, ++ struct dentry *dentry, struct inode *inode, ++ const char *name, void *buffer, size_t size) +{ -+ return aufs_listxattr(dentry, list, list_size); ++ return au_getxattr(dentry, inode, name, buffer, size); +} + -+static int au_xattr_get(struct dentry *dentry, const char *name, void *buffer, -+ size_t size, int type) ++static int au_xattr_set(const struct xattr_handler *handler, ++ struct dentry *dentry, struct inode *inode, ++ const char *name, const void *value, size_t size, ++ int flags) +{ -+ return aufs_getxattr(dentry, name, buffer, size); -+} -+ -+static int au_xattr_set(struct dentry *dentry, const char *name, -+ const void *value, size_t size, int flags, int type) -+{ -+ return aufs_setxattr(dentry, name, value, size, flags); ++ return au_setxattr(dentry, inode, name, value, size, flags); +} + +static const struct xattr_handler au_xattr_handler = { -+ /* no prefix, no flags */ -+ .list = au_xattr_list, ++ .name = "", ++ .prefix = "", + .get = au_xattr_get, + .set = au_xattr_set -+ /* why no remove? */ +}; + +static const struct xattr_handler *au_xattr_handlers[] = { -+ &au_xattr_handler ++ &au_xattr_handler, ++ NULL +}; + +void au_xattr_init(struct super_block *sb) +{ -+ /* sb->s_xattr = au_xattr_handlers; */ ++ sb->s_xattr = au_xattr_handlers; +} -+#endif diff --git a/fs/aufs/xino.c b/fs/aufs/xino.c new file mode 100644 index 0000000..2a411f9 @@ -33947,10 +34000,10 @@ index 350a2c8..6f42279 100644 return error; diff --git a/fs/inode.c b/fs/inode.c -index 7e3ef3a..675fe84 100644 +index 88110fd..9a9ba3a 100644 --- a/fs/inode.c +++ b/fs/inode.c -@@ -1593,7 +1593,7 @@ EXPORT_SYMBOL(generic_update_time); +@@ -1642,7 +1642,7 @@ EXPORT_SYMBOL(generic_update_time); * This does the actual work of updating an inodes time or version. Must have * had called mnt_want_write() before calling this. */ @@ -33960,10 +34013,10 @@ index 7e3ef3a..675fe84 100644 int (*update_time)(struct inode *, struct timespec *, int); diff --git a/fs/proc/base.c b/fs/proc/base.c -index ac0df4d..42255e5 100644 +index ca651ac..0e8551a 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c -@@ -1938,7 +1938,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path) +@@ -1953,7 +1953,7 @@ static int map_files_get_link(struct dentry *dentry, struct path *path) down_read(&mm->mmap_sem); vma = find_exact_vma(mm, vm_start, vm_end); if (vma && vma->vm_file) { @@ -33989,10 +34042,10 @@ index f8595e8..cb8eda0 100644 ino = inode->i_ino; } diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c -index f6fa99e..2750949 100644 +index 35b92d8..5b981db 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c -@@ -298,7 +298,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) +@@ -291,7 +291,10 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid) const char *name = NULL; if (file) { @@ -34004,7 +34057,7 @@ index f6fa99e..2750949 100644 dev = inode->i_sb->s_dev; ino = inode->i_ino; pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT; -@@ -1634,7 +1637,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) +@@ -1627,7 +1630,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid) struct proc_maps_private *proc_priv = &numa_priv->proc_maps; struct vm_area_struct *vma = v; struct numa_maps *md = &numa_priv->md; @@ -34014,10 +34067,10 @@ index f6fa99e..2750949 100644 struct mm_walk walk = { .hugetlb_entry = gather_hugetlb_stats, diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c -index faacb0c..17b43be 100644 +index 3717562..6a328f1 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c -@@ -163,7 +163,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, +@@ -155,7 +155,10 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma, file = vma->vm_file; if (file) { @@ -34030,7 +34083,7 @@ index faacb0c..17b43be 100644 ino = inode->i_ino; pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT; diff --git a/fs/read_write.c b/fs/read_write.c -index 66215a7..a1da117 100644 +index 190e0d36..4052813 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -515,6 +515,28 @@ ssize_t __vfs_write(struct file *file, const char __user *p, size_t count, @@ -34063,10 +34116,10 @@ index 66215a7..a1da117 100644 { mm_segment_t old_fs; diff --git a/fs/splice.c b/fs/splice.c -index dd9bf7e..9326c2a 100644 +index 5a7750b..28160a7 100644 --- a/fs/splice.c +++ b/fs/splice.c -@@ -1111,8 +1111,8 @@ EXPORT_SYMBOL(generic_splice_sendpage); +@@ -855,8 +855,8 @@ EXPORT_SYMBOL(generic_splice_sendpage); /* * Attempt to initiate a splice from pipe to file. */ @@ -34077,7 +34130,7 @@ index dd9bf7e..9326c2a 100644 { ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); -@@ -1128,9 +1128,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, +@@ -872,9 +872,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out, /* * Attempt to initiate a splice from a file to a pipe. */ @@ -34103,10 +34156,10 @@ index 7444f5f..bdac0be 100644 static inline void fput_light(struct file *file, int fput_needed) { diff --git a/include/linux/fs.h b/include/linux/fs.h -index 901e25d..a71aa9e 100644 +index dc0478c..27c05e7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h -@@ -1275,6 +1275,7 @@ extern void fasync_free(struct fasync_struct *); +@@ -1291,6 +1291,7 @@ extern void fasync_free(struct fasync_struct *); /* can be called from interrupts */ extern void kill_fasync(struct fasync_struct **, int, int); @@ -34114,7 +34167,7 @@ index 901e25d..a71aa9e 100644 extern void __f_setown(struct file *filp, struct pid *, enum pid_type, int force); extern void f_setown(struct file *filp, unsigned long arg, int force); extern void f_delown(struct file *filp); -@@ -1699,6 +1700,7 @@ struct file_operations { +@@ -1715,6 +1716,7 @@ struct file_operations { ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); int (*check_flags)(int); @@ -34122,7 +34175,7 @@ index 901e25d..a71aa9e 100644 int (*flock) (struct file *, int, struct file_lock *); ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); -@@ -1759,6 +1761,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, +@@ -1768,6 +1770,12 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, struct iovec *fast_pointer, struct iovec **ret_pointer); @@ -34135,7 +34188,7 @@ index 901e25d..a71aa9e 100644 extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *); extern ssize_t __vfs_write(struct file *, const char __user *, size_t, loff_t *); extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); -@@ -2123,6 +2131,7 @@ extern int current_umask(void); +@@ -2140,6 +2148,7 @@ extern int current_umask(void); extern void ihold(struct inode * inode); extern void iput(struct inode *); extern int generic_update_time(struct inode *, struct timespec *, int); @@ -34144,10 +34197,10 @@ index 901e25d..a71aa9e 100644 /* /sys/fs */ extern struct kobject *fs_kobj; diff --git a/include/linux/mm.h b/include/linux/mm.h -index ef815b9..a772481 100644 +index a92c8d7..1d83a2a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h -@@ -1278,6 +1278,28 @@ static inline int fixup_user_fault(struct task_struct *tsk, +@@ -1266,6 +1266,28 @@ static inline int fixup_user_fault(struct task_struct *tsk, } #endif @@ -34173,11 +34226,11 @@ index ef815b9..a772481 100644 +#define vmr_fput(region) vmr_do_fput(region, __func__, __LINE__) +#endif /* !CONFIG_MMU */ + - extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write); + extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, + unsigned int gup_flags); extern int access_remote_vm(struct mm_struct *mm, unsigned long addr, - void *buf, int len, int write); diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h -index 903200f..55fc528 100644 +index 4a8aced..badd16b 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -275,6 +275,7 @@ struct vm_region { @@ -34197,13 +34250,13 @@ index 903200f..55fc528 100644 #ifndef CONFIG_MMU diff --git a/include/linux/splice.h b/include/linux/splice.h -index da2751d..2e0fca6 100644 +index 00a2116..1f0a4a2 100644 --- a/include/linux/splice.h +++ b/include/linux/splice.h -@@ -83,4 +83,10 @@ extern void splice_shrink_spd(struct splice_pipe_desc *); - extern void spd_release_page(struct splice_pipe_desc *, unsigned int); +@@ -86,4 +86,10 @@ extern void spd_release_page(struct splice_pipe_desc *, unsigned int); extern const struct pipe_buf_operations page_cache_pipe_buf_ops; + extern const struct pipe_buf_operations default_pipe_buf_ops; + +extern long do_splice_from(struct pipe_inode_info *pipe, struct file *out, + loff_t *ppos, size_t len, unsigned int flags); @@ -34212,7 +34265,7 @@ index da2751d..2e0fca6 100644 + unsigned int flags); #endif diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild -index 185f8ea..5deb0d1 100644 +index cd2be1c..78f3c68 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild @@ -59,6 +59,7 @@ header-y += atmsvc.h @@ -34225,7 +34278,7 @@ index 185f8ea..5deb0d1 100644 header-y += auxvec.h diff --git a/include/uapi/linux/aufs_type.h b/include/uapi/linux/aufs_type.h new file mode 100644 -index 0000000..e220283 +index 0000000..b036c0a --- /dev/null +++ b/include/uapi/linux/aufs_type.h @@ -0,0 +1,406 @@ @@ -34257,7 +34310,7 @@ index 0000000..e220283 + +#include + -+#define AUFS_VERSION "4.8" ++#define AUFS_VERSION "4.9" + +/* todo? move this to linux-2.6.19/include/magic.h */ +#define AUFS_SUPER_MAGIC ('a' << 24 | 'u' << 16 | 'f' << 8 | 's') @@ -34636,10 +34689,10 @@ index 0000000..e220283 + +#endif /* __AUFS_TYPE_H__ */ diff --git a/kernel/fork.c b/kernel/fork.c -index beb3172..ad4cfa8 100644 +index 997ac1d..4d0131b 100644 --- a/kernel/fork.c +++ b/kernel/fork.c -@@ -477,7 +477,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) +@@ -624,7 +624,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, struct inode *inode = file_inode(file); struct address_space *mapping = file->f_mapping; @@ -34649,10 +34702,10 @@ index beb3172..ad4cfa8 100644 atomic_dec(&inode->i_writecount); i_mmap_lock_write(mapping); diff --git a/mm/Makefile b/mm/Makefile -index 2ca1faf..6b9da3f 100644 +index 295bd7a..14fa1c8 100644 --- a/mm/Makefile +++ b/mm/Makefile -@@ -40,7 +40,7 @@ obj-y := filemap.o mempool.o oom_kill.o \ +@@ -37,7 +37,7 @@ obj-y := filemap.o mempool.o oom_kill.o \ mm_init.o mmu_context.o percpu.o slab_common.o \ compaction.o vmacache.o \ interval_tree.o list_lru.o workingset.o \ @@ -34662,10 +34715,10 @@ index 2ca1faf..6b9da3f 100644 obj-y += init-mm.o diff --git a/mm/filemap.c b/mm/filemap.c -index 2d0986a..4a31bad 100644 +index 50b52fe..9e607f9 100644 --- a/mm/filemap.c +++ b/mm/filemap.c -@@ -2284,7 +2284,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) +@@ -2304,7 +2304,7 @@ int filemap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) int ret = VM_FAULT_LOCKED; sb_start_pagefault(inode->i_sb); @@ -34675,10 +34728,10 @@ index 2d0986a..4a31bad 100644 if (page->mapping != inode->i_mapping) { unlock_page(page); diff --git a/mm/memory.c b/mm/memory.c -index 793fe0f..45f39f3 100644 +index e18c57b..7be4a39 100644 --- a/mm/memory.c +++ b/mm/memory.c -@@ -2113,7 +2113,7 @@ static inline int wp_page_reuse(struct fault_env *fe, pte_t orig_pte, +@@ -2117,7 +2117,7 @@ static inline int wp_page_reuse(struct fault_env *fe, pte_t orig_pte, } if (!page_mkwrite) @@ -34688,10 +34741,10 @@ index 793fe0f..45f39f3 100644 return VM_FAULT_WRITE; diff --git a/mm/mmap.c b/mm/mmap.c -index ca9d91b..f3ebc5a 100644 +index 1af87c1..95b0ff4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c -@@ -163,7 +163,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma) +@@ -170,7 +170,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma) if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); if (vma->vm_file) @@ -34700,7 +34753,7 @@ index ca9d91b..f3ebc5a 100644 mpol_put(vma_policy(vma)); kmem_cache_free(vm_area_cachep, vma); return next; -@@ -790,7 +790,7 @@ again: +@@ -879,7 +879,7 @@ int __vma_adjust(struct vm_area_struct *vma, unsigned long start, if (remove_next) { if (file) { uprobe_munmap(next, next->vm_start, next->vm_end); @@ -34709,7 +34762,7 @@ index ca9d91b..f3ebc5a 100644 } if (next->anon_vma) anon_vma_merge(vma, next); -@@ -1574,8 +1574,8 @@ out: +@@ -1727,8 +1727,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr, return addr; unmap_and_free_vma: @@ -34719,7 +34772,7 @@ index ca9d91b..f3ebc5a 100644 /* Undo any partial mapping done by a device driver. */ unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end); -@@ -2380,7 +2380,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, +@@ -2533,7 +2533,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, goto out_free_mpol; if (new->vm_file) @@ -34728,7 +34781,7 @@ index ca9d91b..f3ebc5a 100644 if (new->vm_ops && new->vm_ops->open) new->vm_ops->open(new); -@@ -2399,7 +2399,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, +@@ -2552,7 +2552,7 @@ static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma, if (new->vm_ops && new->vm_ops->close) new->vm_ops->close(new); if (new->vm_file) @@ -34737,7 +34790,7 @@ index ca9d91b..f3ebc5a 100644 unlink_anon_vmas(new); out_free_mpol: mpol_put(vma_policy(new)); -@@ -2550,7 +2550,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, +@@ -2703,7 +2703,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, struct vm_area_struct *vma; unsigned long populate = 0; unsigned long ret = -EINVAL; @@ -34746,7 +34799,7 @@ index ca9d91b..f3ebc5a 100644 pr_warn_once("%s (%d) uses deprecated remap_file_pages() syscall. See Documentation/vm/remap_file_pages.txt.\n", current->comm, current->pid); -@@ -2625,10 +2625,27 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, +@@ -2778,10 +2778,27 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size, } } @@ -34775,7 +34828,7 @@ index ca9d91b..f3ebc5a 100644 out: up_write(&mm->mmap_sem); if (populate) -@@ -2903,7 +2920,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, +@@ -3056,7 +3073,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap, if (anon_vma_clone(new_vma, vma)) goto out_free_mempol; if (new_vma->vm_file) @@ -34785,10 +34838,10 @@ index ca9d91b..f3ebc5a 100644 new_vma->vm_ops->open(new_vma); vma_link(mm, new_vma, prev, rb_link, rb_parent); diff --git a/mm/nommu.c b/mm/nommu.c -index 95daf81..5086a29 100644 +index 8b8faaf..5d26ed94 100644 --- a/mm/nommu.c +++ b/mm/nommu.c -@@ -644,7 +644,7 @@ static void __put_nommu_region(struct vm_region *region) +@@ -636,7 +636,7 @@ static void __put_nommu_region(struct vm_region *region) up_write(&nommu_region_sem); if (region->vm_file) @@ -34797,7 +34850,7 @@ index 95daf81..5086a29 100644 /* IO memory and memory shared directly out of the pagecache * from ramfs/tmpfs mustn't be released here */ -@@ -802,7 +802,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma) +@@ -794,7 +794,7 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma) if (vma->vm_ops && vma->vm_ops->close) vma->vm_ops->close(vma); if (vma->vm_file) @@ -34806,7 +34859,7 @@ index 95daf81..5086a29 100644 put_nommu_region(vma->vm_region); kmem_cache_free(vm_area_cachep, vma); } -@@ -1328,7 +1328,7 @@ unsigned long do_mmap(struct file *file, +@@ -1320,7 +1320,7 @@ unsigned long do_mmap(struct file *file, goto error_just_free; } } @@ -34815,7 +34868,7 @@ index 95daf81..5086a29 100644 kmem_cache_free(vm_region_jar, region); region = pregion; result = start; -@@ -1403,10 +1403,10 @@ error_just_free: +@@ -1395,10 +1395,10 @@ unsigned long do_mmap(struct file *file, up_write(&nommu_region_sem); error: if (region->vm_file) diff --git a/kernel/kernel/files/patches/mageia/fs-seq_file-reset-iterator-to-first-record-for-zero-off.patch b/kernel/kernel/files/patches/mageia/fs-seq_file-reset-iterator-to-first-record-for-zero-off.patch new file mode 100644 index 00000000..b0cc86e3 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/fs-seq_file-reset-iterator-to-first-record-for-zero-off.patch @@ -0,0 +1,44 @@ +From e522751d605d99a81508e58390a8f51ee96fb662 Mon Sep 17 00:00:00 2001 +From: Tomasz Majchrzak +Date: Tue, 29 Nov 2016 15:18:20 +0100 +Subject: [PATCH] seq_file: reset iterator to first record for zero offset + +If kernfs file is empty on a first read, successive read operations +using the same file descriptor will return no data, even when data is +available. Default kernfs 'seq_next' implementation advances iterator +position even when next object is not there. Kernfs 'seq_start' for +following requests will not return iterator as position is already on +the second object. + +This defect doesn't allow to monitor badblocks sysfs files from MD raid. +They are initially empty but if data appears at some stage, userspace is +not able to read it. + +Signed-off-by: Tomasz Majchrzak +Signed-off-by: Miklos Szeredi +Signed-off-by: Al Viro +--- + fs/seq_file.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/fs/seq_file.c b/fs/seq_file.c +index 368bfb9..a11f271 100644 +--- a/fs/seq_file.c ++++ b/fs/seq_file.c +@@ -190,6 +190,13 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) + */ + m->version = file->f_version; + ++ /* ++ * if request is to read from zero offset, reset iterator to first ++ * record as it might have been already advanced by previous requests ++ */ ++ if (*ppos == 0) ++ m->index = 0; ++ + /* Don't assume *ppos is where we left it */ + if (unlikely(*ppos != m->read_pos)) { + while ((err = traverse(m, *ppos)) == -EAGAIN) +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/gpu-drm-i915-Remove-WaDisableLSQCROPERFforOCL-KBL-workaround.patch b/kernel/kernel/files/patches/mageia/gpu-drm-i915-Remove-WaDisableLSQCROPERFforOCL-KBL-workaround.patch new file mode 100644 index 00000000..7a90bae2 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/gpu-drm-i915-Remove-WaDisableLSQCROPERFforOCL-KBL-workaround.patch @@ -0,0 +1,97 @@ +From 8726f2faa371514fba2f594d799db95203dfeee0 Mon Sep 17 00:00:00 2001 +From: Francisco Jerez +Date: Thu, 12 Jan 2017 12:44:54 +0200 +Subject: drm/i915: Remove WaDisableLSQCROPERFforOCL KBL workaround. + +The WaDisableLSQCROPERFforOCL workaround has the side effect of +disabling an L3SQ optimization that has huge performance implications +and is unlikely to be necessary for the correct functioning of usual +graphic workloads. Userspace is free to re-enable the workaround on +demand, and is generally in a better position to determine whether the +workaround is necessary than the DRM is (e.g. only during the +execution of compute kernels that rely on both L3 fences and HDC R/W +requests). + +The same workaround seems to apply to BDW (at least to production +stepping G1) and SKL as well (the internal workaround database claims +that it does for all steppings, while the BSpec workaround table only +mentions pre-production steppings), but the DRM doesn't do anything +beyond whitelisting the L3SQCREG4 register so userspace can enable it +when it sees fit. Do the same on KBL platforms. + +Improves performance of the GFXBench4 gl_manhattan31 benchmark by 60%, +and gl_4 (AKA car chase) by 14% on a KBL GT2 running Mesa master -- +This is followed by a regression of 35% and 10% respectively for the +same benchmarks and platform caused by my recent patch series +switching userspace to use the dataport constant cache instead of the +sampler to implement uniform pull constant loads, which caused us to +hit more heavily the L3 cache (and on platforms other than KBL had the +opposite effect of improving performance of the same two benchmarks). +The overall effect on KBL of this change combined with the recent +userspace change is respectively 4.6% and 2.6%. SynMark2 OglShMapPcf +was affected by the constant cache changes (though it improved as it +did on other platforms rather than regressing), but is not +significantly affected by this patch (with statistical significance of +5% and sample size 20). + +v2: Drop some more code to avoid unused variable warning. + +Fixes: 738fa1b3123f ("drm/i915/kbl: Add WaDisableLSQCROPERFforOCL") +Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99256 +Signed-off-by: Francisco Jerez +Cc: Matthew Auld +Cc: Eero Tamminen +Cc: Jani Nikula +Cc: Mika Kuoppala +Cc: beignet@lists.freedesktop.org +Cc: # v4.7+ +Reviewed-by: Mika Kuoppala +[Removed double Fixes tag] +Signed-off-by: Mika Kuoppala +Link: http://patchwork.freedesktop.org/patch/msgid/1484217894-20505-1-git-send-email-mika.kuoppala@intel.com + +diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c +index db714dc..8acab87 100644 +--- a/drivers/gpu/drm/i915/intel_lrc.c ++++ b/drivers/gpu/drm/i915/intel_lrc.c +@@ -970,18 +970,8 @@ static inline int gen8_emit_flush_coherentl3_wa(struct intel_engine_cs *engine, + uint32_t *batch, + uint32_t index) + { +- struct drm_i915_private *dev_priv = engine->i915; + uint32_t l3sqc4_flush = (0x40400000 | GEN8_LQSC_FLUSH_COHERENT_LINES); + +- /* +- * WaDisableLSQCROPERFforOCL:kbl +- * This WA is implemented in skl_init_clock_gating() but since +- * this batch updates GEN8_L3SQCREG4 with default value we need to +- * set this bit here to retain the WA during flush. +- */ +- if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_E0)) +- l3sqc4_flush |= GEN8_LQSC_RO_PERF_DIS; +- + wa_ctx_emit(batch, index, (MI_STORE_REGISTER_MEM_GEN8 | + MI_SRM_LRM_GLOBAL_GTT)); + wa_ctx_emit_reg(batch, index, GEN8_L3SQCREG4); +diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c +index ab83fc2..49fa800 100644 +--- a/drivers/gpu/drm/i915/intel_ringbuffer.c ++++ b/drivers/gpu/drm/i915/intel_ringbuffer.c +@@ -1095,14 +1095,6 @@ static int kbl_init_workarounds(struct intel_engine_cs *engine) + WA_SET_BIT_MASKED(HDC_CHICKEN0, + HDC_FENCE_DEST_SLM_DISABLE); + +- /* GEN8_L3SQCREG4 has a dependency with WA batch so any new changes +- * involving this register should also be added to WA batch as required. +- */ +- if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_E0)) +- /* WaDisableLSQCROPERFforOCL:kbl */ +- I915_WRITE(GEN8_L3SQCREG4, I915_READ(GEN8_L3SQCREG4) | +- GEN8_LQSC_RO_PERF_DIS); +- + /* WaToEnableHwFixForPushConstHWBug:kbl */ + if (IS_KBL_REVID(dev_priv, KBL_REVID_C0, REVID_FOREVER)) + WA_SET_BIT_MASKED(COMMON_SLICE_CHICKEN2, +-- +cgit v0.10.2 + diff --git a/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-A0-and-B0-revisions.patch b/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-A0-and-B0-revisions.patch new file mode 100644 index 00000000..8cdf7198 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-A0-and-B0-revisions.patch @@ -0,0 +1,127 @@ +From a117f378f44150e6d13d2f19740fb757425b651f Mon Sep 17 00:00:00 2001 +From: Jani Nikula +Date: Fri, 16 Sep 2016 16:59:44 +0300 +Subject: drm/i915/skl: drop workarounds for A0 and B0 revisions + +Pre-production hardware is not supported. + +Reviewed-by: Paulo Zanoni +Signed-off-by: Jani Nikula +Link: http://patchwork.freedesktop.org/patch/msgid/7929af62a68504c84038a8db1625bd96ebaa9e6f.1474034059.git.jani.nikula@intel.com + +diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c +index 0568fb5..57da2b7 100644 +--- a/drivers/gpu/drm/i915/intel_dp.c ++++ b/drivers/gpu/drm/i915/intel_dp.c +@@ -1299,10 +1299,6 @@ bool intel_dp_source_supports_hbr2(struct intel_dp *intel_dp) + struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); + struct drm_device *dev = dig_port->base.base.dev; + +- /* WaDisableHBR2:skl */ +- if (IS_SKL_REVID(dev, 0, SKL_REVID_B0)) +- return false; +- + if ((IS_HASWELL(dev) && !IS_HSW_ULX(dev)) || IS_BROADWELL(dev) || + (INTEL_INFO(dev)->gen >= 9)) + return true; +diff --git a/drivers/gpu/drm/i915/intel_dp_link_training.c b/drivers/gpu/drm/i915/intel_dp_link_training.c +index c438b02..0048b52 100644 +--- a/drivers/gpu/drm/i915/intel_dp_link_training.c ++++ b/drivers/gpu/drm/i915/intel_dp_link_training.c +@@ -225,9 +225,6 @@ static u32 intel_dp_training_pattern(struct intel_dp *intel_dp) + * Intel platforms that support HBR2 also support TPS3. TPS3 support is + * also mandatory for downstream devices that support HBR2. However, not + * all sinks follow the spec. +- * +- * Due to WaDisableHBR2 SKL < B0 is the only exception where TPS3 is +- * supported in source but still not enabled. + */ + source_tps3 = intel_dp_source_supports_hbr2(intel_dp); + sink_tps3 = drm_dp_tps3_supported(intel_dp->dpcd); +diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c +index 6fd39ef..acc1dbd 100644 +--- a/drivers/gpu/drm/i915/intel_guc_loader.c ++++ b/drivers/gpu/drm/i915/intel_guc_loader.c +@@ -375,9 +375,8 @@ static int guc_ucode_xfer(struct drm_i915_private *dev_priv) + /* Enable MIA caching. GuC clock gating is disabled. */ + I915_WRITE(GUC_SHIM_CONTROL, GUC_SHIM_CONTROL_VALUE); + +- /* WaDisableMinuteIaClockGating:skl,bxt */ +- if (IS_SKL_REVID(dev, 0, SKL_REVID_B0) || +- IS_BXT_REVID(dev, 0, BXT_REVID_A1)) { ++ /* WaDisableMinuteIaClockGating:bxt */ ++ if (IS_BXT_REVID(dev, 0, BXT_REVID_A1)) { + I915_WRITE(GUC_SHIM_CONTROL, (I915_READ(GUC_SHIM_CONTROL) & + ~GUC_ENABLE_MIA_CLOCK_GATING)); + } +diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c +index 39417b7..47f7afa 100644 +--- a/drivers/gpu/drm/i915/intel_lrc.c ++++ b/drivers/gpu/drm/i915/intel_lrc.c +@@ -269,8 +269,7 @@ logical_ring_init_platform_invariants(struct intel_engine_cs *engine) + struct drm_i915_private *dev_priv = engine->i915; + + engine->disable_lite_restore_wa = +- (IS_SKL_REVID(dev_priv, 0, SKL_REVID_B0) || +- IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) && ++ IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1) && + (engine->id == VCS || engine->id == VCS2); + + engine->ctx_desc_template = GEN8_CTX_VALID; +@@ -1068,9 +1067,8 @@ static int gen9_init_perctx_bb(struct intel_engine_cs *engine, + { + uint32_t index = wa_ctx_start(wa_ctx, *offset, CACHELINE_DWORDS); + +- /* WaSetDisablePixMaskCammingAndRhwoInCommonSliceChicken:skl,bxt */ +- if (IS_SKL_REVID(engine->i915, 0, SKL_REVID_B0) || +- IS_BXT_REVID(engine->i915, 0, BXT_REVID_A1)) { ++ /* WaSetDisablePixMaskCammingAndRhwoInCommonSliceChicken:bxt */ ++ if (IS_BXT_REVID(engine->i915, 0, BXT_REVID_A1)) { + wa_ctx_emit(batch, index, MI_LOAD_REGISTER_IMM(1)); + wa_ctx_emit_reg(batch, index, GEN9_SLICE_COMMON_ECO_CHICKEN0); + wa_ctx_emit(batch, index, +diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c +index 7a74750..2faf64f 100644 +--- a/drivers/gpu/drm/i915/intel_ringbuffer.c ++++ b/drivers/gpu/drm/i915/intel_ringbuffer.c +@@ -851,15 +851,13 @@ static int gen9_init_workarounds(struct intel_engine_cs *engine) + WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN3, + GEN9_DISABLE_OCL_OOB_SUPPRESS_LOGIC); + +- /* WaDisableDgMirrorFixInHalfSliceChicken5:skl,bxt */ +- if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_B0) || +- IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) ++ /* WaDisableDgMirrorFixInHalfSliceChicken5:bxt */ ++ if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) + WA_CLR_BIT_MASKED(GEN9_HALF_SLICE_CHICKEN5, + GEN9_DG_MIRROR_FIX_ENABLE); + +- /* WaSetDisablePixMaskCammingAndRhwoInCommonSliceChicken:skl,bxt */ +- if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_B0) || +- IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { ++ /* WaSetDisablePixMaskCammingAndRhwoInCommonSliceChicken:bxt */ ++ if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { + WA_SET_BIT_MASKED(GEN7_COMMON_SLICE_CHICKEN1, + GEN9_RHWO_OPTIMIZATION_DISABLE); + /* +@@ -1023,15 +1021,8 @@ static int skl_init_workarounds(struct intel_engine_cs *engine) + GEN8_LQSC_RO_PERF_DIS); + + /* WaEnableGapsTsvCreditFix:skl */ +- if (IS_SKL_REVID(dev_priv, SKL_REVID_C0, REVID_FOREVER)) { +- I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | +- GEN9_GAPS_TSV_CREDIT_DISABLE)); +- } +- +- /* WaDisablePowerCompilerClockGating:skl */ +- if (IS_SKL_REVID(dev_priv, SKL_REVID_B0, SKL_REVID_B0)) +- WA_SET_BIT_MASKED(HIZ_CHICKEN, +- BDW_HIZ_POWER_COMPILER_CLOCK_GATING_DISABLE); ++ I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | ++ GEN9_GAPS_TSV_CREDIT_DISABLE)); + + /* WaBarrierPerformanceFixDisable:skl */ + if (IS_SKL_REVID(dev_priv, SKL_REVID_C0, SKL_REVID_D0)) +-- +cgit v0.10.2 + diff --git a/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-D0-revision.patch b/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-D0-revision.patch new file mode 100644 index 00000000..0643ccd9 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-D0-revision.patch @@ -0,0 +1,86 @@ +From 9fc736e833d226853fd53843e35d6a1d542394ed Mon Sep 17 00:00:00 2001 +From: Jani Nikula +Date: Fri, 16 Sep 2016 16:59:46 +0300 +Subject: drm/i915/skl: drop workarounds for D0 revision + +Pre-production hardware is not supported. + +Reviewed-by: Paulo Zanoni +Signed-off-by: Jani Nikula +Link: http://patchwork.freedesktop.org/patch/msgid/d28d21ceddeec226b5d1a20a7382bee9a72709a4.1474034059.git.jani.nikula@intel.com + +diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c +index 47f7afa..ca649cc 100644 +--- a/drivers/gpu/drm/i915/intel_lrc.c ++++ b/drivers/gpu/drm/i915/intel_lrc.c +@@ -994,9 +994,8 @@ static int gen9_init_indirectctx_bb(struct intel_engine_cs *engine, + struct drm_i915_private *dev_priv = engine->i915; + uint32_t index = wa_ctx_start(wa_ctx, *offset, CACHELINE_DWORDS); + +- /* WaDisableCtxRestoreArbitration:skl,bxt */ +- if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_D0) || +- IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) ++ /* WaDisableCtxRestoreArbitration:bxt */ ++ if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) + wa_ctx_emit(batch, index, MI_ARB_ON_OFF | MI_ARB_DISABLE); + + /* WaFlushCoherentL3CacheLinesAtContextSwitch:skl,bxt */ +@@ -1095,9 +1094,8 @@ static int gen9_init_perctx_bb(struct intel_engine_cs *engine, + wa_ctx_emit(batch, index, MI_NOOP); + } + +- /* WaDisableCtxRestoreArbitration:skl,bxt */ +- if (IS_SKL_REVID(engine->i915, 0, SKL_REVID_D0) || +- IS_BXT_REVID(engine->i915, 0, BXT_REVID_A1)) ++ /* WaDisableCtxRestoreArbitration:bxt */ ++ if (IS_BXT_REVID(engine->i915, 0, BXT_REVID_A1)) + wa_ctx_emit(batch, index, MI_ARB_ON_OFF | MI_ARB_ENABLE); + + wa_ctx_emit(batch, index, MI_BATCH_BUFFER_END); +diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c +index 2df06b7..a860c40 100644 +--- a/drivers/gpu/drm/i915/intel_pm.c ++++ b/drivers/gpu/drm/i915/intel_pm.c +@@ -5335,8 +5335,7 @@ static void gen9_enable_rc6(struct drm_i915_private *dev_priv) + rc6_mask = GEN6_RC_CTL_RC6_ENABLE; + DRM_INFO("RC6 %s\n", onoff(rc6_mask & GEN6_RC_CTL_RC6_ENABLE)); + /* WaRsUseTimeoutMode */ +- if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_D0) || +- IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { ++ if (IS_BXT_REVID(dev_priv, 0, BXT_REVID_A1)) { + I915_WRITE(GEN6_RC6_THRESHOLD, 625); /* 800us */ + I915_WRITE(GEN6_RC_CONTROL, GEN6_RC_CTL_HW_ENABLE | + GEN7_RC_CTL_TO_MODE | +diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c +index 474ce84..6880082 100644 +--- a/drivers/gpu/drm/i915/intel_ringbuffer.c ++++ b/drivers/gpu/drm/i915/intel_ringbuffer.c +@@ -1000,10 +1000,8 @@ static int skl_init_workarounds(struct intel_engine_cs *engine) + * until D0 which is the default case so this is equivalent to + * !WaDisablePerCtxtPreemptionGranularityControl:skl + */ +- if (IS_SKL_REVID(dev_priv, SKL_REVID_E0, REVID_FOREVER)) { +- I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, +- _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); +- } ++ I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, ++ _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); + + if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_E0)) { + /* WaDisableChickenBitTSGBarrierAckForFFSliceCS:skl */ +@@ -1023,12 +1021,6 @@ static int skl_init_workarounds(struct intel_engine_cs *engine) + I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | + GEN9_GAPS_TSV_CREDIT_DISABLE)); + +- /* WaBarrierPerformanceFixDisable:skl */ +- if (IS_SKL_REVID(dev_priv, SKL_REVID_C0, SKL_REVID_D0)) +- WA_SET_BIT_MASKED(HDC_CHICKEN0, +- HDC_FENCE_DEST_SLM_DISABLE | +- HDC_BARRIER_PERFORMANCE_DISABLE); +- + /* WaDisableSbeCacheDispatchPortSharing:skl */ + if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_F0)) + WA_SET_BIT_MASKED( +-- +cgit v0.10.2 + diff --git a/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-E0-revision.patch b/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-E0-revision.patch new file mode 100644 index 00000000..1c8f8a38 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-E0-revision.patch @@ -0,0 +1,59 @@ +From 3be192e92ddcad15f7bf6b4b9e3f195eb8c1fe76 Mon Sep 17 00:00:00 2001 +From: Jani Nikula +Date: Fri, 16 Sep 2016 16:59:47 +0300 +Subject: drm/i915/skl: drop workarounds for E0 revision + +Pre-production hardware is not supported. + +Reviewed-by: Paulo Zanoni +Signed-off-by: Jani Nikula +Link: http://patchwork.freedesktop.org/patch/msgid/0633a02177195703502ef2396aab03efc0314334.1474034059.git.jani.nikula@intel.com + +diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c +index ca649cc..2d8eb2e 100644 +--- a/drivers/gpu/drm/i915/intel_lrc.c ++++ b/drivers/gpu/drm/i915/intel_lrc.c +@@ -845,13 +845,12 @@ static inline int gen8_emit_flush_coherentl3_wa(struct intel_engine_cs *engine, + uint32_t l3sqc4_flush = (0x40400000 | GEN8_LQSC_FLUSH_COHERENT_LINES); + + /* +- * WaDisableLSQCROPERFforOCL:skl,kbl ++ * WaDisableLSQCROPERFforOCL:kbl + * This WA is implemented in skl_init_clock_gating() but since + * this batch updates GEN8_L3SQCREG4 with default value we need to + * set this bit here to retain the WA during flush. + */ +- if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_E0) || +- IS_KBL_REVID(dev_priv, 0, KBL_REVID_E0)) ++ if (IS_KBL_REVID(dev_priv, 0, KBL_REVID_E0)) + l3sqc4_flush |= GEN8_LQSC_RO_PERF_DIS; + + wa_ctx_emit(batch, index, (MI_STORE_REGISTER_MEM_GEN8 | +diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c +index 6880082..68dc27f 100644 +--- a/drivers/gpu/drm/i915/intel_ringbuffer.c ++++ b/drivers/gpu/drm/i915/intel_ringbuffer.c +@@ -1003,20 +1003,6 @@ static int skl_init_workarounds(struct intel_engine_cs *engine) + I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1, + _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL)); + +- if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_E0)) { +- /* WaDisableChickenBitTSGBarrierAckForFFSliceCS:skl */ +- I915_WRITE(FF_SLICE_CS_CHICKEN2, +- _MASKED_BIT_ENABLE(GEN9_TSG_BARRIER_ACK_DISABLE)); +- } +- +- /* GEN8_L3SQCREG4 has a dependency with WA batch so any new changes +- * involving this register should also be added to WA batch as required. +- */ +- if (IS_SKL_REVID(dev_priv, 0, SKL_REVID_E0)) +- /* WaDisableLSQCROPERFforOCL:skl */ +- I915_WRITE(GEN8_L3SQCREG4, I915_READ(GEN8_L3SQCREG4) | +- GEN8_LQSC_RO_PERF_DIS); +- + /* WaEnableGapsTsvCreditFix:skl */ + I915_WRITE(GEN8_GARBCNTL, (I915_READ(GEN8_GARBCNTL) | + GEN9_GAPS_TSV_CREDIT_DISABLE)); +-- +cgit v0.10.2 + diff --git a/kernel/kernel/files/patches/mageia/gpu-drm-mach64.patch b/kernel/kernel/files/patches/mageia/gpu-drm-mach64.patch index 9ab07df9..409981fc 100644 --- a/kernel/kernel/files/patches/mageia/gpu-drm-mach64.patch +++ b/kernel/kernel/files/patches/mageia/gpu-drm-mach64.patch @@ -4112,11 +4112,11 @@ head: c99566fb810c9d8cae5e9cd39d1772b55e2f514c + + return 0; +} ---- linux/drivers/gpu/drm/Kconfig.gpu-drm-mach64.orig 2014-03-08 18:52:34.979768492 +0200 -+++ linux/drivers/gpu/drm/Kconfig 2014-03-08 18:55:18.769681473 +0200 -@@ -130,6 +130,17 @@ config DRM_I810 - - source "drivers/gpu/drm/i915/Kconfig" +--- linux/drivers/gpu/drm/Kconfig.gpu-drm-mach64.orig ++++ linux/drivers/gpu/drm/Kconfig +@@ -267,6 +267,17 @@ config DRM_I810 + selected, the module will be called i810. AGP support is required + for this driver to work. +config DRM_MACH64 + tristate "ATI Rage Pro (Mach64)" @@ -4134,11 +4134,11 @@ head: c99566fb810c9d8cae5e9cd39d1772b55e2f514c depends on DRM && PCI --- linux/drivers/gpu/drm/Makefile.gpu-drm-mach64.orig +++ linux/drivers/gpu/drm/Makefile -@@ -38,6 +38,7 @@ obj-$(CONFIG_DRM_R128) += r128/ +@@ -47,6 +47,7 @@ obj-$(CONFIG_DRM_R128) += r128/ obj-$(CONFIG_HSA_AMD) += amd/amdkfd/ obj-$(CONFIG_DRM_RADEON)+= radeon/ obj-$(CONFIG_DRM_AMDGPU)+= amd/amdgpu/ +obj-$(CONFIG_DRM_MACH64)+= mach64/ obj-$(CONFIG_DRM_MGA) += mga/ obj-$(CONFIG_DRM_I810) += i810/ - obj-$(CONFIG_DRM_I915) += i915/ + obj-$(CONFIG_DRM_I915) += i915/ diff --git a/kernel/kernel/files/patches/mageia/net-netfilter-psd-fix-redefines.patch b/kernel/kernel/files/patches/mageia/net-netfilter-psd-fix-redefines.patch new file mode 100644 index 00000000..ddee206e --- /dev/null +++ b/kernel/kernel/files/patches/mageia/net-netfilter-psd-fix-redefines.patch @@ -0,0 +1,85 @@ + +Make defines psd specific so they dont redefine in-kernel defines like +HASH_SIZE. + +Signed-off-by: Thomas Backlund + + + include/linux/netfilter_ipv4/ipt_psd.h | 14 +++++++------- + net/ipv4/netfilter/ipt_psd.c | 14 +++++++------- + 2 files changed, 14 insertions(+), 14 deletions(-) + +diff -Nurp linux-4.9.5-psd/include/linux/netfilter_ipv4/ipt_psd.h linux-4.9.5-psd-fix/include/linux/netfilter_ipv4/ipt_psd.h +--- linux-4.9.5-psd/include/linux/netfilter_ipv4/ipt_psd.h 2017-01-20 21:47:19.788931403 +0200 ++++ linux-4.9.5-psd-fix/include/linux/netfilter_ipv4/ipt_psd.h 2017-01-20 21:58:09.995871253 +0200 +@@ -21,14 +21,14 @@ + #define SCAN_DELAY_THRESHOLD (300) /* old usage of HZ here was erroneously and broke under uml */ + + /* +- * Keep track of up to LIST_SIZE source addresses, using a hash table of +- * HASH_SIZE entries for faster lookups, but limiting hash collisions to +- * HASH_MAX source addresses per the same hash value. ++ * Keep track of up to PSD_LIST_SIZE source addresses, using a hash table of ++ * PSD_HASH_SIZE entries for faster lookups, but limiting hash collisions to ++ * PSD_HASH_MAX source addresses per the same hash value. + */ +-#define LIST_SIZE 0x100 +-#define HASH_LOG 9 +-#define HASH_SIZE (1 << HASH_LOG) +-#define HASH_MAX 0x10 ++#define PSD_LIST_SIZE 0x100 ++#define PSD_HASH_LOG 9 ++#define PSD_HASH_SIZE (1 << PSD_HASH_LOG) ++#define PSD_HASH_MAX 0x10 + + struct ipt_psd_info { + unsigned int weight_threshold; +diff -Nurp linux-4.9.5-psd/net/ipv4/netfilter/ipt_psd.c linux-4.9.5-psd-fix/net/ipv4/netfilter/ipt_psd.c +--- linux-4.9.5-psd/net/ipv4/netfilter/ipt_psd.c 2017-01-20 21:47:19.792931402 +0200 ++++ linux-4.9.5-psd-fix/net/ipv4/netfilter/ipt_psd.c 2017-01-20 21:58:09.998871253 +0200 +@@ -74,8 +74,8 @@ struct host { + */ + static struct { + spinlock_t lock; +- struct host list[LIST_SIZE]; /* List of source addresses */ +- struct host *hash[HASH_SIZE]; /* Hash: pointers into the list */ ++ struct host list[PSD_LIST_SIZE]; /* List of source addresses */ ++ struct host *hash[PSD_HASH_SIZE]; /* Hash: pointers into the list */ + int index; /* Oldest entry to be replaced */ + } state; + +@@ -91,9 +91,9 @@ static inline int hashfunc(struct in_add + hash = 0; + do { + hash ^= value; +- } while ((value >>= HASH_LOG)); ++ } while ((value >>= PSD_HASH_LOG)); + +- return hash & (HASH_SIZE - 1); ++ return hash & (PSD_HASH_SIZE - 1); + } + + static bool +@@ -245,11 +245,11 @@ ipt_psd_match(const struct sk_buff *pskb + /* Got too many source addresses with the same hash value? Then remove the + * oldest one from the hash table, so that they can't take too much of our + * CPU time even with carefully chosen spoofed IP addresses. */ +- if (count >= HASH_MAX && last) last->next = NULL; ++ if (count >= PSD_HASH_MAX && last) last->next = NULL; + + /* We're going to re-use the oldest list entry, so remove it from the hash + * table first (if it is really already in use, and isn't removed from the +- * hash table already because of the HASH_MAX check above). */ ++ * hash table already because of the PSD_HASH_MAX check above). */ + + /* First, find it */ + if (state.list[state.index].src_addr.s_addr) +@@ -273,7 +273,7 @@ ipt_psd_match(const struct sk_buff *pskb + + /* Get our list entry */ + curr = &state.list[state.index++]; +- if (state.index >= LIST_SIZE) state.index = 0; ++ if (state.index >= PSD_LIST_SIZE) state.index = 0; + + /* Link it into the hash table */ + head = &state.hash[hash]; diff --git a/kernel/kernel/files/patches/mageia/net-wireless-brcmfmac-fix-incorrect-event-channel-deduction.patch b/kernel/kernel/files/patches/mageia/net-wireless-brcmfmac-fix-incorrect-event-channel-deduction.patch new file mode 100644 index 00000000..cee31761 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/net-wireless-brcmfmac-fix-incorrect-event-channel-deduction.patch @@ -0,0 +1,29 @@ + +From: Gavin Li + +brcmf_sdio_fromevntchan() was being called on the the data frame +rather than the software header, causing some frames to be +mischaracterized as on the event channel rather than the data channel. + +This fixes a major performance regression (due to dropped packets). + +Fixes: c56caa9db8ab ("brcmfmac: screening firmware event packet") +Signed-off-by: Gavin Li +Cc: [4.7+] +--- + drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +index dfb0658713d9..d2219885071f 100644 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +@@ -1661,7 +1661,7 @@ static u8 brcmf_sdio_rxglom(struct brcmf_sdio *bus, u8 rxseq) + pfirst->len, pfirst->next, + pfirst->prev); + skb_unlink(pfirst, &bus->glom); +- if (brcmf_sdio_fromevntchan(pfirst->data)) ++ if (brcmf_sdio_fromevntchan(&dptr[SDPCM_HWHDR_LEN])) + brcmf_rx_event(bus->sdiodev->dev, pfirst); + else + brcmf_rx_frame(bus->sdiodev->dev, pfirst, diff --git a/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Fix-kernel-oops-introduced-with-commit-e4965.patch b/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Fix-kernel-oops-introduced-with-commit-e4965.patch new file mode 100644 index 00000000..ab148933 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Fix-kernel-oops-introduced-with-commit-e4965.patch @@ -0,0 +1,37 @@ +From 22b68b93ae2506bd56ee3bf232a51bc8ab955b56 Mon Sep 17 00:00:00 2001 +From: Larry Finger +Date: Mon, 19 Dec 2016 20:38:12 -0600 +Subject: [PATCH] rtlwifi: Fix kernel oops introduced with commit e49656147359 + +With commit e49656147359 {"rtlwifi: Use dev_kfree_skb_irq instead of +kfree_skb"), the method used to free an skb was changed because the +kfree_skb() was inside a spinlock. What was forgotten is that kfree_skb() +guards against a NULL value for the argument. Routine dev_kfree_skb_irq() +does not, and a test is needed to prevent kernel panics. + +Fixes: e49656147359 ("rtlwifi: Use dev_kfree_skb_irq instead of kfree_skb") +Signed-off-by: Larry Finger +Cc: Stable # 4.9+ +Cc: Wei Yongjun +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/realtek/rtlwifi/core.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c +index 2caa4ad..ded1493 100644 +--- a/drivers/net/wireless/realtek/rtlwifi/core.c ++++ b/drivers/net/wireless/realtek/rtlwifi/core.c +@@ -1829,7 +1829,8 @@ bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb) + + spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); + pskb = __skb_dequeue(&ring->queue); +- dev_kfree_skb_irq(pskb); ++ if (pskb) ++ dev_kfree_skb_irq(pskb); + + /*this is wrong, fill_tx_cmddesc needs update*/ + pdesc = &ring->desc[0]; +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Fix-regression-caused-by-commit-d86e64768859.patch b/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Fix-regression-caused-by-commit-d86e64768859.patch deleted file mode 100644 index c251e081..00000000 --- a/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Fix-regression-caused-by-commit-d86e64768859.patch +++ /dev/null @@ -1,429 +0,0 @@ -From cf4747d7535a936105f0abe8d8109d3fe339162b Mon Sep 17 00:00:00 2001 -From: Larry Finger -Date: Wed, 12 Oct 2016 13:54:04 -0500 -Subject: [PATCH] rtlwifi: Fix regression caused by commit d86e64768859 - -In commit d86e64768859 ("rtlwifi: rtl818x: constify local structures"), -the configuration struct for most of the drivers was changed to be -constant. The problem is that five of the modified drivers need to be -able to update the firmware name based on the exact model of the card. -As the file names were stored in one of the members of that struct, -these drivers would fail with a kernel BUG splat when they tried to -update the firmware name. - -Rather than reverting the previous commit, I used a suggestion by -Johannes Berg and made the firmware file name pointers be local to -the routines that update the software variables. - -The configuration struct of rtl8192cu, which was not touched in the -previous patch, is now constantfied. - -Fixes: d86e64768859 ("rtlwifi: rtl818x: constify local structures") -Suggested-by: Johannes Berg -Signed-off-by: Larry Finger -Cc: Stable # 4.8 -Cc: Julia Lawall -Signed-off-by: Kalle Valo ---- - drivers/net/wireless/realtek/rtlwifi/core.c | 2 +- - drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c | 8 ++++---- - drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c | 13 +++++-------- - drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c | 12 ++++++------ - drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c | 6 +++--- - drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c | 8 ++++---- - drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c | 9 +++++---- - drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c | 12 +++++------- - drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c | 6 +++--- - drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c | 18 +++++++++--------- - drivers/net/wireless/realtek/rtlwifi/wifi.h | 2 -- - 11 files changed, 45 insertions(+), 51 deletions(-) - -diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c -index f95760c..8e7f23c 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/core.c -+++ b/drivers/net/wireless/realtek/rtlwifi/core.c -@@ -111,7 +111,7 @@ static void rtl_fw_do_work(const struct firmware *firmware, void *context, - if (!err) - goto found_alt; - } -- pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name); -+ pr_err("Selected firmware is not available\n"); - rtlpriv->max_fw_size = 0; - return; - } -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c -index e7b11b4..f361808 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c -@@ -86,6 +86,7 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw) - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - u8 tid; -+ char *fw_name; - - rtl8188ee_bt_reg_init(hw); - rtlpriv->dm.dm_initialgain_enable = 1; -@@ -169,10 +170,10 @@ int rtl88e_init_sw_vars(struct ieee80211_hw *hw) - return 1; - } - -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8188efw.bin"; -+ fw_name = "rtlwifi/rtl8188efw.bin"; - rtlpriv->max_fw_size = 0x8000; -- pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); -- err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, -+ pr_info("Using firmware %s\n", fw_name); -+ err = request_firmware_nowait(THIS_MODULE, 1, fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl_fw_cb); - if (err) { -@@ -284,7 +285,6 @@ static const struct rtl_hal_cfg rtl88ee_hal_cfg = { - .bar_id = 2, - .write_readback = true, - .name = "rtl88e_pci", -- .fw_name = "rtlwifi/rtl8188efw.bin", - .ops = &rtl8188ee_hal_ops, - .mod_params = &rtl88ee_mod_params, - -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c -index 87aa209..8b6e37c 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c -@@ -96,6 +96,7 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); -+ char *fw_name = "rtlwifi/rtl8192cfwU.bin"; - - rtl8192ce_bt_reg_init(hw); - -@@ -167,15 +168,12 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw) - } - - /* request fw */ -- if (IS_VENDOR_UMC_A_CUT(rtlhal->version) && -- !IS_92C_SERIAL(rtlhal->version)) -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU.bin"; -- else if (IS_81XXC_VENDOR_UMC_B_CUT(rtlhal->version)) -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cfwU_B.bin"; -+ if (IS_81XXC_VENDOR_UMC_B_CUT(rtlhal->version)) -+ fw_name = "rtlwifi/rtl8192cfwU_B.bin"; - - rtlpriv->max_fw_size = 0x4000; -- pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); -- err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, -+ pr_info("Using firmware %s\n", fw_name); -+ err = request_firmware_nowait(THIS_MODULE, 1, fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl_fw_cb); - if (err) { -@@ -262,7 +260,6 @@ static const struct rtl_hal_cfg rtl92ce_hal_cfg = { - .bar_id = 2, - .write_readback = true, - .name = "rtl92c_pci", -- .fw_name = "rtlwifi/rtl8192cfw.bin", - .ops = &rtl8192ce_hal_ops, - .mod_params = &rtl92ce_mod_params, - -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c -index 7c6f7f0..f953320 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/sw.c -@@ -59,6 +59,7 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) - { - struct rtl_priv *rtlpriv = rtl_priv(hw); - int err; -+ char *fw_name; - - rtlpriv->dm.dm_initialgain_enable = true; - rtlpriv->dm.dm_flag = 0; -@@ -77,18 +78,18 @@ static int rtl92cu_init_sw_vars(struct ieee80211_hw *hw) - } - if (IS_VENDOR_UMC_A_CUT(rtlpriv->rtlhal.version) && - !IS_92C_SERIAL(rtlpriv->rtlhal.version)) { -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_A.bin"; -+ fw_name = "rtlwifi/rtl8192cufw_A.bin"; - } else if (IS_81XXC_VENDOR_UMC_B_CUT(rtlpriv->rtlhal.version)) { -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_B.bin"; -+ fw_name = "rtlwifi/rtl8192cufw_B.bin"; - } else { -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8192cufw_TMSC.bin"; -+ fw_name = "rtlwifi/rtl8192cufw_TMSC.bin"; - } - /* provide name of alternative file */ - rtlpriv->cfg->alt_fw_name = "rtlwifi/rtl8192cufw.bin"; -- pr_info("Loading firmware %s\n", rtlpriv->cfg->fw_name); -+ pr_info("Loading firmware %s\n", fw_name); - rtlpriv->max_fw_size = 0x4000; - err = request_firmware_nowait(THIS_MODULE, 1, -- rtlpriv->cfg->fw_name, rtlpriv->io.dev, -+ fw_name, rtlpriv->io.dev, - GFP_KERNEL, hw, rtl_fw_cb); - return err; - } -@@ -187,7 +188,6 @@ static struct rtl_hal_usbint_cfg rtl92cu_interface_cfg = { - - static struct rtl_hal_cfg rtl92cu_hal_cfg = { - .name = "rtl92c_usb", -- .fw_name = "rtlwifi/rtl8192cufw.bin", - .ops = &rtl8192cu_hal_ops, - .mod_params = &rtl92cu_mod_params, - .usb_interface_cfg = &rtl92cu_interface_cfg, -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c -index 0538a4d..1ebfee1 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c -@@ -92,6 +92,7 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) - u8 tid; - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); -+ char *fw_name = "rtlwifi/rtl8192defw.bin"; - - rtlpriv->dm.dm_initialgain_enable = true; - rtlpriv->dm.dm_flag = 0; -@@ -181,10 +182,10 @@ static int rtl92d_init_sw_vars(struct ieee80211_hw *hw) - - rtlpriv->max_fw_size = 0x8000; - pr_info("Driver for Realtek RTL8192DE WLAN interface\n"); -- pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); -+ pr_info("Loading firmware file %s\n", fw_name); - - /* request fw */ -- err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, -+ err = request_firmware_nowait(THIS_MODULE, 1, fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl_fw_cb); - if (err) { -@@ -266,7 +267,6 @@ static const struct rtl_hal_cfg rtl92de_hal_cfg = { - .bar_id = 2, - .write_readback = true, - .name = "rtl8192de", -- .fw_name = "rtlwifi/rtl8192defw.bin", - .ops = &rtl8192de_hal_ops, - .mod_params = &rtl92de_mod_params, - -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c -index ac299cb..46b605de3 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c -@@ -91,6 +91,7 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw) - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - int err = 0; -+ char *fw_name; - - rtl92ee_bt_reg_init(hw); - rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; -@@ -170,11 +171,11 @@ int rtl92ee_init_sw_vars(struct ieee80211_hw *hw) - } - - /* request fw */ -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8192eefw.bin"; -+ fw_name = "rtlwifi/rtl8192eefw.bin"; - - rtlpriv->max_fw_size = 0x8000; -- pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); -- err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, -+ pr_info("Using firmware %s\n", fw_name); -+ err = request_firmware_nowait(THIS_MODULE, 1, fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl_fw_cb); - if (err) { -@@ -266,7 +267,6 @@ static const struct rtl_hal_cfg rtl92ee_hal_cfg = { - .bar_id = 2, - .write_readback = true, - .name = "rtl92ee_pci", -- .fw_name = "rtlwifi/rtl8192eefw.bin", - .ops = &rtl8192ee_hal_ops, - .mod_params = &rtl92ee_mod_params, - -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c -index 5e8e02d..3e1eaea 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c -@@ -89,12 +89,13 @@ static void rtl92se_fw_cb(const struct firmware *firmware, void *context) - struct ieee80211_hw *hw = context; - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rt_firmware *pfirmware = NULL; -+ char *fw_name = "rtlwifi/rtl8192sefw.bin"; - - RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD, - "Firmware callback routine entered!\n"); - complete(&rtlpriv->firmware_loading_complete); - if (!firmware) { -- pr_err("Firmware %s not available\n", rtlpriv->cfg->fw_name); -+ pr_err("Firmware %s not available\n", fw_name); - rtlpriv->max_fw_size = 0; - return; - } -@@ -117,6 +118,7 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - int err = 0; - u16 earlyrxthreshold = 7; -+ char *fw_name = "rtlwifi/rtl8192sefw.bin"; - - rtlpriv->dm.dm_initialgain_enable = true; - rtlpriv->dm.dm_flag = 0; -@@ -214,9 +216,9 @@ static int rtl92s_init_sw_vars(struct ieee80211_hw *hw) - rtlpriv->max_fw_size = RTL8190_MAX_FIRMWARE_CODE_SIZE*2 + - sizeof(struct fw_hdr); - pr_info("Driver for Realtek RTL8192SE/RTL8191SE\n" -- "Loading firmware %s\n", rtlpriv->cfg->fw_name); -+ "Loading firmware %s\n", fw_name); - /* request fw */ -- err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, -+ err = request_firmware_nowait(THIS_MODULE, 1, fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl92se_fw_cb); - if (err) { -@@ -310,7 +312,6 @@ static const struct rtl_hal_cfg rtl92se_hal_cfg = { - .bar_id = 1, - .write_readback = false, - .name = "rtl92s_pci", -- .fw_name = "rtlwifi/rtl8192sefw.bin", - .ops = &rtl8192se_hal_ops, - .mod_params = &rtl92se_mod_params, - -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c -index 89c828a..c51a9e8 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c -@@ -94,6 +94,7 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw) - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - int err = 0; -+ char *fw_name = "rtlwifi/rtl8723fw.bin"; - - rtl8723e_bt_reg_init(hw); - -@@ -176,14 +177,12 @@ int rtl8723e_init_sw_vars(struct ieee80211_hw *hw) - return 1; - } - -- if (IS_VENDOR_8723_A_CUT(rtlhal->version)) -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8723fw.bin"; -- else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8723fw_B.bin"; -+ if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) -+ fw_name = "rtlwifi/rtl8723fw_B.bin"; - - rtlpriv->max_fw_size = 0x6000; -- pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); -- err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, -+ pr_info("Using firmware %s\n", fw_name); -+ err = request_firmware_nowait(THIS_MODULE, 1, fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl_fw_cb); - if (err) { -@@ -280,7 +279,6 @@ static const struct rtl_hal_cfg rtl8723e_hal_cfg = { - .bar_id = 2, - .write_readback = true, - .name = "rtl8723e_pci", -- .fw_name = "rtlwifi/rtl8723efw.bin", - .ops = &rtl8723e_hal_ops, - .mod_params = &rtl8723e_mod_params, - .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c -index 20b53f0..847644d 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c -@@ -91,6 +91,7 @@ int rtl8723be_init_sw_vars(struct ieee80211_hw *hw) - struct rtl_priv *rtlpriv = rtl_priv(hw); - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); -+ char *fw_name = "rtlwifi/rtl8723befw.bin"; - - rtl8723be_bt_reg_init(hw); - rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer(); -@@ -184,8 +185,8 @@ int rtl8723be_init_sw_vars(struct ieee80211_hw *hw) - } - - rtlpriv->max_fw_size = 0x8000; -- pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); -- err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, -+ pr_info("Using firmware %s\n", fw_name); -+ err = request_firmware_nowait(THIS_MODULE, 1, fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl_fw_cb); - if (err) { -@@ -280,7 +281,6 @@ static const struct rtl_hal_cfg rtl8723be_hal_cfg = { - .bar_id = 2, - .write_readback = true, - .name = "rtl8723be_pci", -- .fw_name = "rtlwifi/rtl8723befw.bin", - .ops = &rtl8723be_hal_ops, - .mod_params = &rtl8723be_mod_params, - .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, -diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c -index 22f687b1..297938e 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c -+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c -@@ -93,6 +93,7 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw) - struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); - struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); - struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); -+ char *fw_name, *wowlan_fw_name; - - rtl8821ae_bt_reg_init(hw); - rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer(); -@@ -203,17 +204,17 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw) - } - - if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE) { -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8812aefw.bin"; -- rtlpriv->cfg->wowlan_fw_name = "rtlwifi/rtl8812aefw_wowlan.bin"; -+ fw_name = "rtlwifi/rtl8812aefw.bin"; -+ wowlan_fw_name = "rtlwifi/rtl8812aefw_wowlan.bin"; - } else { -- rtlpriv->cfg->fw_name = "rtlwifi/rtl8821aefw.bin"; -- rtlpriv->cfg->wowlan_fw_name = "rtlwifi/rtl8821aefw_wowlan.bin"; -+ fw_name = "rtlwifi/rtl8821aefw.bin"; -+ 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, -+ pr_info("Using firmware %s\n", fw_name); -+ err = request_firmware_nowait(THIS_MODULE, 1, fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl_fw_cb); - if (err) { -@@ -222,9 +223,9 @@ int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw) - return 1; - } - /*load wowlan firmware*/ -- pr_info("Using firmware %s\n", rtlpriv->cfg->wowlan_fw_name); -+ pr_info("Using firmware %s\n", wowlan_fw_name); - err = request_firmware_nowait(THIS_MODULE, 1, -- rtlpriv->cfg->wowlan_fw_name, -+ wowlan_fw_name, - rtlpriv->io.dev, GFP_KERNEL, hw, - rtl_wowlan_fw_cb); - if (err) { -@@ -320,7 +321,6 @@ static const struct rtl_hal_cfg rtl8821ae_hal_cfg = { - .bar_id = 2, - .write_readback = true, - .name = "rtl8821ae_pci", -- .fw_name = "rtlwifi/rtl8821aefw.bin", - .ops = &rtl8821ae_hal_ops, - .mod_params = &rtl8821ae_mod_params, - .maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, -diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h -index 595f7d5..dafe486 100644 ---- a/drivers/net/wireless/realtek/rtlwifi/wifi.h -+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h -@@ -2278,9 +2278,7 @@ struct rtl_hal_cfg { - u8 bar_id; - bool write_readback; - 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; --- -2.10.1 - diff --git a/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Use-dev_kfree_skb_irq-instead-of-kfree_skb.patch b/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Use-dev_kfree_skb_irq-instead-of-kfree_skb.patch new file mode 100644 index 00000000..50aa874d --- /dev/null +++ b/kernel/kernel/files/patches/mageia/net-wireless-rtlwifi-Use-dev_kfree_skb_irq-instead-of-kfree_skb.patch @@ -0,0 +1,34 @@ +From e49656147359411fb7529a211e852e587e5970dd Mon Sep 17 00:00:00 2001 +From: Wei Yongjun +Date: Tue, 1 Nov 2016 14:48:40 +0000 +Subject: [PATCH] rtlwifi: Use dev_kfree_skb_irq instead of kfree_skb + +It is not allowed to call kfree_skb() from hardware interrupt +context or with interrupts being disabled, spin_lock_irqsave() +make sure always in irq disable context. So the kfree_skb() +should be replaced with dev_kfree_skb_irq(). + +This is detected by Coccinelle semantic patch. + +Signed-off-by: Wei Yongjun +Signed-off-by: Kalle Valo +--- + drivers/net/wireless/realtek/rtlwifi/core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c +index f95760c..a11e8f5 100644 +--- a/drivers/net/wireless/realtek/rtlwifi/core.c ++++ b/drivers/net/wireless/realtek/rtlwifi/core.c +@@ -1832,7 +1832,7 @@ bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb) + + spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); + pskb = __skb_dequeue(&ring->queue); +- kfree_skb(pskb); ++ dev_kfree_skb_irq(pskb); + + /*this is wrong, fill_tx_cmddesc needs update*/ + pdesc = &ring->desc[0]; +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/nvmepatch1-V4.patch b/kernel/kernel/files/patches/mageia/nvmepatch1-V4.patch deleted file mode 100644 index 9bcefef0..00000000 --- a/kernel/kernel/files/patches/mageia/nvmepatch1-V4.patch +++ /dev/null @@ -1,111 +0,0 @@ -diff --git a/drivers/nvme/host/scsi.c b/drivers/nvme/host/scsi.c -index e947e298a737..44009105f8c8 100644 ---- a/drivers/nvme/host/scsi.c -+++ b/drivers/nvme/host/scsi.c -@@ -72,15 +72,6 @@ static int sg_version_num = 30534; /* 2 digits for each component */ - #define ALL_LUNS_RETURNED 0x02 - #define ALL_WELL_KNOWN_LUNS_RETURNED 0x01 - #define RESTRICTED_LUNS_RETURNED 0x00 --#define NVME_POWER_STATE_START_VALID 0x00 --#define NVME_POWER_STATE_ACTIVE 0x01 --#define NVME_POWER_STATE_IDLE 0x02 --#define NVME_POWER_STATE_STANDBY 0x03 --#define NVME_POWER_STATE_LU_CONTROL 0x07 --#define POWER_STATE_0 0 --#define POWER_STATE_1 1 --#define POWER_STATE_2 2 --#define POWER_STATE_3 3 - #define DOWNLOAD_SAVE_ACTIVATE 0x05 - #define DOWNLOAD_SAVE_DEFER_ACTIVATE 0x0E - #define ACTIVATE_DEFERRED_MICROCODE 0x0F -@@ -1229,64 +1220,6 @@ static void nvme_trans_fill_read_cap(u8 *response, struct nvme_id_ns *id_ns, - - /* Start Stop Unit Helper Functions */ - --static int nvme_trans_power_state(struct nvme_ns *ns, struct sg_io_hdr *hdr, -- u8 pc, u8 pcmod, u8 start) --{ -- int res; -- int nvme_sc; -- struct nvme_id_ctrl *id_ctrl; -- int lowest_pow_st; /* max npss = lowest power consumption */ -- unsigned ps_desired = 0; -- -- nvme_sc = nvme_identify_ctrl(ns->ctrl, &id_ctrl); -- res = nvme_trans_status_code(hdr, nvme_sc); -- if (res) -- return res; -- -- lowest_pow_st = max(POWER_STATE_0, (int)(id_ctrl->npss - 1)); -- kfree(id_ctrl); -- -- switch (pc) { -- case NVME_POWER_STATE_START_VALID: -- /* Action unspecified if POWER CONDITION MODIFIER != 0 */ -- if (pcmod == 0 && start == 0x1) -- ps_desired = POWER_STATE_0; -- if (pcmod == 0 && start == 0x0) -- ps_desired = lowest_pow_st; -- break; -- case NVME_POWER_STATE_ACTIVE: -- /* Action unspecified if POWER CONDITION MODIFIER != 0 */ -- if (pcmod == 0) -- ps_desired = POWER_STATE_0; -- break; -- case NVME_POWER_STATE_IDLE: -- /* Action unspecified if POWER CONDITION MODIFIER != [0,1,2] */ -- if (pcmod == 0x0) -- ps_desired = POWER_STATE_1; -- else if (pcmod == 0x1) -- ps_desired = POWER_STATE_2; -- else if (pcmod == 0x2) -- ps_desired = POWER_STATE_3; -- break; -- case NVME_POWER_STATE_STANDBY: -- /* Action unspecified if POWER CONDITION MODIFIER != [0,1] */ -- if (pcmod == 0x0) -- ps_desired = max(POWER_STATE_0, (lowest_pow_st - 2)); -- else if (pcmod == 0x1) -- ps_desired = max(POWER_STATE_0, (lowest_pow_st - 1)); -- break; -- case NVME_POWER_STATE_LU_CONTROL: -- default: -- res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, -- ILLEGAL_REQUEST, SCSI_ASC_INVALID_CDB, -- SCSI_ASCQ_CAUSE_NOT_REPORTABLE); -- break; -- } -- nvme_sc = nvme_set_features(ns->ctrl, NVME_FEAT_POWER_MGMT, ps_desired, 0, -- NULL); -- return nvme_trans_status_code(hdr, nvme_sc); --} -- - static int nvme_trans_send_activate_fw_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr, - u8 buffer_id) - { -@@ -2235,11 +2168,10 @@ static int nvme_trans_synchronize_cache(struct nvme_ns *ns, - static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr, - u8 *cmd) - { -- u8 immed, pcmod, pc, no_flush, start; -+ u8 immed, pcmod, no_flush, start; - - immed = cmd[1] & 0x01; - pcmod = cmd[3] & 0x0f; -- pc = (cmd[4] & 0xf0) >> 4; - no_flush = cmd[4] & 0x04; - start = cmd[4] & 0x01; - -@@ -2254,8 +2186,8 @@ static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr, - if (res) - return res; - } -- /* Setup the expected power state transition */ -- return nvme_trans_power_state(ns, hdr, pc, pcmod, start); -+ -+ return 0; - } - } - --- -2.7.4 diff --git a/kernel/kernel/files/patches/mageia/nvmepatch2-V4.patch b/kernel/kernel/files/patches/mageia/nvmepatch2-V4.patch deleted file mode 100644 index 454cb4a5..00000000 --- a/kernel/kernel/files/patches/mageia/nvmepatch2-V4.patch +++ /dev/null @@ -1,107 +0,0 @@ -diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c -index 2feacc70bf61..b92a7f767bfc 100644 ---- a/drivers/nvme/host/core.c -+++ b/drivers/nvme/host/core.c -@@ -597,7 +597,7 @@ int nvme_identify_ns(struct nvme_ctrl *dev, unsigned nsid, - } - - int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid, -- dma_addr_t dma_addr, u32 *result) -+ void *buffer, size_t buflen, u32 *result) - { - struct nvme_command c; - struct nvme_completion cqe; -@@ -606,10 +606,9 @@ int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid, - memset(&c, 0, sizeof(c)); - c.features.opcode = nvme_admin_get_features; - c.features.nsid = cpu_to_le32(nsid); -- c.features.dptr.prp1 = cpu_to_le64(dma_addr); - c.features.fid = cpu_to_le32(fid); - -- ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, -+ ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, buffer, buflen, 0, - NVME_QID_ANY, 0, 0); - if (ret >= 0 && result) - *result = le32_to_cpu(cqe.result); -@@ -617,7 +616,7 @@ int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid, - } - - int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11, -- dma_addr_t dma_addr, u32 *result) -+ void *buffer, size_t buflen, u32 *result) - { - struct nvme_command c; - struct nvme_completion cqe; -@@ -625,12 +624,11 @@ int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11, - - memset(&c, 0, sizeof(c)); - c.features.opcode = nvme_admin_set_features; -- c.features.dptr.prp1 = cpu_to_le64(dma_addr); - c.features.fid = cpu_to_le32(fid); - c.features.dword11 = cpu_to_le32(dword11); - -- ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, NULL, 0, 0, -- NVME_QID_ANY, 0, 0); -+ ret = __nvme_submit_sync_cmd(dev->admin_q, &c, &cqe, -+ buffer, buflen, 0, NVME_QID_ANY, 0, 0); - if (ret >= 0 && result) - *result = le32_to_cpu(cqe.result); - return ret; -@@ -664,7 +662,7 @@ int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count) - u32 result; - int status, nr_io_queues; - -- status = nvme_set_features(ctrl, NVME_FEAT_NUM_QUEUES, q_count, 0, -+ status = nvme_set_features(ctrl, NVME_FEAT_NUM_QUEUES, q_count, NULL, 0, - &result); - if (status < 0) - return status; -diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h -index ab18b78102bf..c2151761ec5f 100644 ---- a/drivers/nvme/host/nvme.h -+++ b/drivers/nvme/host/nvme.h -@@ -292,9 +292,9 @@ int nvme_identify_ns(struct nvme_ctrl *dev, unsigned nsid, - struct nvme_id_ns **id); - int nvme_get_log_page(struct nvme_ctrl *dev, struct nvme_smart_log **log); - int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid, -- dma_addr_t dma_addr, u32 *result); -+ void *buffer, size_t buflen, u32 *result); - int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11, -- dma_addr_t dma_addr, u32 *result); -+ void *buffer, size_t buflen, u32 *result); - int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count); - void nvme_start_keep_alive(struct nvme_ctrl *ctrl); - void nvme_stop_keep_alive(struct nvme_ctrl *ctrl); -diff --git a/drivers/nvme/host/scsi.c b/drivers/nvme/host/scsi.c -index 44009105f8c8..c2a0a1c7d05d 100644 ---- a/drivers/nvme/host/scsi.c -+++ b/drivers/nvme/host/scsi.c -@@ -906,7 +906,7 @@ static int nvme_trans_log_temperature(struct nvme_ns *ns, struct sg_io_hdr *hdr, - kfree(smart_log); - - /* Get Features for Temp Threshold */ -- res = nvme_get_features(ns->ctrl, NVME_FEAT_TEMP_THRESH, 0, 0, -+ res = nvme_get_features(ns->ctrl, NVME_FEAT_TEMP_THRESH, 0, NULL, 0, - &feature_resp); - if (res != NVME_SC_SUCCESS) - temp_c_thresh = LOG_TEMP_UNKNOWN; -@@ -1039,7 +1039,7 @@ static int nvme_trans_fill_caching_page(struct nvme_ns *ns, - if (len < MODE_PAGE_CACHING_LEN) - return -EINVAL; - -- nvme_sc = nvme_get_features(ns->ctrl, NVME_FEAT_VOLATILE_WC, 0, 0, -+ nvme_sc = nvme_get_features(ns->ctrl, NVME_FEAT_VOLATILE_WC, 0, NULL, 0, - &feature_resp); - res = nvme_trans_status_code(hdr, nvme_sc); - if (res) -@@ -1328,7 +1328,7 @@ static int nvme_trans_modesel_get_mp(struct nvme_ns *ns, struct sg_io_hdr *hdr, - case MODE_PAGE_CACHING: - dword11 = ((mode_page[2] & CACHING_MODE_PAGE_WCE_MASK) ? 1 : 0); - nvme_sc = nvme_set_features(ns->ctrl, NVME_FEAT_VOLATILE_WC, -- dword11, 0, NULL); -+ dword11, NULL, 0, NULL); - res = nvme_trans_status_code(hdr, nvme_sc); - break; - case MODE_PAGE_CONTROL: --- -2.7.4 diff --git a/kernel/kernel/files/patches/mageia/nvmepatch3-V4.patch b/kernel/kernel/files/patches/mageia/nvmepatch3-V4.patch deleted file mode 100644 index 797c4681..00000000 --- a/kernel/kernel/files/patches/mageia/nvmepatch3-V4.patch +++ /dev/null @@ -1,264 +0,0 @@ -diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c -index b92a7f767bfc..a143c72c3d0d 100644 ---- a/drivers/nvme/host/core.c -+++ b/drivers/nvme/host/core.c -@@ -56,6 +56,11 @@ EXPORT_SYMBOL_GPL(nvme_max_retries); - static int nvme_char_major; - module_param(nvme_char_major, int, 0); - -+static unsigned long default_ps_max_latency_us = 25000; -+module_param(default_ps_max_latency_us, ulong, 0644); -+MODULE_PARM_DESC(ps_max_latency_us, -+ "default max power saving latency; overridden per device in sysfs"); -+ - static LIST_HEAD(nvme_ctrl_list); - static DEFINE_SPINLOCK(dev_list_lock); - -@@ -1205,6 +1210,98 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl, - blk_queue_write_cache(q, vwc, vwc); - } - -+static void nvme_configure_apst(struct nvme_ctrl *ctrl) -+{ -+ /* -+ * APST (Autonomous Power State Transition) lets us program a -+ * table of power state transitions that the controller will -+ * perform automatically. We configure it with a simple -+ * heuristic: we are willing to spend at most 2% of the time -+ * transitioning between power states. Therefore, when running -+ * in any given state, we will enter the next lower-power -+ * non-operational state after waiting 100 * (enlat + exlat) -+ * microseconds, as long as that state's total latency is under -+ * the requested maximum latency. -+ * -+ * We will not autonomously enter any non-operational state for -+ * which the total latency exceeds ps_max_latency_us. Users -+ * can set ps_max_latency_us to zero to turn off APST. -+ */ -+ -+ unsigned apste; -+ struct nvme_feat_auto_pst *table; -+ int ret; -+ -+ if (!ctrl->apsta) -+ return; /* APST isn't supported. */ -+ -+ if (ctrl->npss > 31) { -+ dev_warn(ctrl->device, "NPSS is invalid; not using APST\n"); -+ return; -+ } -+ -+ table = kzalloc(sizeof(*table), GFP_KERNEL); -+ if (!table) -+ return; -+ -+ if (ctrl->ps_max_latency_us == 0) { -+ /* Turn off APST. */ -+ apste = 0; -+ } else { -+ __le64 target = cpu_to_le64(0); -+ int state; -+ -+ /* -+ * Walk through all states from lowest- to highest-power. -+ * According to the spec, lower-numbered states use more -+ * power. NPSS, despite the name, is the index of the -+ * lowest-power state, not the number of states. -+ */ -+ for (state = (int)ctrl->npss; state >= 0; state--) { -+ u64 total_latency_us, transition_ms; -+ -+ if (target) -+ table->entries[state] = target; -+ -+ /* -+ * Is this state a useful non-operational state for -+ * higher-power states to autonomously transition to? -+ */ -+ if (!(ctrl->psd[state].flags & 2)) -+ continue; /* It's an operational state. */ -+ -+ total_latency_us = -+ (u64)cpu_to_le32(ctrl->psd[state].entry_lat) + -+ + cpu_to_le32(ctrl->psd[state].exit_lat); -+ if (total_latency_us > ctrl->ps_max_latency_us) -+ continue; -+ -+ /* -+ * This state is good. Use it as the APST idle -+ * target for higher power states. -+ */ -+ transition_ms = total_latency_us + 19; -+ do_div(transition_ms, 20); -+ if (transition_ms >= (1 << 24)) -+ transition_ms = (1 << 24); -+ -+ target = cpu_to_le64((state << 3) | -+ (transition_ms << 8)); -+ } -+ -+ apste = 1; -+ } -+ -+ ret = nvme_set_features(ctrl, NVME_FEAT_AUTO_PST, apste, -+ table, sizeof(*table), NULL); -+ if (ret) -+ dev_err(ctrl->device, "failed to set APST feature (%d)\n", ret); -+ -+ kfree(table); -+} -+ -+static struct attribute_group nvme_dev_dynamic_attrs_group; -+ - /* - * Initialize the cached copies of the Identify data and various controller - * register in our nvme_ctrl structure. This should be called as soon as -@@ -1271,6 +1368,10 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) - ctrl->sgls = le32_to_cpu(id->sgls); - ctrl->kas = le16_to_cpu(id->kas); - -+ ctrl->npss = id->npss; -+ ctrl->apsta = id->apsta; -+ memcpy(ctrl->psd, id->psd, sizeof(ctrl->psd)); -+ - if (ctrl->ops->is_fabrics) { - ctrl->icdoff = le16_to_cpu(id->icdoff); - ctrl->ioccsz = le32_to_cpu(id->ioccsz); -@@ -1294,6 +1395,10 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) - } - - kfree(id); -+ -+ nvme_configure_apst(ctrl); -+ -+ sysfs_update_group(&ctrl->device->kobj, &nvme_dev_dynamic_attrs_group); - return ret; - } - EXPORT_SYMBOL_GPL(nvme_init_identify); -@@ -1564,6 +1669,41 @@ static ssize_t nvme_sysfs_show_address(struct device *dev, - } - static DEVICE_ATTR(address, S_IRUGO, nvme_sysfs_show_address, NULL); - -+static ssize_t nvme_sysfs_show_ps_max_latency_us( -+ struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct nvme_ctrl *ctrl = dev_get_drvdata(dev); -+ -+ return snprintf(buf, PAGE_SIZE, "%llu\n", ctrl->ps_max_latency_us); -+} -+ -+static ssize_t nvme_sysfs_store_ps_max_latency_us( -+ struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t size) -+{ -+ struct nvme_ctrl *ctrl = dev_get_drvdata(dev); -+ int ret; -+ u64 val; -+ -+ ret = kstrtoull(buf, 10, &val); -+ if (ret) -+ return ret; -+ -+ if (ctrl->ps_max_latency_us != val) { -+ ctrl->ps_max_latency_us = val; -+ nvme_configure_apst(ctrl); -+ } -+ -+ return size; -+} -+ -+static DEVICE_ATTR(ps_max_latency_us, 0644, -+ nvme_sysfs_show_ps_max_latency_us, -+ nvme_sysfs_store_ps_max_latency_us); -+ - static struct attribute *nvme_dev_attrs[] = { - &dev_attr_reset_controller.attr, - &dev_attr_rescan_controller.attr, -@@ -1605,8 +1745,33 @@ static struct attribute_group nvme_dev_attrs_group = { - .is_visible = nvme_dev_attrs_are_visible, - }; - -+static struct attribute *nvme_dev_dynamic_attrs[] = { -+ &dev_attr_ps_max_latency_us.attr, -+ NULL -+}; -+ -+static umode_t nvme_dev_dynamic_attrs_are_visible(struct kobject *kobj, -+ struct attribute *a, int n) -+{ -+ struct device *dev = container_of(kobj, struct device, kobj); -+ struct nvme_ctrl *ctrl = dev_get_drvdata(dev); -+ -+ if (a == &dev_attr_ps_max_latency_us.attr) { -+ if (!ctrl->apsta) -+ return 0; -+ } -+ -+ return a->mode; -+} -+ -+static struct attribute_group nvme_dev_dynamic_attrs_group = { -+ .attrs = nvme_dev_dynamic_attrs, -+ .is_visible = nvme_dev_dynamic_attrs_are_visible, -+}; -+ - static const struct attribute_group *nvme_dev_attr_groups[] = { - &nvme_dev_attrs_group, -+ &nvme_dev_dynamic_attrs_group, - NULL, - }; - -@@ -1991,6 +2156,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, - ctrl->quirks = quirks; - INIT_WORK(&ctrl->scan_work, nvme_scan_work); - INIT_WORK(&ctrl->async_event_work, nvme_async_event_work); -+ ctrl->ps_max_latency_us = default_ps_max_latency_us; - - ret = nvme_set_instance(ctrl); - if (ret) -diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h -index c2151761ec5f..16d51006afc0 100644 ---- a/drivers/nvme/host/nvme.h -+++ b/drivers/nvme/host/nvme.h -@@ -129,13 +129,19 @@ struct nvme_ctrl { - u32 vs; - u32 sgls; - u16 kas; -+ u8 npss; -+ u8 apsta; - unsigned int kato; - bool subsystem; - unsigned long quirks; -+ struct nvme_id_power_state psd[32]; - struct work_struct scan_work; - struct work_struct async_event_work; - struct delayed_work ka_work; - -+ /* Power saving configuration */ -+ u64 ps_max_latency_us; -+ - /* Fabrics only */ - u16 sqsize; - u32 ioccsz; -diff --git a/include/linux/nvme.h b/include/linux/nvme.h -index d8b37bab2887..a76237dac4b0 100644 ---- a/include/linux/nvme.h -+++ b/include/linux/nvme.h -@@ -543,6 +543,12 @@ struct nvme_dsm_range { - __le64 slba; - }; - -+/* Features */ -+ -+struct nvme_feat_auto_pst { -+ __le64 entries[32]; -+}; -+ - /* Admin commands */ - - enum nvme_admin_opcode { --- -2.7.4 diff --git a/kernel/kernel/files/patches/mageia/series b/kernel/kernel/files/patches/mageia/series index 2a2a481b..ca9b5050 100644 --- a/kernel/kernel/files/patches/mageia/series +++ b/kernel/kernel/files/patches/mageia/series @@ -14,7 +14,14 @@ ### ### Stable Queue ### -patch-4.8.10-rc1.patch + +# CVE-2016-8405 +stable-fbdev-color-map-copying-bounds-checking.patch + +stable-tile-ptrace-preserve-previous-registers-for-short-regset-write.patch +stable-drm-schedule-the-output_poll_work-with-1s-delay-if-we-have-delayed-event.patch +stable-drm-fix-broken-vt-switch-with-video-1366x768-option.patch +stable-drm-i915-ignore-bogus-plane-coordinates-on-skl-when-the-plane-is-not-visible.patch ### ### Arch x86 @@ -78,6 +85,9 @@ acpi-processor-M720SR-limit-to-C2.patch # backlight fixes ACPI-video-Add-a-quirk-to-force-acpi-video-backlight.patch +# drop obsolete warn +acpi-do-not-warn-if-_BQC-does-not-exist.patch + ### ### Block ### @@ -122,15 +132,10 @@ block-Make-CFQ-default-to-IOPS-mode-on-SSDs.patch # Include new BFQ I/O scheduler # (See http://algo.ing.unimo.it/people/paolo/disk_sched) -# -# Release of BFQ I/O scheduler v8r4 (rediffed from git https://github.com/linusw/linux-bfq) -linux-BFQ-v8r4.patch - -# Let NVME drives enter in power state -# (see https://github.com/damige/linux-nvme/tree/master/src) -nvmepatch1-V4.patch -nvmepatch2-V4.patch -nvmepatch3-V4.patch +block-cgroups-kconfig-build-bits-for-BFQ-v7r11-4.5.0.patch +block-introduce-the-BFQ-v7r11-I-O-sched-for-4.5.0.patch +block-bfq-add-Early-Queue-Merge-EQM-to-BFQ-v7r11-for.patch +block-Turn-into-BFQ-v8r6-for-4.9.0.patch ### ### Char @@ -139,13 +144,22 @@ nvmepatch3-V4.patch # hard locks Dell R720xd Revert-ipmi-Start-the-timer-and-thread-on-internal-m.patch +# tpm_crb fixes for SkyLake +char-tpm-tpm_crb-implement-tpm-crb-idle-state.patch +char-tmp-tpm_crb-fix-Intel-PTT-hw-bug-during-idle-state.patch +char-tpm-tpm_crb-open-code-the-crb_init-into-acpi_add.patch +char-tmp-tpm_crb-implement-runtime-pm-for-tpm_crb.patch + ### ### File-system ### # aufs from: http://aufs.sourceforge.net/ (mga#8314) -fs-aufs-4.8.patch -fs-aufs-4.8-modular.patch +fs-aufs-4.9.patch +fs-aufs-4.9-modular.patch + +# needed for mdadm: imsm: enable bad block support for imsm metadata +fs-seq_file-reset-iterator-to-first-record-for-zero-off.patch ### ### FireWire @@ -180,6 +194,12 @@ gpu-drm-mach64-linux-3.14-buildfix.patch gpu-drm-mach64-3.17-buildfix.patch gpu-drm-mach64-3.18-buildfix.patch +# i915 skl/kbl speedup +gpu-drm-i915-skl-drop-workarounds-for-A0-and-B0-revisions.patch +gpu-drm-i915-skl-drop-workarounds-for-D0-revision.patch +gpu-drm-i915-skl-drop-workarounds-for-E0-revision.patch +gpu-drm-i915-Remove-WaDisableLSQCROPERFforOCL-KBL-workaround.patch + ### ### Hardware Monitoring ### @@ -230,9 +250,14 @@ net-netfilter-IFWLOG-remove-unused-label.patch net-netfilter-psd.patch net-netfilter-psd-mdv.patch net-netfilter-psd-2.6.35-buildfix.patch +net-netfilter-psd-fix-redefines.patch -# rtlwifi regression -net-wireless-rtlwifi-Fix-regression-caused-by-commit-d86e64768859.patch +# rtlwifi fixes +net-wireless-rtlwifi-Use-dev_kfree_skb_irq-instead-of-kfree_skb.patch +net-wireless-rtlwifi-Fix-kernel-oops-introduced-with-commit-e4965.patch + +# fix speed regression +net-wireless-brcmfmac-fix-incorrect-event-channel-deduction.patch ### ### Platform drivers @@ -338,8 +363,6 @@ video-mageia-logo.patch # add rtl8723bs support (mga#15874) 3rd-rtl8723bs.patch -3rd-rtl8723bs-4.7-buildfix.patch -3rd-rtl8723bs-4.8-buildfix.patch ### ### Security @@ -368,6 +391,11 @@ video-mageia-logo.patch # wipe powerpc refrence so we can nuke dangling symlinks (mga#17676) tools-testing-selftest-Makefile-remove-powerpc-reference.patch +# perf build fixes +tools-build-Make-fixdep-parsing-wait-for-last-target.patch +tools-perf-tools-Force-fixdep-compilation-at-the-start-of-.patch +tools-perf-tools-Move-perf-build-related-variables-under-n.patch + ### ### UAPI ### diff --git a/kernel/kernel/files/patches/mageia/stable-drm-fix-broken-vt-switch-with-video-1366x768-option.patch b/kernel/kernel/files/patches/mageia/stable-drm-fix-broken-vt-switch-with-video-1366x768-option.patch new file mode 100644 index 00000000..1e434efd --- /dev/null +++ b/kernel/kernel/files/patches/mageia/stable-drm-fix-broken-vt-switch-with-video-1366x768-option.patch @@ -0,0 +1,71 @@ +From fdf35a6b22247746a7053fc764d04218a9306f82 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Mon, 9 Jan 2017 15:56:14 +0100 +Subject: drm: Fix broken VT switch with video=1366x768 option +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Takashi Iwai + +commit fdf35a6b22247746a7053fc764d04218a9306f82 upstream. + +I noticed that the VT switch doesn't work any longer with a Dell +laptop with 1366x768 eDP when the machine is connected with a DP +monitor. It behaves as if VT were switched, but the graphics remain +frozen. Actually the keyboard works, so I could switch back to VT7 +again. + +I tried to track down the problem, and encountered a long story until +we reach to this error: + +- The machine is booted with video=1366x768 option (the distro + installer seems to add it as default). +- Recently, drm_helper_probe_single_connector_modes() deals with + cmdline modes, and it tries to create a new mode when no + matching mode is found. +- The drm_mode_create_from_cmdline_mode() creates a mode based on + either CVT of GFT according to the given cmdline mode; in our case, + it's 1366x768. +- Since both CVT and GFT can't express the width 1366 due to + alignment, the resultant mode becomes 1368x768, slightly larger than + the given size. +- Later on, the atomic commit is performed, and in + drm_atomic_check_only(), the size of each plane is checked. +- The size check of 1366x768 fails due to the above, and eventually + the whole VT switch fails. + +Back in the history, we've had a manual fix-up of 1368x768 in various +places via c09dedb7a50e ("drm/edid: Add a workaround for 1366x768 HD +panel"), but they have been all in drm_edid.c at probing the modes +from EDID. For addressing the problem above, we need a similar hack +to the mode newly created from cmdline, manually adjusting the width +when the expected size is 1366 while we get 1368 instead. + +Fixes: eaf99c749d43 ("drm: Perform cmdline mode parsing during...") +Signed-off-by: Takashi Iwai +Link: http://patchwork.freedesktop.org/patch/msgid/20170109145614.29454-1-tiwai@suse.de +Reviewed-by: Ville Syrjälä +Signed-off-by: Ville Syrjälä +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/drm_modes.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/drivers/gpu/drm/drm_modes.c ++++ b/drivers/gpu/drm/drm_modes.c +@@ -1462,6 +1462,13 @@ drm_mode_create_from_cmdline_mode(struct + return NULL; + + mode->type |= DRM_MODE_TYPE_USERDEF; ++ /* fix up 1368x768: GFT/CVT can't express 1366 width due to alignment */ ++ if (cmd->xres == 1366 && mode->hdisplay == 1368) { ++ mode->hdisplay = 1366; ++ mode->hsync_start--; ++ mode->hsync_end--; ++ drm_mode_set_name(mode); ++ } + drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); + return mode; + } diff --git a/kernel/kernel/files/patches/mageia/stable-drm-i915-ignore-bogus-plane-coordinates-on-skl-when-the-plane-is-not-visible.patch b/kernel/kernel/files/patches/mageia/stable-drm-i915-ignore-bogus-plane-coordinates-on-skl-when-the-plane-is-not-visible.patch new file mode 100644 index 00000000..e1d1a683 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/stable-drm-i915-ignore-bogus-plane-coordinates-on-skl-when-the-plane-is-not-visible.patch @@ -0,0 +1,49 @@ +From 3bfdfdcbce2796ce75bf2d85fd8471858d702e5d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= +Date: Mon, 7 Nov 2016 22:20:54 +0200 +Subject: drm/i915: Ignore bogus plane coordinates on SKL when the plane is not visible +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ville Syrjälä + +commit 3bfdfdcbce2796ce75bf2d85fd8471858d702e5d upstream. + +When the plane is invisible we may have all sorts of bogus stuff +in the coordinates, which we must ignore or else we might fail the +plane update. This started to happen on SKL when I moved the plane +offset computation to happen in the check phase. Previously we +happily ignored it all since we never called the update_plane hook +with an invisible plane. + +Cc: Sivakumar Thulasimani +Cc: drm-intel-fixes@lists.freedesktop.org +Fixes: b63a16f6cd89 ("drm/i915: Compute display surface offset in the plane check hook for SKL+") +Signed-off-by: Ville Syrjälä +Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98258 +Testcase: igt/pm_rpm/legacy-planes +Testcase: igt/pm_rpm/universal-planes +Reviewed-by: Matt Roper +Signed-off-by: Matt Roper +Link: http://patchwork.freedesktop.org/patch/msgid/1478550057-24864-3-git-send-email-ville.syrjala@linux.intel.com +(cherry picked from commit a5e4c7d0aa6784d8abe95c3ceef0da9656d17468) +Signed-off-by: Jani Nikula +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/i915/intel_display.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/gpu/drm/i915/intel_display.c ++++ b/drivers/gpu/drm/i915/intel_display.c +@@ -2975,6 +2975,9 @@ int skl_check_plane_surface(struct intel + unsigned int rotation = plane_state->base.rotation; + int ret; + ++ if (!plane_state->base.visible) ++ return 0; ++ + /* Rotate src coordinates to match rotated GTT view */ + if (intel_rotation_90_or_270(rotation)) + drm_rect_rotate(&plane_state->base.src, diff --git a/kernel/kernel/files/patches/mageia/stable-drm-schedule-the-output_poll_work-with-1s-delay-if-we-have-delayed-event.patch b/kernel/kernel/files/patches/mageia/stable-drm-schedule-the-output_poll_work-with-1s-delay-if-we-have-delayed-event.patch new file mode 100644 index 00000000..7875c08d --- /dev/null +++ b/kernel/kernel/files/patches/mageia/stable-drm-schedule-the-output_poll_work-with-1s-delay-if-we-have-delayed-event.patch @@ -0,0 +1,55 @@ +From 68f458eec7069d618a6c884ca007426e0cea411b Mon Sep 17 00:00:00 2001 +From: Peter Ujfalusi +Date: Mon, 9 Jan 2017 16:31:58 +0200 +Subject: drm: Schedule the output_poll_work with 1s delay if we have delayed event + +From: Peter Ujfalusi + +commit 68f458eec7069d618a6c884ca007426e0cea411b upstream. + +Instead of scheduling the work to handle the initial delayed event, use 1s +delay. + +This delay should not be needed, but Optimus/nouveau will fail in a +mysterious way if the delayed event is handled as soon as possible like it +is done in drm_helper_probe_single_connector_modes() in case the poll +was enabled before. + +Reverting 339fd36238dd would give back the 10 sec (!) delay to handle the +delayed event. Adding 1sec delay to the poll_work is enough to work around +the issue in Optimus setups and gives shorter response on handling the +initial delayed event. + +Fixes: 339fd36238dd ("drm: drm_probe_helper: Fix output_poll_work scheduling") +Signed-off-by: Peter Ujfalusi +[danvet: Add FIXME to the comment to make it stick out more.] +Signed-off-by: Daniel Vetter +Link: http://patchwork.freedesktop.org/patch/msgid/20170109143158.21917-1-peter.ujfalusi@ti.com +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/drm_probe_helper.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/drm_probe_helper.c ++++ b/drivers/gpu/drm/drm_probe_helper.c +@@ -143,8 +143,18 @@ void drm_kms_helper_poll_enable_locked(s + } + + if (dev->mode_config.delayed_event) { ++ /* ++ * FIXME: ++ * ++ * Use short (1s) delay to handle the initial delayed event. ++ * This delay should not be needed, but Optimus/nouveau will ++ * fail in a mysterious way if the delayed event is handled as ++ * soon as possible like it is done in ++ * drm_helper_probe_single_connector_modes() in case the poll ++ * was enabled before. ++ */ + poll = true; +- delay = 0; ++ delay = HZ; + } + + if (poll) diff --git a/kernel/kernel/files/patches/mageia/stable-fbdev-color-map-copying-bounds-checking.patch b/kernel/kernel/files/patches/mageia/stable-fbdev-color-map-copying-bounds-checking.patch new file mode 100644 index 00000000..be9e7b23 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/stable-fbdev-color-map-copying-bounds-checking.patch @@ -0,0 +1,82 @@ +From 2dc705a9930b4806250fbf5a76e55266e59389f2 Mon Sep 17 00:00:00 2001 +From: Kees Cook +Date: Tue, 24 Jan 2017 15:18:24 -0800 +Subject: fbdev: color map copying bounds checking + +From: Kees Cook + +commit 2dc705a9930b4806250fbf5a76e55266e59389f2 upstream. + +Copying color maps to userspace doesn't check the value of to->start, +which will cause kernel heap buffer OOB read due to signedness wraps. + +CVE-2016-8405 + +Link: http://lkml.kernel.org/r/20170105224249.GA50925@beast +Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") +Signed-off-by: Kees Cook +Reported-by: Peter Pi (@heisecode) of Trend Micro +Cc: Min Chong +Cc: Dan Carpenter +Cc: Tomi Valkeinen +Cc: Bartlomiej Zolnierkiewicz +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/video/fbdev/core/fbcmap.c | 26 ++++++++++++++------------ + 1 file changed, 14 insertions(+), 12 deletions(-) + +--- a/drivers/video/fbdev/core/fbcmap.c ++++ b/drivers/video/fbdev/core/fbcmap.c +@@ -163,17 +163,18 @@ void fb_dealloc_cmap(struct fb_cmap *cma + + int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to) + { +- int tooff = 0, fromoff = 0; +- int size; ++ unsigned int tooff = 0, fromoff = 0; ++ size_t size; + + if (to->start > from->start) + fromoff = to->start - from->start; + else + tooff = from->start - to->start; +- size = to->len - tooff; +- if (size > (int) (from->len - fromoff)) +- size = from->len - fromoff; +- if (size <= 0) ++ if (fromoff >= from->len || tooff >= to->len) ++ return -EINVAL; ++ ++ size = min_t(size_t, to->len - tooff, from->len - fromoff); ++ if (size == 0) + return -EINVAL; + size *= sizeof(u16); + +@@ -187,17 +188,18 @@ int fb_copy_cmap(const struct fb_cmap *f + + int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to) + { +- int tooff = 0, fromoff = 0; +- int size; ++ unsigned int tooff = 0, fromoff = 0; ++ size_t size; + + if (to->start > from->start) + fromoff = to->start - from->start; + else + tooff = from->start - to->start; +- size = to->len - tooff; +- if (size > (int) (from->len - fromoff)) +- size = from->len - fromoff; +- if (size <= 0) ++ if (fromoff >= from->len || tooff >= to->len) ++ return -EINVAL; ++ ++ size = min_t(size_t, to->len - tooff, from->len - fromoff); ++ if (size == 0) + return -EINVAL; + size *= sizeof(u16); + diff --git a/kernel/kernel/files/patches/mageia/stable-tile-ptrace-preserve-previous-registers-for-short-regset-write.patch b/kernel/kernel/files/patches/mageia/stable-tile-ptrace-preserve-previous-registers-for-short-regset-write.patch new file mode 100644 index 00000000..454c386d --- /dev/null +++ b/kernel/kernel/files/patches/mageia/stable-tile-ptrace-preserve-previous-registers-for-short-regset-write.patch @@ -0,0 +1,32 @@ +From fd7c99142d77dc4a851879a66715abf12a3193fb Mon Sep 17 00:00:00 2001 +From: Dave Martin +Date: Fri, 6 Jan 2017 17:54:51 +0000 +Subject: tile/ptrace: Preserve previous registers for short regset write + +From: Dave Martin + +commit fd7c99142d77dc4a851879a66715abf12a3193fb upstream. + +Ensure that if userspace supplies insufficient data to +PTRACE_SETREGSET to fill all the registers, the thread's old +registers are preserved. + +Signed-off-by: Dave Martin +Signed-off-by: Chris Metcalf +Signed-off-by: Greg Kroah-Hartman + +--- + arch/tile/kernel/ptrace.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/tile/kernel/ptrace.c ++++ b/arch/tile/kernel/ptrace.c +@@ -111,7 +111,7 @@ static int tile_gpr_set(struct task_stru + const void *kbuf, const void __user *ubuf) + { + int ret; +- struct pt_regs regs; ++ struct pt_regs regs = *task_pt_regs(target); + + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, ®s, 0, + sizeof(regs)); diff --git a/kernel/kernel/files/patches/mageia/tools-build-Make-fixdep-parsing-wait-for-last-target.patch b/kernel/kernel/files/patches/mageia/tools-build-Make-fixdep-parsing-wait-for-last-target.patch new file mode 100644 index 00000000..f15fccc5 --- /dev/null +++ b/kernel/kernel/files/patches/mageia/tools-build-Make-fixdep-parsing-wait-for-last-target.patch @@ -0,0 +1,51 @@ +From 1cd6472e3f8d3fdee0fd19f7088807b284d3080f Mon Sep 17 00:00:00 2001 +From: Jiri Olsa +Date: Thu, 1 Dec 2016 14:00:25 +0100 +Subject: [PATCH] tools build: Make fixdep parsing wait for last target + +The fixdep tool, among other things, replaces the target of the object +in the gcc generated dependency output file. + +The parsing code assumes there's only single target in the rule but this +is not always the case as described in here: + + https://gcc.gnu.org/ml/gcc-help/2016-11/msg00099.html + +Make the fixdep code smart enough to skip all the possible targets. + +Signed-off-by: Jiri Olsa +Tested-by: Arnaldo Carvalho de Melo +Acked-by: Peter Foley +Cc: Wang Nan +Link: http://lkml.kernel.org/r/20161201130025.GA16430@krava +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/build/fixdep.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/tools/build/fixdep.c b/tools/build/fixdep.c +index 1521d36..734d154 100644 +--- a/tools/build/fixdep.c ++++ b/tools/build/fixdep.c +@@ -49,7 +49,7 @@ static void parse_dep_file(void *map, size_t len) + char *end = m + len; + char *p; + char s[PATH_MAX]; +- int is_target; ++ int is_target, has_target = 0; + int saw_any_target = 0; + int is_first_dep = 0; + +@@ -67,7 +67,8 @@ static void parse_dep_file(void *map, size_t len) + if (is_target) { + /* The /next/ file is the first dependency */ + is_first_dep = 1; +- } else { ++ has_target = 1; ++ } else if (has_target) { + /* Save this token/filename */ + memcpy(s, m, p-m); + s[p - m] = 0; +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/tools-perf-tools-Force-fixdep-compilation-at-the-start-of-.patch b/kernel/kernel/files/patches/mageia/tools-perf-tools-Force-fixdep-compilation-at-the-start-of-.patch new file mode 100644 index 00000000..7bc4952d --- /dev/null +++ b/kernel/kernel/files/patches/mageia/tools-perf-tools-Force-fixdep-compilation-at-the-start-of-.patch @@ -0,0 +1,237 @@ +From abb26210a39522a6645bce3f438ed9a26bedb11b Mon Sep 17 00:00:00 2001 +From: Jiri Olsa +Date: Tue, 6 Dec 2016 14:18:49 +0100 +Subject: [PATCH] perf tools: Force fixdep compilation at the start of the + build + +The fixdep tool needs to be built before everything else, because it fixes +every object dependency file. + +We handle this currently by making all objects to depend on fixdep, which is +error prone and is easily forgotten when new object is added. + +Instead of this, this patch force fixdep tool to be built as the first target +in the separate make session. This way we don't need to handle extra fixdep +dependencies and we are certain there's no fixdep race with any parallel make +job. + +Committer notes: + +Testing it: + +Before: + + $ rm -rf /tmp/build/perf/ ; mkdir -p /tmp/build/perf ; make -k O=/tmp/build/perf -C tools/perf install-bin + make: Entering directory '/home/acme/git/linux/tools/perf' + BUILD: Doing 'make -j4' parallel build + + Auto-detecting system features: + ... dwarf: [ on ] + ... dwarf_getlocations: [ on ] + ... glibc: [ on ] + ... gtk2: [ on ] + ... libaudit: [ on ] + ... libbfd: [ on ] + ... libelf: [ on ] + ... libnuma: [ on ] + ... numa_num_possible_cpus: [ on ] + ... libperl: [ on ] + ... libpython: [ on ] + ... libslang: [ on ] + ... libcrypto: [ on ] + ... libunwind: [ on ] + ... libdw-dwarf-unwind: [ on ] + ... zlib: [ on ] + ... lzma: [ on ] + ... get_cpuid: [ on ] + ... bpf: [ on ] + + GEN /tmp/build/perf/common-cmds.h + HOSTCC /tmp/build/perf/fixdep.o + HOSTLD /tmp/build/perf/fixdep-in.o + LINK /tmp/build/perf/fixdep + MKDIR /tmp/build/perf/pmu-events/ + HOSTCC /tmp/build/perf/pmu-events/json.o + MKDIR /tmp/build/perf/pmu-events/ + HOSTCC /tmp/build/perf/pmu-events/jsmn.o + HOSTCC /tmp/build/perf/pmu-events/jevents.o + HOSTLD /tmp/build/perf/pmu-events/jevents-in.o + PERF_VERSION = 4.9.rc8.g868cd5 + CC /tmp/build/perf/perf-read-vdso32 + + +After: + + $ rm -rf /tmp/build/perf/ ; mkdir -p /tmp/build/perf ; make -k O=/tmp/build/perf -C tools/perf install-bin + make: Entering directory '/home/acme/git/linux/tools/perf' + BUILD: Doing 'make -j4' parallel build + HOSTCC /tmp/build/perf/fixdep.o + HOSTLD /tmp/build/perf/fixdep-in.o + LINK /tmp/build/perf/fixdep + + Auto-detecting system features: + ... dwarf: [ on ] + ... dwarf_getlocations: [ on ] + ... glibc: [ on ] + ... gtk2: [ on ] + ... libaudit: [ on ] + ... libbfd: [ on ] + ... libelf: [ on ] + ... libnuma: [ on ] + ... numa_num_possible_cpus: [ on ] + ... libperl: [ on ] + ... libpython: [ on ] + ... libslang: [ on ] + ... libcrypto: [ on ] + ... libunwind: [ on ] + ... libdw-dwarf-unwind: [ on ] + ... zlib: [ on ] + ... lzma: [ on ] + ... get_cpuid: [ on ] + ... bpf: [ on ] + + GEN /tmp/build/perf/common-cmds.h + MKDIR /tmp/build/perf/fd/ + CC /tmp/build/perf/fd/array.o + LD /tmp/build/perf/fd/libapi-in.o + MKDIR /tmp/build/perf/fs/ + CC /tmp/build/perf/event-parse.o + CC /tmp/build/perf/fs/fs.o + PERF_VERSION = 4.9.rc8.g57a92f + CC /tmp/build/perf/event-plugin.o + MKDIR /tmp/build/perf/fs/ + CC /tmp/build/perf/fs/tracing_path.o + + +Signed-off-by: Jiri Olsa +Tested-by: Arnaldo Carvalho de Melo +Cc: David Ahern +Cc: Namhyung Kim +Cc: Peter Zijlstra +Link: http://lkml.kernel.org/r/1481030331-31944-3-git-send-email-jolsa@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/Makefile.perf | 50 ++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 38 insertions(+), 12 deletions(-) + +diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf +index 9e5a6e1..33b1d9f 100644 +--- a/tools/perf/Makefile.perf ++++ b/tools/perf/Makefile.perf +@@ -177,6 +177,35 @@ ifeq ($(filter-out $(NON_CONFIG_TARGETS) + endif + endif + ++# The fixdep build - we force fixdep tool to be built as ++# the first target in the separate make session not to be ++# disturbed by any parallel make jobs. Once fixdep is done ++# we issue the requested build with FIXDEP=1 variable. ++# ++# The fixdep build is disabled for $(NON_CONFIG_TARGETS) ++# targets, because it's not necessary. ++ ++ifdef FIXDEP ++ force_fixdep := 0 ++else ++ force_fixdep := $(config) ++endif ++ ++export srctree OUTPUT RM CC CXX LD AR CFLAGS CXXFLAGS V BISON FLEX AWK ++export HOSTCC HOSTLD HOSTAR ++ ++include $(srctree)/tools/build/Makefile.include ++ ++ifeq ($(force_fixdep),1) ++goals := $(filter-out all sub-make, $(MAKECMDGOALS)) ++ ++$(goals) all: sub-make ++ ++sub-make: fixdep ++ $(Q)$(MAKE) FIXDEP=1 -f Makefile.perf $(goals) ++ ++else # force_fixdep ++ + # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed. + # Without this setting the output feature dump file misses some features, for + # example, liberty. Select all checkers so we won't get an incomplete feature +@@ -348,10 +377,6 @@ strip: $(PROGRAMS) $(OUTPUT)perf + + PERF_IN := $(OUTPUT)perf-in.o + +-export srctree OUTPUT RM CC LD AR CFLAGS V BISON FLEX AWK +-export HOSTCC HOSTLD HOSTAR +-include $(srctree)/tools/build/Makefile.include +- + JEVENTS := $(OUTPUT)pmu-events/jevents + JEVENTS_IN := $(OUTPUT)pmu-events/jevents-in.o + +@@ -470,7 +495,7 @@ $(OUTPUT)perf: $(PERFLIBS) $(PERF_IN) $( + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS) \ + $(PERF_IN) $(PMU_EVENTS_IN) $(LIBS) -o $@ + +-$(GTK_IN): fixdep FORCE ++$(GTK_IN): FORCE + $(Q)$(MAKE) $(build)=gtk + + $(OUTPUT)libperf-gtk.so: $(GTK_IN) $(PERFLIBS) +@@ -515,7 +540,7 @@ endif + __build-dir = $(subst $(OUTPUT),,$(dir $@)) + build-dir = $(if $(__build-dir),$(__build-dir),.) + +-prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h fixdep archheaders ++prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders + + $(OUTPUT)%.o: %.c prepare FORCE + $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@ +@@ -555,7 +580,7 @@ $(patsubst perf-%,%.o,$(PROGRAMS)): $(wi + + LIBPERF_IN := $(OUTPUT)libperf-in.o + +-$(LIBPERF_IN): prepare fixdep FORCE ++$(LIBPERF_IN): prepare FORCE + $(Q)$(MAKE) $(build)=libperf + + $(LIB_FILE): $(LIBPERF_IN) +@@ -563,10 +588,10 @@ $(LIB_FILE): $(LIBPERF_IN) + + LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) + +-$(LIBTRACEEVENT): fixdep FORCE ++$(LIBTRACEEVENT): FORCE + $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) $(OUTPUT)libtraceevent.a + +-libtraceevent_plugins: fixdep FORCE ++libtraceevent_plugins: FORCE + $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) plugins + + $(LIBTRACEEVENT_DYNAMIC_LIST): libtraceevent_plugins +@@ -579,21 +604,21 @@ $(LIBTRACEEVENT)-clean: + install-traceevent-plugins: libtraceevent_plugins + $(Q)$(MAKE) -C $(TRACE_EVENT_DIR) $(LIBTRACEEVENT_FLAGS) O=$(OUTPUT) install_plugins + +-$(LIBAPI): fixdep FORCE ++$(LIBAPI): FORCE + $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) $(OUTPUT)libapi.a + + $(LIBAPI)-clean: + $(call QUIET_CLEAN, libapi) + $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null + +-$(LIBBPF): fixdep FORCE ++$(LIBBPF): FORCE + $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) + + $(LIBBPF)-clean: + $(call QUIET_CLEAN, libbpf) + $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) clean >/dev/null + +-$(LIBSUBCMD): fixdep FORCE ++$(LIBSUBCMD): FORCE + $(Q)$(MAKE) -C $(SUBCMD_DIR) O=$(OUTPUT) $(OUTPUT)libsubcmd.a + + $(LIBSUBCMD)-clean: +@@ -790,3 +815,4 @@ FORCE: + .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare + .PHONY: libtraceevent_plugins archheaders + ++endif # force_fixdep diff --git a/kernel/kernel/files/patches/mageia/tools-perf-tools-Move-perf-build-related-variables-under-n.patch b/kernel/kernel/files/patches/mageia/tools-perf-tools-Move-perf-build-related-variables-under-n.patch new file mode 100644 index 00000000..9b50c1cd --- /dev/null +++ b/kernel/kernel/files/patches/mageia/tools-perf-tools-Move-perf-build-related-variables-under-n.patch @@ -0,0 +1,49 @@ +From 8ac1eb7bab7c8d9d6f00b3e2a408611c45d9dff0 Mon Sep 17 00:00:00 2001 +From: Jiri Olsa +Date: Tue, 6 Dec 2016 14:18:50 +0100 +Subject: [PATCH] perf tools: Move perf build related variables under non + fixdep leg + +Because there's no need for them in fixdep build. + +Signed-off-by: Jiri Olsa +Cc: David Ahern +Cc: Namhyung Kim +Cc: Peter Zijlstra +Link: http://lkml.kernel.org/r/1481030331-31944-4-git-send-email-jolsa@kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +--- + tools/perf/Makefile.perf | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf +index 33b1d9f..8f1c258 100644 +--- a/tools/perf/Makefile.perf ++++ b/tools/perf/Makefile.perf +@@ -164,11 +164,6 @@ BISON = bison + STRIP = strip + AWK = awk + +-LIB_DIR = $(srctree)/tools/lib/api/ +-TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ +-BPF_DIR = $(srctree)/tools/lib/bpf/ +-SUBCMD_DIR = $(srctree)/tools/lib/subcmd/ +- + # include Makefile.config by default and rule out + # non-config cases + config := 1 +@@ -210,6 +205,11 @@ sub-make: fixdep + + else # force_fixdep + ++LIB_DIR = $(srctree)/tools/lib/api/ ++TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ ++BPF_DIR = $(srctree)/tools/lib/bpf/ ++SUBCMD_DIR = $(srctree)/tools/lib/subcmd/ ++ + # Set FEATURE_TESTS to 'all' so all possible feature checkers are executed. + # Without this setting the output feature dump file misses some features, for + # example, liberty. Select all checkers so we won't get an incomplete feature +-- +2.10.2 + diff --git a/kernel/kernel/files/patches/mageia/tools-testing-selftest-Makefile-remove-powerpc-reference.patch b/kernel/kernel/files/patches/mageia/tools-testing-selftest-Makefile-remove-powerpc-reference.patch index 677e97df..fea25f61 100644 --- a/kernel/kernel/files/patches/mageia/tools-testing-selftest-Makefile-remove-powerpc-reference.patch +++ b/kernel/kernel/files/patches/mageia/tools-testing-selftest-Makefile-remove-powerpc-reference.patch @@ -1,9 +1,9 @@ --- linux/tools/testing/selftests/Makefile.orig +++ linux/tools/testing/selftests/Makefile -@@ -15,7 +15,6 @@ TARGETS += memory-hotplug - TARGETS += mount +@@ -16,7 +16,6 @@ TARGETS += mount TARGETS += mqueue TARGETS += net + TARGETS += nsfs -TARGETS += powerpc TARGETS += pstore TARGETS += ptrace diff --git a/kernel/kernel/pspec.xml b/kernel/kernel/pspec.xml index 7fc3e080..7232bb6d 100644 --- a/kernel/kernel/pspec.xml +++ b/kernel/kernel/pspec.xml @@ -12,7 +12,7 @@ kernel

The Linux kernel (the core of the Linux operating system) for Pisi Linux kernel contains the Linux kernel, the core of any Linux operating system. The kernel handles the basic functions of the operating system: memory allocation, process allocation, device input and output, etc. - https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.8.tar.gz + https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.tar.gz configs/kernel-i686-config configs/kernel-x86_64-config @@ -28,15 +28,16 @@ - patches/linux/patch-4.8.13.xz - + patches/linux/patch-4.9.6.xz + + + patches/mageia/stable-fbdev-color-map-copying-bounds-checking.patch + patches/mageia/stable-tile-ptrace-preserve-previous-registers-for-short-regset-write.patch + patches/mageia/stable-drm-schedule-the-output_poll_work-with-1s-delay-if-we-have-delayed-event.patch + patches/mageia/stable-drm-fix-broken-vt-switch-with-video-1366x768-option.patch + patches/mageia/stable-drm-i915-ignore-bogus-plane-coordinates-on-skl-when-the-plane-is-not-visible.patch - patches/mageia/Revert-ipmi-Start-the-timer-and-thread-on-internal-m.patch - patches/mageia/x86-pci-toshiba-equium-a60-assign-busses.patch - patches/mageia/x86-boot-video-80x25-if-break.patch - patches/mageia/x86-default_poweroff_up_machines.patch - patches/mageia/x86-increase-default-minimum-vmalloc-area-by-64MB-to-192MB.patch patches/mageia/Revert-cpufreq-pcc-Enable-autoload-of-pcc-cpufreq-fo.patch patches/mageia/Revert-x86-mm-mtrr-Remove-kernel-internal-MTRR-inter.patch patches/mageia/base-cacheinfo-silence-DT-warnings.patch @@ -45,6 +46,7 @@ patches/mageia/acpi-CLEVO-M360S-disable_acpi_irq.patch patches/mageia/acpi-processor-M720SR-limit-to-C2.patch patches/mageia/ACPI-video-Add-a-quirk-to-force-acpi-video-backlight.patch + patches/mageia/acpi-do-not-warn-if-_BQC-does-not-exist.patch @@ -83,7 +90,11 @@ patches/mageia/gpu-drm-mach64-restore-mach64_PCI_IDS.patch patches/mageia/gpu-drm-mach64-linux-3.14-buildfix.patch patches/mageia/gpu-drm-mach64-3.17-buildfix.patch - patches/mageia/gpu-drm-mach64-3.18-buildfix.patch + patches/mageia/gpu-drm-mach64-3.18-buildfix.patch + patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-A0-and-B0-revisions.patch + patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-D0-revision.patch + patches/mageia/gpu-drm-i915-skl-drop-workarounds-for-E0-revision.patch + patches/mageia/gpu-drm-i915-Remove-WaDisableLSQCROPERFforOCL-KBL-workaround.patch patches/mageia/input-i8042-quirks-for-Fujitsu-Lifebook-A544-and-Lif.patch patches/mageia/net-sis190-fix-list-usage.patch patches/mageia/net-netfilter-IFWLOG.patch @@ -96,7 +107,10 @@ patches/mageia/net-netfilter-psd.patch patches/mageia/net-netfilter-psd-mdv.patch patches/mageia/net-netfilter-psd-2.6.35-buildfix.patch - patches/mageia/net-wireless-rtlwifi-Fix-regression-caused-by-commit-d86e64768859.patch + patches/mageia/net-netfilter-psd-fix-redefines.patch + patches/mageia/net-wireless-rtlwifi-Use-dev_kfree_skb_irq-instead-of-kfree_skb.patch + patches/mageia/net-wireless-rtlwifi-Fix-kernel-oops-introduced-with-commit-e4965.patch + patches/mageia/net-wireless-brcmfmac-fix-incorrect-event-channel-deduction.patch patches/mageia/platform-x86-add-shuttle-wmi-driver.patch patches/mageia/platform-x86-shuttle-wmi-drop-devinit-exit.patch patches/mageia/platform-x86-shuttle-wmi-4.2-buildfix.patch @@ -131,9 +145,10 @@ patches/mageia/3rd-viahss-2.6.35-buildfix.patch patches/mageia/3rd-viahss-3.0-buildfix.patch patches/mageia/3rd-rtl8723bs.patch - patches/mageia/3rd-rtl8723bs-4.7-buildfix.patch - patches/mageia/3rd-rtl8723bs-4.8-buildfix.patch patches/mageia/tools-testing-selftest-Makefile-remove-powerpc-reference.patch + patches/mageia/tools-build-Make-fixdep-parsing-wait-for-last-target.patch + patches/mageia/tools-perf-tools-Force-fixdep-compilation-at-the-start-of-.patch + patches/mageia/tools-perf-tools-Move-perf-build-related-variables-under-n.patch @@ -189,6 +204,17 @@ + + 2017-01-27 + 4.9.6 + Version Bump. + security + + systemRestart + + Ertuğrul Erata + ertugrulerata@gmail.com + 2016-12-10 4.8.13