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/dhd_cdc.c | 250 ++++++++++++++++++--------------------------------
1 files changed, 90 insertions(+), 160 deletions(-)
diff --git a/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_cdc.c b/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_cdc.c
index 926300d..fda0c7e 100644
--- a/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_cdc.c
+++ b/kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_cdc.c
@@ -1,15 +1,16 @@
-/* SPDX-License-Identifier: GPL-2.0 */
/*
* DHD Protocol Module for CDC and BDC.
*
- * 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: dhd_cdc.c 708487 2018-10-31 05:33:14Z $
+ * $Id: dhd_cdc.c 692135 2017-03-26 17:19:39Z $
*
* BDC is like CDC, except it includes a header for data packets to convey
* packet priority over the bus, and flags (e.g. to indicate checksum status
@@ -42,27 +43,17 @@
#include <dngl_stats.h>
#include <dhd.h>
#include <dhd_proto.h>
-#ifdef BCMDBUS
-#include <dbus.h>
-#else
#include <dhd_bus.h>
-#endif /* BCMDBUS */
#include <dhd_dbg.h>
-
#ifdef PROP_TXSTATUS
#include <wlfc_proto.h>
#include <dhd_wlfc.h>
-#endif
-
-#ifdef LOAD_DHD_WITH_FW_ALIVE
-#include <dhd_chip_info.h>
-#endif
+#endif // endif
#ifdef DHD_ULP
#include <dhd_ulp.h>
#endif /* DHD_ULP */
-
#define RETRIES 2 /* # of retries to retrieve matching ioctl response */
#define BUS_HEADER_LEN (24+DHD_SDALIGN) /* Must be at least SDPCM_RESERVE
@@ -77,24 +68,21 @@
uint16 reqid;
uint8 pending;
uint32 lastcmd;
-#ifdef BCMDBUS
- uint ctl_completed;
-#endif
uint8 bus_header[BUS_HEADER_LEN];
cdc_ioctl_t msg;
unsigned char buf[WLC_IOCTL_MAXLEN + ROUND_UP_MARGIN];
} dhd_prot_t;
-#if defined(BCMDBUS)
-extern int dhd_dbus_txdata(dhd_pub_t *dhdp, void *pktbuf);
-#endif
+uint16
+dhd_prot_get_ioctl_trans_id(dhd_pub_t *dhdp)
+{
+ /* SDIO does not have ioctl_trans_id yet, so return -1 */
+ return -1;
+}
static int
dhdcdc_msg(dhd_pub_t *dhd)
{
-#ifdef BCMDBUS
- int timeout = 0;
-#endif /* BCMDBUS */
int err = 0;
dhd_prot_t *prot = dhd->prot;
int len = ltoh32(prot->msg.len) + sizeof(cdc_ioctl_t);
@@ -111,51 +99,8 @@
len = CDC_MAX_MSG_SIZE;
/* Send request */
-#ifdef BCMDBUS
- DHD_OS_IOCTL_RESP_LOCK(dhd);
- prot->ctl_completed = FALSE;
- err = dbus_send_ctl(dhd->dbus, (void *)&prot->msg, len);
- if (err) {
- DHD_ERROR(("dbus_send_ctl error=0x%x\n", err));
- DHD_OS_IOCTL_RESP_UNLOCK(dhd);
- DHD_OS_WAKE_UNLOCK(dhd);
- return err;
- }
-#else
err = dhd_bus_txctl(dhd->bus, (uchar*)&prot->msg, len);
-#endif
-#ifdef BCMDBUS
- timeout = dhd_os_ioctl_resp_wait(dhd, &prot->ctl_completed);
- if ((!timeout) || (!prot->ctl_completed)) {
- DHD_ERROR(("Txctl timeout %d ctl_completed %d\n",
- timeout, prot->ctl_completed));
- DHD_ERROR(("Txctl wait timed out\n"));
- err = -1;
- }
- DHD_OS_IOCTL_RESP_UNLOCK(dhd);
-#endif
-#if defined(BCMDBUS) && defined(INTR_EP_ENABLE)
- /* If the ctl write is successfully completed, wait for an acknowledgement
- * that indicates that it is now ok to do ctl read from the dongle
- */
- if (err != -1) {
- DHD_OS_IOCTL_RESP_LOCK(dhd);
- prot->ctl_completed = FALSE;
- if (dbus_poll_intr(dhd->dbus)) {
- DHD_ERROR(("dbus_poll_intr not submitted\n"));
- } else {
- /* interrupt polling is sucessfully submitted. Wait for dongle to send
- * interrupt
- */
- timeout = dhd_os_ioctl_resp_wait(dhd, &prot->ctl_completed);
- if (!timeout) {
- DHD_ERROR(("intr poll wait timed out\n"));
- }
- }
- DHD_OS_IOCTL_RESP_UNLOCK(dhd);
- }
-#endif /* defined(BCMDBUS) && defined(INTR_EP_ENABLE) */
DHD_OS_WAKE_UNLOCK(dhd);
return err;
}
@@ -163,49 +108,18 @@
static int
dhdcdc_cmplt(dhd_pub_t *dhd, uint32 id, uint32 len)
{
-#ifdef BCMDBUS
- int timeout = 0;
-#endif /* BCMDBUS */
int ret;
int cdc_len = len + sizeof(cdc_ioctl_t);
dhd_prot_t *prot = dhd->prot;
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
-
do {
-#ifdef BCMDBUS
- DHD_OS_IOCTL_RESP_LOCK(dhd);
- prot->ctl_completed = FALSE;
- ret = dbus_recv_ctl(dhd->dbus, (uchar*)&prot->msg, cdc_len);
- if (ret) {
- DHD_ERROR(("dbus_recv_ctl error=0x%x(%d)\n", ret, ret));
- DHD_OS_IOCTL_RESP_UNLOCK(dhd);
- goto done;
- }
- timeout = dhd_os_ioctl_resp_wait(dhd, &prot->ctl_completed);
- if ((!timeout) || (!prot->ctl_completed)) {
- DHD_ERROR(("Rxctl timeout %d ctl_completed %d\n",
- timeout, prot->ctl_completed));
- ret = -1;
- DHD_OS_IOCTL_RESP_UNLOCK(dhd);
-
- goto done;
- }
- DHD_OS_IOCTL_RESP_UNLOCK(dhd);
-
- ret = cdc_len;
-#else
ret = dhd_bus_rxctl(dhd->bus, (uchar*)&prot->msg, cdc_len);
-#endif /* BCMDBUS */
if (ret < 0)
break;
} while (CDC_IOC_ID(ltoh32(prot->msg.flags)) != id);
-
-#ifdef BCMDBUS
-done:
-#endif /* BCMDBUS */
return ret;
}
@@ -219,7 +133,6 @@
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
DHD_CTL(("%s: cmd %d len %d\n", __FUNCTION__, cmd, len));
-
/* Respond "bcmerror" and "bcmerrorstr" with local cache */
if (cmd == WLC_GET_VAR && buf)
@@ -238,6 +151,24 @@
memset(msg, 0, sizeof(cdc_ioctl_t));
+#ifdef BCMSPI
+ /* 11bit gSPI bus allows 2048bytes of max-data. We restrict 'len'
+ * value which is 8Kbytes for various 'get' commands to 2000. 48 bytes are
+ * left for sw headers and misc.
+ */
+
+ if (len > 2000) {
+ DHD_ERROR(("dhdcdc_query_ioctl: len is truncated to 2000 bytes\n"));
+ len = 2000;
+ }
+#ifdef BCMQT
+ /* WAR: packet length limited for SPI host issue in FIFO mode on Zebu */
+ if (len > 460) {
+ DHD_ERROR(("len is truncated to 460 bytes on Zebu\n"));
+ len = 460;
+ }
+#endif /* BCMQT */
+#endif /* BCMSPI */
msg->cmd = htol32(cmd);
msg->len = htol32(len);
msg->flags = (++prot->reqid << CDCF_IOC_ID_SHIFT);
@@ -293,6 +224,9 @@
return ret;
}
+#ifdef DHD_PM_CONTROL_FROM_FILE
+extern bool g_pm_control;
+#endif /* DHD_PM_CONTROL_FROM_FILE */
static int
dhdcdc_set_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf, uint len, uint8 action)
@@ -317,6 +251,24 @@
return -EIO;
}
+ if (cmd == WLC_SET_PM) {
+#ifdef DHD_PM_CONTROL_FROM_FILE
+ if (g_pm_control == TRUE) {
+ DHD_ERROR(("%s: SET PM ignored!(Requested:%d)\n",
+ __FUNCTION__, buf ? *(char *)buf : 0));
+ goto done;
+ }
+#endif /* DHD_PM_CONTROL_FROM_FILE */
+#if defined(WLAIBSS)
+ if (dhd->op_mode == DHD_FLAG_IBSS_MODE) {
+ DHD_ERROR(("%s: SET PM ignored for IBSS!(Requested:%d)\n",
+ __FUNCTION__, buf ? *(char *)buf : 0));
+ goto done;
+ }
+#endif /* WLAIBSS */
+ DHD_TRACE_HW4(("%s: SET PM to %d\n", __FUNCTION__, buf ? *(char *)buf : 0));
+ }
+
memset(msg, 0, sizeof(cdc_ioctl_t));
msg->cmd = htol32(cmd);
@@ -332,8 +284,7 @@
memcpy(prot->buf, buf, len);
#ifdef DHD_ULP
- if (buf && (!strncmp(buf, "wowl_force", sizeof("wowl_force")) ||
- !strncmp(buf, "ulp", sizeof("ulp")))) {
+ if (buf && (!strncmp(buf, "ulp", sizeof("ulp")))) {
/* force all the writes after this point to NOT to use cached sbwad value */
dhd_ulp_disable_cached_sbwad(dhd);
}
@@ -375,26 +326,6 @@
return ret;
}
-#ifdef BCMDBUS
-int
-dhd_prot_ctl_complete(dhd_pub_t *dhd)
-{
- dhd_prot_t *prot;
-
- if (dhd == NULL)
- return BCME_ERROR;
-
- prot = dhd->prot;
-
- ASSERT(prot);
- DHD_OS_IOCTL_RESP_LOCK(dhd);
- prot->ctl_completed = TRUE;
- dhd_os_ioctl_resp_wake(dhd);
- DHD_OS_IOCTL_RESP_UNLOCK(dhd);
- return 0;
-}
-#endif /* BCMDBUS */
-
int
dhd_prot_ioctl(dhd_pub_t *dhd, int ifidx, wl_ioctl_t * ioc, void * buf, int len)
{
@@ -403,7 +334,8 @@
uint8 action;
if ((dhd->busstate == DHD_BUS_DOWN) || dhd->hang_was_sent) {
- DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__));
+ DHD_ERROR(("%s : bus is down. we have nothing to do - bs: %d, has: %d\n",
+ __FUNCTION__, dhd->busstate, dhd->hang_was_sent));
goto done;
}
@@ -419,7 +351,7 @@
ioc->cmd, (unsigned long)ioc->cmd, prot->lastcmd,
(unsigned long)prot->lastcmd));
if ((ioc->cmd == WLC_SET_VAR) || (ioc->cmd == WLC_GET_VAR)) {
- DHD_TRACE(("iovar cmd=%s\n", (char*)buf));
+ DHD_TRACE(("iovar cmd=%s\n", buf ? (char*)buf : "\0"));
}
goto done;
}
@@ -477,7 +409,7 @@
bcm_bprintf(strbuf, "Protocol CDC: reqid %d\n", dhdp->prot->reqid);
#ifdef PROP_TXSTATUS
dhd_wlfc_dump(dhdp, strbuf);
-#endif
+#endif // endif
}
/* The FreeBSD PKTPUSH could change the packet buf pinter
@@ -504,7 +436,6 @@
if (PKTSUMNEEDED(PKTBUF))
h->flags |= BDC_FLAG_SUM_NEEDED;
-
h->priority = (PKTPRIO(PKTBUF) & BDC_PRIORITY_MASK);
h->flags2 = 0;
h->dataOffset = 0;
@@ -520,7 +451,7 @@
#ifdef BDC
/* Length of BDC(+WLFC) headers pushed */
hdrlen = BDC_HEADER_LEN + (((struct bdc_header *)PKTBUF)->dataOffset * 4);
-#endif
+#endif // endif
return hdrlen;
}
@@ -530,7 +461,7 @@
{
#ifdef BDC
struct bdc_header *h;
-#endif
+#endif // endif
uint8 data_offset = 0;
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
@@ -577,7 +508,6 @@
PKTPULL(dhd->osh, pktbuf, BDC_HEADER_LEN);
#endif /* BDC */
-
#ifdef PROP_TXSTATUS
if (!DHD_PKTTAG_PKTDIR(PKTTAG(pktbuf))) {
/*
@@ -586,12 +516,6 @@
dhd_wlfc_parse_header_info(dhd, pktbuf, (data_offset << 2),
reorder_buf_info, reorder_info_len);
-#ifdef BCMDBUS
-#ifndef DHD_WLFC_THREAD
- dhd_wlfc_commit_packets(dhd,
- (f_commitpkt_t)dhd_dbus_txdata, (void *)dhd, NULL, FALSE);
-#endif /* DHD_WLFC_THREAD */
-#endif /* BCMDBUS */
}
#endif /* PROP_TXSTATUS */
@@ -599,7 +523,6 @@
PKTPULL(dhd->osh, pktbuf, (data_offset << 2));
return 0;
}
-
int
dhd_prot_attach(dhd_pub_t *dhd)
@@ -621,7 +544,7 @@
dhd->prot = cdc;
#ifdef BDC
dhd->hdrlen += BDC_HEADER_LEN;
-#endif
+#endif // endif
dhd->maxctl = WLC_IOCTL_MAXLEN + sizeof(cdc_ioctl_t) + ROUND_UP_MARGIN;
return 0;
@@ -637,7 +560,7 @@
{
#ifdef PROP_TXSTATUS
dhd_wlfc_deinit(dhd);
-#endif
+#endif // endif
DHD_OS_PREFREE(dhd, dhd->prot, sizeof(dhd_prot_t));
dhd->prot = NULL;
}
@@ -661,30 +584,39 @@
{
int ret = 0;
wlc_rev_info_t revinfo;
+#ifndef OEM_ANDROID
+ char buf[128];
+#endif /* OEM_ANDROID */
DHD_TRACE(("%s: Enter\n", __FUNCTION__));
-#ifdef LOAD_DHD_WITH_FW_ALIVE
- if(alive == FW_ALIVE_MAGIC) {
- ret = dhd_preinit_ioctls_alive(dhd);
- } else
-#endif /* LOAD_DHD_WITH_FW_ALIVE */
- {
- /* Get the device rev info */
- memset(&revinfo, 0, sizeof(revinfo));
- ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_REVINFO, &revinfo, sizeof(revinfo), FALSE, 0);
- if (ret < 0)
- goto done;
+#ifndef OEM_ANDROID
+ /* Get the device MAC address */
+ strcpy(buf, "cur_etheraddr");
+ ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_VAR, buf, sizeof(buf), FALSE, 0);
+ if (ret < 0)
+ goto done;
+ memcpy(dhd->mac.octet, buf, ETHER_ADDR_LEN);
+#endif /* OEM_ANDROID */
+#ifdef DHD_FW_COREDUMP
+ /* Check the memdump capability */
+ dhd_get_memdump_info(dhd);
+#endif /* DHD_FW_COREDUMP */
-#if defined(BCMDBUS) && defined(BCMDHDUSB)
- /* dbus_set_revinfo(dhd->dbus, revinfo.chipnum, revinfo.chiprev); */
-#endif /* BCMDBUS && BCMDHDUSB */
+#ifdef BCMASSERT_LOG
+ dhd_get_assert_info(dhd);
+#endif /* BCMASSERT_LOG */
- dhd_process_cid_mac(dhd, TRUE);
+ /* Get the device rev info */
+ memset(&revinfo, 0, sizeof(revinfo));
+ ret = dhd_wl_ioctl_cmd(dhd, WLC_GET_REVINFO, &revinfo, sizeof(revinfo), FALSE, 0);
+ if (ret < 0)
+ goto done;
- ret = dhd_preinit_ioctls(dhd);
- if (!ret)
- dhd_process_cid_mac(dhd, FALSE);
- }
+ DHD_SSSR_DUMP_INIT(dhd);
+
+ dhd_process_cid_mac(dhd, TRUE);
+ ret = dhd_preinit_ioctls(dhd);
+ dhd_process_cid_mac(dhd, FALSE);
/* Always assumes wl for now */
dhd->iswl = TRUE;
@@ -703,7 +635,6 @@
{
/* Nothing to do for CDC */
}
-
static void
dhd_get_hostreorder_pkts(void *osh, struct reorder_info *ptr, void **pkt,
@@ -849,7 +780,6 @@
else if (flags & WLHOST_REORDERDATA_CURIDX_VALID) {
cur_idx = reorder_info_buf[WLHOST_REORDERDATA_CURIDX_OFFSET];
exp_idx = reorder_info_buf[WLHOST_REORDERDATA_EXPIDX_OFFSET];
-
if ((exp_idx == ptr->exp_idx) && (cur_idx != ptr->exp_idx)) {
/* still in the current hole */
--
Gitblit v1.6.2