From 297b60346df8beafee954a0fd7c2d64f33f3b9bc Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Sat, 11 May 2024 01:44:05 +0000
Subject: [PATCH] rtl8211F_led_control
---
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/wl_cfg_btcoex.c | 128 ++++++++++++++++++++++++++----------------
1 files changed, 79 insertions(+), 49 deletions(-)
diff --git a/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/wl_cfg_btcoex.c b/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/wl_cfg_btcoex.c
index 363e925..e67adc7 100644
--- a/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/wl_cfg_btcoex.c
+++ b/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/wl_cfg_btcoex.c
@@ -1,15 +1,16 @@
-/* SPDX-License-Identifier: GPL-2.0 */
/*
* Linux cfg80211 driver - Dongle Host Driver (DHD) related
*
- * Copyright (C) 1999-2019, Broadcom Corporation
- *
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
+ *
+ * Copyright (C) 1999-2017, Broadcom Corporation
+ *
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to you
* under the terms of the GNU General Public License version 2 (the "GPL"),
* available at http://www.broadcom.com/licenses/GPLv2.php, with the
* following added to such license:
- *
+ *
* As a special exception, the copyright holders of this software give you
* permission to link this software with independent modules, and to copy and
* distribute the resulting executable under terms of your choice, provided that
@@ -17,7 +18,7 @@
* the license of that module. An independent module is a module which is not
* derived from this software. The special exception does not apply to any
* modifications of the software.
- *
+ *
* Notwithstanding the above, under no circumstances may you combine this
* software in any way with any other Broadcom software provided under a license
* other than the GPL, without Broadcom's express prior written consent.
@@ -25,7 +26,7 @@
*
* <<Broadcom-WL-IPTag/Open:>>
*
- * $Id: wl_cfg_btcoex.c 709309 2019-01-17 09:04:00Z $
+ * $Id: wl_cfg_btcoex.c 814554 2019-04-11 23:06:22Z $
*/
#include <net/rtnetlink.h>
@@ -43,10 +44,10 @@
extern uint dhd_pkt_filter_enable;
extern uint dhd_master_mode;
extern void dhd_pktfilter_offload_enable(dhd_pub_t * dhd, char *arg, int enable, int master_mode);
-#endif
+#endif // endif
struct btcoex_info {
- struct timer_list timer;
+ timer_list_compat_t timer;
u32 timer_ms;
u32 timer_on;
u32 ts_dhcp_start; /* ms ts ecord time stats */
@@ -59,6 +60,7 @@
struct net_device *dev;
};
+#if defined(OEM_ANDROID)
static struct btcoex_info *btcoex_info_loc = NULL;
/* TODO: clean up the BT-Coex code, it still have some legacy ioctl/iovar functions */
@@ -71,6 +73,9 @@
#define BT_DHCP_OPPR_WIN_TIME 2500
/* T2 turn off SCO/SCO supperesion is (timeout) */
#define BT_DHCP_FLAG_FORCE_TIME 5500
+
+#define BTCOEXMODE "BTCOEXMODE"
+#define POWERMODE "POWERMODE"
enum wl_cfg80211_btcoex_status {
BT_DHCP_IDLE,
@@ -93,9 +98,12 @@
} var;
int error;
- bcm_mkiovar(name, (char *)(®), sizeof(reg),
- (char *)(&var), sizeof(var.buf));
- error = wldev_ioctl(dev, WLC_GET_VAR, (char *)(&var), sizeof(var.buf), false);
+ bzero(&var, sizeof(var));
+ error = bcm_mkiovar(name, (char *)(®), sizeof(reg), (char *)(&var), sizeof(var.buf));
+ if (error == 0) {
+ return BCME_BUFTOOSHORT;
+ }
+ error = wldev_ioctl_get(dev, WLC_GET_VAR, (char *)(&var), sizeof(var.buf));
*retval = dtoh32(var.val);
return (error);
@@ -104,16 +112,15 @@
static int
dev_wlc_bufvar_set(struct net_device *dev, char *name, char *buf, int len)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31)
- char ioctlbuf_local[1024];
-#else
- static char ioctlbuf_local[1024];
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 31) */
+ char ioctlbuf_local[WLC_IOCTL_SMLEN];
+ int ret;
- bcm_mkiovar(name, buf, len, ioctlbuf_local, sizeof(ioctlbuf_local));
-
- return (wldev_ioctl(dev, WLC_SET_VAR, ioctlbuf_local, sizeof(ioctlbuf_local), true));
+ ret = bcm_mkiovar(name, buf, len, ioctlbuf_local, sizeof(ioctlbuf_local));
+ if (ret == 0)
+ return BCME_BUFTOOSHORT;
+ return (wldev_ioctl_set(dev, WLC_SET_VAR, ioctlbuf_local, ret));
}
+
/*
get named driver variable to uint register value and return error indication
calling example: dev_wlc_intvar_set_reg(dev, "btc_params",66, value)
@@ -123,7 +130,7 @@
{
char reg_addr[8];
- memset(reg_addr, 0, sizeof(reg_addr));
+ bzero(reg_addr, sizeof(reg_addr));
memcpy((char *)®_addr[0], (char *)addr, 4);
memcpy((char *)®_addr[4], (char *)val, 4);
@@ -276,13 +283,12 @@
#if defined(BT_DHCP_USE_FLAGS)
char buf_flag7_dhcp_on[8] = { 7, 00, 00, 00, 0x1, 0x0, 0x00, 0x00 };
char buf_flag7_default[8] = { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
-#endif
-
+#endif // endif
#if defined(BT_DHCP_eSCO_FIX)
/* set = 1, save & turn on 0 - off & restore prev settings */
set_btc_esco_params(dev, set);
-#endif
+#endif // endif
#if defined(BT_DHCP_USE_FLAGS)
WL_TRACE(("WI-FI priority boost via bt flags, set:%d\n", set));
@@ -296,18 +302,12 @@
dev_wlc_bufvar_set(dev, "btc_flags",
(char *)&buf_flag7_default[0],
sizeof(buf_flag7_default));
-#endif
+#endif // endif
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
-static void wl_cfg80211_bt_timerfunc(struct timer_list *t)
-{
- struct btcoex_info *bt_local = from_timer(bt_local, t, timer);
-#else
static void wl_cfg80211_bt_timerfunc(ulong data)
{
struct btcoex_info *bt_local = (struct btcoex_info *)data;
-#endif
WL_TRACE(("Enter\n"));
bt_local->timer_on = 0;
schedule_work(&bt_local->work);
@@ -317,7 +317,9 @@
{
struct btcoex_info *btcx_inf;
+ GCC_DIAGNOSTIC_PUSH_SUPPRESS_CAST();
btcx_inf = container_of(work, struct btcoex_info, work);
+ GCC_DIAGNOSTIC_POP();
if (btcx_inf->timer_on) {
btcx_inf->timer_on = 0;
@@ -397,13 +399,7 @@
btco_inf->ts_dhcp_ok = 0;
/* Set up timer for BT */
btco_inf->timer_ms = 10;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
- timer_setup(&btco_inf->timer, wl_cfg80211_bt_timerfunc, 0);
-#else
- init_timer(&btco_inf->timer);
- btco_inf->timer.data = (ulong)btco_inf;
- btco_inf->timer.function = wl_cfg80211_bt_timerfunc;
-#endif
+ init_timer_compat(&btco_inf->timer, wl_cfg80211_bt_timerfunc, btco_inf);
btco_inf->dev = ndev;
@@ -431,8 +427,13 @@
int wl_cfg80211_set_btcoex_dhcp(struct net_device *dev, dhd_pub_t *dhd, char *command)
{
+#ifndef OEM_ANDROID
+ static int pm = PM_FAST;
+ int pm_local = PM_OFF;
+#endif /* OEM_ANDROID */
struct btcoex_info *btco_inf = btcoex_info_loc;
char powermode_val = 0;
+ uint8 cmd_len = 0;
char buf_reg66va_dhcp_on[8] = { 66, 00, 00, 00, 0x10, 0x27, 0x00, 0x00 };
char buf_reg41va_dhcp_on[8] = { 41, 00, 00, 00, 0x33, 0x00, 0x00, 0x00 };
char buf_reg68va_dhcp_on[8] = { 68, 00, 00, 00, 0x90, 0x01, 0x00, 0x00 };
@@ -446,23 +447,38 @@
char buf_flag7_default[8] = { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
/* Figure out powermode 1 or o command */
- strncpy((char *)&powermode_val, command + strlen("BTCOEXMODE") +1, 1);
+#ifdef OEM_ANDROID
+ cmd_len = sizeof(BTCOEXMODE);
+#else
+ cmd_len = sizeof(POWERMODE);
+#endif // endif
+ powermode_val = command[cmd_len];
- if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {
+ if (powermode_val == '1') {
WL_TRACE_HW4(("DHCP session starts\n"));
-
#ifdef PKT_FILTER_SUPPORT
dhd->dhcp_in_progress = 1;
+#if defined(APSTA_BLOCK_ARP_DURING_DHCP)
+ if (DHD_OPMODE_STA_SOFTAP_CONCURR(dhd)) {
+ /* Block ARP frames while DHCP of STA interface is in
+ * progress in case of STA/SoftAP concurrent mode
+ */
+ wl_cfg80211_block_arp(dev, TRUE);
+ } else
+#endif /* APSTA_BLOCK_ARP_DURING_DHCP */
if (dhd->early_suspended) {
WL_TRACE_HW4(("DHCP in progressing , disable packet filter!!!\n"));
dhd_enable_packet_filter(0, dhd);
}
-#endif
+#endif /* PKT_FILTER_SUPPORT */
/* Retrieve and saved orig regs value */
if ((saved_status == FALSE) &&
+#ifndef OEM_ANDROID
+ (!dev_wlc_ioctl(dev, WLC_GET_PM, &pm, sizeof(pm))) &&
+#endif // endif
(!dev_wlc_intvar_get_reg(dev, "btc_params", 66, &saved_reg66)) &&
(!dev_wlc_intvar_get_reg(dev, "btc_params", 41, &saved_reg41)) &&
(!dev_wlc_intvar_get_reg(dev, "btc_params", 68, &saved_reg68))) {
@@ -471,6 +487,9 @@
saved_reg66, saved_reg41, saved_reg68));
/* Disable PM mode during dhpc session */
+#ifndef OEM_ANDROID
+ dev_wlc_ioctl(dev, WLC_SET_PM, &pm_local, sizeof(pm_local));
+#endif // endif
/* Disable PM mode during dhpc session */
/* Start BT timer only for SCO connection */
@@ -491,7 +510,8 @@
btco_inf->bt_state = BT_DHCP_START;
btco_inf->timer_on = 1;
- mod_timer(&btco_inf->timer, btco_inf->timer.expires);
+ mod_timer(&btco_inf->timer,
+ timer_expires(&btco_inf->timer));
WL_TRACE(("enable BT DHCP Timer\n"));
}
}
@@ -499,22 +519,33 @@
WL_ERR(("was called w/o DHCP OFF. Continue\n"));
}
}
- else if (strnicmp((char *)&powermode_val, "2", strlen("2")) == 0) {
-
-
+#ifdef OEM_ANDROID
+ else if (powermode_val == '2') {
+#else
+ else if (powermode_val == '0') {
+#endif // endif
#ifdef PKT_FILTER_SUPPORT
dhd->dhcp_in_progress = 0;
WL_TRACE_HW4(("DHCP is complete \n"));
- /* Enable packet filtering */
+#if defined(APSTA_BLOCK_ARP_DURING_DHCP)
+ if (DHD_OPMODE_STA_SOFTAP_CONCURR(dhd)) {
+ /* Unblock ARP frames */
+ wl_cfg80211_block_arp(dev, FALSE);
+ } else
+#endif /* APSTA_BLOCK_ARP_DURING_DHCP */
if (dhd->early_suspended) {
+ /* Enable packet filtering */
WL_TRACE_HW4(("DHCP is complete , enable packet filter!!!\n"));
dhd_enable_packet_filter(1, dhd);
}
#endif /* PKT_FILTER_SUPPORT */
/* Restoring PM mode */
+#ifndef OEM_ANDROID
+ dev_wlc_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm));
+#endif // endif
/* Stop any bt timer because DHCP session is done */
WL_TRACE(("disable BT DHCP Timer\n"));
@@ -557,7 +588,6 @@
WL_ERR(("Unkwown yet power setting, ignored\n"));
}
- snprintf(command, 3, "OK");
-
- return (strlen("OK"));
+ return (snprintf(command, sizeof("OK"), "OK") + 1);
}
+#endif /* defined(OEM_ANDROID) */
--
Gitblit v1.6.2