Driver commit for release MM6X18540.p33_V1 2025-11-12_13:06:28

Firmware version for commit:
W8997-16.92.21.p153.7
W9098-17.92.1.p149.81
IW416-16.92.21.p153.7
W8987-16.92.21.p153.7
IW612-18.99.3.p27.6
IW610-18.99.5.p83
AW693-18.99.2.p145.147

Signed-off-by: Pushpendra Tiwari <pushpendra.tiwari@nxp.com>
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
This commit is contained in:
Sherry Sun 2025-11-13 10:11:50 +08:00
parent 65b034884c
commit 371a047ac6
55 changed files with 3450 additions and 1076 deletions

35
Kconfig Executable file
View file

@ -0,0 +1,35 @@
# File: Makefile
#
# Copyright 2025 NXP
#
# This software file (the File) is distributed by NXP
# under the terms of the GNU General Public License Version 2, June 1991
# (the License). You may use, redistribute and/or modify the File in
# accordance with the terms and conditions of the License, a copy of which
# is available by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
# worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
# IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
# ARE EXPRESSLY DISCLAIMED. The License provides additional details about
# this warranty disclaimer.
#
config WLAN_VENDOR_NXP
bool "NXP WLAN devices"
default y
help
If you have a wireless card belonging to this class, say Y.
config NXP_WLAN_DRIVER
tristate "NXP WLAN Driver"
depends on CFG80211 && (MMC || PCI || USB)
select LIB80211
select FW_LOADER
help
This adds support for wireless adapters based on NXP
WLAN chipsets.
Say Y here to add support for NXP WLAN driver into the kernel,
or say M here to compile as a module (mlan.ko and moal.ko)

View file

@ -175,7 +175,7 @@ APPDIR= $(shell if test -d "mapp"; then echo mapp; fi)
#############################################################################
ccflags-y += -I$(KERNELDIR)/include
ccflags-y += -DMLAN_RELEASE_VERSION='"540.p22"'
ccflags-y += -DMLAN_RELEASE_VERSION='"540.p33"'
ccflags-y += -DFPNUM='"92"'
@ -511,6 +511,8 @@ endif
# Default for out-of-tree builds
CONFIG_NXP_WLAN_DRIVER ?= m
MOALOBJS = mlinux/moal_main.o \
mlinux/moal_ioctl.o \
@ -590,9 +592,7 @@ endif
obj-m := mlan.o
obj-$(CONFIG_NXP_WLAN_DRIVER) := mlan.o
mlan-objs := $(MLANOBJS)
ifeq ($(CONFIG_MUSB),y)
@ -604,7 +604,7 @@ endif
ifeq ($(CONFIG_PCIE),y)
MOALOBJS += mlinux/moal_pcie.o
endif
obj-m += moal.o
obj-$(CONFIG_NXP_WLAN_DRIVER) += moal.o
moal-objs := $(MOALOBJS)
# Otherwise we were called directly from the command line; invoke the kernel build system.

72
README
View file

@ -11,9 +11,56 @@
Goto source code directory.
make [clean] build
The driver and utility binaries can be found in bin_wlan directory.
The driver source code is compatible with hosts running Linux kernel versions ranging from 2.6.32 to 6.15.0.
The driver source code is compatible with hosts running Linux kernel versions ranging from 2.6.32 to 6.17.0.
2) FOR DRIVER INSTALL
2) FOR INTEGRATING DRIVER INTO LINUX KERNEL (BUILT-IN SUPPORT)
a) mkdir -p <Linux_Kernel_Repo>/drivers/net/wireless/nxp
b) Clone the WLAN source code from nxp-imx/mwifiex repo to the drivers/net/wireless/nxp directory in the kernel repo.
cd <Linux_Kernel_Repo>/drivers/net/wireless/nxp
git clone https://github.com/nxp-imx/mwifiex.git
c) Make sure the directories mlan/, mlinux/ as well as the files Makefile, Kconfig are present in drivers/net/wireless/nxp/mwifiex.
d) In <Linux_Kernel_Repo>/drivers/net/wireless/Kconfig, add the following line:
'source "drivers/net/wireless/nxp/mwifiex/Kconfig"'
e) In <Linux_Kernel_Repo>/drivers/net/wireless/Makefile, add the following line:
'obj-$(CONFIG_WLAN_VENDOR_NXP) += nxp/mwifiex/'
f) Run make defconfig or menuconfig to enable support for NXP WLAN devices:
Device Drivers > Network device support > Wireless LAN
[*] "NXP WLAN devices"
g) To configure the driver as a module:
<M> "NXP WLAN Driver"
Or to configure the driver as inbuilt:
<*> "NXP WLAN Driver"
h) Save. Verify the kernel .config file for CONFIG_WLAN_VENDOR_NXP and CONFIG_NXP_WLAN_DRIVER flags.
i) source <toolchain>
j) make
There is a high chance that the inbuilt NXP WLAN driver would be loaded before rootfs is mounted.
In such scenario, the firmware files can also be added to the linux kernel Image using the following steps:
a) mkdir -p <Linux_Kernel_Repo>/kernel/firmware/nxp
b) Copy FW files to <Linux_Kernel_Repo>/kernel/firmware/nxp/
c) In kernel .config, add 2 new config flags:
i) CONFIG_EXTRA_FIRMWARE="nxp/wifi_mod_para.conf nxp/pcieuartaw693_combo_v1.bin nxp/sduart_nw61x_v1.bin.se"
ii) CONFIG_EXTRA_FIRMWARE_DIR="kernel/firmware"
d) make
To pass module parameters to the inbuilt NXP WLAN driver, append the kernel bootargs with:
moal.<param>=<value>
For Example:
moal.mod_para=nxp/wifi_mod_para.conf moal.ps_mode=2 moal.drvdbg=0x37
To speed up driver loading, WLAN interface creation and reduce boot time, append the kernel bootargs with:
loglevel=2
Performance Comparison - WLAN Interface Creation Time (Example measurements):
Test Platform: iMX8MQ + PCIE AW693 on Linux 6.12.32 iMX BSP
a) WLAN drivers as loadable modules (rc.local/init script): 10 seconds
b) WLAN drivers as auto-load modules (modprobe.d/modules-load.d): 7 seconds
c) WLAN drivers built into kernel: 5 seconds
d) WLAN drivers built into kernel with loglevel=2: 3 seconds
Note: Option 2 is the default configuration in iMX Linux BSP from kernel version 6.12.xx onwards.
3) FOR DRIVER INSTALL
a) Copy firmware image to /lib/firmware/nxp/, copy wifi_mod_para.conf to /lib/firmware/nxp/.
b) Install WLAN driver
@ -88,6 +135,7 @@
amsdu_deaggr=0|1 <buf copy in amsud deaggregation | avoid buf copy in amsud deaggregation (default)>
bootup_cal_ctrl=0|1 <disable boot time config default | enable boot time config>
ps_mode=0|1|2 <use MLAN default | enable IEEE PS mode | disable IEEE PS mode>
tcpackenh=0|1 <disable TCP ACK enhancement | enable TCP ACK enhancement (default)>
sched_scan=0|1 <disable sched_scan | enable sched_scan default>
max_tx_buf=2048|4096|8192 <maximum AMSDU Tx buffer size>
pm_keep_power=1|0 <PM keep power in suspend (default) | PM no power in suspend>
@ -112,6 +160,16 @@
For AW693, it's recommended to use mod_para configuration file for antcfg as MAC1 supports 2x2 and MAC2 supports only 1x1.
For 8897/8997: antcfg=0x11|0x13|0x33 <Bit0:Rx Path A, Bit1:Rx Path B, Bit 4:Tx Path A, Bit 5:Tx Path B>
For others: antcfg=0|1|2|0xffff <default | Tx/Rx antenna 1 | Tx/Rx antenna 2 | enable antenna diversity>
plinkstats=0|1|2 <Disable plinkstats (default) | Enable plinkstats | Restore plinkstats>
Example usage:
insmod moal.ko plinkstats=0 : Disable link statistics prints
insmod moal.ko plinkstats=1 : Enable link statistics prints
insmod moal.ko plinkstats=2 : Reset link statistics prints
insmod moal.ko plinkstats=1,0x7,5,0 : Enable Num TX Packets, Num RX Packets and Channel prints on dmesg.
insmod moal.ko plinkstats=1,0xf,5,1 : Enable Num TX Packets, Num RX Packets, Channel and Region prints on dmesg, and netlink event also enabled.
Note:
1. For more details about plinkstats parameters, refer plinkstats command details in README_MLAN file.
2. When changing drvdbg mask dynamically while running test, set MLSTATS bit(0x800) along with the change, if wifi logging feature is enabled.
slew_rate: Slew Rate Control value = 0|1|2|3 (0 is the slowest slew rate and 03 has the highest slew rate (default))
init_cfg=<init config (MAC addresses, registers etc.) file name>
e.g. copy init_cfg.conf to firmware directory, init_cfg=nxp/init_cfg.conf
@ -221,7 +279,7 @@
for module parameters.
insmod sdxxx.ko "<para1> <para2> ..."
3) FOR DRIVER PROC & DEBUG
4) FOR DRIVER PROC & DEBUG
The following info are provided in /proc/net/mwlan/adapterX/mlanY|uapY|wfdY/info,
on kernel 2.6.24 or later, the entry is /proc/mwlan/adapterX/mlanY|uapY|wfdY/info.
@ -387,7 +445,7 @@
will be printed to the console)
echo 15 > /proc/sys/kernel/printk (all messages will be printed to console)
4) FOR FW RELOAD
5) FOR FW RELOAD
a) Enable parallel firmware download in driver parameter
insmod sdxxx.ko fw_serial=0
@ -404,7 +462,7 @@
(Note: This feature will be supported on IW416 and 8997.
For 8987, it only work with the board which supports parallel fw download)
5) FOR RF test mode commands:
6) FOR RF test mode commands:
Following commands are used to perform RF testing of the wifi chipset.
Please not that these test mode commands can only be issued while the
@ -579,7 +637,7 @@
echo "trigger_frame=1 0 1 2 5484 0 256 0 0 0 1 0 0 0 1 60 1 0 65535 0 511 5 0 61 0 0 0 0 90 0 0 0 0" > /proc/mwlan/adapter0/config
echo "tx_frame=1 0x1102 0xabababab 200" >/proc/mwlan/adapter0/config
6) Set host sleep parameters
7) Set host sleep parameters
hssetpara
This command is used to set host sleep parameters.
@ -587,7 +645,7 @@
echo "hssetpara=2 0xff 0xc8 3 400" > /proc/mwlan/adapter0/config
echo "hssetpara=2 1 0xc8 3 400 " > /proc/mwlan/adapter0/config
7) For Antenna Diversity Command
8) For Antenna Diversity Command
antcfg
This command is used to set/get the mode of Tx/Rx path.

View file

@ -1008,6 +1008,7 @@ mlan_status wlan_cmd_11ax_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
hecfg->he_cap.len = MIN(hecfg->he_cap.len,
MRVDRV_SIZE_OF_CMD_BUFFER - cmd->size);
tlv->len = wlan_cpu_to_le16(hecfg->he_cap.len);
/* he_cap.len is already bounded using MIN function above. */
// coverity[cert_arr30_c_violation:SUPPRESS]
// coverity[cert_str31_c_violation:SUPPRESS]
// coverity[overrun-buffer-arg:SUPPRESS]
@ -1031,6 +1032,7 @@ mlan_status wlan_cmd_11ax_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
hecap->len =
MIN(hecap->len, MRVDRV_SIZE_OF_CMD_BUFFER - cmd->size);
tlv->len = wlan_cpu_to_le16(hecap->len);
/* he_cap->len is already bounded using MIN function above */
// coverity[cert_arr30_c_violation:SUPPRESS]
// coverity[overrun-buffer-arg:SUPPRESS]
// coverity[cert_str31_c_violation:SUPPRESS]

View file

@ -3677,7 +3677,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
pstate_rdh->max_bcn_dtim_ms = 0;
pstate_rdh->priv_curr_idx = RDH_STAGE_FIRST_ENTRY_PRIV_IDX;
pstate_rdh->stage = RDH_STOP_TRAFFIC;
/* fall through */
fallthrough;
case RDH_STOP_TRAFFIC:
PRINTM(MCMD_D, "%s(): stage(%d)=%s\n", __func__,
@ -3690,7 +3690,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
pstate_rdh->priv_curr_idx = RDH_STAGE_FIRST_ENTRY_PRIV_IDX;
pstate_rdh->stage = RDH_GET_INFO_CHANNEL;
/* fall through */
fallthrough;
case RDH_GET_INFO_CHANNEL:
PRINTM(MCMD_D, "%s(): stage(%d)=%s, priv_idx=%d\n", __func__,
@ -3803,7 +3803,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
pstate_rdh->priv_curr_idx = RDH_STAGE_FIRST_ENTRY_PRIV_IDX;
pstate_rdh->stage = RDH_GET_INFO_BEACON_DTIM;
/* fall through */
fallthrough;
case RDH_GET_INFO_BEACON_DTIM:
PRINTM(MCMD_D, "%s(): stage(%d)=%s, priv_idx=%d\n", __func__,
@ -3876,7 +3876,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
/* else */
pstate_rdh->priv_curr_idx = RDH_STAGE_FIRST_ENTRY_PRIV_IDX;
pstate_rdh->stage = RDH_SET_CUSTOM_IE;
/* fall through */
fallthrough;
case RDH_SET_CUSTOM_IE:
PRINTM(MCMD_D, "%s(): stage(%d)=%s, priv_idx=%d\n", __func__,
@ -3927,7 +3927,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
/* else */
pstate_rdh->priv_curr_idx = RDH_STAGE_FIRST_ENTRY_PRIV_IDX;
pstate_rdh->stage = RDH_REM_CUSTOM_IE;
/* fall through */
fallthrough;
case RDH_REM_CUSTOM_IE:
PRINTM(MCMD_D, "%s(): stage(%d)=%s, priv_idx=%d\n", __func__,
@ -3994,7 +3994,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
/* else */
pstate_rdh->priv_curr_idx = RDH_STAGE_FIRST_ENTRY_PRIV_IDX;
pstate_rdh->stage = RDH_STOP_INTFS;
/* fall through */
fallthrough;
case RDH_STOP_INTFS:
PRINTM(MCMD_D, "%s(): stage(%d)=%s, priv_idx=%d\n", __func__,
@ -4041,7 +4041,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
pstate_rdh->stage = RDH_RESTART_INTFS;
goto rdh_restart_intfs; /* skip next stage */
}
/* fall through */
fallthrough;
case RDH_SET_NEW_CHANNEL:
PRINTM(MCMD_D, "%s(): stage(%d)=%s, priv_idx=%d\n", __func__,
@ -4083,7 +4083,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
/* else */
pstate_rdh->priv_curr_idx = RDH_STAGE_FIRST_ENTRY_PRIV_IDX;
pstate_rdh->stage = RDH_RESTART_INTFS;
/* fall through */
fallthrough;
case RDH_RESTART_INTFS:
rdh_restart_intfs:
@ -4126,7 +4126,7 @@ mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
/* else */
pstate_rdh->priv_curr_idx = RDH_STAGE_FIRST_ENTRY_PRIV_IDX;
pstate_rdh->stage = RDH_RESTART_TRAFFIC;
/* fall through */
fallthrough;
case RDH_RESTART_TRAFFIC:
PRINTM(MCMD_D, "%s(): stage(%d)=%s\n", __func__,

View file

@ -644,7 +644,7 @@ mlan_status wlan_11n_deaggregate_pkt(mlan_private *priv, pmlan_buffer pmbuf)
case MLAN_STATUS_FAILURE:
PRINTM(MERROR, "Deaggr, send to moal failed\n");
daggr_mbuf->status_code = MLAN_ERROR_PKT_INVALID;
/* fall through */
fallthrough;
case MLAN_STATUS_SUCCESS:
wlan_recv_packet_complete(pmadapter, daggr_mbuf, ret);
break;
@ -872,7 +872,8 @@ int wlan_11n_aggregate_pkt(mlan_private *priv, raListTbl *pra_list,
}
PRINTM(MDAT_D, "Handling Aggr packet\n");
#ifdef PCIEAW693
if (IS_PCIEAW693(pmadapter->card_type)) {
if (!wlan_copy_on_tx_enabled(pmadapter) &&
IS_PCIEAW693(pmadapter->card_type)) {
return wlan_send_amsdu_subframe_list(priv, pra_list, headroom,
ptrindex);
}

View file

@ -3801,6 +3801,7 @@ void wlan_add_fw_cfp_tables(pmlan_private pmpriv, t_u8 *buf, t_u16 buf_left)
int k = 0, rows, cols;
t_u16 max_tx_pwr_bg = WLAN_TX_PWR_DEFAULT;
t_u16 max_tx_pwr_a = WLAN_TX_PWR_DEFAULT;
t_u8 ww_country_code[COUNTRY_CODE_LEN] = {'W', 'W', '\0'};
t_u8 *tlv_buf;
t_u8 *data;
t_u8 *tmp;
@ -3911,13 +3912,17 @@ void wlan_add_fw_cfp_tables(pmlan_private pmpriv, t_u8 *buf, t_u16 buf_left)
pmadapter->otp_region->country_code[1],
pmadapter->country_code[0],
pmadapter->country_code[1]);
/* FW code mismatch, replace with the driver
* code */
pmadapter->otp_region->country_code[0] =
pmadapter->country_code[0];
pmadapter->otp_region->country_code[1] =
pmadapter->country_code[1];
if (memcmp(pmadapter,
pmadapter->otp_region->country_code,
ww_country_code,
COUNTRY_CODE_LEN - 1)) {
/* FW code mismatch and not WW, replace
* with the driver code */
pmadapter->otp_region->country_code[0] =
pmadapter->country_code[0];
pmadapter->otp_region->country_code[1] =
pmadapter->country_code[1];
}
}
pmadapter->country_code[2] = '\0';
pmadapter->domain_reg.country_code[0] =

View file

@ -1550,7 +1550,7 @@ static mlan_status wlan_dnld_cmd_to_fw(mlan_private *pmpriv,
(t_u8 *)pcmd + S_DS_GEN)),
cmd_size, wlan_le16_to_cpu(pcmd->seq_num), timeout);
DBG_HEXDUMP(MCMD_D, "DNLD_CMD", (t_u8 *)pcmd, cmd_size);
DBG_HEXDUMP(MCMD_D, "DNLD_CMD", (t_u8 *)pcmd, cmd_size);
#if defined(SDIO) || defined(PCIE)
if (!IS_USB(pmadapter->card_type)) {
@ -2152,7 +2152,9 @@ mlan_status wlan_prepare_cmd(mlan_private *pmpriv, t_u16 cmd_no,
goto done;
}
if (pmadapter->hw_status == WlanHardwareStatusReset) {
if ((pmadapter->hw_status == WlanHardwareStatusReset) ||
(pmadapter->hw_status == WlanHardwareStatusClosing) ||
(pmadapter->hw_status == WlanHardwareStatusNotReady)) {
if ((cmd_no != HostCmd_CMD_FUNC_INIT)
#ifdef PCIE
&& (cmd_no != HostCmd_CMD_PCIE_HOST_BUF_DETAILS)
@ -2658,7 +2660,8 @@ mlan_status wlan_process_cmdresp(mlan_adapter *pmadapter)
/* Check init command response */
if (pmadapter->hw_status == WlanHardwareStatusInitializing ||
pmadapter->hw_status == WlanHardwareStatusGetHwSpec) {
pmadapter->hw_status == WlanHardwareStatusGetHwSpec
) {
if (ret == MLAN_STATUS_FAILURE) {
#if 0
//ignore command error for WARM RESET
@ -2752,8 +2755,6 @@ mlan_status wlan_process_cmdresp(mlan_adapter *pmadapter)
(HostCmd_CMD_GET_HW_SPEC == cmdresp_no)) {
pmadapter->hw_status = WlanHardwareStatusGetHwSpecdone;
}
#if defined(PCIEAW693)
#endif
done:
LEAVE();
@ -5469,12 +5470,12 @@ mlan_status wlan_adapter_get_hw_spec(pmlan_adapter pmadapter)
}
#endif
ret = wlan_prepare_cmd(priv, HostCmd_CMD_FUNC_INIT, HostCmd_ACT_GEN_SET,
0, MNULL, MNULL);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
ret = wlan_prepare_cmd(priv, HostCmd_CMD_FUNC_INIT,
HostCmd_ACT_GEN_SET, 0, MNULL, MNULL);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/** DPD data dnld cmd prepare */
if ((pmadapter->pdpd_data) && (pmadapter->dpd_data_len > 0)) {
@ -5980,8 +5981,15 @@ mlan_status wlan_process_vdll_event(pmlan_private pmpriv, pmlan_buffer pevent)
break;
case VDLL_IND_TYPE_OFFSET:
offset = wlan_le32_to_cpu(ind->offset);
/**
* Include metadata length of firmware with meata data support
* otherwise by default 0 will added to offset.
*/
offset = pmadapter->fw_meta_data_len;
offset += wlan_le32_to_cpu(ind->offset);
PRINTM(MEVENT, "VDLL_IND (OFFSET): offset=0x%x\n", offset);
// coverity[integer_overflow:SUPPRESS]
wlan_get_vdll_image(pmadapter, offset);
break;
case VDLL_IND_TYPE_ERR_SIG:
@ -6083,6 +6091,45 @@ mlan_status wlan_process_csi_event(pmlan_private pmpriv)
return status;
}
/**
* @brief This function handle the csi status event
*
* @param pmpriv A pointer to mlan_private structure
*
* @return MLAN_STATUS_SUCCESS
*/
mlan_status wlan_process_csi_status(pmlan_private pmpriv)
{
pmlan_adapter pmadapter = pmpriv->adapter;
mlan_status status = MLAN_STATUS_FAILURE;
t_u32 eventcause = pmadapter->event_cause;
t_u8 *evt_buf = MNULL;
pmlan_buffer pmbuf = pmadapter->pmlan_buffer_event;
pmlan_callbacks pcb = &pmadapter->callbacks;
pmlan_event pevent;
ENTER();
status = pcb->moal_malloc(pmadapter->pmoal_handle, MAX_EVENT_SIZE,
MLAN_MEM_DEF, &evt_buf);
if ((status == MLAN_STATUS_SUCCESS) && evt_buf) {
csi_status_info *pStatus =
(csi_status_info *)(pmbuf->pbuf + pmbuf->data_offset +
sizeof(eventcause));
pevent = (pmlan_event)evt_buf;
pevent->bss_index = pmpriv->bss_index;
pevent->event_id = MLAN_EVENT_ID_CSI_STATUS;
pevent->event_len = sizeof(csi_status_info);
memcpy_ext(pmadapter, (t_u8 *)pevent->event_buf, pStatus,
pevent->event_len, pevent->event_len);
wlan_recv_event(pmpriv, pevent->event_id, pevent);
}
pcb->moal_mfree(pmadapter->pmoal_handle, evt_buf);
return status;
}
/**
* @brief This function handle the multi_chan info event
*
@ -6438,6 +6485,8 @@ mlan_status wlan_cmd_drcs_cfg(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
wlan_cpu_to_le16(drcs_cfg->chan_idx);
channel_time_slicing->chantime = drcs_cfg->chantime;
channel_time_slicing->switchtime = drcs_cfg->switchtime;
/* Safe access: buffer size is validated and structure
* is statically allocated */
// coverity[overflow_sink:SUPPRESS]
channel_time_slicing->rx_wait_time =
drcs_cfg->rx_wait_time;
@ -6638,9 +6687,9 @@ mlan_status wlan_cmd_cfg_data(pmlan_private pmpriv, HostCmd_DS_COMMAND *pcmd,
{
mlan_status ret = MLAN_STATUS_SUCCESS;
HostCmd_DS_802_11_CFG_DATA *pcfg_data = &(pcmd->params.cfg_data);
pmlan_adapter pmadapter = pmpriv->adapter;
t_u32 len = 0;
t_u32 data_offset;
pmlan_adapter pmadapter = pmpriv->adapter;
t_u8 *temp_pcmd = (t_u8 *)pcmd;
ENTER();
@ -8111,6 +8160,8 @@ mlan_status wlan_ret_tx_rx_pkt_stats(pmlan_private pmpriv,
cmdsize - S_DS_GEN - sizeof(HostCmd_DS_TX_RX_HISTOGRAM);
if (length > 0) {
info->param.tx_rx_histogram.size = length;
/* buffer size is validated and memcpy_ext ensures safe
* bounded copying within allocated memory regions. */
// coverity[overrun-buffer-arg:SUPPRESS]
// coverity[cert_arr30_c_violation:SUPPRESS]
// coverity[cert_str31_c_violation:SUPPRESS]
@ -9987,7 +10038,7 @@ static void wlan_fill_link_statistic(mlan_private *priv,
if (radio_stat->num_channels > MAX_NUM_CHAN) {
radio_stat->num_channels =
wlan_le32_to_cpu(MAX_NUM_CHAN);
PRINTM(MERROR,
PRINTM(MINFO,
"%s : radio_stat->num_channels=%d\n",
__func__, radio_stat->num_channels);
break;
@ -11389,8 +11440,11 @@ mlan_status wlan_cmd_chan_trpc_config(pmlan_private pmpriv,
sizeof(MrvlIEtypesHeader_t));
tlv->band = cap->band;
if (cmd_action == HostCmd_ACT_GEN_SET)
if (cmd_action == HostCmd_ACT_GEN_SET) {
tlv->power = cap->power;
tlv->strong_rssi_thresh = cap->strong_rssi_thresh;
tlv->weak_rssi_thresh = cap->weak_rssi_thresh;
}
size += sizeof(MrvlIEtypes_per_band_txpwr_cap);
} else {
trpc_cfg->sub_band = wlan_cpu_to_le16(cfg->sub_band);
@ -11511,6 +11565,8 @@ mlan_status wlan_ret_chan_trpc_config(pmlan_private pmpriv,
tlv = (MrvlIEtypes_per_band_txpwr_cap *)header;
cap->band = tlv->band;
cap->power = tlv->power;
cap->strong_rssi_thresh = tlv->strong_rssi_thresh;
cap->weak_rssi_thresh = tlv->weak_rssi_thresh;
} else {
cfg = (mlan_ds_misc_chan_trpc_cfg *)&(
misc->param.trpc_cfg);
@ -11639,6 +11695,42 @@ mlan_status wlan_ret_ch_load(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
return MLAN_STATUS_SUCCESS;
}
mlan_status wlan_cmd_get_foundry_type(pmlan_private pmpriv,
HostCmd_DS_COMMAND *cmd, t_u16 cmd_action)
{
ENTER();
if (cmd_action != HostCmd_ACT_GEN_GET) {
PRINTM(MERROR,
"wlan_cmd_get_foundry_type: support GET only.\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
cmd->command = wlan_cpu_to_le16(HostCmd_CMD_DS_GET_FOUNDRY_TYPE);
cmd->size = wlan_cpu_to_le16(S_DS_GEN + 4);
LEAVE();
return MLAN_STATUS_SUCCESS;
}
mlan_status wlan_ret_foundry_type(pmlan_private pmpriv,
HostCmd_DS_COMMAND *resp,
mlan_ioctl_req *pioctl_buf)
{
const HostCmd_DS_GET_FOUNDRY_TYPE *fab_cmd = &resp->params.foundry_type;
mlan_ds_misc_cfg *misc_cfg = MNULL;
ENTER();
if (pioctl_buf) {
misc_cfg = (mlan_ds_misc_cfg *)pioctl_buf->pbuf;
misc_cfg->param.soc_foundry_type.foundry_type =
wlan_le16_to_cpu(fab_cmd->foundry_type);
PRINTM(MCMND, "get SOC foundry_type %d \n",
fab_cmd->foundry_type);
}
LEAVE();
return MLAN_STATUS_SUCCESS;
}
/**
* @brief This function prepares command of RANGE_EXT
*

View file

@ -664,6 +664,10 @@ typedef enum {
#define MLAN_BUF_FLAG_LLDE_PKT_FILTER MBIT(19)
#ifdef XDP_SUPPORT
#define MLAN_BUF_FLAG_XDP MBIT(20)
#endif
#ifdef DEBUG_LEVEL1
/** Debug level bit definition */
#define MMSG MBIT(0)
@ -911,6 +915,7 @@ typedef enum _mlan_event_id {
/* Agiled channel switch triggered */
MLAN_EVENT_ID_FW_AGCS_TRIGGER = 0x00000044,
#endif /* UAP_SUPPORT */
MLAN_EVENT_ID_CSI_STATUS = 0x00000045,
/* Event generated by MLAN driver (MSB=1) */
MLAN_EVENT_ID_DRV_CONNECTED = 0x80000001,
MLAN_EVENT_ID_DRV_DEFER_HANDLING = 0x80000002,
@ -1299,6 +1304,25 @@ typedef MLAN_PACK_START struct _csi_record_ds {
/** At the end of CSI raw data, user defined TailID of 4 bytes*/
} MLAN_PACK_END csi_record_ds, *pcsi_record_ds;
/** Definition of csi status */
#define CSI_STATUS_ENABLED 0
#define CSI_STATUS_DISABLED 1
#define CSI_STATUS_CONFIG_WRONG 2
#define CSI_STATUS_INTERNAL_RESET 3
#define CSI_STATUS_INTERNAL_STOP 4
#define CSI_STATUS_INTERNAL_DISABLED 5
/** Csi status event data structure */
typedef struct _csi_status_info {
/** Csi status report by fw */
t_u8 status;
/** Channel */
t_u8 channel;
/** Number of csi filters, only valid in CSI_STATUS_ENABLED, 0 in other
* status */
t_u16 cnt;
} MLAN_PACK_END csi_status_info;
/** mlan_ioctl_req data structure */
typedef struct _mlan_ioctl_req {
/** Pointer to previous mlan_ioctl_req */
@ -2613,6 +2637,12 @@ typedef struct _sta_stats {
#pragma pack(pop)
#endif
typedef enum {
MOAL_DMA_SYNC_BIDIR = 0,
MOAL_DMA_SYNC_TO_DEVICE = 1,
MOAL_DMA_SYNC_FROM_DEVICE = 2,
} moal_dma_sync_direction_t;
/** mlan_callbacks data structure */
typedef struct _mlan_callbacks {
/** moal_get_fw_data */
@ -2687,6 +2717,20 @@ typedef struct _mlan_callbacks {
/** moal_mfree_consistent */
mlan_status (*moal_mfree_consistent)(t_void *pmoal, t_u32 size,
t_u8 *pbuf, t_u64 buf_pa);
/** moal_malloc_cached */
mlan_status (*moal_malloc_cached)(t_void *pmoal, t_u32 size,
t_u8 **ppbuf, t_u64 *pbuf_pa);
/** moal_mfree_cached */
mlan_status (*moal_mfree_cached)(t_void *pmoal, t_u32 size, t_u8 *pbuf,
t_u64 buf_pa);
/** moal_dma_sync_to_cpu */
mlan_status (*moal_dma_sync_to_cpu)(t_void *pmoal, t_u32 size,
t_u64 buf_pa,
moal_dma_sync_direction_t direction);
/** moal_dma_sync_to_device */
mlan_status (*moal_dma_sync_to_device)(
t_void *pmoal, t_u32 size, t_u64 buf_pa,
moal_dma_sync_direction_t direction);
/** moal_map_memory */
mlan_status (*moal_map_memory)(t_void *pmoal, t_u8 *pbuf,
t_u64 *pbuf_pa, t_u32 size, t_u32 flag);
@ -2770,6 +2814,9 @@ typedef struct _mlan_callbacks {
void (*moal_write_u16)(void *dest, t_u16 val);
void (*moal_write_u32)(void *dest, t_u32 val);
} moal_unaligned_access;
t_u32 (*moal_crc32_be)(t_u32 initial_crc, t_u8 const *data,
unsigned long len);
} mlan_callbacks, *pmlan_callbacks;
/** Parameter unchanged, use MLAN default setting */
@ -2936,6 +2983,8 @@ typedef struct _mlan_device {
t_u8 second_mac;
/** napi */
t_u8 napi;
t_u8 copy_on_rx;
t_u8 copy_on_tx;
/** antcfg */
t_u32 antcfg;
/** dmcs */
@ -3111,6 +3160,7 @@ MLAN_API void mlan_process_pcie_interrupt_cb(t_void *pmadapter, int type);
#endif
#endif
#ifdef ANDROID_SDK_VERSION
#ifndef UINT_MAX
#ifdef MLAN_64BIT
#define UINT_MAX UINT64_MAX
@ -3118,6 +3168,17 @@ MLAN_API void mlan_process_pcie_interrupt_cb(t_void *pmadapter, int type);
#define UINT_MAX UINT32_MAX
#endif
#endif
#else
#ifndef CONFIG_KASAN
#ifndef UINT_MAX
#ifdef MLAN_64BIT
#define UINT_MAX UINT64_MAX
#else
#define UINT_MAX UINT32_MAX
#endif
#endif
#endif
#endif
typedef enum {
TYPE_SINT8,

View file

@ -194,7 +194,7 @@ ENUM_ELEMENT(EVENT_DUMMY_HOST_WAKEUP_SIGNAL, 0x0001),
ENUM_ELEMENT(EVENT_SSU_DUMP_DMA, 0x008C),
#endif
ENUM_ELEMENT(EVENT_CSI, 0x008D),
ENUM_ELEMENT(EVENT_CSI, 0x008D), ENUM_ELEMENT(EVENT_CSI_STATUS, 0x00A7),
ENUM_ELEMENT(EVENT_FW_HANG_REPORT, 0x008F),
ENUM_ELEMENT(EVENT_DPD_LOG, 0x0091),
/** Card Event definition : RESET PN */

View file

@ -4667,6 +4667,9 @@ typedef MLAN_PACK_START struct _hostcmd_twt_report {
t_u8 data[36];
} MLAN_PACK_END hostcmd_twt_report, *phostcmd_twt_report;
typedef MLAN_PACK_START struct _HostCmd_DS_GET_FOUNDRY_TYPE {
t_u8 foundry_type;
} MLAN_PACK_END HostCmd_DS_GET_FOUNDRY_TYPE;
/** Type definition of hostcmd_twt_information */
typedef struct MLAN_PACK_START _hostcmd_twt_information {
/** TWT Flow Identifier. Range: [0-7] */
@ -7637,6 +7640,10 @@ typedef MLAN_PACK_START struct _HostCmd_DS_AGCS_CFG {
/* ch threshold to trigger channel switch for nighthawk */
t_u16 ch_th;
/* Channel switching is triggered only when the current pkts > the min
* average packet percentage. */
t_u16 min_pkt_percentage;
} MLAN_PACK_END HostCmd_DS_AGCS_CFG;
#endif /* UAP_SUPPORT */
@ -7941,6 +7948,7 @@ typedef struct MLAN_PACK_START _HostCmd_DS_COMMAND {
/** Auth, (Re)Assoc timeout configuration */
HostCmd_DS_AUTH_ASSOC_TIMEOUT_CFG auth_assoc_cfg;
t_u8 assoc_rsp_buf[ASSOC_RSP_BUF_SIZE];
HostCmd_DS_GET_FOUNDRY_TYPE foundry_type;
#ifdef UAP_SUPPORT
/** Agiled channel switch configuration */
HostCmd_DS_AGCS_CFG agcs_cfg;
@ -7994,8 +8002,11 @@ typedef struct _MrvlIEtypes_per_band_txpwr_cap {
t_u8 band;
/** power value */
t_u8 power;
/** strong rssi threshold value */
t_s8 strong_rssi_thresh;
/** weak rssi threshold value */
t_s8 weak_rssi_thresh;
} MLAN_PACK_END MrvlIEtypes_per_band_txpwr_cap;
/** req host side download vdll block */
#define VDLL_IND_TYPE_REQ 0
/** notify vdll start offset in firmware image */

View file

@ -481,6 +481,8 @@ ENUM_ELEMENT(HostCmd_CMD_GET_HW_SPEC, 0x0003),
/** Host Command ID : HS Event masking configuration */
ENUM_ELEMENT(HostCmd_CMD_HS_EVENT_MASK, 0x028a),
/** Host Command ID : Get foundry type */
ENUM_ELEMENT(HostCmd_CMD_DS_GET_FOUNDRY_TYPE, 0X028c),
#ifdef UAP_SUPPORT
/** Host Command ID : Agiled channel switch configuration */

View file

@ -472,19 +472,14 @@ mlan_status wlan_init_priv(pmlan_private priv)
memset(pmadapter, &priv->assoc_rsp_buf, 0, sizeof(priv->assoc_rsp_buf));
priv->assoc_rsp_size = 0;
// coverity[no_effect:SUPPRESS]
// coverity[misra_c_2012_rule_21_18_violation:SUPPRESS]
memset(pmadapter, &priv->assoc_req_buf, 0, sizeof(priv->assoc_req_buf));
_memset(pmadapter, &priv->assoc_req_buf, 0,
sizeof(priv->assoc_req_buf));
priv->assoc_req_size = 0;
// coverity[no_effect:SUPPRESS]
// coverity[misra_c_2012_rule_21_18_violation:SUPPRESS]
memset(pmadapter, &priv->prior_assoc_rsp, 0,
sizeof(priv->prior_assoc_rsp));
_memset(pmadapter, &priv->prior_assoc_rsp, 0,
sizeof(priv->prior_assoc_rsp));
priv->prior_assoc_rsp_size = 0;
// coverity[no_effect:SUPPRESS]
// coverity[misra_c_2012_rule_21_18_violation:SUPPRESS]
memset(pmadapter, &priv->prior_assoc_req, 0,
sizeof(priv->prior_assoc_req));
_memset(pmadapter, &priv->prior_assoc_req, 0,
sizeof(priv->prior_assoc_req));
priv->prior_assoc_req_size = 0;
wlan_11d_priv_init(priv);
@ -1578,7 +1573,7 @@ mlan_status wlan_init_fw(pmlan_adapter pmadapter)
#ifdef MFG_CMD_SUPPORT
if (pmadapter->mfg_mode != MTRUE) {
#endif
wlan_adapter_get_hw_spec(pmadapter);
wlan_adapter_get_hw_spec(pmadapter);
#ifdef MFG_CMD_SUPPORT
}
#ifdef PCIE
@ -1589,7 +1584,8 @@ mlan_status wlan_init_fw(pmlan_adapter pmadapter)
}
}
if (((pmadapter->card_type) & 0xff) == CARD_TYPE_AW693) {
if (((pmadapter->card_type) & 0xff) == CARD_TYPE_AW693
) {
ret = wlan_prepare_cmd(priv, HostCmd_CMD_FUNC_INIT,
HostCmd_ACT_GEN_SET, 0, MNULL, MNULL);
if (ret) {

View file

@ -4,7 +4,7 @@
* structures.
*
*
* Copyright 2008-2021 NXP
* Copyright 2008-2021, 2025 NXP
*
* This software file (the File) is distributed by NXP
* under the terms of the GNU General Public License Version 2, June 1991
@ -106,6 +106,40 @@ typedef MLAN_PACK_START struct _FWSyncPkt {
t_u32 fw_ready;
} MLAN_PACK_END FWSyncPkt;
/** Firmware Meta data section */
#define FW_CMD_24 0x00000018
#define TLV_FLAG_WIFI 0x1
#define TLV_ID_UUID 0x40
#define TLV_ID_UUID_LEN 16
#define TLV_ID_PUBLIC_KEY 0x50
#define TLV_ID_PUBLIC_KEY_LEN 64
#define TLV_ID_PUBLICK_KEY_OFFSET 33
#define META_MAGIC_OFFSET 12
#define META_MAGIC_LEN 8
#define DATA_CRC_OFFSET 4
#define DATA_CRC_LEN 4
/*
* Minimum payload len is sum of a must required fields length for Wi-Fi
* ==========================================================================
* | ID | | |PAY | ID | | | | PAY| | META | META|DATA|
* |(UUID)|FLAG|LEN|LOAD|(PUB KEY)|FLAG|LEN|PAD|LOAD|PAD|DATA LEN|MAGIC|CRC |
* ==========================================================================
* 2B 2B 4B 16B 2B 2B 4B 1B 64B 3B 4B 8B 4B
*/
#define MIN_PAYLOAD_LEN 116
typedef MLAN_PACK_START struct _FWMetaData {
t_u16 id;
t_u16 flag;
t_u32 len;
} MLAN_PACK_END FWMetaData;
#ifdef BIG_ENDIAN_SUPPORT
/** Convert sequence number and command fields
* of fwheader to correct endian format

View file

@ -40,6 +40,8 @@ enum _mlan_ioctl_req_id {
MLAN_OID_SCAN_CANCEL = 0x00010006,
MLAN_OID_SCAN_TABLE_FLUSH = 0x0001000A,
MLAN_OID_SCAN_BGSCAN_CONFIG = 0x0001000B,
MLAN_OID_SCAN_TABLE_FLUSH_WITH_BAND = 0x0001000C,
/* BSS Configuration Group */
MLAN_IOCTL_BSS = 0x00020000,
MLAN_OID_BSS_START = 0x00020001,
@ -395,6 +397,7 @@ enum _mlan_ioctl_req_id {
MLAN_OID_MISC_AUTH_ASSOC_TIMEOUT_CONFIG = 0x00200099,
MLAN_OID_MISC_PREV_ASSOC_INFO = 0x0020009A,
MLAN_OID_MISC_FOUNDRY_TYPE = 0X0020009B,
MLAN_OID_MISC_NAV_MITIGATION_HW = 0x0020009C,
MLAN_OID_MISC_PREAMBLE_PWR_BOOST = 0x0020009D,
@ -670,6 +673,8 @@ typedef struct _mlan_ds_scan {
mlan_scan_cfg scan_cfg;
/** 6E Scan config parameters */
mlan_scan_6g_cfg scan_6g_cfg;
/** Select the band to flush from scan table */
t_u32 band;
} param;
} mlan_ds_scan, *pmlan_ds_scan;
@ -6526,6 +6531,11 @@ typedef struct _mlan_ds_cross_chip_synch {
t_u32 init_tsf_high;
} mlan_ds_cross_chip_synch;
typedef struct _mlan_ds_foundry_type {
/**get foundry type UMC or TSMC*/
t_u8 foundry_type;
} mlan_ds_foundry_type;
#define MAX_RFUS 2
#define MAX_PATHS 2
typedef struct _mlan_ds_tsp_cfg {
@ -6588,6 +6598,10 @@ typedef struct _mlan_ds_misc_per_band_txpwr_cap {
t_u8 power;
/** band */
t_u8 band;
/** stronger rssi threshold */
t_s8 strong_rssi_thresh;
/** weaker rssi threshold */
t_s8 weak_rssi_thresh;
} mlan_ds_misc_per_band_txpwr_cap;
/** valid range for mlan_ds_auth_assoc_timeout_cfg */
@ -6648,6 +6662,9 @@ typedef struct _mlan_ds_agcs_cfg {
t_u16 nav_mitigation_th;
/* ch threshold to trigger channel switch for nighthawk */
t_u16 ch_th;
/* Channel switching is triggered only when the current pkts > the min
* average packet percentage. */
t_u16 min_pkt_percentage;
} mlan_ds_agcs_cfg;
#endif /* UAP_SUPPORT */
@ -6833,6 +6850,7 @@ typedef struct _mlan_ds_misc_cfg {
mlan_ds_ed_mac_cfg edmac_cfg;
mlan_ds_gpio_cfg_ops gpio_cfg_ops;
mlan_ds_auth_assoc_timeout_cfg auth_assoc_cfg;
mlan_ds_foundry_type soc_foundry_type;
mlan_ds_misc_per_band_txpwr_cap per_band_txpwr_cap;
#ifdef UAP_SUPPORT
/** config AGCS for MLAN_OID_MISC_AGCS_CONFIG */
@ -6895,6 +6913,11 @@ typedef struct _agcs_stats {
t_s16 noise;
/** The noise floor threshold currently used by fw */
t_s16 nf_threshold;
/** Record the scan channel list index according to 6G/5G/2G */
t_u8 scan_idx;
/** When the current band is 5g, has the same/diff class of 5g been
* scanned? */
t_u8 is_5g_scaned;
} agcs_stats, *pagcs_stats;
/** Type definition of agcs_event for WOAL_EVENT_AGCS */

View file

@ -316,6 +316,8 @@ static mlan_status wlan_get_common_rates(mlan_private *pmpriv, t_u8 *rate1,
PRINTM(MINFO, "Tx DataRate is set to 0x%X\n", pmpriv->data_rate);
if (!pmpriv->is_data_rate_auto) {
/* rate1_size is decremented in sync with ptr++ and loop exits
* when rate1_size becomes 0 ensures no overflow */
// coverity[integer_overflow:SUPPRESS]
while (rate1_size && *ptr) {
/* loop exits when rate1_size becomes 0 */

View file

@ -30,6 +30,9 @@ Change log:
#ifndef _MLAN_MAIN_H_
#define _MLAN_MAIN_H_
#define PUBLIC_KEY_SIZE 64
#define UUID_LEN 16
#ifdef DEBUG_LEVEL1
extern t_void (*print_callback)(t_pvoid pmoal_handle, t_u32 level,
char *pformat, IN...);
@ -115,6 +118,7 @@ extern t_u32 mlan_drvdbg;
print_callback(MNULL, MIF_D, msg); \
} while (0)
#ifdef DEBUG_LEVEL1
#define PRINTM_MIOCTL(msg...) \
do { \
if ((mlan_drvdbg & MIOCTL) && (print_callback)) \
@ -130,10 +134,10 @@ extern t_u32 mlan_drvdbg;
if ((mlan_drvdbg & MEVENT) && (print_callback)) \
print_callback(MNULL, MEVENT, msg); \
} while (0)
#define PRINTM_MCMND(msg...) \
#define PRINTM_MCMND(msg, ...) \
do { \
if ((mlan_drvdbg & MCMND) && (print_callback)) \
print_callback(MNULL, MCMND, msg); \
print_callback(MNULL, MCMND, msg, ##__VA_ARGS__); \
} while (0)
#define PRINTM_MDATA(msg...) \
do { \
@ -155,7 +159,7 @@ extern t_u32 mlan_drvdbg;
if ((mlan_drvdbg & MMSG) && (print_callback)) \
print_callback(MNULL, MMSG, msg); \
} while (0)
#endif
#define PRINTM_MSCH_D(msg...) \
do { \
if ((mlan_drvdbg & MSCH_D) && (print_callback)) \
@ -176,6 +180,16 @@ extern t_u32 mlan_drvdbg;
} while (0)
#endif /* __GNUC__ */
#ifndef fallthrough
#if defined(__GNUC__) && __GNUC__ >= 7
#define fallthrough __attribute__((fallthrough))
#elif defined(__clang__) && __clang_major__ >= 10
#define fallthrough __attribute__((fallthrough))
#else
#define fallthrough /* fall through */
#endif
#endif
/** Max hex dump data length */
#define MAX_DATA_DUMP_LEN 64
@ -2064,6 +2078,9 @@ typedef struct _mlan_init_para {
/** adma ring size */
t_u16 ring_size;
#endif
/** copy policy on RX and RX data path */
t_u8 copy_on_rx;
t_u8 copy_on_tx;
t_u8 ext_scan;
t_u8 mcs32;
/** antcfg */
@ -2412,6 +2429,12 @@ typedef struct _mlan_pcie_card {
/** last tx_pkt_size */
t_u32 last_tx_pkt_size[MLAN_MAX_TXRX_BD];
/** A list of mlan_buffer objects used for data tx */
mlan_buffer *tx_coherent_buf_list[MLAN_MAX_TXRX_BD];
/** A list of mlan_buffer objects used for data rx */
mlan_buffer *rx_coherent_buf_list[MLAN_MAX_TXRX_BD];
} mlan_pcie_card, *pmlan_pcie_card;
#endif
@ -2714,6 +2737,8 @@ struct _mlan_adapter {
mlan_list_head ioctl_pending_q;
/** pending_ioctl flag */
t_u8 pending_ioctl;
/** pending clean */
t_u8 pending_clean;
pmlan_private pending_disconnect_priv;
/** mlan_processing */
t_u32 scan_processing;
@ -3141,6 +3166,9 @@ struct _mlan_adapter {
/** agiled channel switch info */
agcs_stats agcs_info;
#endif /* UAP_SUPPORT */
t_u8 key[PUBLIC_KEY_SIZE];
t_u8 uuid[UUID_LEN];
t_u32 fw_meta_data_len;
};
/** IPv4 ARP request header */
@ -3227,10 +3255,10 @@ typedef MLAN_PACK_START struct {
#define MLAN_IP_PROTOCOL_UDP (0x11)
#define LLDE_FILTER_PKT_ALL 0
#define LLDE_FILTER_PKT_ICMP_PING 1
#define LLDE_FILTER_PKT_TCP_ACK 2
#define LLDE_FILTER_PKT_TCP_DATA 4
#define LLDE_FILTER_PKT_UDP 8
#define LLDE_FILTER_PKT_ICMP_PING MBIT(0)
#define LLDE_FILTER_PKT_TCP_ACK MBIT(1)
#define LLDE_FILTER_PKT_TCP_DATA MBIT(2)
#define LLDE_FILTER_PKT_UDP MBIT(3)
#define MLAN_TCP_ACK_OFFSET 24
#define MLAN_TCP_ACK_HEADER_LEN 52
@ -3376,6 +3404,7 @@ mlan_status wlan_misc_csi(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req);
mlan_status wlan_cmd_csi(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
t_u16 cmd_action, t_u16 *pdata_buf);
mlan_status wlan_process_csi_event(pmlan_private pmpriv);
mlan_status wlan_process_csi_status(pmlan_private pmpriv);
mlan_status wlan_misc_hal_phy_cfg(pmlan_adapter pmadapter,
pmlan_ioctl_req pioctl_req);
@ -3864,6 +3893,10 @@ mlan_status wlan_ops_sta_init_cmd(t_void *priv, t_u8 first_bss);
/** Flush the scan table */
mlan_status wlan_flush_scan_table(pmlan_adapter pmadapter);
/** Flush the scan table with band */
mlan_status wlan_flush_scan_table_with_band(pmlan_adapter pmadapter,
mlan_private *pmpriv, t_u32 band);
/** Scan for networks */
mlan_status wlan_scan_networks(mlan_private *pmpriv, t_void *pioctl_buf,
wlan_user_scan_cfg *puser_scan_in);
@ -4685,6 +4718,15 @@ mlan_status wlan_cmd_get_ch_load(pmlan_private pmpriv, HostCmd_DS_COMMAND *cmd,
t_u16 cmd_action, t_void *pdata_buf);
mlan_status wlan_ret_ch_load(pmlan_private pmpriv, HostCmd_DS_COMMAND *resp,
mlan_ioctl_req *pioctl_buf);
mlan_status wlan_cmd_get_foundry_type(pmlan_private pmpriv,
HostCmd_DS_COMMAND *cmd,
t_u16 cmd_action);
mlan_status wlan_ret_foundry_type(pmlan_private pmpriv,
HostCmd_DS_COMMAND *resp,
mlan_ioctl_req *pioctl_buf);
mlan_status wlan_misc_ioctl_foundry_type(pmlan_adapter pmadapter,
mlan_ioctl_req *pioctl_req);
mlan_status wlan_misc_ioctl_get_tsf(pmlan_adapter pmadapter,
pmlan_ioctl_req pioctl_req);
@ -5219,4 +5261,16 @@ void wlan_delete_iPhone_entry(mlan_private *priv, t_u8 *mac);
extern void print_chan_switch_block_event(t_u16 reason_code);
mlan_status mlan_read_meta_data(mlan_adapter *pmadapter, pmlan_fw_image pmfw);
static inline t_bool wlan_copy_on_tx_enabled(const mlan_adapter *adapter)
{
return adapter->init_para.copy_on_tx;
}
static inline t_bool wlan_copy_on_rx_enabled(const mlan_adapter *adapter)
{
return adapter->init_para.copy_on_rx;
}
#endif /* !_MLAN_MAIN_H_ */

View file

@ -275,6 +275,9 @@ static mlan_status wlan_custom_ioctl_auto_delete(pmlan_private pmpriv,
cnt, MAX_IE_SIZE);
if (pmpriv->mgmt_ie[index].ie_length >
(cnt + del_len)) {
/*buffer bounds are validated using MIN
*and logic ensures safe access within
*allocated array size. */
// coverity[cert_arr30_c_violation:
// SUPPRESS]
// coverity[cert_str31_c_violation:SUPPRESS]
@ -1142,12 +1145,6 @@ mlan_status wlan_misc_csi(pmlan_adapter pmadapter, pmlan_ioctl_req pioctl_req)
ENTER();
if (csi_cfg->param.csi_params.csi_enable == 1) {
if (pmadapter->csi_enabled) {
PRINTM(MERROR,
"Enable CSI: CSI was already enabled.\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
cmd_act = CSI_CMD_ENABLE;
} else {
if (!pmadapter->csi_enabled) {
@ -2766,6 +2763,9 @@ static void wlan_get_ap_ext_cap(mlan_private *pmpriv, ExtCap_t *ext_cap)
pbss_desc = &pmpriv->curr_bss_params.bss_descriptor;
memset(pmadapter, ext_cap, 0, sizeof(ExtCap_t));
if (pbss_desc->pext_cap) {
/* pointer arithmetic is safely bounded and offset is validated
* against structure size before use, ensuring no invalid
* pointer dereference. */
// coverity[cert_exp34_c_violation:SUPPRESS]
memcpy_ext(pmadapter, (t_u8 *)ext_cap,
(t_u8 *)pbss_desc->pext_cap +
@ -4367,6 +4367,7 @@ void wlan_check_sta_capability(pmlan_private priv, pmlan_buffer pevent,
priv->adapter, assoc_req_ie, ie_len,
&sta_ptr->multi_ap_ie);
#endif
pExtCap = (IEEEtypes_ExtCap_t *)
wlan_get_specific_ie(priv, assoc_req_ie,
ie_len,
@ -7291,6 +7292,32 @@ mlan_status wlan_misc_ioctl_ch_load(pmlan_adapter pmadapter,
LEAVE();
return ret;
}
mlan_status wlan_misc_ioctl_foundry_type(pmlan_adapter pmadapter,
mlan_ioctl_req *pioctl_req)
{
mlan_private *pmpriv = pmadapter->priv[pioctl_req->bss_index];
mlan_status ret = MLAN_STATUS_SUCCESS;
t_u16 cmd_action = 0;
ENTER();
if (pioctl_req->action == MLAN_ACT_GET)
cmd_action = HostCmd_ACT_GEN_GET;
else {
PRINTM(MERROR, " foundry_type only support get operation \n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
/* Send request to firmware */
ret = wlan_prepare_cmd(pmpriv, HostCmd_CMD_DS_GET_FOUNDRY_TYPE,
cmd_action, 0, (t_void *)pioctl_req, MNULL);
if (ret == MLAN_STATUS_SUCCESS)
ret = MLAN_STATUS_PENDING;
LEAVE();
return ret;
}
/**
* @brief Get CHAN_TPRC setting
*

View file

@ -1290,6 +1290,45 @@ static mlan_status wlan_pcie_create_txbd_ring(mlan_adapter *pmadapter)
ADMA_BD_FLAG_SOP | ADMA_BD_FLAG_EOP);
padma_bd_buf->pkt_size = 0;
padma_bd_buf->reserved = 0;
if (wlan_copy_on_tx_enabled(pmadapter)) {
mlan_buffer *pmbuf = MNULL;
t_u8 *tx_coherent_vbase;
t_u64 tx_coherent_pbase = 0;
/* alloc tx coherent buf */
pmbuf = wlan_alloc_mlan_buffer(
pmadapter, 0, 0, MOAL_MALLOC_BUFFER);
if (!pmbuf) {
PRINTM(MERROR,
"Tx buffer create : Unable to allocate mlan_buffer\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
ret = pcb->moal_malloc_cached(
pmadapter->pmoal_handle,
MLAN_TX_DATA_BUF_SIZE_4K,
&tx_coherent_vbase, &tx_coherent_pbase);
if (ret != MLAN_STATUS_SUCCESS) {
PRINTM(MERROR,
"%s: No free moal_malloc_consistent\n",
__FUNCTION__);
/* free pmbuf */
wlan_free_mlan_buffer(pmadapter, pmbuf);
LEAVE();
return MLAN_STATUS_FAILURE;
}
pmbuf->buf_pa = tx_coherent_pbase;
pmbuf->pbuf = tx_coherent_vbase;
pmbuf->data_offset = 0;
pmbuf->data_len = MLAN_TX_DATA_BUF_SIZE_4K;
pmbuf->total_pcie_buf_len =
MLAN_TX_DATA_BUF_SIZE_4K;
pmadapter->pcard_pcie->tx_coherent_buf_list[i] =
pmbuf;
}
}
#endif
@ -1339,11 +1378,13 @@ static mlan_status wlan_pcie_delete_txbd_ring(mlan_adapter *pmadapter)
for (i = 0; i < pmadapter->pcard_pcie->txrx_bd_size; i++) {
if (pmadapter->pcard_pcie->tx_buf_list[i]) {
pmbuf = pmadapter->pcard_pcie->tx_buf_list[i];
pcb->moal_unmap_memory(pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa,
MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_TODEVICE);
if (!wlan_copy_on_tx_enabled(pmadapter)) {
pcb->moal_unmap_memory(
pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa, MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_TODEVICE);
}
wlan_write_data_complete(pmadapter, pmbuf,
MLAN_STATUS_FAILURE);
}
@ -1378,6 +1419,19 @@ static mlan_status wlan_pcie_delete_txbd_ring(mlan_adapter *pmadapter)
padma_bd_buf->pkt_size = 0;
padma_bd_buf->reserved = 0;
}
/* release tx coherent buf */
if (pmadapter->pcard_pcie->tx_coherent_buf_list[i]) {
pmbuf = pmadapter->pcard_pcie
->tx_coherent_buf_list[i];
if (pmbuf->pbuf)
pcb->moal_mfree_cached(
pmadapter->pmoal_handle,
pmbuf->total_pcie_buf_len,
pmbuf->pbuf, pmbuf->buf_pa);
wlan_free_mlan_buffer(pmadapter, pmbuf);
}
pmadapter->pcard_pcie->tx_coherent_buf_list[i] = MNULL;
}
#endif
pmadapter->pcard_pcie->txbd_ring[i] = MNULL;
@ -1412,7 +1466,6 @@ static mlan_status wlan_pcie_create_rxbd_ring(mlan_adapter *pmadapter)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
pmlan_callbacks pcb = &pmadapter->callbacks;
mlan_buffer *pmbuf = MNULL;
t_u32 i;
#if defined(PCIE8997) || defined(PCIE8897)
mlan_pcie_data_buf *prxbd_buf;
@ -1420,6 +1473,9 @@ static mlan_status wlan_pcie_create_rxbd_ring(mlan_adapter *pmadapter)
#if defined(PCIE9098) || defined(PCIE9097) || defined(PCIEAW693) || \
defined(PCIEIW624)
adma_dual_desc_buf *padma_bd_buf;
mlan_buffer *pcbuf = MNULL;
t_u8 *rx_coherent_vbase;
t_u64 rx_coherent_pbase = 0;
#endif
ENTER();
@ -1483,7 +1539,8 @@ static mlan_status wlan_pcie_create_rxbd_ring(mlan_adapter *pmadapter)
for (i = 0; i < pmadapter->pcard_pcie->txrx_bd_size; i++) {
/* Allocate buffer here so that firmware can DMA data on it */
pmbuf = wlan_alloc_mlan_buffer(pmadapter, MLAN_RX_DATA_BUF_SIZE,
mlan_buffer *pmbuf =
wlan_alloc_mlan_buffer(pmadapter, MLAN_RX_DATA_BUF_SIZE,
MLAN_RX_HEADER_LEN,
MOAL_ALLOC_MLAN_BUFFER);
if (!pmbuf) {
@ -1496,16 +1553,19 @@ static mlan_status wlan_pcie_create_rxbd_ring(mlan_adapter *pmadapter)
pmadapter->pcard_pcie->rx_buf_list[i] = pmbuf;
if (MLAN_STATUS_FAILURE ==
pcb->moal_map_memory(pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
&pmbuf->buf_pa, MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_FROMDEVICE)) {
PRINTM(MERROR,
"Rx ring create : moal_map_memory failed\n");
wlan_pcie_delete_rxbd_ring(pmadapter);
LEAVE();
return MLAN_STATUS_FAILURE;
if (!wlan_copy_on_rx_enabled(pmadapter)) {
if (MLAN_STATUS_FAILURE ==
pcb->moal_map_memory(
pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
&pmbuf->buf_pa, MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_FROMDEVICE)) {
PRINTM(MERROR,
"Rx ring create : moal_map_memory failed\n");
wlan_pcie_delete_rxbd_ring(pmadapter);
LEAVE();
return MLAN_STATUS_FAILURE;
}
}
PRINTM(MINFO,
@ -1515,6 +1575,44 @@ static mlan_status wlan_pcie_create_rxbd_ring(mlan_adapter *pmadapter)
pmbuf, pmbuf->pbuf, (t_u32)((t_u64)pmbuf->buf_pa >> 32),
(t_u32)pmbuf->buf_pa, pmbuf->data_len);
#if defined(PCIE9098) || defined(PCIE9097) || defined(PCIEAW693) || \
defined(PCIEIW624)
if (wlan_copy_on_rx_enabled(pmadapter)) {
/* alloc rx buf */
pcbuf = wlan_alloc_mlan_buffer(pmadapter, 0, 0,
MOAL_MALLOC_BUFFER);
if (!pcbuf) {
PRINTM(MERROR,
"Rx buffer create : Unable to allocate mlan_buffer\n");
wlan_pcie_delete_rxbd_ring(pmadapter);
LEAVE();
return MLAN_STATUS_FAILURE;
}
ret = pcb->moal_malloc_cached(pmadapter->pmoal_handle,
MLAN_RX_DATA_BUF_SIZE,
&rx_coherent_vbase,
&rx_coherent_pbase);
if (ret != MLAN_STATUS_SUCCESS) {
PRINTM(MERROR,
"%s: No free moal_malloc_cached\n",
__FUNCTION__);
wlan_pcie_delete_rxbd_ring(pmadapter);
wlan_free_mlan_buffer(pmadapter, pcbuf);
LEAVE();
return MLAN_STATUS_FAILURE;
}
pcbuf->buf_pa = rx_coherent_pbase;
pcbuf->pbuf = rx_coherent_vbase;
pcbuf->data_offset = 0;
pcbuf->data_len = MLAN_RX_DATA_BUF_SIZE;
pcbuf->total_pcie_buf_len = MLAN_RX_DATA_BUF_SIZE;
pmadapter->pcard_pcie->rx_coherent_buf_list[i] = pcbuf;
pmbuf = pcbuf;
}
#endif
#if defined(PCIE8997) || defined(PCIE8897)
if (!pmadapter->pcard_pcie->reg->use_adma) {
prxbd_buf =
@ -1578,22 +1676,38 @@ static mlan_status wlan_pcie_delete_rxbd_ring(mlan_adapter *pmadapter)
defined(PCIEIW624)
adma_dual_desc_buf *padma_bd_buf;
#endif
const t_bool unmap_buffers = !wlan_copy_on_rx_enabled(pmadapter);
ENTER();
for (i = 0; i < pmadapter->pcard_pcie->txrx_bd_size; i++) {
if (pmadapter->pcard_pcie->rx_buf_list[i]) {
pmbuf = pmadapter->pcard_pcie->rx_buf_list[i];
pcb->moal_unmap_memory(pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa,
MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_FROMDEVICE);
if (unmap_buffers) {
pcb->moal_unmap_memory(
pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa, MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_FROMDEVICE);
}
wlan_free_mlan_buffer(
pmadapter,
pmadapter->pcard_pcie->rx_buf_list[i]);
}
pmadapter->pcard_pcie->rx_buf_list[i] = MNULL;
/* release rx coherent buf */
if (pmadapter->pcard_pcie->rx_coherent_buf_list[i]) {
pmbuf = pmadapter->pcard_pcie->rx_coherent_buf_list[i];
if (pmbuf->pbuf)
pcb->moal_mfree_cached(
pmadapter->pmoal_handle,
pmbuf->total_pcie_buf_len, pmbuf->pbuf,
pmbuf->buf_pa);
wlan_free_mlan_buffer(pmadapter, pmbuf);
}
pmadapter->pcard_pcie->rx_coherent_buf_list[i] = MNULL;
#if defined(PCIE8997) || defined(PCIE8897)
if (!pmadapter->pcard_pcie->reg->use_adma) {
prxbd_buf = (mlan_pcie_data_buf *)
@ -2053,6 +2167,8 @@ static mlan_status wlan_pcie_send_data_complete(mlan_adapter *pmadapter)
t_u32 wrdoneidx;
t_u32 rdptr = 0;
t_u32 unmap_count = 0;
const t_bool unmap_on_tx = !wlan_copy_on_tx_enabled(pmadapter);
#if defined(PCIE8997) || defined(PCIE8897)
t_u32 txrx_rw_ptr_mask = pmadapter->pcard_pcie->reg->txrx_rw_ptr_mask;
t_u32 txrx_rw_ptr_rollover_ind =
@ -2110,15 +2226,21 @@ static mlan_status wlan_pcie_send_data_complete(mlan_adapter *pmadapter)
"SEND DATA COMP: Detach pmbuf %p at tx_ring[%d], pmadapter->txbd_rdptr=0x%x\n",
pmbuf, wrdoneidx,
pmadapter->pcard_pcie->txbd_rdptr);
ret = pcb->moal_unmap_memory(
pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset, pmbuf->buf_pa,
pmbuf->data_len, PCI_DMA_TODEVICE);
if (ret == MLAN_STATUS_FAILURE) {
PRINTM(MERROR, "%s: moal_unmap_memory failed\n",
__FUNCTION__);
break;
if (unmap_on_tx) {
ret = pcb->moal_unmap_memory(
pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa, pmbuf->data_len,
PCI_DMA_TODEVICE);
if (ret == MLAN_STATUS_FAILURE) {
PRINTM(MERROR,
"%s: moal_unmap_memory failed\n",
__FUNCTION__);
break;
}
}
unmap_count++;
#if defined(PCIE8997) || defined(PCIE8897)
if (pmadapter->pcard_pcie->txbd_flush)
@ -2320,9 +2442,18 @@ static mlan_status wlan_pcie_send_adma_data(mlan_adapter *pmadapter,
t_u32 rxbd_val = 0;
t_u32 wrindx;
t_u32 wr_ptr_start = 0;
const t_bool handle_mapping = !wlan_copy_on_tx_enabled(pmadapter);
ENTER();
if (!handle_mapping) {
PRINTM(MERROR,
"%s() copy on TX is enabled, SG should not be used",
__FUNCTION__);
ret = MLAN_STATUS_FAILURE;
goto done;
}
if (!pmbuf) {
PRINTM(MERROR, "%s() has no buffer", __FUNCTION__);
ret = MLAN_STATUS_FAILURE;
@ -2361,6 +2492,7 @@ static mlan_status wlan_pcie_send_adma_data(mlan_adapter *pmadapter,
ret = MLAN_STATUS_FAILURE;
goto done;
}
wrindx = pmadapter->pcard_pcie->txbd_wrptr & (num_tx_buffs - 1);
PRINTM(MDAT_D,
"SEND DATA: Attach pmbuf %p at tx_ring[%d], txbd_wrptr=0x%x\n",
@ -2473,6 +2605,7 @@ done_unmap:
PRINTM(MERROR, "SEND DATA: failed to moal_unmap_memory\n");
ret = MLAN_STATUS_FAILURE;
}
pcb->moal_spin_lock(pmadapter->pmoal_handle,
pmadapter->pmlan_pcie_lock);
pmadapter->pcard_pcie->txbd_pending--;
@ -2529,6 +2662,7 @@ static mlan_status wlan_pcie_send_data(mlan_adapter *pmadapter, t_u8 type,
t_u32 wrindx;
t_u8 *payload;
t_u32 wr_ptr_start = 0;
const t_bool copy_on_tx = wlan_copy_on_tx_enabled(pmadapter);
ENTER();
@ -2568,17 +2702,38 @@ static mlan_status wlan_pcie_send_data(mlan_adapter *pmadapter, t_u8 type,
write_u16_unaligned(pmadapter, &payload[2],
wlan_cpu_to_le16(type));
/* Map pmbuf, and attach to tx ring */
if (MLAN_STATUS_FAILURE ==
pcb->moal_map_memory(pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
&pmbuf->buf_pa, pmbuf->data_len,
PCI_DMA_TODEVICE)) {
PRINTM(MERROR,
"SEND DATA: failed to moal_map_memory\n");
ret = MLAN_STATUS_FAILURE;
goto done;
if (copy_on_tx) {
mlan_buffer *staged_buf;
/* copy tx data to staged buf */
wrindx = pmadapter->pcard_pcie->txbd_wrptr &
(num_tx_buffs - 1);
staged_buf = pmadapter->pcard_pcie
->tx_coherent_buf_list[wrindx];
memcpy_ext(pmadapter, staged_buf->pbuf,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->data_len, MLAN_TX_DATA_BUF_SIZE_4K);
/* make sure payload will be wisible to device */
pcb->moal_dma_sync_to_device(pmadapter->pmoal_handle,
pmbuf->data_len,
staged_buf->buf_pa,
MOAL_DMA_SYNC_TO_DEVICE);
} else {
/* Map pmbuf, and attach to tx ring */
if (MLAN_STATUS_FAILURE ==
pcb->moal_map_memory(
pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
&pmbuf->buf_pa, pmbuf->data_len,
PCI_DMA_TODEVICE)) {
PRINTM(MERROR,
"SEND DATA: failed to moal_map_memory\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
}
wrindx = pmadapter->pcard_pcie->txbd_wrptr & (num_tx_buffs - 1);
PRINTM(MDAT_D,
"SEND DATA: Attach pmbuf %p at tx_ring[%d], txbd_wrptr=0x%x\n",
@ -2623,7 +2778,18 @@ static mlan_status wlan_pcie_send_data(mlan_adapter *pmadapter, t_u8 type,
wr_ptr_start = ADMA_WPTR_START;
padma_bd_buf = (adma_dual_desc_buf *)pmadapter
->pcard_pcie->txbd_ring[wrindx];
padma_bd_buf->paddr = wlan_cpu_to_le64(pmbuf->buf_pa);
if (copy_on_tx) {
/* attach tx staged buf */
padma_bd_buf->paddr =
pmadapter->pcard_pcie
->tx_coherent_buf_list[wrindx]
->buf_pa;
} else {
padma_bd_buf->paddr =
wlan_cpu_to_le64(pmbuf->buf_pa);
}
padma_bd_buf->len = pmbuf->data_len;
#if defined(PCIEAW693)
@ -2716,13 +2882,16 @@ static mlan_status wlan_pcie_send_data(mlan_adapter *pmadapter, t_u8 type,
return ret;
done_unmap:
if (MLAN_STATUS_FAILURE ==
pcb->moal_unmap_memory(
pmadapter->pmoal_handle, pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa, pmbuf->data_len, PCI_DMA_TODEVICE)) {
if (!copy_on_tx &&
MLAN_STATUS_FAILURE ==
pcb->moal_unmap_memory(pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa, pmbuf->data_len,
PCI_DMA_TODEVICE)) {
PRINTM(MERROR, "SEND DATA: failed to moal_unmap_memory\n");
ret = MLAN_STATUS_FAILURE;
}
pcb->moal_spin_lock(pmadapter->pmoal_handle,
pmadapter->pmlan_pcie_lock);
pmadapter->pcard_pcie->txbd_pending--;
@ -2886,8 +3055,23 @@ static void wlan_pcie_rx_ring_attach_buf(mlan_adapter *pmadapter,
(adma_dual_desc_buf *)
pmadapter->pcard_pcie->rxbd_ring[rd_index];
if (pmbuf) {
padma_bd_buf->paddr = wlan_cpu_to_le64(pmbuf->buf_pa);
padma_bd_buf->len = wlan_cpu_to_le16(pmbuf->data_len);
if (wlan_copy_on_rx_enabled(pmadapter)) {
/* attach rx staged buf */
padma_bd_buf->paddr = wlan_cpu_to_le64(
pmadapter->pcard_pcie
->rx_coherent_buf_list[rd_index]
->buf_pa);
padma_bd_buf->len = wlan_cpu_to_le16(
pmadapter->pcard_pcie
->rx_coherent_buf_list[rd_index]
->data_len);
} else {
padma_bd_buf->paddr =
wlan_cpu_to_le64(pmbuf->buf_pa);
padma_bd_buf->len =
wlan_cpu_to_le16(pmbuf->data_len);
}
padma_bd_buf->flags = wlan_cpu_to_le16(
ADMA_BD_FLAG_INT_EN | ADMA_BD_FLAG_DST_HOST);
padma_bd_buf->pkt_size = 0;
@ -3076,15 +3260,20 @@ mlan_status wlan_pcie_reattach_pmbuf(mlan_adapter *pmadapter, t_u32 rd_index,
pmadapter->pcard_pcie->rx_buf_list[rd_index] = MNULL;
return ret;
}
if (MLAN_STATUS_FAILURE ==
pcb->moal_map_memory(pmadapter->pmoal_handle,
(*pmbuf)->pbuf + (*pmbuf)->data_offset,
&(*pmbuf)->buf_pa, MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_FROMDEVICE)) {
if (wlan_copy_on_rx_enabled(pmadapter)) {
/* do noting */
} else if (MLAN_STATUS_FAILURE ==
pcb->moal_map_memory(pmadapter->pmoal_handle,
(*pmbuf)->pbuf + (*pmbuf)->data_offset,
&(*pmbuf)->buf_pa,
MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_FROMDEVICE)) {
wlan_free_mlan_buffer(pmadapter, *pmbuf);
ret = MLAN_STATUS_FAILURE;
return ret;
}
PRINTM(MDAT_D, "RECV DATA: Attach new pmbuf %p at rx_ring[%d]\n",
*pmbuf, rd_index);
pmadapter->pcard_pcie->rx_buf_list[rd_index] = *pmbuf;
@ -3114,6 +3303,7 @@ static mlan_status wlan_pcie_process_recv_data(mlan_adapter *pmadapter)
t_u32 in_ts_sec = 0;
t_u32 in_ts_usec = 0;
const t_bool copy_on_rx = wlan_copy_on_rx_enabled(pmadapter);
ENTER();
@ -3162,16 +3352,34 @@ static mlan_status wlan_pcie_process_recv_data(mlan_adapter *pmadapter)
PRINTM(MERROR, "RECV DATA: invalid pmbuf");
goto reattach;
}
if (MLAN_STATUS_FAILURE ==
pcb->moal_unmap_memory(pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa, MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_FROMDEVICE)) {
if (copy_on_rx) {
mlan_buffer *staged_buf =
pmadapter->pcard_pcie
->rx_coherent_buf_list[rd_index];
pcb->moal_dma_sync_to_cpu(pmadapter->pmoal_handle,
MLAN_RX_DATA_BUF_SIZE,
staged_buf->buf_pa,
MOAL_DMA_SYNC_FROM_DEVICE);
/* copy rx data from staged buf */
rx_len =
read_u16_unaligned(pmadapter, staged_buf->pbuf);
rx_len = wlan_le16_to_cpu(rx_len);
memcpy_ext(pmadapter, pmbuf->pbuf + pmbuf->data_offset,
staged_buf->pbuf, rx_len,
MLAN_RX_DATA_BUF_SIZE);
} else if (MLAN_STATUS_FAILURE ==
pcb->moal_unmap_memory(
pmadapter->pmoal_handle,
pmbuf->pbuf + pmbuf->data_offset,
pmbuf->buf_pa, MLAN_RX_DATA_BUF_SIZE,
PCI_DMA_FROMDEVICE)) {
PRINTM(MERROR,
"RECV DATA: moal_unmap_memory failed.\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
PRINTM(MDAT_D,
"RECV DATA: Detach pmbuf %p at rx_ring[%d], pmadapter->rxbd_rdptr=0x%x\n",
pmbuf, rd_index, pmadapter->pcard_pcie->rxbd_rdptr);

View file

@ -5188,6 +5188,43 @@ mlan_status wlan_flush_scan_table(pmlan_adapter pmadapter)
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Internal function used to flush the scan list with band
*
* @param pmadapter A pointer to mlan_adapter structure
* @param pmpriv A pointer to mlan_private
* @param band BAND_A/BAND_G/BAND_6G
*
* @return MLAN_STATUS_SUCCESS
*/
mlan_status wlan_flush_scan_table_with_band(pmlan_adapter pmadapter,
mlan_private *pmpriv, t_u32 band)
{
BSSDescriptor_t *pbss_entry;
t_s32 table_idx = pmadapter->num_in_scan_table - 1;
t_u32 i = 0;
ENTER();
PRINTM(MINFO, "Flushing scan table with band %u\n", band);
for (i = 0; i < pmadapter->num_in_scan_table; i++) {
pbss_entry = &pmadapter->pscan_table[table_idx];
if (pbss_entry->bss_band & band) {
PRINTM(MCMND,
"SCAN: flush AP, MAC Addr-" MACSTR
" ssid: %-32s\n",
MAC2STR(pbss_entry->mac_address),
pbss_entry->ssid.ssid);
wlan_scan_delete_table_entry(pmpriv, table_idx);
}
table_idx--;
}
LEAVE();
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Internal function used to start a scan based on an input config
*
@ -7014,6 +7051,7 @@ static t_u32 wlan_copy_ie_with_fragments(pmlan_adapter pmadapter,
}
LEAVE();
/* Explicit bound checking is already done before memcpy */
// coverity[overflow_sink:SUPPRESS]
return *pos - buf;
}
@ -7120,6 +7158,8 @@ static t_u32 wlan_gen_new_ie(mlan_private *pmpriv, t_u8 *ie, t_u32 ie_len,
pmadapter, sub, merged_ie, merged_ie_len,
&pos, new_ie, new_ie_len)) <= 0)
return 0;
/* Safe: sub pointer and length validated by
* wlan_find_elem_match with bounds checking */
// coverity[overflow_sink:SUPPRESS]
sub = wlan_find_elem_match(
pmadapter, id, sub->data + sub->ieee_hdr.len,
@ -7281,6 +7321,8 @@ static void wlan_gen_non_trans_bssid_profile(mlan_private *pmpriv,
bss_new_entry->multi_bssid_ap = MULTI_BSSID_SUB_AP;
/* Allocate the beacon buffer for new entry */
/* Safe: ie_len is validated beacon buffer size minus fixed
* header, allocation size is controlled */
// coverity[overflow_sink:SUPPRESS]
ret = pcb->moal_malloc(pmadapter->pmoal_handle, ie_len,
MLAN_MEM_DEF, (t_u8 **)&pbeacon_buf);
@ -7291,6 +7333,8 @@ static void wlan_gen_non_trans_bssid_profile(mlan_private *pmpriv,
}
/** Generate the NonTx BSSID Beacon buffer */
/* Safe: ie_len matches allocated pbeacon_buf size,
* wlan_gen_new_ie performs bounds checking */
// coverity[overflow_sink:SUPPRESS]
copied_len = wlan_gen_new_ie(
pmpriv, pbss_entry->pbeacon_buf + BEACON_FIX_SIZE,
@ -7307,6 +7351,8 @@ static void wlan_gen_non_trans_bssid_profile(mlan_private *pmpriv,
DBG_HEXDUMP(MCMD_D, "NonTx BSSID", pbeacon_buf, copied_len);
/** Update NonTx BSS descriptor entries */
/* Safe: copied_len is validated return value from
* wlan_gen_new_ie, pbeacon_buf size is controlled */
// coverity[overflow_sink:SUPPRESS]
if (MLAN_STATUS_SUCCESS !=
wlan_update_nonTx_bss_desc(pmadapter, pbss_entry,
@ -7484,10 +7530,15 @@ wlan_merge_nontx_bssid_profile(pmlan_adapter pmadapter,
pnontx_bssid->ieee_hdr.len, pnontx_bssid->ieee_hdr.len);
/* Check for split nonTxBssid in next MBSSID elem */
/* Safe: wlan_get_next_mbssid_profile validates buffer bounds and
* returns valid pointer or NULL */
// coverity[overflow_sink:SUPPRESS]
while ((pnext_mbssid = wlan_get_next_mbssid_profile(
pbss_entry, ie_len, pnext_mbssid, pnext_nontx_bssid)) !=
MNULL) {
/* Safe: pnext_mbssid is validated by
* wlan_get_next_mbssid_profile, sub_elem_data is within bounds
*/
// coverity[overflow_sink:SUPPRESS]
pnext_nontx_bssid = (IEEEtypes_NonTransBSSIDProfile_t *)
pnext_mbssid->sub_elem_data;
@ -7508,6 +7559,8 @@ wlan_merge_nontx_bssid_profile(pmlan_adapter pmadapter,
}
LEAVE();
/* Safe: copied_len is accumulated from validated length checks
* and never exceeds max_copy_len */
// coverity[overflow_sink:SUPPRESS]
return copied_len;
}
@ -7550,6 +7603,8 @@ static t_void wlan_parse_multi_bssid_ie(mlan_private *pmpriv,
pcurrent_ptr = pmulti_bssid->sub_elem_data;
/* Allocate memory for the merged profile */
/* Safe: max_copy_len is validated beacon buffer size, allocation size
* is controlled and bounded */
// coverity[overflow_sink:SUPPRESS]
// coverity[overwrite_var:SUPPRESS]
ret = pcb->moal_malloc(pmadapter->pmoal_handle, max_copy_len,
@ -7598,6 +7653,8 @@ static t_void wlan_parse_multi_bssid_ie(mlan_private *pmpriv,
profile_len);
/* Generate the NonTx BSSID entry and add to the scan table */
/* Safe: profile_len is validated by
* wlan_merge_nontx_bssid_profile with bounds checking */
// coverity[overflow_sink:SUPPRESS]
wlan_gen_non_trans_bssid_profile(
pmpriv, pbss_entry, pmerged_profile, profile_len,

View file

@ -1046,8 +1046,17 @@ static mlan_status wlan_sdio_prog_fw_w_helper(pmlan_adapter pmadapter,
}
/* Ignore CRC check before download the 1st packet */
if (offset == 0 && (len & MBIT(0)))
if (offset == 0 && (len & MBIT(0))) {
len &= ~MBIT(0);
/* When offset is 0 return an error in case of len=0 to
* avoid infinite loop */
if (len == 0) {
PRINTM(MERROR,
"WLAN: FW download failed as length is 0\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
}
txlen = len;

View file

@ -26,6 +26,7 @@ Change log:
********************************************************/
#include "mlan.h"
#include "mlan_init.h"
#ifdef STA_SUPPORT
#include "mlan_join.h"
#endif
@ -128,6 +129,18 @@ t_u32 mlan_drvdbg = DEFAULT_DEBUG_MASK;
#ifdef USB
extern mlan_status wlan_get_usb_device(pmlan_adapter pmadapter);
#endif
static INLINE t_bool wlan_is_adma_supported(mlan_adapter *pmadapter)
{
t_bool is_adma_supported = 0;
#if defined(PCIE)
is_adma_supported = IS_PCIE(pmadapter->card_type) &&
pmadapter->pcard_pcie->reg->use_adma;
#endif
return is_adma_supported;
}
/********************************************************
Local Functions
*******************************************************/
@ -405,11 +418,19 @@ mlan_status mlan_register(pmlan_device pmdevice, t_void **ppmlan_adapter)
pmadapter->init_para.tx_budget = pmdevice->tx_budget;
pmadapter->init_para.mclient_scheduling =
pmdevice->mclient_scheduling;
ret = wlan_get_pcie_device(pmadapter);
if (MLAN_STATUS_SUCCESS != ret) {
ret = MLAN_STATUS_FAILURE;
goto error;
}
pmadapter->init_para.copy_on_rx =
pmdevice->copy_on_rx &&
wlan_is_adma_supported(pmadapter);
pmadapter->init_para.copy_on_tx =
pmdevice->copy_on_tx &&
wlan_is_adma_supported(pmadapter);
}
#endif
@ -671,6 +692,129 @@ mlan_status mlan_unregister(t_void *padapter)
return ret;
}
/**
* @brief This function reads metadata support enabled firmware
*
* @param padapter A pointer mlan_adapter structure
* @param pmfw A pointer to firmware image
*
* @return MLAN_STATUS_SUCCESS - successful parse or if no meta data
* MLAN_STATUS_FAILURE - failure to parse metadata
*/
mlan_status mlan_read_meta_data(mlan_adapter *pmadapter, pmlan_fw_image pmfw)
{
mlan_status ret = MLAN_STATUS_FAILURE;
t_u8 magic[META_MAGIC_LEN] = {0x6d, 0x65, 0x74, 0x61,
0x6d, 0x61, 0x67, 0x63};
t_u32 len = 0, offset = 0;
const t_u8 *meta_payload = MNULL;
const FWMetaData *data;
const FWHeader *header;
t_u32 fw_data_crc;
t_u32 hdr_crc, local_data_crc;
pmlan_callbacks pcb = &pmadapter->callbacks;
if (pmfw->fw_len < (MIN_PAYLOAD_LEN + sizeof(FWHeader))) {
PRINTM(MERROR,
"FW length too short (%d bytes) to parse meta data\n",
pmfw->fw_len);
return ret;
}
/** check for metamagic in firmware */
if (memcmp(pmadapter, magic,
(pmfw->pfw_buf + pmfw->fw_len) - META_MAGIC_OFFSET,
META_MAGIC_LEN)) {
ret = MLAN_STATUS_SUCCESS;
LEAVE();
return ret;
}
/** read length */
memcpy_ext(pmadapter, &len,
(pmfw->pfw_buf + pmfw->fw_len) - DATA_CRC_OFFSET -
META_MAGIC_OFFSET,
sizeof(len), sizeof(len));
if (len < MIN_PAYLOAD_LEN) {
PRINTM(MMSG, "Invalid meta data len 0x%x in fw image\n", len);
LEAVE();
return ret;
}
/** check if metadata starts with command 24 */
header = (const FWHeader *)((pmfw->pfw_buf + pmfw->fw_len) -
(len + sizeof(FWHeader)));
if (wlan_le32_to_cpu(header->dnld_cmd) != FW_CMD_24) {
PRINTM(MERROR, "Invalid command id:0x%x\n", header->dnld_cmd);
LEAVE();
return ret;
}
memcpy_ext(pmadapter, &fw_data_crc,
(pmfw->pfw_buf + pmfw->fw_len) - DATA_CRC_OFFSET,
DATA_CRC_LEN, DATA_CRC_LEN);
meta_payload = (pmfw->pfw_buf + pmfw->fw_len) - len;
hdr_crc = pcb->moal_crc32_be(0, (const t_u8 *)header,
sizeof(FWHeader) - 4);
local_data_crc = pcb->moal_crc32_be(0, meta_payload, len - 4);
/* compare header crc from firmware and locally generated header crc */
if (hdr_crc != header->crc) {
PRINTM(MERROR, "Invalid header crc\n");
LEAVE();
return ret;
}
/* compare data crc from firmware and locally generated data crc */
if (local_data_crc != fw_data_crc) {
PRINTM(MERROR, "Invalid data crc\n");
LEAVE();
return ret;
}
/* parse metadata for mandatory fields for Wi-Fi */
while (offset <= len) {
data = (const FWMetaData *)(meta_payload + offset);
if (data->flag == TLV_FLAG_WIFI) {
if (data->id == TLV_ID_UUID) {
offset += sizeof(FWMetaData);
memcpy_ext(
pmadapter, pmadapter->uuid,
(const t_u8 *)(meta_payload + offset),
TLV_ID_UUID_LEN, TLV_ID_UUID_LEN);
offset += data->len;
} else if (data->id == TLV_ID_PUBLIC_KEY) {
/**
* Increment by "1" since public key prefixed
* with 0x4 to indicate uncompressed public key
* which forces firmware metadata to be padded
* with "3" bytes for alignment.
*/
offset += sizeof(FWMetaData) + 1;
memcpy_ext(
pmadapter, pmadapter->key,
(const t_u8 *)(meta_payload + offset),
TLV_ID_PUBLIC_KEY_LEN,
TLV_ID_PUBLIC_KEY_LEN);
offset += data->len + 3;
pmadapter->fw_meta_data_len =
len + sizeof(FWHeader);
break;
}
} else {
offset += sizeof(FWMetaData) + data->len;
if (data->id == TLV_ID_PUBLIC_KEY)
offset += 3;
}
}
return MLAN_STATUS_SUCCESS;
}
/**
* @brief This function downloads the firmware
*
@ -691,6 +835,10 @@ mlan_status mlan_dnld_fw(t_void *padapter, pmlan_fw_image pmfw)
ENTER();
MASSERT(padapter);
if (!pmadapter->second_mac)
if (mlan_read_meta_data(pmadapter, pmfw) != MLAN_STATUS_SUCCESS)
return ret;
/* Download helper/firmware */
if (pmfw) {
ret = pmadapter->ops.dnld_fw(pmadapter, pmfw);
@ -1231,6 +1379,22 @@ static void mlan_refill_rx_ring(t_void *padapter)
}
#endif
/**
* @brief clean up txrx
*
* @param adapter A pointer to mlan_adapter structure
*
* @return N/A
*/
static t_void wlan_free_txrx(pmlan_adapter pmadapter)
{
t_u8 i;
for (i = 0; i < pmadapter->priv_num; i++) {
if (pmadapter->priv[i])
wlan_clean_txrx(pmadapter->priv[i]);
}
}
/**
* @brief The main process
*
@ -1281,6 +1445,12 @@ process_start:
pmadapter->pending_disconnect_priv, MTRUE);
pmadapter->pending_disconnect_priv = MNULL;
}
if (pmadapter->pending_clean) {
PRINTM(MEVENT, "Cancel all pending cmd and txrx\n");
wlan_cancel_all_pending_cmd(pmadapter, MFALSE);
wlan_free_txrx(pmadapter);
pmadapter->pending_clean = MFALSE;
}
#if defined(SDIO)
if (IS_SD(pmadapter->card_type)) {
if (pmadapter->rx_pkts_queued > HIGH_RX_PENDING) {
@ -1616,19 +1786,18 @@ static void mlan_check_llde_pkt_filter(mlan_adapter *pmadapter,
* llde packet */
if (matched_filter) {
if ((pmadapter->llde_packet_type == LLDE_FILTER_PKT_ALL) ||
((pmadapter->llde_packet_type == LLDE_FILTER_PKT_UDP) &&
((pmadapter->llde_packet_type & LLDE_FILTER_PKT_UDP) &&
(ip_protocol == MLAN_IP_PROTOCOL_UDP))) {
pmbuf->flags |= MLAN_BUF_FLAG_LLDE_PKT_FILTER;
} else if (((pmadapter->llde_packet_type ==
LLDE_FILTER_PKT_TCP_ACK) ||
(pmadapter->llde_packet_type ==
} else if ((pmadapter->llde_packet_type &
(LLDE_FILTER_PKT_TCP_ACK |
LLDE_FILTER_PKT_TCP_DATA)) &&
(ip_protocol == MLAN_IP_PROTOCOL_TCP)) {
/*TODO: identify TCP ACK and Data packets and set the
* MLAN_BUF_FLAG_LLDE_PKT_FILTER flag accordingly */
pmbuf->flags |= MLAN_BUF_FLAG_LLDE_PKT_FILTER;
} else if ((pmadapter->llde_packet_type ==
} else if ((pmadapter->llde_packet_type &
LLDE_FILTER_PKT_ICMP_PING) &&
(ip_protocol == MLAN_IP_PROTOCOL_ICMP)) {
pmbuf->flags |= MLAN_BUF_FLAG_LLDE_PKT_FILTER;
@ -1760,22 +1929,6 @@ mlan_status mlan_send_packet(t_void *padapter, pmlan_buffer pmbuf)
return ret;
}
/**
* @brief clean up txrx
*
* @param adapter A pointer to mlan_adapter structure
*
* @return N/A
*/
static t_void wlan_free_txrx(pmlan_adapter pmadapter)
{
t_u8 i;
for (i = 0; i < pmadapter->priv_num; i++) {
if (pmadapter->priv[i])
wlan_clean_txrx(pmadapter->priv[i]);
}
}
/**
* @brief MLAN ioctl handler
*
@ -1794,9 +1947,8 @@ mlan_status mlan_ioctl(t_void *adapter, pmlan_ioctl_req pioctl_req)
ENTER();
if (pioctl_req == MNULL) {
PRINTM(MMSG, "Cancel all pending cmd and txrx queue\n");
wlan_cancel_all_pending_cmd(pmadapter, MFALSE);
wlan_free_txrx(pmadapter);
PRINTM(MMSG, "set pending clean\n");
pmadapter->pending_clean = MTRUE;
goto exit;
}
pmpriv = pmadapter->priv[pioctl_req->bss_index];

View file

@ -4521,7 +4521,9 @@ mlan_status wlan_ops_sta_prepare_cmd(t_void *priv, t_u16 cmd_no,
ret = wlan_cmd_auth_assoc_timeout_cfg(pmpriv, cmd_ptr,
cmd_action, pdata_buf);
break;
case HostCmd_CMD_DS_GET_FOUNDRY_TYPE:
ret = wlan_cmd_get_foundry_type(pmpriv, cmd_ptr, cmd_action);
break;
default:
PRINTM(MERROR, "PREP_CMD: unknown command- %#x\n", cmd_no);
ret = MLAN_STATUS_FAILURE;

View file

@ -1035,6 +1035,10 @@ static mlan_status wlan_ret_tx_power_cfg(pmlan_private pmpriv,
LEAVE();
return MLAN_STATUS_FAILURE;
}
/* Suppressed due to validated TLV length and controlled buffer
* access within wlan_get_power_level, ensuring safe memory
* operations.
*/
// coverity[overrun-buffer-val:SUPPRESS]
// coverity[cert_str31_c_violation:SUPPRESS]
// coverity[cert_arr30_c_violation:SUPPRESS]
@ -3476,6 +3480,9 @@ mlan_status wlan_ops_sta_process_cmdresp(t_void *priv, t_u16 cmdresp_no,
break;
case HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG:
break;
case HostCmd_CMD_DS_GET_FOUNDRY_TYPE:
ret = wlan_ret_foundry_type(pmpriv, resp, pioctl_buf);
break;
case HostCmd_CMD_SUPPLICANT_PMK:
ret = wlan_ret_802_11_supplicant_pmk(pmpriv, resp, pioctl_buf);
break;

View file

@ -1473,6 +1473,10 @@ mlan_status wlan_ops_sta_process_event(t_void *priv)
PRINTM(MEVENT, "EVENT: EVENT_CSI on STA\n");
wlan_process_csi_event(pmpriv);
break;
case EVENT_CSI_STATUS:
PRINTM(MEVENT, "EVENT: EVENT_CSI_STATUS on STA\n");
wlan_process_csi_status(pmpriv);
break;
case EVENT_MEF_HOST_WAKEUP:
PRINTM(MEVENT, "EVENT: EVENT_MEF_HOST_WAKEUP len=%d\n",
pmbuf->data_len);

View file

@ -1444,6 +1444,8 @@ wlan_rate_ioctl_get_supported_rate(pmlan_adapter pmadapter,
mlan_private *pmpriv = pmadapter->priv[pioctl_req->bss_index];
mlan_ds_rate *rate = MNULL;
mlan_status ret = MLAN_STATUS_SUCCESS;
t_u8 temp_rates[MLAN_SUPPORTED_RATES]; // Temporary buffer to avoid
// union overlap
ENTER();
if (pioctl_req->action != MLAN_ACT_GET) {
@ -1452,16 +1454,20 @@ wlan_rate_ioctl_get_supported_rate(pmlan_adapter pmadapter,
return MLAN_STATUS_FAILURE;
}
rate = (mlan_ds_rate *)pioctl_req->pbuf;
_memset(pmadapter, temp_rates, 0x00, sizeof(temp_rates)); // Clear temp
// buffer
if (rate->param.rate_band_cfg.config_bands &&
rate->param.rate_band_cfg.bss_mode)
wlan_get_active_data_rates(
pmpriv, rate->param.rate_band_cfg.bss_mode,
rate->param.rate_band_cfg.config_bands,
rate->param.rates);
rate->param.rate_band_cfg.config_bands, temp_rates);
else
wlan_get_active_data_rates(pmpriv, pmpriv->bss_mode,
pmpriv->config_bands,
rate->param.rates);
pmpriv->config_bands, temp_rates);
// Copy the result into the union safely
memcpy_ext(pmadapter, rate->param.rates, temp_rates,
MLAN_SUPPORTED_RATES, sizeof(rate->param.rates));
pioctl_req->data_read_written =
MLAN_SUPPORTED_RATES + MLAN_SUB_COMMAND_SIZE;
LEAVE();
@ -2949,6 +2955,9 @@ static mlan_status wlan_sec_ioctl_get_key(pmlan_adapter pmadapter,
index = pmpriv->wep_key_curr_index;
sec->param.encrypt_key.key_index =
pmpriv->wep_key[index].key_index;
/* memcpy_ext enforces bounds checking and key_length is
* validated to ensure safe copying within fixed-size
* key_material buffer */
// coverity[cert_arr30_c_violation: SUPPRESS]
// coverity[cert_str31_c_violation:SUPPRESS]
memcpy_ext(pmadapter,
@ -2980,6 +2989,9 @@ static mlan_status wlan_sec_ioctl_get_key(pmlan_adapter pmadapter,
if (pmpriv->wep_key[index].key_length) {
sec->param.encrypt_key.key_index =
pmpriv->wep_key[index].key_index;
/* memcpy_ext enforces bounds checking and key_length is
* validated to ensure safe copying within fixed-size
* key_material buffer */
// coverity[cert_arr30_c_violation: SUPPRESS]
// coverity[cert_str31_c_violation:SUPPRESS]
memcpy_ext(pmadapter,
@ -5377,6 +5389,9 @@ static mlan_status wlan_misc_cfg_ioctl(pmlan_adapter pmadapter,
status =
wlan_misc_auth_assoc_timeout_cfg(pmadapter, pioctl_req);
break;
case MLAN_OID_MISC_FOUNDRY_TYPE:
status = wlan_misc_ioctl_foundry_type(pmadapter, pioctl_req);
break;
case MLAN_OID_MISC_PER_BAND_TXPWR_CAP:
status = wlan_misc_ioctl_per_band_txpwr_cap(pmadapter,
pioctl_req);
@ -5580,6 +5595,11 @@ start_config:
case MLAN_OID_SCAN_TABLE_FLUSH:
status = wlan_flush_scan_table(pmadapter);
break;
case MLAN_OID_SCAN_TABLE_FLUSH_WITH_BAND:
status = wlan_flush_scan_table_with_band(
pmadapter, pmpriv, pscan->param.band);
break;
case MLAN_OID_SCAN_BGSCAN_CONFIG:
/* Send request to firmware */
status = wlan_prepare_cmd(
@ -5595,6 +5615,8 @@ start_config:
if ((status == MLAN_STATUS_SUCCESS) &&
(pscan->sub_command != MLAN_OID_SCAN_TABLE_FLUSH) &&
(pscan->sub_command !=
MLAN_OID_SCAN_TABLE_FLUSH_WITH_BAND) &&
(pscan->sub_command != MLAN_OID_SCAN_CANCEL) &&
(pscan->sub_command != MLAN_OID_SCAN_CONFIG) &&
(pscan->sub_command != MLAN_OID_SCAN_6G_CONFIG)) {

View file

@ -5135,6 +5135,8 @@ static mlan_status wlan_uap_ret_agcs_cfg(pmlan_private pmpriv,
pagcs_cfg->nf_margin = pcmd_agcs_cfg->nf_margin;
pagcs_cfg->nav_mitigation_th = pcmd_agcs_cfg->nav_mitigation_th;
pagcs_cfg->ch_th = pcmd_agcs_cfg->ch_th;
pagcs_cfg->min_pkt_percentage =
pcmd_agcs_cfg->min_pkt_percentage;
}
LEAVE();
@ -5177,6 +5179,7 @@ static mlan_status wlan_cmd_apcmd_agcs_cfg(pmlan_private pmpriv,
pcmd_agcs_cfg->nf_margin = pagcs_cfg->nf_margin;
pcmd_agcs_cfg->nav_mitigation_th = pagcs_cfg->nav_mitigation_th;
pcmd_agcs_cfg->ch_th = pagcs_cfg->ch_th;
pcmd_agcs_cfg->min_pkt_percentage = pagcs_cfg->min_pkt_percentage;
LEAVE();
return MLAN_STATUS_SUCCESS;
@ -5247,6 +5250,8 @@ static mlan_status wlan_process_agcs_event(pmlan_private priv,
(t_s16)wlan_le16_to_cpu(stats->nf_threshold);
pacs_start_event->stats.all_sta_ecs = MTRUE;
pacs_start_event->stats.all_sta_6g = MTRUE;
pacs_start_event->stats.scan_idx = 0;
pacs_start_event->stats.is_5g_scaned = MFALSE;
switch (priv->uap_bandwidth) {
case CHAN_BW_20MHZ:
bandwidth = BW_20MHZ;
@ -5789,6 +5794,9 @@ mlan_status wlan_ops_uap_prepare_cmd(t_void *priv, t_u16 cmd_no,
case HostCmd_CMD_DS_GET_SENSOR_TEMP:
wlan_cmd_get_sensor_temp(pmpriv, cmd_ptr, cmd_action);
break;
case HostCmd_CMD_DS_GET_FOUNDRY_TYPE:
ret = wlan_cmd_get_foundry_type(pmpriv, cmd_ptr, cmd_action);
break;
#ifdef STA_SUPPORT
case HostCmd_CMD_802_11_SCAN_EXT:
ret = wlan_cmd_802_11_scan_ext(pmpriv, cmd_ptr, pdata_buf);
@ -6268,6 +6276,9 @@ mlan_status wlan_ops_uap_process_cmdresp(t_void *priv, t_u16 cmdresp_no,
case HostCmd_CMD_DS_GET_SENSOR_TEMP:
ret = wlan_ret_get_sensor_temp(pmpriv, resp, pioctl_buf);
break;
case HostCmd_CMD_DS_GET_FOUNDRY_TYPE:
ret = wlan_ret_foundry_type(pmpriv, resp, pioctl_buf);
break;
#ifdef STA_SUPPORT
case HostCmd_CMD_802_11_SCAN_EXT:
ret = wlan_ret_802_11_scan_ext(pmpriv, resp, pioctl_buf);

View file

@ -2355,6 +2355,9 @@ mlan_status wlan_ops_uap_ioctl(t_void *adapter, pmlan_ioctl_req pioctl_req)
else if (misc->sub_command == MLAN_OID_MISC_CH_LOAD_RESULTS)
status = wlan_misc_ioctl_ch_load_results(pmadapter,
pioctl_req);
else if (misc->sub_command == MLAN_OID_MISC_FOUNDRY_TYPE)
status = wlan_misc_ioctl_foundry_type(pmadapter,
pioctl_req);
else if (misc->sub_command == MLAN_OID_MISC_GET_TSF)
status = wlan_misc_ioctl_get_tsf(pmadapter, pioctl_req);
else if (misc->sub_command == MLAN_OID_MISC_CROSS_CHIP_SYNCH)

View file

@ -535,7 +535,13 @@ static INLINE t_void util_scalar_decrement(
* @return Value after offset or 0 if (scalar_value + offset)
* overflows
*/
#ifdef ANDROID_SDK_VERSION
#define INT_MAX 2147483647
#else
#ifndef CONFIG_KASAN
#define INT_MAX 2147483647
#endif
#endif
static INLINE t_s32 util_scalar_offset(
t_void *pmoal_handle, pmlan_scalar pscalar, t_s32 offset,
mlan_status (*moal_spin_lock)(t_void *handle, t_void *plock),

View file

@ -1003,6 +1003,8 @@ static t_bool wlan_wmm_txq_count_donw(mlan_wmm_contention *txq_cont,
if (txq_cont->remaining_aifs == 0)
txq_cont->remaining_backoff -= duration;
/* Input values are bounded and subtraction logic ensures no integer
* overflow during contention timer update. */
// coverity[integer_overflow:SUPPRESS]
return txq_cont->remaining_backoff == 0 &&
txq_cont->remaining_aifs == 0;
@ -1286,6 +1288,8 @@ static t_s32 wlan_wmm_refill_budget(t_s32 current_value, t_u32 init_value)
if (current_value > 0)
return init_value;
/* Input values are constrained and addition logic ensures no overflow
*/
// coverity[integer_overflow:SUPPRESS]
return current_value + init_value;
}
@ -3819,6 +3823,7 @@ static INLINE t_u8 wlan_del_tx_pkts_in_ralist(pmlan_private priv,
return ret;
}
#ifdef UAP_SUPPORT
/**
* @brief Drop tx pkts
*
@ -3848,6 +3853,7 @@ t_void wlan_drop_tx_pkts(pmlan_private priv)
priv->wmm.ra_list_spinlock);
return;
}
#endif
/**
* @brief Remove peer ralist
@ -5042,6 +5048,7 @@ void wlan_dump_ralist(mlan_private *priv)
* @return tid_down
*
*/
// coverity[HIS_COMF:SUPPRESS]
int wlan_get_wmm_tid_down(mlan_private *priv, int tid)
{
return wlan_wmm_downgrade_tid(priv, tid);

View file

@ -664,6 +664,10 @@ typedef enum {
#define MLAN_BUF_FLAG_LLDE_PKT_FILTER MBIT(19)
#ifdef XDP_SUPPORT
#define MLAN_BUF_FLAG_XDP MBIT(20)
#endif
#ifdef DEBUG_LEVEL1
/** Debug level bit definition */
#define MMSG MBIT(0)
@ -911,6 +915,7 @@ typedef enum _mlan_event_id {
/* Agiled channel switch triggered */
MLAN_EVENT_ID_FW_AGCS_TRIGGER = 0x00000044,
#endif /* UAP_SUPPORT */
MLAN_EVENT_ID_CSI_STATUS = 0x00000045,
/* Event generated by MLAN driver (MSB=1) */
MLAN_EVENT_ID_DRV_CONNECTED = 0x80000001,
MLAN_EVENT_ID_DRV_DEFER_HANDLING = 0x80000002,
@ -1299,6 +1304,25 @@ typedef MLAN_PACK_START struct _csi_record_ds {
/** At the end of CSI raw data, user defined TailID of 4 bytes*/
} MLAN_PACK_END csi_record_ds, *pcsi_record_ds;
/** Definition of csi status */
#define CSI_STATUS_ENABLED 0
#define CSI_STATUS_DISABLED 1
#define CSI_STATUS_CONFIG_WRONG 2
#define CSI_STATUS_INTERNAL_RESET 3
#define CSI_STATUS_INTERNAL_STOP 4
#define CSI_STATUS_INTERNAL_DISABLED 5
/** Csi status event data structure */
typedef struct _csi_status_info {
/** Csi status report by fw */
t_u8 status;
/** Channel */
t_u8 channel;
/** Number of csi filters, only valid in CSI_STATUS_ENABLED, 0 in other
* status */
t_u16 cnt;
} MLAN_PACK_END csi_status_info;
/** mlan_ioctl_req data structure */
typedef struct _mlan_ioctl_req {
/** Pointer to previous mlan_ioctl_req */
@ -2613,6 +2637,12 @@ typedef struct _sta_stats {
#pragma pack(pop)
#endif
typedef enum {
MOAL_DMA_SYNC_BIDIR = 0,
MOAL_DMA_SYNC_TO_DEVICE = 1,
MOAL_DMA_SYNC_FROM_DEVICE = 2,
} moal_dma_sync_direction_t;
/** mlan_callbacks data structure */
typedef struct _mlan_callbacks {
/** moal_get_fw_data */
@ -2687,6 +2717,20 @@ typedef struct _mlan_callbacks {
/** moal_mfree_consistent */
mlan_status (*moal_mfree_consistent)(t_void *pmoal, t_u32 size,
t_u8 *pbuf, t_u64 buf_pa);
/** moal_malloc_cached */
mlan_status (*moal_malloc_cached)(t_void *pmoal, t_u32 size,
t_u8 **ppbuf, t_u64 *pbuf_pa);
/** moal_mfree_cached */
mlan_status (*moal_mfree_cached)(t_void *pmoal, t_u32 size, t_u8 *pbuf,
t_u64 buf_pa);
/** moal_dma_sync_to_cpu */
mlan_status (*moal_dma_sync_to_cpu)(t_void *pmoal, t_u32 size,
t_u64 buf_pa,
moal_dma_sync_direction_t direction);
/** moal_dma_sync_to_device */
mlan_status (*moal_dma_sync_to_device)(
t_void *pmoal, t_u32 size, t_u64 buf_pa,
moal_dma_sync_direction_t direction);
/** moal_map_memory */
mlan_status (*moal_map_memory)(t_void *pmoal, t_u8 *pbuf,
t_u64 *pbuf_pa, t_u32 size, t_u32 flag);
@ -2770,6 +2814,9 @@ typedef struct _mlan_callbacks {
void (*moal_write_u16)(void *dest, t_u16 val);
void (*moal_write_u32)(void *dest, t_u32 val);
} moal_unaligned_access;
t_u32 (*moal_crc32_be)(t_u32 initial_crc, t_u8 const *data,
unsigned long len);
} mlan_callbacks, *pmlan_callbacks;
/** Parameter unchanged, use MLAN default setting */
@ -2936,6 +2983,8 @@ typedef struct _mlan_device {
t_u8 second_mac;
/** napi */
t_u8 napi;
t_u8 copy_on_rx;
t_u8 copy_on_tx;
/** antcfg */
t_u32 antcfg;
/** dmcs */
@ -3111,6 +3160,7 @@ MLAN_API void mlan_process_pcie_interrupt_cb(t_void *pmadapter, int type);
#endif
#endif
#ifdef ANDROID_SDK_VERSION
#ifndef UINT_MAX
#ifdef MLAN_64BIT
#define UINT_MAX UINT64_MAX
@ -3118,6 +3168,17 @@ MLAN_API void mlan_process_pcie_interrupt_cb(t_void *pmadapter, int type);
#define UINT_MAX UINT32_MAX
#endif
#endif
#else
#ifndef CONFIG_KASAN
#ifndef UINT_MAX
#ifdef MLAN_64BIT
#define UINT_MAX UINT64_MAX
#else
#define UINT_MAX UINT32_MAX
#endif
#endif
#endif
#endif
typedef enum {
TYPE_SINT8,

View file

@ -40,6 +40,8 @@ enum _mlan_ioctl_req_id {
MLAN_OID_SCAN_CANCEL = 0x00010006,
MLAN_OID_SCAN_TABLE_FLUSH = 0x0001000A,
MLAN_OID_SCAN_BGSCAN_CONFIG = 0x0001000B,
MLAN_OID_SCAN_TABLE_FLUSH_WITH_BAND = 0x0001000C,
/* BSS Configuration Group */
MLAN_IOCTL_BSS = 0x00020000,
MLAN_OID_BSS_START = 0x00020001,
@ -395,6 +397,7 @@ enum _mlan_ioctl_req_id {
MLAN_OID_MISC_AUTH_ASSOC_TIMEOUT_CONFIG = 0x00200099,
MLAN_OID_MISC_PREV_ASSOC_INFO = 0x0020009A,
MLAN_OID_MISC_FOUNDRY_TYPE = 0X0020009B,
MLAN_OID_MISC_NAV_MITIGATION_HW = 0x0020009C,
MLAN_OID_MISC_PREAMBLE_PWR_BOOST = 0x0020009D,
@ -670,6 +673,8 @@ typedef struct _mlan_ds_scan {
mlan_scan_cfg scan_cfg;
/** 6E Scan config parameters */
mlan_scan_6g_cfg scan_6g_cfg;
/** Select the band to flush from scan table */
t_u32 band;
} param;
} mlan_ds_scan, *pmlan_ds_scan;
@ -6526,6 +6531,11 @@ typedef struct _mlan_ds_cross_chip_synch {
t_u32 init_tsf_high;
} mlan_ds_cross_chip_synch;
typedef struct _mlan_ds_foundry_type {
/**get foundry type UMC or TSMC*/
t_u8 foundry_type;
} mlan_ds_foundry_type;
#define MAX_RFUS 2
#define MAX_PATHS 2
typedef struct _mlan_ds_tsp_cfg {
@ -6588,6 +6598,10 @@ typedef struct _mlan_ds_misc_per_band_txpwr_cap {
t_u8 power;
/** band */
t_u8 band;
/** stronger rssi threshold */
t_s8 strong_rssi_thresh;
/** weaker rssi threshold */
t_s8 weak_rssi_thresh;
} mlan_ds_misc_per_band_txpwr_cap;
/** valid range for mlan_ds_auth_assoc_timeout_cfg */
@ -6648,6 +6662,9 @@ typedef struct _mlan_ds_agcs_cfg {
t_u16 nav_mitigation_th;
/* ch threshold to trigger channel switch for nighthawk */
t_u16 ch_th;
/* Channel switching is triggered only when the current pkts > the min
* average packet percentage. */
t_u16 min_pkt_percentage;
} mlan_ds_agcs_cfg;
#endif /* UAP_SUPPORT */
@ -6833,6 +6850,7 @@ typedef struct _mlan_ds_misc_cfg {
mlan_ds_ed_mac_cfg edmac_cfg;
mlan_ds_gpio_cfg_ops gpio_cfg_ops;
mlan_ds_auth_assoc_timeout_cfg auth_assoc_cfg;
mlan_ds_foundry_type soc_foundry_type;
mlan_ds_misc_per_band_txpwr_cap per_band_txpwr_cap;
#ifdef UAP_SUPPORT
/** config AGCS for MLAN_OID_MISC_AGCS_CONFIG */
@ -6895,6 +6913,11 @@ typedef struct _agcs_stats {
t_s16 noise;
/** The noise floor threshold currently used by fw */
t_s16 nf_threshold;
/** Record the scan channel list index according to 6G/5G/2G */
t_u8 scan_idx;
/** When the current band is 5g, has the same/diff class of 5g been
* scanned? */
t_u8 is_5g_scaned;
} agcs_stats, *pagcs_stats;
/** Type definition of agcs_event for WOAL_EVENT_AGCS */

View file

@ -1689,10 +1689,10 @@ done:
* @return 0 -- success, otherwise fail
*/
int woal_cfg80211_set_wiphy_params(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
int radio_idx,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
u32 changed)
u32 changed)
{
moal_private *priv = NULL;
moal_handle *handle = (moal_handle *)woal_get_wiphy_priv(wiphy);
@ -2673,17 +2673,17 @@ done:
* @brief Request the driver to get antenna configuration
*
* @param wiphy A pointer to wiphy structure
* @param radio_idx Radio index
* @param radio_idx Radio index
* @param tx_ant Bitmaps of allowed antennas to use for TX
* @param rx_ant Bitmaps of allowed antennas to use for RX
*
* @return 0 -- success, otherwise fail
*/
int woal_cfg80211_get_antenna(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
int radio_idx,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
u32 *tx_ant, u32 *rx_ant)
u32 *tx_ant, u32 *rx_ant)
{
moal_handle *handle = (moal_handle *)woal_get_wiphy_priv(wiphy);
moal_private *priv = NULL;
@ -2744,17 +2744,17 @@ done:
* @brief Request the driver to set antenna configuration
*
* @param wiphy A pointer to wiphy structure
* @param radio_idx Radio index
* @param radio_idx Radio index
* @param tx_ant Bitmaps of allowed antennas to use for TX
* @param rx_ant Bitmaps of allowed antennas to use for RX
*
* @return 0 -- success, otherwise fail
*/
int woal_cfg80211_set_antenna(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
int radio_idx,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
u32 tx_ant, u32 rx_ant)
u32 tx_ant, u32 rx_ant)
{
moal_handle *handle = (moal_handle *)woal_get_wiphy_priv(wiphy);
moal_private *priv = NULL;
@ -3509,13 +3509,26 @@ int woal_cfg80211_mgmt_tx(struct wiphy *wiphy,
}
}
}
/* This section is for IWD's WPA2-FT roaming support */
if (ieee80211_is_auth(
((const struct ieee80211_mgmt *)buf)->frame_control) &&
(priv->bss_type == MLAN_BSS_TYPE_STA) &&
(woal_cpu_to_le16(
((const struct ieee80211_mgmt *)buf)->u.auth.auth_alg) ==
WLAN_AUTH_FT)) {
woal_mgmt_frame_register(priv, IEEE80211_STYPE_AUTH, MTRUE);
woal_cancel_scan(priv, MOAL_IOCTL_WAIT);
priv->auth_flag = HOST_MLME_AUTH_PENDING;
priv->auth_mgmt_tx = 1;
priv->auth_alg = woal_cpu_to_le16(
((const struct ieee80211_mgmt *)buf)->u.auth.auth_alg);
priv->host_mlme = MTRUE;
}
#if KERNEL_VERSION(2, 6, 39) <= CFG80211_VERSION_CODE
if ((ieee80211_is_action(
((const struct ieee80211_mgmt *)buf)->frame_control))
else if ((ieee80211_is_action(
((const struct ieee80211_mgmt *)buf)->frame_control))
#if KERNEL_VERSION(3, 8, 0) <= CFG80211_VERSION_CODE
|| (moal_extflg_isset(priv->phandle, EXT_HOST_MLME) &&
(priv->bss_type != MLAN_BSS_TYPE_STA))
|| moal_extflg_isset(priv->phandle, EXT_HOST_MLME)
#endif
) {
#ifdef WIFI_DIRECT_SUPPORT
@ -3626,18 +3639,6 @@ int woal_cfg80211_mgmt_tx(struct wiphy *wiphy,
}
#endif
if (ieee80211_is_auth(
((const struct ieee80211_mgmt *)buf)->frame_control) &&
(priv->bss_type == MLAN_BSS_TYPE_STA)) {
woal_mgmt_frame_register(priv, IEEE80211_STYPE_AUTH, MTRUE);
woal_cancel_scan(priv, MOAL_IOCTL_WAIT);
priv->auth_flag = HOST_MLME_AUTH_PENDING;
priv->auth_mgmt_tx = 1;
priv->auth_alg = woal_cpu_to_le16(
((const struct ieee80211_mgmt *)buf)->u.auth.auth_alg);
priv->host_mlme = MTRUE;
}
#if KERNEL_VERSION(3, 8, 0) > LINUX_VERSION_CODE
*cookie = random32() | 1;
#else
@ -4223,7 +4224,7 @@ static t_u8 *woal_remove_11ax_ies(moal_private *priv, const t_u8 *ie, t_u8 len,
length + sizeof(IEEEtypes_Header_t);
break;
}
// fall through
fallthrough;
default:
if ((*new_ie_len + length + 2) < (int)ie_out_len) {
moal_memcpy_ext(priv->phandle,
@ -4511,7 +4512,7 @@ static t_u16 woal_filter_beacon_ies(moal_private *priv, const t_u8 *ie,
if (priv->chan.chan->band != NL80211_BAND_6GHZ)
break;
#endif
/* FALLTHRU */
fallthrough;
default:
if ((out_len + length + 2) < (int)ie_out_len) {
moal_memcpy_ext(priv->phandle, ie_out + out_len,
@ -4897,6 +4898,9 @@ int woal_cfg80211_mgmt_frame_ie(
beacon_ies_data->mgmt_subtype_mask =
MGMT_MASK_BEACON | MGMT_MASK_ASSOC_RESP |
MGMT_MASK_PROBE_RESP;
/* woal_filter_beacon_ies() enforces bounds internally
* and output is limited by MAX_IE_SIZE, preventing
* overflow */
// coverity[integer_overflow:SUPPRESS]
beacon_ies_data->ie_length = woal_filter_beacon_ies(
priv, beacon_ies, beacon_ies_len,
@ -4905,6 +4909,7 @@ int woal_cfg80211_mgmt_frame_ie(
IE_MASK_VENDOR,
proberesp_ies, proberesp_ies_len);
if (beacon_ies_data->ie_length)
/* ie_length is already checked as non-zero */
// coverity[integer_overflow:SUPPRESS]
DBG_HEXDUMP(MCMD_D, "beacon ie",
beacon_ies_data->ie_buffer,

View file

@ -103,8 +103,10 @@ t_u8 is_cfg80211_special_region_code(t_u8 *region_string);
*/
static const void *const mrvl_wiphy_privid = &mrvl_wiphy_privid;
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
/* Get the private structure from wiphy */
void *woal_get_wiphy_priv(struct wiphy *wiphy);
#endif
/* Get the private structure from net device */
void *woal_get_netdev_priv(struct net_device *dev);
@ -135,6 +137,7 @@ t_u8 woal_band_cfg_to_ieee_band(t_u32 band);
t_u8 woal_ieee_band_to_radio_type(t_u8 ieee_band);
t_u8 woal_radio_type_to_ieee_band(t_u8 radio_type);
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
int woal_cfg80211_change_virtual_intf(struct wiphy *wiphy,
struct net_device *dev,
enum nl80211_iftype type,
@ -144,10 +147,10 @@ int woal_cfg80211_change_virtual_intf(struct wiphy *wiphy,
struct vif_params *params);
int woal_cfg80211_set_wiphy_params(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
int radio_idx,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
u32 changed);
u32 changed);
int woal_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
#if ((KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE) || \
@ -194,21 +197,22 @@ int woal_cfg80211_set_bitrate_mask(struct wiphy *wiphy, struct net_device *dev,
const struct cfg80211_bitrate_mask *mask);
#if KERNEL_VERSION(2, 6, 38) <= CFG80211_VERSION_CODE
int woal_cfg80211_set_antenna(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
int radio_idx,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
u32 tx_ant, u32 rx_ant);
u32 tx_ant, u32 rx_ant);
int woal_cfg80211_get_antenna(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
int radio_idx,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
u32 *tx_ant, u32 *rx_ant);
u32 *tx_ant, u32 *rx_ant);
#endif
#if KERNEL_VERSION(3, 14, 0) <= CFG80211_VERSION_CODE
int woal_cfg80211_set_qos_map(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_qos_map *qos_map);
#endif
#endif
#ifdef STA_CFG80211
#ifdef STA_SUPPORT
@ -244,6 +248,7 @@ int woal_cfg80211_set_channel(struct wiphy *wiphy,
enum nl80211_channel_type channel_type);
#endif
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#if KERNEL_VERSION(2, 6, 37) < CFG80211_VERSION_CODE
int woal_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *dev,
#if ((KERNEL_VERSION(6, 1, 0) <= LINUX_VERSION_CODE) || \
@ -280,7 +285,10 @@ int woal_cfg80211_set_default_beacon_key(struct wiphy *wiphy,
int woal_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_gtk_rekey_data *data);
#endif
#endif
void woal_mgmt_frame_register(moal_private *priv, u16 frame_type, bool reg);
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
void woal_cfg80211_mgmt_frame_register(struct wiphy *wiphy,
#if KERNEL_VERSION(3, 6, 0) <= CFG80211_VERSION_CODE
struct wireless_dev *wdev,
@ -317,6 +325,7 @@ int woal_cfg80211_mgmt_tx(struct wiphy *wiphy,
#endif
#endif
u64 *cookie);
#endif
mlan_status woal_register_cfg80211(moal_private *priv);
@ -334,6 +343,7 @@ int woal_cfg80211_bss_role_cfg(moal_private *priv, t_u16 action,
void woal_cancel_cac(moal_private *priv);
#endif
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#if KERNEL_VERSION(4, 1, 0) <= CFG80211_VERSION_CODE
struct wireless_dev *
woal_cfg80211_add_virtual_intf(struct wiphy *wiphy, const char *name,
@ -379,6 +389,7 @@ int woal_cfg80211_del_virtual_intf(struct wiphy *wiphy,
#else
int woal_cfg80211_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev);
#endif
#endif
void woal_remove_virtual_interface(moal_handle *handle);
@ -427,11 +438,13 @@ int woal_cfg80211_deinit_p2p(moal_private *priv);
/** Define for remain on channel duration timer */
#define MAX_REMAIN_ON_CHANNEL_DURATION (5000)
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
int woal_cfg80211_remain_on_channel_cfg(moal_private *priv, t_u8 wait_option,
t_u8 remove, t_u8 *status,
struct ieee80211_channel *chan,
enum mlan_channel_type channel_type,
t_u32 duration);
#endif
#ifdef UAP_CFG80211
int woal_uap_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
@ -553,11 +566,13 @@ void woal_cfg80211_notify_antcfg(moal_private *priv, struct wiphy *wiphy,
void woal_deauth_event(moal_private *priv, int reason_code, u8 *bssid);
#endif
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#if KERNEL_VERSION(3, 8, 0) <= CFG80211_VERSION_CODE
mlan_status woal_chandef_create(moal_private *priv,
struct cfg80211_chan_def *chandef,
chan_band_info *pchan_info);
#endif
#endif
#if KERNEL_VERSION(4, 20, 0) <= CFG80211_VERSION_CODE
void woal_cfg80211_setup_he_cap(moal_private *priv,
@ -573,7 +588,10 @@ mlan_status woal_request_6e_inband_frame(
struct cfg80211_unsol_bcast_probe_resp *unsol_bcast_probe_resp);
#endif
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
void woal_cfg80211_free_bands(struct wiphy *wiphy);
#endif
struct ieee80211_supported_band *woal_setup_wiphy_bands(t_u8 ieee_band);
void woal_clear_all_mgmt_ies(moal_private *priv, t_u8 wait_option);
@ -587,6 +605,7 @@ int woal_cfg80211_mgmt_frame_ie(
int woal_get_active_intf_freq(moal_private *priv);
int woal_get_rx_freq(moal_private *priv, t_u8 band_config, t_u8 chan_num);
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
void woal_cfg80211_setup_ht_cap(struct ieee80211_sta_ht_cap *ht_info,
t_u32 dev_cap, t_u8 *mcs_set,
t_u8 mpdu_density);
@ -594,13 +613,16 @@ void woal_cfg80211_setup_ht_cap(struct ieee80211_sta_ht_cap *ht_info,
void woal_cfg80211_setup_vht_cap(moal_private *priv,
struct ieee80211_sta_vht_cap *vht_cap);
#endif
#endif
int woal_cfg80211_assoc(moal_private *priv, void *sme, t_u8 wait_option,
pmlan_ds_misc_assoc_rsp assoc_rsp);
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
void woal_clear_wiphy_dfs_state(struct wiphy *wiphy);
void woal_update_channel_dfs_state(t_u8 channel, t_u8 dfs_state);
int woal_get_wiphy_chan_dfs_state(struct wiphy *wiphy,
mlan_ds_11h_chan_dfs_state *ch_dfs_state);
#endif
mlan_status woal_reset_wifi(moal_handle *handle, t_u8 cnt, char *reason);

View file

@ -196,14 +196,6 @@ static const struct nla_policy
};
// clang-format off
static const struct nla_policy
woal_fw_roaming_policy[MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_MAX + 1] = {
[MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONTROL] = {.type = NLA_U32},
[MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONFIG_BSSID] = {
.type = NLA_BINARY},
[MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONFIG_SSID] = {
.type = NLA_BINARY},
};
// clang-format on
static const struct nla_policy
@ -928,9 +920,6 @@ static int woal_cfg80211_subcmd_get_supp_feature_set(struct wiphy *wiphy,
supp_feature_set |= WLAN_FEATURE_INFRA_5G;
if (fw_info.rtt_support)
supp_feature_set |= WLAN_FEATURE_D2AP_RTT;
if (fw_info.fw_roaming_support)
supp_feature_set |= WLAN_FEATURE_CONTROL_ROAMING;
priv->phandle->wifi_hal_flag = MTRUE;
reply_len = sizeof(supp_feature_set);
@ -2024,6 +2013,9 @@ int woal_ring_event_logger(moal_private *priv, int ring_id, pmlan_event pmevent)
MIN(UINT16_MAX,
msg_hdr.entry_size +
sizeof(connectivity_event->event));
/* msg_hdr.entry_size is carefully bounded using MIN
* function and all data fits within the statically
* sized event_buf, ensuring safe access */
// coverity[overrun-buffer-arg:SUPPRESS]
// coverity[cert_arr30_c_violation:SUPPRESS]
// coverity[cert_str31_c_violation:SUPPRESS]
@ -2408,6 +2400,8 @@ static int woal_deinit_packet_filter(moal_private *priv)
spin_unlock_irqrestore(&pkt_filter->lock, flags);
vfree(pkt_filter);
/* packet_filter is cleared after deinitialization and free, with no
* expected concurrent access, making locking unnecessary */
// coverity[LOCK_EVASION:SUPPRESS]
priv->packet_filter = NULL;
@ -2877,6 +2871,7 @@ int woal_filter_packet(moal_private *priv, t_u8 *data, t_u32 len,
if (pkt_filter->state != PACKET_FILTER_STATE_START)
goto done;
/* pkt_filter is already validated in call of unlikely macro */
// coverity[misra_c_2012_directive_4_14_violation:SUPPRESS]
// coverity[tainted_data:SUPPRESS]
DBG_HEXDUMP(MDAT_D, "packet_filter_program",
@ -2884,6 +2879,7 @@ int woal_filter_packet(moal_private *priv, t_u8 *data, t_u32 len,
pkt_filter->packet_filter_len);
DBG_HEXDUMP(MDAT_D, "packet_filter_data", data, len);
spin_lock_irqsave(&pkt_filter->lock, flags);
/* pkt_filter is already validated in call of unlikely macro */
// coverity[misra_c_2012_directive_4_14_violation:SUPPRESS]
// coverity[tainted_data:SUPPRESS]
ret = process_packet(pkt_filter->packet_filter_program,
@ -4313,261 +4309,6 @@ int woal_roam_ap_info(moal_private *priv, t_u8 *data, int len)
return ret;
}
/**
* @brief vendor command to get fw roaming capability
*
* @param wiphy A pointer to wiphy struct
* @param wdev A pointer to wireless_dev struct
* @param data a pointer to data
* @param len data length
*
* @return 0: success fail otherwise
*/
static int
woal_cfg80211_subcmd_get_roaming_capability(struct wiphy *wiphy,
struct wireless_dev *wdev,
const void *data, int len)
{
int ret = MLAN_STATUS_SUCCESS;
wifi_roaming_capabilities capa;
struct sk_buff *skb = NULL;
int err = 0;
ENTER();
if (!wdev || !wdev->netdev) {
LEAVE();
return -EFAULT;
}
capa.max_blacklist_size = MAX_AP_LIST;
capa.max_whitelist_size = MAX_SSID_NUM;
/* Alloc the SKB for vendor_event */
skb = cfg80211_vendor_cmd_alloc_reply_skb(
wiphy, sizeof(wifi_roaming_capabilities) + 50);
if (unlikely(!skb)) {
PRINTM(MERROR, "skb alloc failed\n");
goto done;
}
/* Push the data to the skb */
nla_put(skb, MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CAPA,
sizeof(wifi_roaming_capabilities), (t_u8 *)&capa);
err = cfg80211_vendor_cmd_reply(skb);
if (unlikely(err))
PRINTM(MERROR, "Vendor Command reply failed ret:%d\n", err);
done:
LEAVE();
return ret;
}
/**
* @brief vendor command to enable/disable fw roaming
*
* @param wiphy A pointer to wiphy struct
* @param wdev A pointer to wireless_dev struct
* @param data a pointer to data
* @param len data length
*
* @return 0: success fail otherwise
*/
static int woal_cfg80211_subcmd_fw_roaming_enable(struct wiphy *wiphy,
struct wireless_dev *wdev,
const void *data, int len)
{
moal_private *priv;
struct net_device *dev;
int ret = MLAN_STATUS_SUCCESS;
struct sk_buff *skb = NULL;
const struct nlattr *iter;
int type, rem, err;
t_u32 fw_roaming_enable = 0;
#ifdef STA_CFG80211
#if KERNEL_VERSION(3, 14, 0) <= CFG80211_VERSION_CODE
t_u8 enable = 0;
#endif
#endif
ENTER();
if (!wdev || !wdev->netdev) {
LEAVE();
return -EFAULT;
}
dev = wdev->netdev;
priv = (moal_private *)woal_get_netdev_priv(dev);
if (!priv || !priv->phandle) {
LEAVE();
return -EFAULT;
}
nla_for_each_attr (iter, data, len, rem) {
type = nla_type(iter);
switch (type) {
case MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONTROL:
fw_roaming_enable = nla_get_u32(iter);
break;
default:
PRINTM(MERROR, "Unknown type: %d\n", type);
ret = -EINVAL;
goto done;
}
}
PRINTM(MMSG, "FW roaming set enable=%d from wifi hal.\n",
fw_roaming_enable);
ret = woal_enable_fw_roaming(priv, fw_roaming_enable);
/* Alloc the SKB for vendor_event */
skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, sizeof(t_u32) + 50);
if (unlikely(!skb)) {
PRINTM(MERROR, "skb alloc failed\n");
goto done;
}
nla_put(skb, MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONTROL, sizeof(t_u32),
&fw_roaming_enable);
err = cfg80211_vendor_cmd_reply(skb);
if (unlikely(err))
PRINTM(MERROR, "Vendor Command reply failed ret:%d\n", err);
#ifdef STA_CFG80211
#if KERNEL_VERSION(3, 14, 0) <= CFG80211_VERSION_CODE
if (!fw_roaming_enable)
woal_cfg80211_vendor_event(priv, event_set_key_mgmt_offload,
&enable, sizeof(enable));
#endif
#endif
done:
LEAVE();
return ret;
}
/**
* @brief vendor command to config blacklist and whitelist for fw roaming
*
* @param wiphy A pointer to wiphy struct
* @param wdev A pointer to wireless_dev struct
* @param data a pointer to data
* @param len data length
*
* @return 0: success fail otherwise
*/
static int woal_cfg80211_subcmd_fw_roaming_config(struct wiphy *wiphy,
struct wireless_dev *wdev,
const void *data, int len)
{
moal_private *priv;
struct net_device *dev;
int ret = MLAN_STATUS_SUCCESS;
const struct nlattr *iter;
int type, rem;
woal_roam_offload_cfg *roam_offload_cfg = NULL;
wifi_bssid_params blacklist;
wifi_ssid_params whitelist;
ENTER();
if (!wdev || !wdev->netdev) {
LEAVE();
return -EFAULT;
}
dev = wdev->netdev;
priv = (moal_private *)woal_get_netdev_priv(dev);
if (!priv || !priv->phandle) {
LEAVE();
return -EFAULT;
}
memset((char *)&blacklist, 0, sizeof(wifi_bssid_params));
memset((char *)&whitelist, 0, sizeof(wifi_ssid_params));
nla_for_each_attr (iter, data, len, rem) {
type = nla_type(iter);
switch (type) {
case MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONFIG_BSSID:
moal_memcpy_ext(priv->phandle, (t_u8 *)&blacklist,
nla_data(iter), nla_len(iter),
sizeof(wifi_bssid_params));
break;
case MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONFIG_SSID:
moal_memcpy_ext(priv->phandle, (t_u8 *)&whitelist,
nla_data(iter), nla_len(iter),
sizeof(wifi_ssid_params));
break;
default:
PRINTM(MERROR, "Unknown type: %d\n", type);
ret = -EINVAL;
goto done;
}
}
if (moal_extflg_isset(priv->phandle, EXT_ROAMOFFLOAD_IN_HS)) {
/*save blacklist and whitelist in driver*/
priv->phandle->fw_roam_params.black_list.ap_num =
blacklist.num_bssid;
moal_memcpy_ext(
priv->phandle,
(t_u8 *)priv->phandle->fw_roam_params.black_list.ap_mac,
(t_u8 *)blacklist.mac_addr,
sizeof(wifi_bssid_params) - sizeof(blacklist.num_bssid),
sizeof(mlan_ds_misc_roam_offload_aplist) -
sizeof(priv->phandle->fw_roam_params.black_list
.ap_num));
priv->phandle->fw_roam_params.ssid_list.ssid_num =
whitelist.num_ssid;
moal_memcpy_ext(
priv->phandle,
(t_u8 *)priv->phandle->fw_roam_params.ssid_list.ssids,
(t_u8 *)whitelist.whitelist_ssid,
sizeof(wifi_ssid_params) - sizeof(whitelist.num_ssid),
MAX_SSID_NUM * sizeof(mlan_802_11_ssid));
} else {
roam_offload_cfg = (woal_roam_offload_cfg *)kmalloc(
sizeof(woal_roam_offload_cfg), GFP_KERNEL);
if (!roam_offload_cfg) {
PRINTM(MERROR, "kmalloc failed!\n");
ret = -ENOMEM;
goto done;
}
/*download parameters directly to fw*/
memset((char *)roam_offload_cfg, 0,
sizeof(woal_roam_offload_cfg));
roam_offload_cfg->black_list.ap_num = blacklist.num_bssid;
moal_memcpy_ext(priv->phandle,
(t_u8 *)&roam_offload_cfg->black_list.ap_mac,
(t_u8 *)blacklist.mac_addr,
sizeof(wifi_bssid_params) -
sizeof(blacklist.num_bssid),
sizeof(mlan_ds_misc_roam_offload_aplist) -
sizeof(priv->phandle->fw_roam_params
.black_list.ap_num));
roam_offload_cfg->ssid_list.ssid_num = whitelist.num_ssid;
moal_memcpy_ext(priv->phandle,
(t_u8 *)&roam_offload_cfg->ssid_list.ssids,
(t_u8 *)whitelist.whitelist_ssid,
sizeof(wifi_ssid_params) -
sizeof(whitelist.num_ssid),
MAX_SSID_NUM * sizeof(mlan_802_11_ssid));
if (woal_config_fw_roaming(priv, ROAM_OFFLOAD_PARAM_CFG,
roam_offload_cfg)) {
PRINTM(MERROR, "%s: config fw roaming failed \n",
__func__);
ret = -EFAULT;
}
}
done:
if (roam_offload_cfg)
kfree(roam_offload_cfg);
LEAVE();
return ret;
}
/**
* @brief vendor command to enable/disable 11k
*
@ -7129,9 +6870,14 @@ static t_u16 extractNumericVal(char *str, t_u32 str_len, char *substr,
if (findStr == NULL)
return finalVal;
/* Function usage is controlled and input validation ensures safe
* operation */
// coverity[misra_c_2012_rule_21_13_violation:SUPPRESS]
// coverity[overflow_sink:SUPPRESS]
while ((j < str_len) && (findStr[j] != '\0') && isdigit(findStr[j])) {
/* Loop bounds protected by str_len check and isdigit()
* validation. Buffer overflow prevented by result[6] sizing for
* maximum expected value */
// coverity[overflow_sink:SUPPRESS]
result[i++] = findStr[j];
j++;
@ -7869,7 +7615,7 @@ static int woal_cfg80211_subcmd_get_usable_channels(struct wiphy *wiphy,
for (j = 0; (j < sband->n_channels); j++) {
ch = &sband->channels[j];
if (ch->flags & IEEE80211_CHAN_DISABLED) {
PRINTM(MERROR, "Skip DISABLED channels %d\n",
PRINTM(MINFO, "Skip DISABLED channels %d\n",
ieee80211_frequency_to_channel(
ch->center_freq));
continue;
@ -8109,44 +7855,6 @@ static const struct wiphy_vendor_command vendor_commands[] = {
.doit = woal_cfg80211_subcmd_set_roaming_offload_key,
#if KERNEL_VERSION(5, 3, 0) <= CFG80211_VERSION_CODE
.policy = VENDOR_CMD_RAW_DATA,
#endif
},
{
.info = {
.vendor_id = MRVL_VENDOR_ID,
.subcmd = sub_cmd_get_roaming_capability,
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV |
WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = woal_cfg80211_subcmd_get_roaming_capability,
#if KERNEL_VERSION(5, 3, 0) <= CFG80211_VERSION_CODE
.policy = VENDOR_CMD_RAW_DATA,
#endif
},
{
.info = {
.vendor_id = MRVL_VENDOR_ID,
.subcmd = sub_cmd_fw_roaming_enable,
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV |
WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = woal_cfg80211_subcmd_fw_roaming_enable,
#if KERNEL_VERSION(5, 3, 0) <= CFG80211_VERSION_CODE
.policy = woal_fw_roaming_policy,
.maxattr = MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_MAX,
#endif
},
{
.info = {
.vendor_id = MRVL_VENDOR_ID,
.subcmd = sub_cmd_fw_roaming_config,
},
.flags = WIPHY_VENDOR_CMD_NEED_WDEV |
WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = woal_cfg80211_subcmd_fw_roaming_config,
#if KERNEL_VERSION(5, 3, 0) <= CFG80211_VERSION_CODE
.policy = woal_fw_roaming_policy,
.maxattr = MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_MAX,
#endif
},
{

View file

@ -846,10 +846,6 @@ enum vendor_sub_command {
sub_cmd_get_drv_mem_dump = 0x1407,
sub_cmd_start_packet_fate_monitor = 0x1408,
sub_cmd_rssi_monitor = 0x1500,
/*Sub-command for wifi hal*/
sub_cmd_get_roaming_capability = 0x1700,
sub_cmd_fw_roaming_enable = 0x1701,
sub_cmd_fw_roaming_config = 0x1702,
subcmd_cfr_request = 0x1900,
subcmd_cfr_cancel,
subcmd_get_csi_dump_path,
@ -923,51 +919,6 @@ enum mrvl_wlan_vendor_attr_roam_auth {
MRVL_WLAN_VENDOR_ATTR_ROAM_AUTH_AFTER_LAST - 1
};
/** WiFi roaming capabilities structure */
typedef struct {
/** max blacklist size */
u32 max_blacklist_size;
/** max whitelist size */
u32 max_whitelist_size;
} wifi_roaming_capabilities;
/** WiFi BSSID params structure */
typedef struct {
/** Num of BSSID */
u32 num_bssid;
/** List of AP mac address */
t_u8 mac_addr[MAX_AP_LIST][MLAN_MAC_ADDR_LENGTH];
} wifi_bssid_params;
/** SSID structure */
typedef struct {
/** Length */
u32 length;
/** SSID */
char ssid[MLAN_MAX_SSID_LENGTH];
} ssid_t;
/** WiFi SSID params structure */
typedef struct {
/** No of SSID */
u32 num_ssid;
/** Whitelist SSID */
ssid_t whitelist_ssid[MAX_SSID_NUM];
} wifi_ssid_params;
/*Attribute for wifi hal*/
enum mrvl_wlan_vendor_attr_fw_roaming {
MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_INVALID = 0,
MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CAPA,
MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONTROL,
MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONFIG_BSSID,
MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_CONFIG_SSID,
/* keep last */
MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_AFTER_LAST,
MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_MAX =
MRVL_WLAN_VENDOR_ATTR_FW_ROAMING_AFTER_LAST - 1
};
enum attr_rtt {
ATTR_RTT_INVALID = 0,
ATTR_RTT_CAPA,

View file

@ -1564,11 +1564,12 @@ reflective_enum_lookup_name(const struct reflective_enum_element *elements,
{
const struct reflective_enum_element *elem = elements;
// The elements array is guaranteed to be NULL-terminated.
// coverity[overflow_sink:SUPPRESS]
while (elem->name && elem->id != id) {
elem++;
}
// The elements array is guaranteed to be NULL-terminated.
// coverity[overflow_sink:SUPPRESS]
return elem->name;
}

View file

@ -3196,6 +3196,7 @@ void woal_print_linkstats_event(void *context)
queue_work(handle->evt_workqueue, &handle->evt_work);
LEAVE();
/* evt is freed in woal_evt_work_queue, hence suppressed*/
// coverity[misra_c_2012_rule_22_1_violation:SUPPRESS]
return;
}
@ -6181,7 +6182,7 @@ static int woal_priv_set_get_usbaggrctrl(moal_private *priv, t_u8 *respbuf,
}
pcfg_misc->param.usb_aggr_params.rx_deaggr_ctrl.aggr_tmo =
(t_u16)data[7];
/* fall through */
fallthrough;
case 7:
if (data[6] < 0 || (data[6] > 10000 &&
data[6] != MLAN_USB_TX_AGGR_TIMEOUT_DYN)) {
@ -6192,7 +6193,7 @@ static int woal_priv_set_get_usbaggrctrl(moal_private *priv, t_u8 *respbuf,
}
pcfg_misc->param.usb_aggr_params.tx_aggr_ctrl.aggr_tmo =
(t_u16)data[6];
/* fall through */
fallthrough;
case 6:
if ((data[5] < 512) || ((data[5] % 512) != 0)) {
PRINTM(MERROR, "Invalid Rx alignment value (%d)\n",
@ -6206,7 +6207,7 @@ static int woal_priv_set_get_usbaggrctrl(moal_private *priv, t_u8 *respbuf,
usb_resubmit_urbs = 1;
pcfg_misc->param.usb_aggr_params.rx_deaggr_ctrl.aggr_align =
(t_u16)data[5];
/* fall through */
fallthrough;
case 5:
if ((data[4] < 2048) || ((data[4] % 2048) != 0)) {
PRINTM(MERROR, "Invalid Tx alignment value (%d)\n",
@ -6216,7 +6217,7 @@ static int woal_priv_set_get_usbaggrctrl(moal_private *priv, t_u8 *respbuf,
}
pcfg_misc->param.usb_aggr_params.tx_aggr_ctrl.aggr_align =
(t_u16)data[4];
/* fall through */
fallthrough;
case 4:
if ((data[3] == 2) || (data[3] == 4) || (data[3] == 8) ||
(data[3] == 16)) {
@ -6238,7 +6239,7 @@ static int woal_priv_set_get_usbaggrctrl(moal_private *priv, t_u8 *respbuf,
usb_resubmit_urbs = 1;
pcfg_misc->param.usb_aggr_params.rx_deaggr_ctrl.aggr_max =
(t_u16)data[3];
/* fall through */
fallthrough;
case 3:
if ((data[2] == 2) || (data[2] == 4) || (data[2] == 8) ||
(data[2] == 16)) {
@ -6256,7 +6257,7 @@ static int woal_priv_set_get_usbaggrctrl(moal_private *priv, t_u8 *respbuf,
}
pcfg_misc->param.usb_aggr_params.tx_aggr_ctrl.aggr_max =
(t_u16)data[2];
/* fall through */
fallthrough;
case 2:
if ((data[1] != 0) && (data[1] != 1)) {
PRINTM(MERROR, "Invalid Rx enable value (%d)\n",
@ -6269,7 +6270,7 @@ static int woal_priv_set_get_usbaggrctrl(moal_private *priv, t_u8 *respbuf,
usb_resubmit_urbs = 1;
pcfg_misc->param.usb_aggr_params.rx_deaggr_ctrl.enable =
(t_u16)data[1];
/* fall through */
fallthrough;
case 1:
if ((data[0] != 0) && (data[0] != 1)) {
PRINTM(MERROR, "Invalid Tx enable value (%d)\n",
@ -10859,7 +10860,7 @@ static int woal_priv_get_signal(moal_private *priv, t_u8 *respbuf,
ret = -EINVAL;
goto done;
}
/* Fall through */
fallthrough;
case 1: /* Check type range */
if (in_data[0] < 1 || in_data[0] > 3) {
ret = -EINVAL;
@ -11851,19 +11852,19 @@ static int woal_priv_sdio_mpa_ctrl(moal_private *priv, t_u8 *respbuf,
switch (user_data_len) {
case 6:
misc->param.mpa_ctrl.rx_max_ports = data[5];
/* fall through */
fallthrough;
case 5:
misc->param.mpa_ctrl.tx_max_ports = data[4];
/* fall through */
fallthrough;
case 4:
misc->param.mpa_ctrl.rx_buf_size = data[3];
/* fall through */
fallthrough;
case 3:
misc->param.mpa_ctrl.tx_buf_size = data[2];
/* fall through */
fallthrough;
case 2:
misc->param.mpa_ctrl.rx_enable = data[1];
/* fall through */
fallthrough;
case 1:
/* Set cmd */
req->action = MLAN_ACT_SET;
@ -13528,6 +13529,40 @@ void woal_process_chan_event(moal_private *priv, t_u8 type, t_u8 channel,
}
}
/**
* @brief Check fw bands support 2G
*
* @param bands fw bands
*
* @return TRUE if supported, FALSE otherwise
*
*/
static BOOLEAN woal_2g_support(t_u16 fw_bands)
{
t_u16 supported_bands = BAND_B | BAND_G | BAND_GN;
supported_bands |= BAND_GAC;
supported_bands |= BAND_GAX;
return (fw_bands & supported_bands) ? MTRUE : MFALSE;
}
/**
* @brief Check fw bands support 5G
*
* @param bands fw bands
*
* @return TRUE if supported, FALSE otherwise
*
*/
static BOOLEAN woal_5g_support(t_u16 fw_bands)
{
t_u16 supported_bands = BAND_A | BAND_AN;
supported_bands |= BAND_AAC;
supported_bands |= BAND_AAX;
return (fw_bands & supported_bands) ? MTRUE : MFALSE;
}
#ifdef UAP_SUPPORT
/**
* @brief This function prepare agcs event
@ -13689,6 +13724,99 @@ mlan_status moal_agcs_trans_state(moal_private *priv, agcs_state next_state)
return ret;
}
/**
* @brief AGCS select channel list
*
* @param phandle Pointer to moal_handle structure
* @param band Destination band channel list
* @param dest_scan_cfg Pointer to destination wlan_user_scan_cfg structure
* @param cur_idx Pointer to channel index
* @param pchaninfo Pointer to current chan_band_info structure
* @param support_ecsa All clients support ECSA
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*
*/
static mlan_status woal_agcs_pick_scan_list(moal_handle *phandle, t_u8 band,
wlan_user_scan_cfg *dest_scan_cfg,
t_u8 *cur_idx,
chan_band_info *pchaninfo,
t_u8 support_ecsa)
{
wlan_user_scan_chan *pchan_list;
t_u8 chidx;
mlan_status status = MLAN_STATUS_FAILURE;
if (((band == BAND_6GHZ) &&
!(phandle->hw_info.fw_cap_ext & FW_CAPINFO_EXT_6G)) ||
((band == BAND_5GHZ) && !woal_5g_support(phandle->fw_bands)) ||
((band == BAND_2GHZ) && !woal_2g_support(phandle->fw_bands))) {
/* UAP does not support this band */
PRINTM(MMSG, "AGCS UAP does not support this band(%d)\n", band);
goto done;
}
if (!dest_scan_cfg) {
PRINTM(MERROR, "AGCS dest_scan_cfg is NULL\n");
goto done;
}
pchan_list = phandle->agcs_info.chan_list;
for (chidx = 0; (pchan_list[chidx].chan_number != 0) &&
(chidx < WLAN_USER_SCAN_CHAN_MAX) &&
((*cur_idx) < WLAN_USER_SCAN_CHAN_MAX);
chidx++) {
if (band == BAND_5GHZ &&
pchan_list[chidx].radio_type == BAND_5GHZ &&
pchaninfo->bandcfg.chanBand == BAND_5GHZ) {
if (!support_ecsa) {
if ((pchaninfo->channel < 149) &&
(pchan_list[chidx].chan_number >= 149)) {
/* selected channel is not the same
* class as uap current channel */
continue;
}
if ((pchaninfo->channel >= 149) &&
(pchan_list[chidx].chan_number < 149)) {
/* selected channel is not the same
* class as uap current channel */
continue;
}
} else {
if ((pchaninfo->channel < 149) &&
(pchan_list[chidx].chan_number < 149)) {
/* selected channel is the same class as
* uap current channel */
continue;
}
if ((pchaninfo->channel >= 149) &&
(pchan_list[chidx].chan_number >= 149)) {
/* selected channel is the same class as
* uap current channel */
continue;
}
}
}
/* When the band in the list is the same as the destination band
* and the channel is different from the current channel,
* selected. */
if ((pchan_list[chidx].radio_type == band) &&
(pchaninfo->channel != pchan_list[chidx].chan_number)) {
moal_memcpy_ext(
phandle,
(t_void *)&dest_scan_cfg->chan_list[(*cur_idx)],
(const t_void *)&pchan_list[chidx],
sizeof(wlan_user_scan_chan),
sizeof(wlan_user_scan_chan));
(*cur_idx)++;
status = MLAN_STATUS_SUCCESS;
}
}
done:
return status;
}
/**
* @brief Process agiled cs event
*
@ -13701,12 +13829,16 @@ mlan_status moal_agcs_trans_state(moal_private *priv, agcs_state next_state)
void woal_process_agcs_event(moal_private *priv, pagcs_stats pstart_event)
{
moal_private *pmpriv = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
mlan_status status = MLAN_STATUS_FAILURE;
chan_band_info chaninfo;
t_u8 chidx, next_ch;
t_u8 cur_idx;
moal_handle *phandle = NULL;
wlan_user_scan_cfg *scan_cfg = NULL;
wlan_user_scan_chan *pchan_list;
t_u8 scan_band_priority[3];
t_u8 band_count;
t_u8 current_band_idx = 0;
t_u8 swap_class = 0;
memset(&chaninfo, 0, sizeof(chaninfo));
@ -13722,6 +13854,13 @@ void woal_process_agcs_event(moal_private *priv, pagcs_stats pstart_event)
status = MLAN_STATUS_FAILURE;
goto done;
}
/* For the first channel select of this channel switch event,
* record the scan event content. */
if (phandle->agcs_state == AGCS_STATE_START) {
moal_memcpy_ext(phandle, &phandle->agcs_scan_event,
pstart_event, sizeof(agcs_stats),
sizeof(agcs_stats));
}
status = moal_agcs_trans_state(priv, AGCS_STATE_TRIGGERED);
if (status == MLAN_STATUS_FAILURE) {
PRINTM(MERROR,
@ -13746,201 +13885,66 @@ void woal_process_agcs_event(moal_private *priv, pagcs_stats pstart_event)
goto done;
}
next_ch = 0;
chidx = 0;
if (pstart_event->all_sta_ecs) {
/* If all connected STAs support ECS, channel switch to
* diff operating class */
if ((pstart_event->all_sta_6g) &&
(priv->phandle->hw_info.fw_cap_ext &
FW_CAPINFO_EXT_6G)) {
/* If all connected STAs support 6g, switch to
* diff band(5g<->6g) */
if (chaninfo.bandcfg.chanBand == BAND_6GHZ) {
for (chidx = 0, next_ch = 0;
(pchan_list[chidx].chan_number !=
0) &&
(chidx < WLAN_USER_SCAN_CHAN_MAX);
chidx++) {
if (pchan_list[chidx]
.radio_type ==
BAND_5GHZ) {
moal_memcpy_ext(
phandle,
(t_void *)&scan_cfg
->chan_list
[next_ch],
(const t_void
*)&pchan_list
[chidx],
sizeof(wlan_user_scan_chan),
sizeof(wlan_user_scan_chan));
next_ch++;
}
}
} else {
for (chidx = 0, next_ch = 0;
(pchan_list[chidx].chan_number !=
0) &&
(chidx < WLAN_USER_SCAN_CHAN_MAX);
chidx++) {
if (pchan_list[chidx]
.radio_type ==
BAND_6GHZ) {
moal_memcpy_ext(
phandle,
(t_void *)&scan_cfg
->chan_list
[next_ch],
(const t_void
*)&pchan_list
[chidx],
sizeof(wlan_user_scan_chan),
sizeof(wlan_user_scan_chan));
next_ch++;
}
}
}
} else {
/* switch to diff operating class(upper 5g <->
* lower 5g) */
if (chaninfo.channel < 149) {
for (chidx = 0, next_ch = 0;
(pchan_list[chidx].chan_number !=
0) &&
(chidx < WLAN_USER_SCAN_CHAN_MAX);
chidx++) {
if ((pchan_list[chidx]
.radio_type ==
BAND_5GHZ) &&
(pchan_list[chidx]
.chan_number >=
149)) {
moal_memcpy_ext(
phandle,
(t_void *)&scan_cfg
->chan_list
[next_ch],
(const t_void
*)&pchan_list
[chidx],
sizeof(wlan_user_scan_chan),
sizeof(wlan_user_scan_chan));
next_ch++;
}
}
} else {
for (chidx = 0, next_ch = 0;
(pchan_list[chidx].chan_number !=
0) &&
(chidx < WLAN_USER_SCAN_CHAN_MAX);
chidx++) {
if ((pchan_list[chidx]
.radio_type ==
BAND_5GHZ) &&
(pchan_list[chidx]
.chan_number <
149)) {
moal_memcpy_ext(
phandle,
(t_void *)&scan_cfg
->chan_list
[next_ch],
(const t_void
*)&pchan_list
[chidx],
sizeof(wlan_user_scan_chan),
sizeof(wlan_user_scan_chan));
next_ch++;
}
}
}
}
cur_idx = 0;
status = MLAN_STATUS_FAILURE;
memset(scan_band_priority, 0, sizeof(scan_band_priority));
band_count = 0;
/* Setup band priority based on current channel and STA
* capabilities */
if (chaninfo.bandcfg.chanBand == BAND_6GHZ) {
/* If the current channel is 6G, the target band
* priority selection order is 5G->6G->2G */
scan_band_priority[band_count++] = BAND_5GHZ;
scan_band_priority[band_count++] = BAND_6GHZ;
scan_band_priority[band_count++] = BAND_2GHZ;
} else {
/* channel switch to same operating class */
if (chaninfo.channel < 14) {
for (chidx = 0, next_ch = 0;
(pchan_list[chidx].chan_number != 0) &&
(chidx < WLAN_USER_SCAN_CHAN_MAX);
chidx++) {
if ((pchan_list[chidx].radio_type ==
BAND_2GHZ) &&
(chaninfo.channel !=
pchan_list[chidx].chan_number)) {
moal_memcpy_ext(
phandle,
(t_void *)&scan_cfg
->chan_list
[next_ch],
(const t_void
*)&pchan_list
[chidx],
sizeof(wlan_user_scan_chan),
sizeof(wlan_user_scan_chan));
next_ch++;
}
}
} else if (chaninfo.channel < 149) {
/* lower 5g channels */
for (chidx = 0, next_ch = 0;
(pchan_list[chidx].chan_number != 0) &&
(chidx < WLAN_USER_SCAN_CHAN_MAX);
chidx++) {
if ((pchan_list[chidx].radio_type ==
BAND_5GHZ) &&
(pchan_list[chidx].chan_number <
149) &&
(chaninfo.channel !=
pchan_list[chidx].chan_number)) {
moal_memcpy_ext(
phandle,
(t_void *)&scan_cfg
->chan_list
[next_ch],
(const t_void
*)&pchan_list
[chidx],
sizeof(wlan_user_scan_chan),
sizeof(wlan_user_scan_chan));
next_ch++;
}
}
} else {
/* upper 5g channels */
for (chidx = 0, next_ch = 0;
(pchan_list[chidx].chan_number != 0) &&
(chidx < WLAN_USER_SCAN_CHAN_MAX);
chidx++) {
if ((pchan_list[chidx].radio_type ==
BAND_5GHZ) &&
(pchan_list[chidx].chan_number >=
149) &&
(chaninfo.channel !=
pchan_list[chidx].chan_number)) {
moal_memcpy_ext(
phandle,
(t_void *)&scan_cfg
->chan_list
[next_ch],
(const t_void
*)&pchan_list
[chidx],
sizeof(wlan_user_scan_chan),
sizeof(wlan_user_scan_chan));
next_ch++;
}
}
}
/* If the current channel is 6G, the target band
* priority selection order is 6G->5G->2G */
if (pstart_event->all_sta_6g)
scan_band_priority[band_count++] = BAND_6GHZ;
scan_band_priority[band_count++] = BAND_5GHZ;
/* select the same/diff class in 5g */
if (chaninfo.bandcfg.chanBand == BAND_5GHZ)
scan_band_priority[band_count++] = BAND_5GHZ;
scan_band_priority[band_count++] = BAND_2GHZ;
}
if (scan_cfg->chan_list[0].chan_number == 0) {
PRINTM(MERROR, "Fail to select channel\n");
for (current_band_idx = phandle->agcs_scan_event.scan_idx;
current_band_idx < band_count; current_band_idx++) {
swap_class = pstart_event->all_sta_ecs;
if (scan_band_priority[current_band_idx] == BAND_5GHZ &&
chaninfo.bandcfg.chanBand == BAND_5GHZ) {
/* Different/same channels are selected based on
* whether all STAs support ECSA. If no channel
* is selected, the same/different category
* channels are selected again.
*/
if (phandle->agcs_scan_event.is_5g_scaned)
swap_class = !swap_class;
else
phandle->agcs_scan_event.is_5g_scaned =
MTRUE;
}
status = woal_agcs_pick_scan_list(
phandle, scan_band_priority[current_band_idx],
scan_cfg, &cur_idx, &chaninfo, swap_class);
if (cur_idx)
break;
}
phandle->agcs_scan_event.scan_idx = current_band_idx + 1;
if ((scan_cfg->chan_list[0].chan_number == 0) ||
(phandle->agcs_scan_event.scan_idx > band_count)) {
PRINTM(MMSG,
"No channel selected, cur_idx=%d scan_idx=%d\n",
cur_idx, phandle->agcs_scan_event.scan_idx);
status = MLAN_STATUS_FAILURE;
goto done;
}
/** scan type: 0 legacy, 1: enhance scan*/
scan_cfg->ext_scan_type = EXT_SCAN_ENHANCE;
phandle->agcs_num_in_chan_stats = next_ch;
phandle->agcs_num_in_chan_stats = cur_idx;
/* Call for scan */
status = woal_request_userscan(priv, MOAL_NO_WAIT, scan_cfg);
if (status == MLAN_STATUS_FAILURE) {
@ -13983,6 +13987,7 @@ void woal_process_ch_sel_and_switch(moal_private *priv, pagcs_event pevent)
ChanStatistics_t *pchan_stats, *pbest_chan_stats;
int i;
t_u16 best_ch_load = 0;
int ret;
if (!priv || !priv->phandle) {
PRINTM(MERROR, "priv or handle is null\n");
@ -14014,12 +14019,19 @@ void woal_process_ch_sel_and_switch(moal_private *priv, pagcs_event pevent)
for (i = 0; i < (int)scan_resp.num_in_chan_stats; i++) {
if (pchan_stats[i].cca_scan_duration) {
if (pbest_chan_stats->noise >
pchan_stats[i].noise) {
best_ch_load =
pchan_stats[i].cca_busy_duration * 100 /
pchan_stats[i].cca_scan_duration;
if ((pbest_chan_stats->noise >
pchan_stats[i].noise) &&
(best_ch_load <
handle->agcs_info
.chload_threshold_percentage)) {
pbest_chan_stats = &pchan_stats[i];
}
}
}
best_ch_load = 0;
if (pbest_chan_stats->cca_scan_duration) {
best_ch_load = pbest_chan_stats->cca_busy_duration *
100 /
@ -14055,7 +14067,19 @@ void woal_process_ch_sel_and_switch(moal_private *priv, pagcs_event pevent)
new_oper_class = 132;
break;
case CHAN_BW_80MHZ:
band_width = CHANNEL_BW_80MHZ;
/* If the target band is 2G, then the bandwidth
* must be downgraded to 40MHz */
if (pbest_chan_stats->bandcfg.chanBand ==
BAND_2GHZ) {
if (chaninfo.bandcfg.chan2Offset ==
SEC_CHAN_BELOW)
band_width =
CHANNEL_BW_40MHZ_BELOW;
else
band_width =
CHANNEL_BW_40MHZ_ABOVE;
} else
band_width = CHANNEL_BW_80MHZ;
if (pbest_chan_stats->bandcfg.chanBand ==
BAND_6GHZ)
new_oper_class = 133;
@ -14069,18 +14093,23 @@ void woal_process_ch_sel_and_switch(moal_private *priv, pagcs_event pevent)
}
moal_agcs_trans_state(priv, AGCS_STATE_CSA_START);
woal_channel_switch(priv, MTRUE, new_oper_class,
pbest_chan_stats->chan_num,
handle->agcs_info.csa_cnt,
pbest_chan_stats->bandcfg.chanBand,
band_width, MTRUE);
ret = woal_channel_switch(
priv, MFALSE, new_oper_class,
pbest_chan_stats->chan_num,
handle->agcs_info.csa_cnt,
pbest_chan_stats->bandcfg.chanBand, band_width,
MTRUE);
if (ret) {
moal_agcs_trans_state(priv,
AGCS_STATE_COMPLETE);
}
} else {
moal_agcs_trans_state(priv, AGCS_STATE_COMPLETE);
PRINTM(MEVENT,
"AGCS no channel switch NF_newChannel(%d) < NF_threshold(%d) && chload_newChannel(%d) < ChLoad_TH(%d)\n",
pbest_chan_stats->noise,
pevent->stats.nf_threshold, best_ch_load,
handle->agcs_info.chload_threshold_percentage);
woal_process_agcs_event(priv, &handle->agcs_scan_event);
}
}
}
@ -14825,6 +14854,47 @@ done:
return ret;
}
static int woal_priv_get_foundry_type(moal_private *priv, t_u8 *respbuf,
t_u32 respbuflen)
{
mlan_ioctl_req *ioctl_req = NULL;
mlan_ds_misc_cfg *misc = NULL;
mlan_status status = MLAN_STATUS_SUCCESS;
int ret = 0;
ENTER();
ioctl_req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_misc_cfg));
if (ioctl_req == NULL) {
LEAVE();
return -ENOMEM;
}
misc = (mlan_ds_misc_cfg *)ioctl_req->pbuf;
misc->sub_command = MLAN_OID_MISC_FOUNDRY_TYPE;
ioctl_req->req_id = MLAN_IOCTL_MISC_CFG;
ioctl_req->action = MLAN_ACT_GET;
status = woal_request_ioctl(priv, ioctl_req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
ret = -EFAULT;
goto done;
}
memset(respbuf, 0, respbuflen);
moal_memcpy_ext(priv->phandle, respbuf,
&misc->param.soc_foundry_type.foundry_type,
sizeof(t_u8), respbuflen);
ret = sizeof(t_u8);
done:
if (status != MLAN_STATUS_PENDING)
kfree(ioctl_req);
LEAVE();
return ret;
}
/**
* @brief Set/Get Tx/Rx antenna
*
@ -16998,10 +17068,10 @@ static int woal_priv_cfg_noa(moal_private *priv, t_u8 *respbuf,
switch (user_data_len) {
case 5:
noa_cfg.noa_interval = (t_u32)data[4];
/* fall through */
fallthrough;
case 4:
noa_cfg.noa_duration = (t_u32)data[3];
/* fall through */
fallthrough;
case 3:
if (data[2] < 1 || data[2] > 255) {
PRINTM(MERROR,
@ -17010,7 +17080,7 @@ static int woal_priv_cfg_noa(moal_private *priv, t_u8 *respbuf,
goto done;
}
noa_cfg.noa_count = (t_u8)data[2];
/* fall through */
fallthrough;
case 2:
if (data[1] < 0 || data[1] > 255) {
PRINTM(MERROR, "Invalid Index\n");
@ -17018,7 +17088,7 @@ static int woal_priv_cfg_noa(moal_private *priv, t_u8 *respbuf,
goto done;
}
noa_cfg.index = (t_u16)data[1];
/* fall through */
fallthrough;
case 1:
if (data[0] < 0 || data[0] > 1) {
PRINTM(MERROR, "Invalid noa enable\n");
@ -17092,7 +17162,7 @@ static int woal_priv_cfg_opp_ps(moal_private *priv, t_u8 *respbuf,
switch (user_data_len) {
case 2:
opp_ps_cfg.ct_window = (t_u8)data[1];
/* fall through */
fallthrough;
case 1:
if (data[0] < 0 || data[0] > 1) {
PRINTM(MERROR, "Invalid ps enable\n");
@ -17101,7 +17171,7 @@ static int woal_priv_cfg_opp_ps(moal_private *priv, t_u8 *respbuf,
}
opp_ps_cfg.opp_ps_enable = (t_u8)data[0];
opp_ps_cfg.flags |= WIFI_DIRECT_OPP_PS;
/* fall through */
fallthrough;
default:
break;
}
@ -17175,7 +17245,7 @@ static int woal_priv_cfg_clock_sync(moal_private *priv, t_u8 *respbuf,
case 5:
clock_sync_cfg->clock_sync_gpio_pulse_width =
(t_u16)data[4];
/* fall through */
fallthrough;
case 4:
if (data[3] < 0 || data[3] > 1) {
PRINTM(MERROR, "Invalid Level/Trigger\n");
@ -17184,7 +17254,7 @@ static int woal_priv_cfg_clock_sync(moal_private *priv, t_u8 *respbuf,
}
clock_sync_cfg->clock_sync_gpio_level_toggle =
(t_u8)data[3];
/* fall through */
fallthrough;
case 3:
if (data[2] < 1 || data[2] > 255) {
PRINTM(MERROR,
@ -17194,7 +17264,7 @@ static int woal_priv_cfg_clock_sync(moal_private *priv, t_u8 *respbuf,
}
clock_sync_cfg->clock_sync_gpio_pin_number =
(t_u8)data[2];
/* fall through */
fallthrough;
case 2:
if (data[1] < 0 || data[1] > 2) {
PRINTM(MERROR, "Invalid Role\n");
@ -17202,7 +17272,7 @@ static int woal_priv_cfg_clock_sync(moal_private *priv, t_u8 *respbuf,
goto done;
}
clock_sync_cfg->clock_sync_Role = (t_u8)data[1];
/* fall through */
fallthrough;
case 1:
if (data[0] < 0 || data[0] > 2) {
PRINTM(MERROR, "Invalid Mode\n");
@ -22100,9 +22170,12 @@ static int woal_priv_get_uuid(moal_private *priv, t_u8 *respbuf,
/* Channel switch announcement count */
#define AGCS_PARAMS_CSA_COUNT 5
/* nav migigation(long duration) pkts threshold */
#define AGCS_PARAMS_NAV_MITIGATION_THR 10
#define AGCS_PARAMS_NAV_MITIGATION_THR 50
/* ch threshold to trigger channel switch for nighthawk */
#define AGCS_PARAMS_TRG_CHLOAD_THR 75
/* Channel switching is triggered only when the current pkts > the min average
* packet percentage. */
#define AGCS_PARAMS_MIN_PKTS_PERCENT 5
/* After AGCS triggered, scan the candidate channel list with duration, unit is
* ms */
@ -22159,6 +22232,9 @@ static void wlan_copy_agcs_info(moal_handle *phandle,
AGCS_PARAMS_NAV_MITIGATION_THR;
if (pagcs_info_req->ch_th == 0)
pagcs_info_req->ch_th = AGCS_PARAMS_TRG_CHLOAD_THR;
if (pagcs_info_req->min_pkt_percentage == 0)
pagcs_info_req->min_pkt_percentage =
AGCS_PARAMS_MIN_PKTS_PERCENT;
if (pagcs_info_req->chan_list[0].chan_number == 0) {
for (tmp_idx = 0; (tmp_idx < sizeof(agcs_chan_2g)) &&
@ -22271,6 +22347,8 @@ static int woal_priv_agcs(moal_private *priv, t_u8 *respbuf, t_u32 respbuflen)
misc->param.agcs_cfg.nav_mitigation_th =
pagcs_info_req->nav_mitigation_th;
misc->param.agcs_cfg.ch_th = pagcs_info_req->ch_th;
misc->param.agcs_cfg.min_pkt_percentage =
pagcs_info_req->min_pkt_percentage;
req->action = MLAN_ACT_SET;
}
@ -22300,6 +22378,8 @@ static int woal_priv_agcs(moal_private *priv, t_u8 *respbuf, t_u32 respbuflen)
pagcs_info_req->nav_mitigation_th =
misc->param.agcs_cfg.nav_mitigation_th;
pagcs_info_req->ch_th = misc->param.agcs_cfg.ch_th;
pagcs_info_req->min_pkt_percentage =
misc->param.agcs_cfg.min_pkt_percentage;
if (priv->phandle->agcs_info.chload_threshold_percentage == 0)
pagcs_info_req->chload_threshold_percentage =
@ -22357,7 +22437,7 @@ static int woal_priv_per_band_txpwr_cap(moal_private *priv, t_u8 *respbuf,
mlan_ioctl_req *req = NULL;
mlan_ds_misc_cfg *misc = NULL;
int ret = 0;
int data[2] = {0};
int data[4] = {0};
int header_len = 0, user_data_len = 0;
mlan_status status = MLAN_STATUS_SUCCESS;
@ -22385,7 +22465,7 @@ static int woal_priv_per_band_txpwr_cap(moal_private *priv, t_u8 *respbuf,
parse_arguments(respbuf + header_len, data, ARRAY_SIZE(data),
&user_data_len);
if (!user_data_len || user_data_len > 2) {
if (!user_data_len || user_data_len > 4) {
PRINTM(MERROR, "Invalid number of args!\n");
ret = -EINVAL;
goto done;
@ -22401,16 +22481,46 @@ static int woal_priv_per_band_txpwr_cap(moal_private *priv, t_u8 *respbuf,
ret = -EINVAL;
goto done;
}
/* tx power capping cannot be negative or above 25 dBm */
if (data[1] < 0 || data[1] > 25) {
PRINTM(MERROR,
"per_band_txpwr_cap: Invalid power value input\n");
if (data[0] == BAND_6GHZ && !woal_is_6g_sub_band_allowed(priv)) {
PRINTM(MERROR, "per_band_txpwr_cap: 6g band not supported\n");
ret = -EINVAL;
goto done;
}
/* tx power capping cannot be negative or above 25 dBm */
if (data[1] < 0 || data[1] > 25) {
if (data[1] == 0xff && data[0] == BAND_6GHZ) {
/* rssi based tpc */
} else {
PRINTM(MERROR,
"per_band_txpwr_cap: Invalid power value input\n");
ret = -EINVAL;
goto done;
}
}
if (data[0] == BAND_6GHZ && data[1] == 0xff) {
if ((data[2] == 0 || data[3] == 0) && (data[2] != data[3])) {
/* both thresholds must be 0 for dynamic TPC */
PRINTM(MERROR,
"per_band_txpwr_cap: Invalid RSSI value input\n");
ret = -EINVAL;
goto done;
} else if (((data[2] > 0 || data[2] < -120) ||
(data[3] > 0 || data[3] < -120) ||
(data[2] < data[3]))) {
/* both thresholds must be between -1 and -120 dBm
* inclusive for peer rssi threshold based TPC
*/
PRINTM(MERROR,
"per_band_txpwr_cap: Invalid RSSI value input\n");
ret = -EINVAL;
goto done;
}
}
misc->param.per_band_txpwr_cap.band = (t_u8)data[0];
misc->param.per_band_txpwr_cap.power = (t_u8)data[1];
misc->param.per_band_txpwr_cap.strong_rssi_thresh = (t_s8)data[2];
misc->param.per_band_txpwr_cap.weak_rssi_thresh = (t_s8)data[3];
/* Send IOCTL request to MLAN */
status = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (status != MLAN_STATUS_SUCCESS) {
@ -22420,6 +22530,8 @@ static int woal_priv_per_band_txpwr_cap(moal_private *priv, t_u8 *respbuf,
data[0] = misc->param.per_band_txpwr_cap.band;
data[1] = misc->param.per_band_txpwr_cap.power;
data[2] = misc->param.per_band_txpwr_cap.strong_rssi_thresh;
data[3] = misc->param.per_band_txpwr_cap.weak_rssi_thresh;
moal_memcpy_ext(priv->phandle, respbuf, (t_u8 *)data, sizeof(data),
respbuflen);
ret = sizeof(data);
@ -23482,6 +23594,13 @@ int woal_android_priv_cmd(struct net_device *dev, struct ifreq *req)
len = woal_priv_get_ch_load(priv, buf,
priv_cmd.total_len);
goto handled;
} else if (strnicmp(buf + strlen(CMD_NXP),
PRIV_CMD_FOUNDRY_TYPE,
strlen(PRIV_CMD_FOUNDRY_TYPE)) == 0) {
/* mc_aggr_cfg*/
len = woal_priv_get_foundry_type(priv, buf,
priv_cmd.total_len);
goto handled;
} else if (strnicmp(buf + strlen(CMD_NXP),
PRIV_CMD_CROSS_CHIP_SYNCH,
strlen(PRIV_CMD_CROSS_CHIP_SYNCH)) == 0) {

View file

@ -312,6 +312,7 @@ typedef struct _chan_stats {
#define PRIV_CMD_ARB_CFG "arb"
#define PRIV_CMD_FOUNDRY_TYPE "foundry_type"
/**Private command to configure static rx abort config */
#define PRIV_CMD_RX_ABORT_CFG "rx_abort_cfg"
/**Private command to configure static OFDM DESENSE config */

View file

@ -102,12 +102,18 @@ static int wifi_reset_config = 5;
static int tx_budget = 2600;
static int mclient_scheduling = 1;
static int copy_policy = 0;
static int ext_scan;
/** Boot Time config */
static int bootup_cal_ctrl = 0;
/** IEEE PS mode */
static int ps_mode;
/** tcpackenh parameter */
static int tcpackenh = 1;
/** plinkstats parameter */
static char *plinkstats = NULL;
/** passive to active scan */
static int p2a_scan;
/** scan chan gap */
@ -133,6 +139,14 @@ static char *uap_name;
static int uap_max_sta;
/** WACP mode */
static int wacp_mode = WACP_MODE_DEFAULT;
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
/** XDP(express datapath) mode */
static int xdp = 0;
#endif
#endif
#endif
/** Fw cutom data config */
@ -452,7 +466,19 @@ static int make_before_break = 0;
static int auto_11ax = 1;
static int reject_addba_req = 0;
#if defined(USB) && defined(USB_CUSTOMER_VIDPID)
/** bandctrl */
static int bandctrl = 0;
#if defined(USB)
/**
* @brief This function checks if a device name exists in the card type mapping
* table
*
* @param device_name A pointer to the device name string to search for
* @param card_type A pointer to store the corresponding card type if found
* @return MLAN_STATUS_SUCCESS if device name is found,
* MLAN_STATUS_FAILURE otherwise
*/
mlan_status check_device_name_info(char *device_name, t_u16 *card_type)
{
t_u32 tbl_size =
@ -1085,6 +1111,12 @@ static mlan_status parse_cfg_read_block(t_u8 *data, t_u32 size,
MLAN_STATUS_SUCCESS)
goto err;
params->mclient_scheduling = out_data;
} else if (strncmp(line, "copy_policy",
strlen("copy_policy")) == 0) {
if (parse_line_read_int(line, &out_data) !=
MLAN_STATUS_SUCCESS)
goto err;
params->copy_policy = out_data;
} else if (strncmp(line, "ext_scan", strlen("ext_scan")) == 0) {
if (parse_line_read_int(line, &out_data) !=
MLAN_STATUS_SUCCESS)
@ -1105,6 +1137,20 @@ static mlan_status parse_cfg_read_block(t_u8 *data, t_u32 size,
goto err;
params->ps_mode = out_data;
PRINTM(MMSG, "ps_mode = %d\n", params->ps_mode);
} else if (strncmp(line, "tcpackenh", strlen("tcpackenh")) ==
0) {
if (parse_line_read_int(line, &out_data) !=
MLAN_STATUS_SUCCESS)
goto err;
params->tcpackenh = out_data;
PRINTM(MMSG, "tcpackenh = %d\n", params->tcpackenh);
} else if (strncmp(line, "plinkstats", strlen("plinkstats")) ==
0) {
if (parse_line_read_string(line, &out_str) !=
MLAN_STATUS_SUCCESS)
goto err;
woal_dup_string(&params->plinkstats, out_str);
PRINTM(MMSG, "plinkstats=%s\n", params->plinkstats);
} else if (strncmp(line, "p2a_scan", strlen("p2a_scan")) == 0) {
if (parse_line_read_int(line, &out_data) !=
MLAN_STATUS_SUCCESS)
@ -1265,7 +1311,10 @@ static mlan_status parse_cfg_read_block(t_u8 *data, t_u32 size,
sizeof(handle->mode_psd_file));
strncpy(handle->mode_psd_file,
params->txpwrlimit_cfg,
strlen(params->txpwrlimit_cfg) + 1);
sizeof(handle->mode_psd_file) - 1);
handle->mode_psd_file
[sizeof(handle->mode_psd_file) - 1] =
'\0';
PRINTM(MMSG, "Mode PSD file name: %s",
handle->mode_psd_file);
}
@ -1765,6 +1814,18 @@ static mlan_status parse_cfg_read_block(t_u8 *data, t_u32 size,
params->wacp_mode = out_data;
PRINTM(MMSG, "wacp_moe=%d\n", params->wacp_mode);
}
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
else if (strncmp(line, "xdp", strlen("xdp")) == 0) {
if (parse_line_read_int(line, &out_data) !=
MLAN_STATUS_SUCCESS)
goto err;
params->xdp = out_data;
PRINTM(MMSG, "xdp=%d\n", params->xdp);
}
#endif
#endif
#endif
else if (strncmp(line, "fw_data_cfg", strlen("fw_data_cfg")) ==
0) {
@ -1891,6 +1952,12 @@ static mlan_status parse_cfg_read_block(t_u8 *data, t_u32 size,
PRINTM(MMSG, "make_before_break=%x\n",
params->make_before_break);
}
else if (strncmp(line, "bandctrl", strlen("bandctrl")) == 0) {
if (parse_line_read_int(line, &out_data) !=
MLAN_STATUS_SUCCESS)
goto err;
params->bandctrl = out_data;
}
}
if (params->tx_budget <= 0)
@ -1932,6 +1999,9 @@ static void woal_setup_module_param(moal_handle *handle, moal_mod_para *params)
woal_dup_string(&handle->params.fw_name, fw_name);
if (params && params->fw_name)
woal_dup_string(&handle->params.fw_name, params->fw_name);
woal_dup_string(&handle->params.plinkstats, plinkstats);
if (params && params->plinkstats)
woal_dup_string(&handle->params.plinkstats, params->plinkstats);
if (req_fw_nowait)
moal_extflg_set(handle, EXT_REQ_FW_NOWAIT);
handle->params.fw_reload = fw_reload;
@ -2018,12 +2088,22 @@ static void woal_setup_module_param(moal_handle *handle, moal_mod_para *params)
handle->params.uap_max_sta = uap_max_sta;
handle->params.wacp_mode = wacp_mode;
handle->params.mcs32 = mcs32;
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
handle->params.xdp = xdp;
#endif
#endif
if (params) {
handle->params.max_uap_bss = params->max_uap_bss;
woal_dup_string(&handle->params.uap_name, params->uap_name);
handle->params.uap_max_sta = params->uap_max_sta;
handle->params.wacp_mode = params->wacp_mode;
handle->params.mcs32 = params->mcs32;
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
handle->params.xdp = params->xdp;
#endif
#endif
}
#endif /* UAP_SUPPORT */
handle->params.fw_data_cfg = fw_data_cfg;
@ -2069,6 +2149,10 @@ static void woal_setup_module_param(moal_handle *handle, moal_mod_para *params)
if (params)
handle->params.amsdu_deaggr = params->amsdu_deaggr;
handle->params.copy_policy = copy_policy;
if (params)
handle->params.copy_policy = params->copy_policy;
handle->params.tx_budget = params ? params->tx_budget : tx_budget;
handle->params.mclient_scheduling =
params ? params->mclient_scheduling : mclient_scheduling;
@ -2090,10 +2174,12 @@ static void woal_setup_module_param(moal_handle *handle, moal_mod_para *params)
handle->params.bootup_cal_ctrl = bootup_cal_ctrl;
handle->params.ps_mode = ps_mode;
handle->params.p2a_scan = p2a_scan;
handle->params.tcpackenh = tcpackenh;
handle->params.scan_chan_gap = scan_chan_gap;
handle->params.sched_scan = sched_scan;
handle->params.max_tx_buf = max_tx_buf;
if (params) {
handle->params.tcpackenh = params->tcpackenh;
handle->params.bootup_cal_ctrl = params->bootup_cal_ctrl;
handle->params.ps_mode = params->ps_mode;
handle->params.max_tx_buf = params->max_tx_buf;
@ -2161,7 +2247,8 @@ static void woal_setup_module_param(moal_handle *handle, moal_mod_para *params)
if (handle->params.txpwrlimit_cfg) {
memset(handle->mode_psd_file, 0, sizeof(handle->mode_psd_file));
strncpy(handle->mode_psd_file, handle->params.txpwrlimit_cfg,
strlen(handle->params.txpwrlimit_cfg) + 1);
sizeof(handle->mode_psd_file) - 1);
handle->mode_psd_file[sizeof(handle->mode_psd_file) - 1] = '\0';
PRINTM(MINFO, "Mode PSD file name: %s", handle->mode_psd_file);
}
@ -2367,6 +2454,10 @@ static void woal_setup_module_param(moal_handle *handle, moal_mod_para *params)
if (params)
handle->params.tpe_ie_ignore = params->tpe_ie_ignore;
handle->params.make_before_break = make_before_break;
handle->params.bandctrl = bandctrl;
if (params)
handle->params.bandctrl = params->bandctrl;
}
/**
@ -2389,6 +2480,10 @@ void woal_free_module_param(moal_handle *handle)
kfree(params->wifi_fw_name);
params->wifi_fw_name = NULL;
}
if (params->plinkstats) {
kfree(params->plinkstats);
params->plinkstats = NULL;
}
if (params->hw_name) {
kfree(params->hw_name);
params->hw_name = NULL;
@ -2473,7 +2568,7 @@ static mlan_status woal_req_mod_param(moal_handle *handle, char *mod_file)
status = request_firmware(&handle->param_data, mod_file, dev);
if (status < 0) {
PRINTM(MERROR, "Request firmware: %s failed, error: %d\n",
mod_file, ret);
mod_file, status);
ret = MLAN_STATUS_FAILURE;
}
out:
@ -2848,6 +2943,12 @@ void woal_init_from_dev_tree(void)
PRINTM(MIOCTL, "bootup_cal_ctrl=%d\n",
bootup_cal_ctrl);
}
} else if (!strncmp(prop->name, "tcpackenh",
strlen("tcpackenh"))) {
if (!of_property_read_u32(dt_node, prop->name, &data)) {
tcpackenh = data;
PRINTM(MIOCTL, "tcpackenh=%d\n", tcpackenh);
}
} else if (!strncmp(prop->name, "inact_tmo",
strlen("inact_tmo"))) {
if (!of_property_read_u32(dt_node, prop->name, &data)) {
@ -2904,6 +3005,17 @@ void woal_init_from_dev_tree(void)
wacp_mode = data;
}
}
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
else if (!strncmp(prop->name, "xdp", strlen("xdp"))) {
if (!of_property_read_u32(dt_node, prop->name, &data)) {
PRINTM(MMSG, "xdp=0x%x\n", data);
xdp = data;
}
}
#endif
#endif
#endif
else if (!strncmp(prop->name, "fw_data_cfg",
strlen("fw_data_cfg"))) {
@ -2991,7 +3103,15 @@ void woal_init_from_dev_tree(void)
make_before_break = data;
}
}
else if (!strncmp(prop->name, "bandctrl", strlen("bandctrl"))) {
if (!of_property_read_u32(dt_node, prop->name, &data)) {
PRINTM(MIOCTL, "bandctrl=0x%x\n", data);
bandctrl = data;
}
}
}
of_node_put(dt_node);
LEAVE();
return;
}
@ -3199,6 +3319,111 @@ out:
return ret;
}
#if defined(USB)
/**
* @brief Parse module parameter configuration file to extract c_vidpid value
*
* This function reads the module parameter configuration file specified by
* mod_para and searches for the c_vidpid parameter value. It parses through
* configuration blocks and extracts the c_vidpid string when found.
*
* @param c_vidpid Pointer to store the extracted c_vidpid string
*
* @return MLAN_STATUS_SUCCESS on success, MLAN_STATUS_FAILURE on
* error
*/
mlan_status woal_get_c_vidpid(char **c_vidpid)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
int status;
const struct firmware *tmp_param_data = NULL;
t_u8 line[MAX_LINE_LEN], *data = NULL;
t_u32 size, i, tbl_size;
char *card_type = NULL, *blk_id = NULL, *out_str = NULL;
;
if (mod_para == NULL) {
PRINTM(MMSG, "No module param cfg file specified\n");
goto out;
}
status = request_firmware(&tmp_param_data, mod_para, NULL);
if (status < 0) {
PRINTM(MERROR, "Request conf: %s failed, error: %d\n", mod_para,
status);
goto err;
}
tbl_size = sizeof(card_type_map_tbl) / sizeof(card_type_map_tbl[0]);
// Casting is done to read and parse the data
// coverity[misra_c_2012_rule_11_8_violation:SUPPRESS]
data = (t_u8 *)tmp_param_data->data;
size = (t_u32)tmp_param_data->size;
while ((int)parse_cfg_get_line(data, size, line, NULL) != -1) {
if (line[0] == '#')
continue;
if (strstr(line, "={")) {
ret = parse_line_read_card_info(line, &card_type,
&blk_id);
if (ret != MLAN_STATUS_SUCCESS)
goto err;
PRINTM(MINFO,
"Traverse for c_vidpid, card_type: %s, config block: %s\n",
card_type, blk_id);
for (i = 0; i < tbl_size; i++) {
if (strcmp(card_type_map_tbl[i].name,
card_type) == 0) {
continue;
}
}
} else {
if (strncmp(line, "}", strlen("}")) == 0) {
continue;
} else {
if (strncmp(line, "c_vidpid",
strlen("c_vidpid")) == 0) {
if (parse_line_read_string(line,
&out_str) !=
MLAN_STATUS_SUCCESS)
goto err;
woal_dup_string(c_vidpid, out_str);
PRINTM(MINFO, "c_vidpid = %s\n",
out_str);
goto out;
}
}
}
}
out:
if (tmp_param_data) {
release_firmware(tmp_param_data);
/* rewind pos */
(void)parse_cfg_get_line(NULL, 0, NULL, NULL);
}
return ret;
err:
PRINTM(MMSG, "Invalid line: %s\n", line);
if (tmp_param_data) {
release_firmware(tmp_param_data);
/* rewind pos */
(void)parse_cfg_get_line(NULL, 0, NULL, NULL);
}
ret = MLAN_STATUS_FAILURE;
return ret;
}
#endif
/* Register module parameter 'plinkstats' for runtime configuration.
* Accepts string input via sysfs or kernel command line.
* Format: "0" to disable, "1" to enable, "2" to reset. */
module_param(plinkstats, charp, 0);
MODULE_PARM_DESC(plinkstats, "0: Disable; 1: Enable; 2: Reset");
module_param(mod_para, charp, 0);
MODULE_PARM_DESC(mod_para, "Module parameters configuration file");
module_param(hw_test, int, 0660);
@ -3292,6 +3517,11 @@ module_param(bootup_cal_ctrl, int, 0660);
MODULE_PARM_DESC(
bootup_cal_ctrl,
"0: Disable boot time optimization (default); 1: Enable boot time optimization");
// coverity[misra_c_2012_rule_7_1_violation:SUPPRESS]
module_param(tcpackenh, int, 0660);
MODULE_PARM_DESC(
tcpackenh,
"1: MLAN default; 0: Disable tcpackenh; 1: Enable tcpackenh default");
module_param(ps_mode, int, 0660);
MODULE_PARM_DESC(
ps_mode,
@ -3466,6 +3696,11 @@ module_param(mclient_scheduling, int, 0);
MODULE_PARM_DESC(mclient_scheduling,
"0: disable multi-client scheduling; 1 - enable(default)");
module_param(copy_policy, int, 0);
MODULE_PARM_DESC(
copy_policy,
"copy policy used on RX and TX. bit#0 - RX, bit#1 - TX 0: zero-copy (default), 1 use memcpy");
#ifdef SDIO
module_param(sdio_rx_aggr, int, 0);
MODULE_PARM_DESC(sdio_rx_aggr,
@ -3573,6 +3808,13 @@ module_param(wacp_mode, int, 0);
MODULE_PARM_DESC(
wacp_mode,
"WACP mode for UAP/GO 0: WACP_MODE_DEFAULT; 1: WACP_MODE_1; 2: WACP_MODE_2");
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
module_param(xdp, int, 0);
MODULE_PARM_DESC(xdp,
"Express data path 0: disable xdp(default); 1: enable xdp");
#endif
#endif
#endif
module_param(fw_data_cfg, int, 0);
MODULE_PARM_DESC(
@ -3665,3 +3907,7 @@ module_param(make_before_break, int, 0);
MODULE_PARM_DESC(
make_before_break,
"1: make_before_break during roam; 0: no make_before_break during roam");
module_param(bandctrl, int, 0660);
MODULE_PARM_DESC(bandctrl,
"0: Disable bandctrl mode(default); 1: Enable bandctrl mode");

View file

@ -4722,6 +4722,7 @@ done:
*
* @return 0 --success, otherwise fail
*/
// coverity[HIS_CALLING:SUPPRESS]
int woal_set_drvdbg(moal_private *priv, t_u32 drv_dbg)
{
mlan_ioctl_req *req = NULL;
@ -6402,6 +6403,8 @@ mlan_status woal_cancel_scan(moal_private *priv, t_u8 wait_option)
/* add 300ms delay, incase firmware delay 0x7f event after scan cancel
* command response */
woal_sched_timeout(300);
/* scan_priv is cleared after scan completion in a controlled context
* where concurrent access is not expected */
// coverity[LOCK_EVASION:SUPPRESS]
handle->scan_priv = NULL;
done:
@ -7597,6 +7600,175 @@ done:
return ret;
}
/**
* @brief set bandctrl
*
* @param priv A pointer to moal_private structure
* @param bandctrl new bandctrl
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_set_bandctrl(moal_private *priv, t_u32 bandctrl)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
int band = 0;
mlan_ioctl_req *req = NULL;
mlan_ds_radio_cfg *radio_cfg = NULL;
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
int cfg80211_wext;
#endif
ENTER();
if (priv == NULL) {
ret = MLAN_STATUS_FAILURE;
LEAVE();
return ret;
}
if (priv->band_ctrl == bandctrl) {
LEAVE();
return ret;
}
if (bandctrl == BANDCTRL_BLOCK_SCAN) {
priv->fake_scan_complete = MTRUE;
woal_flush_scan_table(priv, BAND_SELECT_ALL);
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
/* Clear the internal BSS list maintained by the cfg80211
* subsystem */
if (priv->wdev && priv->wdev->wiphy) {
cfg80211_bss_flush(priv->wdev->wiphy);
}
#endif
/** deauth ext-ap */
if (priv->media_connected && !priv->cfg_disconnect) {
PRINTM(MMSG, "Disconnect STA " MACSTR "\n",
MAC2STR(priv->cfg_bssid));
woal_disconnect(priv, MOAL_IOCTL_WAIT_TIMEOUT,
priv->cfg_bssid,
DEF_DEAUTH_REASON_CODE);
}
} else if (bandctrl == BANDCTRL_SET_BANDCFG) {
priv->fake_scan_complete = MFALSE;
} else if (bandctrl == BANDCTRL_2G_ONLY) {
/** deauth ext-5g ap */
if (priv->media_connected && !priv->cfg_disconnect &&
(priv->channel > 14)) {
PRINTM(MMSG, "Disconnect STA " MACSTR "\n",
MAC2STR(priv->cfg_bssid));
woal_disconnect(priv, MOAL_IOCTL_WAIT_TIMEOUT,
priv->cfg_bssid,
DEF_DEAUTH_REASON_CODE);
}
woal_flush_scan_table(priv, BAND_SELECT_2G_ONLY);
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
/* Clear the internal BSS list maintained by the cfg80211
* subsystem */
if (priv->wdev && priv->wdev->wiphy) {
cfg80211_bss_flush(priv->wdev->wiphy);
}
#endif
priv->fake_scan_complete = MFALSE;
}
priv->band_ctrl = bandctrl;
if (priv->band_ctrl == BANDCTRL_SET_BANDCFG ||
priv->band_ctrl == BANDCTRL_2G_ONLY) {
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_radio_cfg));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
radio_cfg = (mlan_ds_radio_cfg *)req->pbuf;
radio_cfg->sub_command = MLAN_OID_BAND_CFG;
req->req_id = MLAN_IOCTL_RADIO_CFG;
/* Get fw supported values from MLAN */
req->action = MLAN_ACT_GET;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
if (ret != MLAN_STATUS_SUCCESS)
goto done;
if (priv->band_ctrl == BANDCTRL_SET_BANDCFG) {
band = radio_cfg->param.band_cfg.fw_bands;
} else {
band = BAND_B | BAND_G;
band |= BAND_GN;
band |= BAND_GAX;
}
/* Set config_bands to MLAN */
req->action = MLAN_ACT_SET;
memset(&radio_cfg->param.band_cfg, 0, sizeof(mlan_ds_band_cfg));
radio_cfg->param.band_cfg.config_bands = band;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
}
done:
if (req && (ret != MLAN_STATUS_PENDING))
kfree(req);
/* Stopping the previous background scan */
if (priv->sched_scanning == MTRUE) {
PRINTM(MMSG, "wlan: %s %s stop sch scan\n", __func__,
priv->netdev->name);
priv->bg_scan_start = MFALSE;
priv->bg_scan_reported = MFALSE;
woal_stop_bg_scan(priv, MOAL_IOCTL_WAIT);
#ifdef STA_CFG80211
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
cfg80211_wext = priv->phandle->params.cfg80211_wext;
if (IS_STA_CFG80211(cfg80211_wext)) {
woal_bgscan_stop_event(priv);
}
#endif
#endif
}
LEAVE();
return ret;
}
/**
* @brief flush scan table
*
* @param priv A pointer to moal_private structure
* @param band_select BAND_SELECT_2G_ONLY/BAND_SELECT_ALL
*
* @return MLAN_STATUS_SUCCESS -- success, otherwise fail
*/
mlan_status woal_flush_scan_table(moal_private *priv, t_u32 band_select)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_ioctl_req *req = NULL;
mlan_ds_scan *scan = NULL;
ENTER();
/* Allocate an IOCTL request buffer */
req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_scan));
if (req == NULL) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
scan = (mlan_ds_scan *)req->pbuf;
if (band_select == BAND_SELECT_2G_ONLY) {
scan->sub_command = MLAN_OID_SCAN_TABLE_FLUSH_WITH_BAND;
scan->param.band = BAND_A;
scan->param.band |= BAND_6G;
} else {
scan->sub_command = MLAN_OID_SCAN_TABLE_FLUSH;
}
req->req_id = MLAN_IOCTL_SCAN;
req->action = MLAN_ACT_SET;
ret = woal_request_ioctl(priv, req, MOAL_IOCTL_WAIT);
done:
if (ret != MLAN_STATUS_PENDING)
kfree(req);
LEAVE();
return ret;
}
/**
* @brief Add RX Filter
*

File diff suppressed because it is too large Load diff

View file

@ -69,6 +69,27 @@ Change log:
#include <linux/config.h>
#endif
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
#include <linux/bpf.h>
/*
* <------------------ First 256 Bytes of xdp frame ------------------->
* =====================================================================
* | 0 - 31 | 32 - 224 | 225 -254 | 255 |
* | occupied by frame | driver header | Reserved | occupied by frame|
* | initiator | | | initiator |
* =====================================================================
* XDP frame data pointer is decremented by WIFI_HEADER_START_OFFSET to add
* WIFI_HEADROOM bytes of driver header.
*/
#define XDP_RESERVED_BYTES 32
#define WIFI_HEADER_START_OFFSET (XDP_PACKET_HEADROOM - XDP_RESERVED_BYTES)
#define WIFI_HEADROOM (sizeof(mlan_buffer) + MLAN_MIN_DATA_HEADER_LEN)
/* XDP frame data start offset */
#define XDP_DATA_OFFSET 96
#endif
#endif
#ifdef USB
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
#include <linux/freezer.h>
@ -1800,6 +1821,13 @@ typedef struct _moal_priv_linkstats {
t_s16 noise;
} moal_priv_linkstats;
#define BANDCTRL_SET_BANDCFG MBIT(0)
#define BANDCTRL_BLOCK_SCAN MBIT(1)
#define BANDCTRL_2G_ONLY MBIT(2)
#define BAND_SELECT_ALL 0
#define BAND_SELECT_2G_ONLY 1
/** Private structure for MOAL */
struct _moal_private {
/** Handle structure */
@ -2229,6 +2257,16 @@ struct _moal_private {
t_u64 rx_airtime_base;
/*TX airtime count*/
t_u64 tx_airtime_base;
t_u32 band_ctrl;
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
/** xdp */
struct bpf_prog *xdp_prog;
struct xdp_rxq_info xdp_rxq;
#endif
#endif
};
#ifdef SDIO
@ -2848,10 +2886,12 @@ typedef struct _moal_mod_para {
int amsdu_deaggr;
int tx_budget;
int mclient_scheduling;
int copy_policy;
int ext_scan;
int bootup_cal_ctrl;
int ps_mode;
int p2a_scan;
int tcpackenh;
/** scan chan gap */
int scan_chan_gap;
int sched_scan;
@ -2923,6 +2963,11 @@ typedef struct _moal_mod_para {
int auto_11ax;
/** hs_auto_arp setting */
int hs_auto_arp;
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
int xdp;
#endif
#endif
/** Dual-BT **/
int dual_nb;
/* reject addba req config for HS or FW Auto-reconnect */
@ -2933,6 +2978,10 @@ typedef struct _moal_mod_para {
int tpe_ie_ignore;
/* make_before_break during roam */
int make_before_break;
int bandctrl;
/** plinkstats_cfg setting */
char *plinkstats;
} moal_mod_para;
void woal_tp_acnt_timer_func(void *context);
@ -3038,6 +3087,9 @@ typedef MLAN_PACK_START struct {
t_u16 nav_mitigation_th;
/* ch threshold to trigger channel switch for nighthawk */
t_u16 ch_th;
/* Channel switching is triggered only when the current pkts > the min
* average packet percentage. */
t_u16 min_pkt_percentage;
} MLAN_PACK_END wlan_agcs_info;
#endif /* UAP_SUPPORT */
@ -3466,7 +3518,9 @@ struct _moal_handle {
t_s8 driver_version[MLAN_MAX_VER_STR_LEN];
char *fwdump_fname;
#ifdef ANDROID_KERNEL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
struct wakeup_source *ws;
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
struct wakeup_source ws;
#else
struct wake_lock wake_lock;
@ -3544,6 +3598,8 @@ struct _moal_handle {
wlan_agcs_info agcs_info;
/* fw cap and cap_ext */
mlan_hw_info hw_info;
/* agcs scan event */
agcs_stats agcs_scan_event;
#endif /* UAP_SUPPORT */
#ifdef DUMP_TO_PROC
@ -3554,6 +3610,12 @@ struct _moal_handle {
t_u8 *ssu_dump_buf;
#endif
#endif
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
struct page *page;
t_u32 xdp_rd;
#endif
#endif
};
/**
@ -4212,17 +4274,26 @@ mlan_status woal_shutdown_fw(moal_private *priv, t_u8 wait_option);
/* Functions in interface module */
#ifdef ANDROID_KERNEL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
static inline void wakeup_source_init(struct device *dev,
struct wakeup_source **ws,
const char *name)
#else
static inline void wakeup_source_init(struct wakeup_source *ws,
const char *name)
#endif
{
ENTER();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
*ws = wakeup_source_register(dev, name);
#else
if (ws) {
memset(ws, 0, sizeof(*ws));
ws->name = name;
}
wakeup_source_add(ws);
#endif
LEAVE();
}
@ -4234,8 +4305,12 @@ static inline void wakeup_source_trash(struct wakeup_source *ws)
PRINTM(MERROR, "ws is null!\n");
return;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
wakeup_source_unregister(ws);
#else
wakeup_source_remove(ws);
__pm_relax(ws);
#endif
LEAVE();
}
@ -4692,6 +4767,8 @@ mlan_status woal_set_scan_time(moal_private *priv, t_u16 active_scan_time,
t_u16 specific_scan_time);
mlan_status woal_get_band(moal_private *priv, int *band);
mlan_status woal_set_band(moal_private *priv, char *pband);
mlan_status woal_set_bandctrl(moal_private *priv, t_u32 bandctrl);
mlan_status woal_flush_scan_table(moal_private *priv, t_u32 band_select);
mlan_status woal_add_rxfilter(moal_private *priv, char *rxfilter);
mlan_status woal_remove_rxfilter(moal_private *priv, char *rxfilter);
mlan_status woal_priv_qos_cfg(moal_private *priv, t_u32 action, char *qos_cfg);
@ -4935,7 +5012,8 @@ extern mlan_status moal_agcs_trans_state(moal_private *priv,
extern void woal_agcs_event(moal_private *priv, pagcs_event pacs_start_event);
#endif /* UAP_SUPPORT */
#if defined(USB) && defined(USB_CUSTOMER_VIDPID)
#if defined(USB)
extern mlan_status check_device_name_info(char *device_name, t_u16 *card_type);
extern mlan_status woal_get_c_vidpid(char **c_vidpid);
#endif
#endif /* _MOAL_MAIN_H */

View file

@ -557,7 +557,9 @@ err_init_fw:
handle->init_wait_q_woken);
}
#ifdef ANDROID_KERNEL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
wakeup_source_trash(handle->ws);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
wakeup_source_trash(&handle->ws);
#else
wake_lock_destroy(&handle->wake_lock);
@ -1479,6 +1481,8 @@ static mlan_status woal_pcie_init(pcie_service_card *card)
}
#endif
card->cache_alignment_mask = dma_get_cache_alignment() - 1;
ret = pci_request_region(pdev, 0, DRV_NAME);
if (ret) {
PRINTM(MERROR, "req_reg(0) error\n");
@ -1552,7 +1556,6 @@ static mlan_status woal_pcie_register_dev(moal_handle *handle)
card->handle = handle;
switch (pcie_int_mode) {
/* fall through */
case PCIE_INT_MODE_MSI:
pcie_int_mode = PCIE_INT_MODE_MSI;
ret = pci_enable_msi(pdev);
@ -1569,7 +1572,7 @@ static mlan_status woal_pcie_register_dev(moal_handle *handle)
}
// follow through
/* fall through */
fallthrough;
case PCIE_INT_MODE_LEGACY:
pcie_int_mode = PCIE_INT_MODE_LEGACY;
ret = request_irq(pdev->irq, woal_pcie_interrupt, IRQF_SHARED,
@ -3147,7 +3150,6 @@ static void woal_pcie_work(struct work_struct *work)
PRINTM(MMSG, "========START IN-BAND RESET===========\n");
woal_send_auto_recovery_start_event(handle);
// handle-> mac0 , ref_handle->second mac
if (handle->pref_mac) {
if (handle->second_mac) {

View file

@ -156,6 +156,7 @@ typedef struct _pcie_service_card {
void __iomem *pci_mmap;
/** I/O memory regions pointer to the bus */
void __iomem *pci_mmap1;
t_u32 cache_alignment_mask;
} pcie_service_card, *ppcie_service_card;
/** Register to bus driver function */

View file

@ -125,6 +125,9 @@ static int woal_associate_ssid_bssid(moal_private *priv, struct iwreq *wrq)
mac_idx++;
} else {
if (mac_idx < ETH_ALEN) {
/* Data inside buf is copied from user space and
* its length is bounded and validated before
* use */
// coverity[misra_c_2012_directive_4_14_violation:SUPPRESS]
ssid_bssid->bssid[mac_idx] =
(t_u8)woal_atox(buf + i);
@ -285,7 +288,7 @@ static int woal_get_signal(moal_private *priv, struct iwreq *wrq)
ret = -EINVAL;
goto done;
}
/* Fall through */
fallthrough;
case 1: /* Check type range */
if (in_data[0] < 1 || in_data[0] > 3) {
ret = -EINVAL;
@ -4086,7 +4089,8 @@ static int woal_set_get_ip_addr(moal_private *priv, struct iwreq *wrq)
misc->param.ipaddr_cfg.ip_addr_num = 1;
misc->param.ipaddr_cfg.ip_addr_type = IPADDR_TYPE_IPV4;
}
/* Data inside buf is copied from userspace and it's length is validated
* before use */
// coverity[misra_c_2012_directive_4_14_violation:SUPPRESS]
if (woal_atoi(&op_code, buf) != MLAN_STATUS_SUCCESS) {
ret = -EINVAL;
@ -5087,19 +5091,19 @@ static int woal_do_sdio_mpa_ctrl(moal_private *priv, struct iwreq *wrq)
switch (data_length) {
case 6:
misc->param.mpa_ctrl.rx_max_ports = data[5];
/* fall through */
fallthrough;
case 5:
misc->param.mpa_ctrl.tx_max_ports = data[4];
/* fall through */
fallthrough;
case 4:
misc->param.mpa_ctrl.rx_buf_size = data[3];
/* fall through */
fallthrough;
case 3:
misc->param.mpa_ctrl.tx_buf_size = data[2];
/* fall through */
fallthrough;
case 2:
misc->param.mpa_ctrl.rx_enable = data[1];
/* fall through */
fallthrough;
case 1:
/* Set cmd */
req->action = MLAN_ACT_SET;

View file

@ -3417,7 +3417,9 @@ err_init_fw:
handle->init_wait_q_woken);
}
#ifdef ANDROID_KERNEL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
wakeup_source_trash(handle->ws);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
wakeup_source_trash(&handle->ws);
#else
wake_lock_destroy(&handle->wake_lock);
@ -3487,7 +3489,6 @@ static void woal_sdiommc_work(struct work_struct *work)
PRINTM(MMSG, "========START IN-BAND RESET===========\n");
handle = card->handle;
woal_send_auto_recovery_start_event(handle);
// handle-> mac0 , ref_handle->second mac
if (handle->pref_mac) {
if (handle->second_mac) {

View file

@ -38,6 +38,11 @@ Change log:
#endif
#ifdef UAP_SUPPORT
#include "moal_uap.h"
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
#include <linux/filter.h>
#endif
#endif
#endif
#if defined(STA_CFG80211) || defined(UAP_CFG80211)
#include "moal_cfg80211_util.h"
@ -59,6 +64,13 @@ Change log:
#include <linux/crc32.h>
#if defined(UAP_SUPPORT) && defined(XDP_SUPPORT)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
static struct sk_buff *woal_process_xdp(moal_private *priv,
struct net_device *ndev,
pmlan_buffer pmbuf);
#endif
#endif
/********************************************************
Local Variables
********************************************************/
@ -242,6 +254,153 @@ mlan_status moal_malloc_consistent(t_void *pmoal, t_u32 size, t_u8 **ppbuf,
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Alloc a non-coherent block of memory
*
* @param pmoal Pointer to the MOAL context
* @param size The size of the buffer to be allocated
* @param ppbuf Pointer to a buffer location to store memory allocated
* @param pbuf_pa Pointer to a buffer location to store physical address
* of above memory
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status moal_malloc_cached(t_void *pmoal, t_u32 size, t_u8 **ppbuf,
t_pu64 pbuf_pa)
{
moal_handle *handle = (moal_handle *)pmoal;
pcie_service_card *card = (pcie_service_card *)handle->card;
dma_addr_t dma;
gfp_t flag;
*pbuf_pa = 0;
if (unlikely(!card))
return MLAN_STATUS_FAILURE;
flag = in_atomic() ? GFP_ATOMIC :
irqs_disabled() ? GFP_ATOMIC :
GFP_KERNEL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
*ppbuf = dma_alloc_noncoherent(&card->dev->dev, size, &dma,
DMA_BIDIRECTIONAL, flag);
#else
*ppbuf = dma_alloc_attrs(&card->dev->dev, size, &dma, flag,
DMA_ATTR_NON_CONSISTENT);
#endif
if (unlikely(*ppbuf == NULL)) {
PRINTM(MERROR,
"%s: allocate noncoherent memory (%d bytes) failed!\n",
__func__, (int)size);
return MLAN_STATUS_FAILURE;
}
*pbuf_pa = (t_u64)dma;
atomic_inc(&handle->malloc_cons_count);
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Free a non-coherent block of memory
*
* @param pmoal Pointer to the MOAL context
* @param size The size of the buffer to be freed
* @param pbuf Pointer to the buffer to be freed
* @param buf_pa Physical address of the buffer to be freed
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status moal_mfree_cached(t_void *pmoal, t_u32 size, t_u8 *pbuf,
t_u64 buf_pa)
{
moal_handle *handle = (moal_handle *)pmoal;
pcie_service_card *card = handle->card;
if (unlikely(!pbuf || !card))
return MLAN_STATUS_FAILURE;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
dma_free_noncoherent(&card->dev->dev, size, pbuf, buf_pa,
DMA_BIDIRECTIONAL);
#else
dma_free_attrs(&card->dev->dev, size, pbuf, buf_pa,
DMA_ATTR_NON_CONSISTENT);
#endif
atomic_dec(&handle->malloc_cons_count);
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Sync DMA buffer for CPU access
*
* @param pmoal Pointer to the MOAL context
* @param size Size of the buffer to sync
* @param buf_pa Physical address of the buffer
* @param direction DMA sync direction
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status moal_dma_sync_to_cpu(t_void *pmoal, t_u32 size, t_u64 buf_pa,
moal_dma_sync_direction_t direction)
{
moal_handle *handle = (moal_handle *)pmoal;
pcie_service_card *card = handle->card;
if (unlikely(!card))
return MLAN_STATUS_FAILURE;
size = (size + card->cache_alignment_mask) &
~card->cache_alignment_mask;
// make sure we have one-to-one mapping to Linux`s enum
// dma_data_direction
BUILD_BUG_ON((int)MOAL_DMA_SYNC_BIDIR != (int)DMA_BIDIRECTIONAL);
BUILD_BUG_ON((int)MOAL_DMA_SYNC_TO_DEVICE != (int)DMA_TO_DEVICE);
BUILD_BUG_ON((int)MOAL_DMA_SYNC_FROM_DEVICE != (int)DMA_FROM_DEVICE);
dma_sync_single_range_for_cpu(&card->dev->dev, buf_pa, 0, size,
(enum dma_data_direction)direction);
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Sync DMA buffer for device access
*
* @param pmoal Pointer to the MOAL context
* @param size Size of the buffer to sync
* @param buf_pa Physical address of the buffer
* @param direction DMA sync direction
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status moal_dma_sync_to_device(t_void *pmoal, t_u32 size, t_u64 buf_pa,
moal_dma_sync_direction_t direction)
{
moal_handle *handle = (moal_handle *)pmoal;
pcie_service_card *card = handle->card;
if (unlikely(!card))
return MLAN_STATUS_FAILURE;
size = (size + card->cache_alignment_mask) &
~card->cache_alignment_mask;
// make sure we have one-to-one mapping to Linux`s enum
// dma_data_direction
BUILD_BUG_ON((int)MOAL_DMA_SYNC_BIDIR != (int)DMA_BIDIRECTIONAL);
BUILD_BUG_ON((int)MOAL_DMA_SYNC_TO_DEVICE != (int)DMA_TO_DEVICE);
BUILD_BUG_ON((int)MOAL_DMA_SYNC_FROM_DEVICE != (int)DMA_FROM_DEVICE);
dma_sync_single_for_device(&card->dev->dev, buf_pa, size,
(enum dma_data_direction)direction);
return MLAN_STATUS_SUCCESS;
}
/**
* @brief Free a consistent block of memory
*
@ -1260,6 +1419,17 @@ mlan_status moal_send_packet_complete(t_void *pmoal, pmlan_buffer pmbuf,
#endif
ENTER();
#ifdef XDP_SUPPORT
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
if (pmbuf && (pmbuf->flags & MLAN_BUF_FLAG_XDP)) {
woal_free_mlan_buffer(handle, pmbuf);
atomic_dec(&handle->tx_pending);
return MLAN_STATUS_SUCCESS;
}
#endif
#endif
if (pmbuf && pmbuf->buf_type == MLAN_BUF_TYPE_RAW_DATA) {
woal_free_mlan_buffer(handle, pmbuf);
atomic_dec(&handle->tx_pending);
@ -2290,6 +2460,11 @@ mlan_status moal_recv_amsdu_packet(t_void *pmoal, pmlan_buffer pmbuf)
mlan_status status = MLAN_STATUS_FAILURE;
struct sk_buff *skb = NULL;
struct sk_buff *frame = NULL;
#if defined(UAP_SUPPORT) && defined(XDP_SUPPORT)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
struct sk_buff *xdp_skb = NULL;
#endif
#endif
int remaining;
const struct ethhdr *eth;
u8 dst[ETH_ALEN], src[ETH_ALEN];
@ -2437,6 +2612,17 @@ mlan_status moal_recv_amsdu_packet(t_void *pmoal, pmlan_buffer pmbuf)
dev_kfree_skb(frame);
continue;
}
#if defined(UAP_SUPPORT) && defined(XDP_SUPPORT)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
if (priv->xdp_prog) {
xdp_skb = woal_process_xdp(priv, priv->netdev, &mbuf);
if (xdp_skb)
napi_gro_receive(&handle->napi_rx, xdp_skb);
dev_kfree_skb(frame);
continue;
}
#endif
#endif
frame->protocol = eth_type_trans(frame, netdev);
frame->ip_summed = CHECKSUM_NONE;
@ -2516,6 +2702,74 @@ static t_u8 moal_user_priority_to_qos(t_u32 userPriority)
return aci;
}
#if defined(UAP_SUPPORT) && defined(XDP_SUPPORT)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
/**
* @brief This function acts based on action returned by bpf program
* XDP_DROP: drop packet
* XDP_PASS: upload packet to network stack
* XDP_REDIRECT: redirect packet to other XDP enabled interface
* @param pmoal Pointer to the MOAL context
* @param pmbuf Pointer to the mlan buffer structure
*
* @return NULL or sk_buff
*/
static struct sk_buff *woal_process_xdp(moal_private *priv,
struct net_device *ndev,
pmlan_buffer pmbuf)
{
t_u32 xdp_act;
struct xdp_buff xdp_buff;
struct sk_buff *skb = NULL;
struct page *page;
__u8 *data;
int ret = 0;
page = dev_alloc_page();
if (unlikely(!page))
netdev_err(ndev, "page alloc failed\n");
data = page_address(page);
memcpy(data + XDP_PACKET_HEADROOM, pmbuf->pbuf + pmbuf->data_offset,
pmbuf->data_len);
xdp_init_buff(&xdp_buff, PAGE_SIZE - XDP_PACKET_HEADROOM,
&priv->xdp_rxq);
xdp_prepare_buff(&xdp_buff, data, XDP_PACKET_HEADROOM, pmbuf->data_len,
false);
xdp_buff_clear_frags_flag(&xdp_buff);
xdp_act = bpf_prog_run_xdp(priv->xdp_prog, &xdp_buff);
switch (xdp_act) {
case XDP_DROP:
__free_page(page);
break;
case XDP_PASS:
skb = build_skb(xdp_buff.data_hard_start, PAGE_SIZE);
skb_reserve(skb, XDP_PACKET_HEADROOM);
skb_put(skb, xdp_buff.data_end - xdp_buff.data);
#if defined(CONFIG_PAGE_POOL)
skb_mark_for_recycle(skb);
#endif
skb->dev = ndev;
skb->protocol = eth_type_trans(skb, skb->dev);
skb->ip_summed = CHECKSUM_NONE;
return skb;
case XDP_REDIRECT:
ret = xdp_do_redirect(ndev, &xdp_buff, priv->xdp_prog);
if (ret)
PRINTM(MERROR, "XDP: redirect failed:%d\n", ret);
priv->phandle->xdp_rd++;
break;
default:
return skb;
}
return skb;
}
#endif
#endif
/**
* @brief This function uploads the packet to the network stack
*
@ -2570,6 +2824,16 @@ mlan_status moal_recv_packet(t_void *pmoal, pmlan_buffer pmbuf)
#endif
priv = woal_bss_index_to_priv(pmoal, pmbuf->bss_index);
#if defined(UAP_SUPPORT) && defined(XDP_SUPPORT)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
if (priv->xdp_prog) {
skb = woal_process_xdp(priv, priv->netdev, pmbuf);
if (skb)
napi_gro_receive(&handle->napi_rx, skb);
goto done;
}
#endif
#endif
skb = (struct sk_buff *)pmbuf->pdesc;
if (priv) {
if (skb) {
@ -2657,9 +2921,6 @@ mlan_status moal_recv_packet(t_void *pmoal, pmlan_buffer pmbuf)
"\n",
priv->netdev->name,
MAC2STR(ethh->h_source));
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
priv->deauth_evt_cnt = 0;
#endif
} else if (ntohs(ethh->h_proto) == NXP_ETH_P_WAPI) {
PRINTM(MEVENT,
"wlan: %s Rx WAPI pkt from " MACSTR "\n",
@ -2801,7 +3062,11 @@ mlan_status moal_recv_packet(t_void *pmoal, pmlan_buffer pmbuf)
#endif
#ifdef ANDROID_KERNEL
if (handle->params.wakelock_timeout) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
__pm_wakeup_event(
handle->ws,
handle->params.wakelock_timeout);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
__pm_wakeup_event(
&handle->ws,
handle->params.wakelock_timeout);
@ -3035,6 +3300,37 @@ static void woal_rx_mgmt_pkt_event(moal_private *priv, t_u8 *pkt, t_u16 len)
#endif
#endif
/**
* @brief Handle CSI STATUS event
*
* @param pmevent Pointer to the mlan event structure
*
* @return N/A
*/
static void woal_process_csi_status_report(pmlan_event pmevent)
{
csi_status_info *pcsi_status = (csi_status_info *)pmevent->event_buf;
if (pcsi_status->status == CSI_STATUS_ENABLED) {
PRINTM(MEVENT,
"csi status report: enable and start csi on channel %d \r\n",
pcsi_status->channel);
} else if (pcsi_status->status == CSI_STATUS_DISABLED) {
PRINTM(MEVENT, "csi status report: stop and disable csi \r\n");
} else if (pcsi_status->status == CSI_STATUS_CONFIG_WRONG) {
PRINTM(MEVENT,
"csi status report: channel or bandwidth config wrong \r\n");
} else if (pcsi_status->status == CSI_STATUS_INTERNAL_RESET) {
PRINTM(MEVENT,
"csi status report: FW internal restart csi on channel %d \r\n",
pcsi_status->channel);
} else if (pcsi_status->status == CSI_STATUS_INTERNAL_STOP) {
PRINTM(MEVENT, "csi status report: FW internal stop csi \r\n");
} else if (pcsi_status->status == CSI_STATUS_INTERNAL_DISABLED) {
PRINTM(MEVENT,
"csi status report: FW internal stop and disable csi, user should put in csi cmd to enable csi \r\n");
}
}
/**
* @brief This function handles rgpower key mismatch event
*
@ -3085,6 +3381,7 @@ static void woal_wifi_reset_event(moal_private *priv, t_u8 deauth_evt_cnt)
spin_unlock_irqrestore(&handle->evt_lock, flags);
queue_work(handle->evt_workqueue, &handle->evt_work);
}
/* evt is freed in woal_evt_work_queue, hence suppressed*/
// coverity[leaked_storage]: SUPPRESS
}
#endif
@ -4040,7 +4337,10 @@ mlan_status moal_recv_event(t_void *pmoal, pmlan_event pmevent)
) {
priv->roaming_required = MTRUE;
#ifdef ANDROID_KERNEL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
__pm_wakeup_event(priv->phandle->ws,
ROAMING_WAKE_LOCK_TIMEOUT);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
__pm_wakeup_event(&priv->phandle->ws,
ROAMING_WAKE_LOCK_TIMEOUT);
#else
@ -5446,7 +5746,13 @@ mlan_status moal_recv_event(t_void *pmoal, pmlan_event pmevent)
roam_info->req_ie_len = ie_len;
roam_info->resp_ie = pinfo->rsp_ie;
roam_info->resp_ie_len = pinfo->header.len;
cfg80211_roamed(priv->netdev, roam_info, GFP_KERNEL);
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
if (priv->wdev->u.client.ssid_len)
#else
if (priv->wdev->ssid_len)
#endif
cfg80211_roamed(priv->netdev, roam_info,
GFP_KERNEL);
kfree(roam_info);
}
#else
@ -5522,6 +5828,9 @@ mlan_status moal_recv_event(t_void *pmoal, pmlan_event pmevent)
custom_len + csi_len);
priv->csi_seq++;
break;
case MLAN_EVENT_ID_CSI_STATUS:
woal_process_csi_status_report(pmevent);
break;
case MLAN_EVENT_ID_DRV_RGPWR_KEY_MISMATCH:
if (handle->sec_rgpower)
woal_rgpower_key_mismatch_event(priv);
@ -5843,3 +6152,17 @@ inline void moal_write_unaligned_u32(void *dest, t_u32 val)
memcpy(dest, &val, sizeof(t_u32));
#endif
}
/**
* @brief This function generates crc through kernek API
*
* @param initial_crc Starting crc
* @param data A pointer to input data buffer
* @param len Length of the buffer
*
* @return crc value
*/
t_u32 moal_crc32_be(t_u32 initial_crc, t_u8 const *data, unsigned long len)
{
return crc32_be(initial_crc, data, len);
}

View file

@ -71,6 +71,15 @@ mlan_status moal_malloc_consistent(t_void *pmoal, t_u32 size, t_u8 **ppbuf,
t_pu64 pbuf_pa);
mlan_status moal_mfree_consistent(t_void *pmoal, t_u32 size, t_u8 *pbuf,
t_u64 buf_pa);
mlan_status moal_malloc_cached(t_void *pmoal, t_u32 size, t_u8 **ppbuf,
t_pu64 pbuf_pa);
mlan_status moal_mfree_cached(t_void *pmoal, t_u32 size, t_u8 *pbuf,
t_u64 buf_pa);
mlan_status moal_dma_sync_to_cpu(t_void *pmoal, t_u32 size, t_u64 buf_pa,
moal_dma_sync_direction_t direction);
mlan_status moal_dma_sync_to_device(t_void *pmoal, t_u32 size, t_u64 buf_pa,
moal_dma_sync_direction_t direction);
mlan_status moal_map_memory(t_void *pmoal, t_u8 *pbuf, t_u64 *pbuf_pa,
t_u32 size, t_u32 flag);
mlan_status moal_unmap_memory(t_void *pmoal, t_u8 *pbuf, t_u64 buf_pa,
@ -134,4 +143,6 @@ inline t_u32 moal_read_unaligned_u32(const void *src);
inline void moal_write_unaligned_u16(void *dest, t_u16 val);
inline void moal_write_unaligned_u32(void *dest, t_u32 val);
t_u32 moal_crc32_be(t_u32 initial_crc, t_u8 const *data, unsigned long len);
#endif /*_MOAL_H */

View file

@ -201,7 +201,7 @@ static int woal_cfg80211_get_tx_power(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
struct wireless_dev *wdev,
#endif
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 14, 0)
@ -213,7 +213,7 @@ static int woal_cfg80211_set_tx_power(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
struct wireless_dev *wdev,
#endif
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
#if CFG80211_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
@ -1560,15 +1560,30 @@ static mlan_status woal_dnld_chan_attr(moal_private *priv, t_bool is6g,
mlan_ds_misc_cfg *misc = NULL;
mlan_ds_chan_attr *ca = NULL;
mlan_ioctl_req *req = NULL;
#if defined(SD9098) || defined(PCIE9098) || defined(USB9098)
t_u8 card_type = 0;
#endif
mlan_status status = MLAN_STATUS_SUCCESS;
ENTER();
if (!priv || !priv->wdev || !priv->wdev->wiphy) {
if (!priv || !priv->phandle || !priv->wdev || !priv->wdev->wiphy) {
PRINTM(MERROR, "No priv or no wdev or wiphy in priv\n");
ret = MLAN_STATUS_FAILURE;
goto done;
}
#if defined(SD9098) || defined(PCIE9098) || defined(USB9098)
card_type = (priv->phandle->card_type) & 0xff;
if ((card_type == CARD_TYPE_9098) &&
(priv->phandle->second_mac == MTRUE)) {
/* Since 9098 has symmetrical MAC, no need to download
* channel flags again, as the FW will use the same
* channel attribute table for both MACs
*/
goto done;
}
#endif
wiphy = priv->wdev->wiphy;
/* Allocate an IOCTL request buffer */
@ -1961,6 +1976,14 @@ mlan_status woal_inform_bss_from_scan_result(moal_private *priv,
goto done;
}
if (priv->phandle->params.bandctrl) {
if (priv->band_ctrl & BANDCTRL_BLOCK_SCAN) {
/* when uap0 starts on 2.4GHz, don't report scan results
* to the kernel */
goto done;
}
}
if (scan_resp.num_in_scan_table) {
scan_table = (BSSDescriptor_t *)scan_resp.pscan_table;
for (i = 0; i < (int)scan_resp.num_in_scan_table; i++) {
@ -2482,6 +2505,15 @@ static int woal_cfg80211_auth_scan(moal_private *priv,
LEAVE();
return ret;
}
if (priv->phandle->params.bandctrl) {
if (priv->band_ctrl & BANDCTRL_BLOCK_SCAN) {
/* when uap0 starts on 2.4GHz, skip the auth scan */
LEAVE();
return ret;
}
}
#ifdef REASSOCIATION
if (MOAL_ACQ_SEMAPHORE_BLOCK(&handle->reassoc_sem)) {
PRINTM(MERROR, "Acquire semaphore error, woal_do_combo_scan\n");
@ -5659,6 +5691,8 @@ static int woal_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev,
continue;
}
#endif
// ssid_len is validated to ensure safe copying within SSID
// buffer size
// coverity[cert_arr30_c_violation: SUPPRESS]
moal_memcpy_ext(priv->phandle, scan_req->ssid_list[i].ssid,
priv->phandle->scan_request->ssids[i].ssid,
@ -5884,6 +5918,12 @@ static int woal_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev,
scan_req->keep_previous_scan =
wlan_check_scan_table_ageout(priv);
if (priv->phandle->params.bandctrl) {
if (priv->band_ctrl) {
scan_req->keep_previous_scan = MFALSE;
}
}
if (MLAN_STATUS_SUCCESS != woal_do_scan(priv, scan_req)) {
PRINTM(MERROR, "woal_do_scan fails!\n");
ret = -EAGAIN;
@ -7238,7 +7278,7 @@ static int woal_cfg80211_set_power_mgmt(struct wiphy *wiphy,
static int woal_cfg80211_get_tx_power(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
struct wireless_dev *wdev,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 14, 0)
@ -7292,7 +7332,7 @@ static int woal_cfg80211_set_tx_power(struct wiphy *wiphy,
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)
struct wireless_dev *wdev,
#endif
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(6, 17, 0)
int radio_idx,
#endif
#if CFG80211_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
@ -7796,6 +7836,15 @@ int woal_cfg80211_sched_scan_start(struct wiphy *wiphy, struct net_device *dev,
}
#endif
if (priv->phandle->params.bandctrl) {
if (priv->band_ctrl & BANDCTRL_BLOCK_SCAN) {
/* when uap0 starts on 2.4GHz, Sched scans are not
* permitted */
LEAVE();
return -EPERM;
}
}
memset(&priv->scan_cfg, 0, sizeof(priv->scan_cfg));
if (!request) {
PRINTM(MERROR, "Invalid sched_scan req parameter\n");
@ -8072,7 +8121,11 @@ int woal_cfg80211_resume(struct wiphy *wiphy)
handle->priv[i]->roaming_required =
MTRUE;
#ifdef ANDROID_KERNEL
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 16, 0)
__pm_wakeup_event(
handle->ws,
ROAMING_WAKE_LOCK_TIMEOUT);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)
__pm_wakeup_event(
&handle->ws,
ROAMING_WAKE_LOCK_TIMEOUT);
@ -11283,6 +11336,18 @@ mlan_status woal_register_sta_cfg80211(struct net_device *dev, t_u8 bss_type)
}
#endif
priv->phandle->band = band;
if (priv->wdev && priv->wdev->wiphy &&
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
!(priv->wdev->wiphy->regulatory_flags &
REGULATORY_WIPHY_SELF_MANAGED)
#endif
) {
woal_dnld_chan_attr(priv, MFALSE, MOAL_IOCTL_WAIT);
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
woal_dnld_chan_attr(priv, MTRUE, MOAL_IOCTL_WAIT);
#endif
}
}
LEAVE();
return ret;
@ -11565,6 +11630,138 @@ static void woal_update_channel_flag(struct wiphy *wiphy, mlan_fw_info *fw_info)
}
#endif
/**
* @brief Parse plinkstats parameter string into integer array
*
* @param input_str input string
* @param parsed_values Output array to store parsed integers
*
* @return Number of successfully parsed integers
*/
// coverity[HIS_RETURN:SUPPRESS]
int parse_plinkstats_args(const char *input_str, int *parsed_values)
{
int parsed_count = 0;
int ret = 0;
/* validate input string and parsed integers arguments*/
if (!input_str || !parsed_values) {
PRINTM(MERROR, "Invalid input to parse_plinkstats_args\n");
return -EINVAL;
} else {
parsed_count = sscanf(input_str, "%i,%i,%i,%i",
&parsed_values[0], &parsed_values[1],
&parsed_values[2], &parsed_values[3]);
}
/* validate parsed count, which shall not be 0 and negative*/
if (parsed_count <= 0) {
PRINTM(MERROR,
"parse_plinkstats_args: No valid integers found in input\n");
} else {
/*update return value which will be used for later length
* validation*/
ret = parsed_count;
}
return ret;
}
/**
* @brief Apply plinkstats configuration based on parsed arguments
*
* @param priv Pointer to moal_private structure
* @param args Parsed argument array
* @param len Number of parsed arguments
*
* @return N/A
*/
static void woal_apply_plinkstats_config(moal_private *priv, int *args, int len)
{
/* First assgined with default values */
priv->plinkstats_cfg.enable = MTRUE;
priv->plinkstats_cfg.filter = PRINT_LINTSTATS_FILTER;
priv->plinkstats_cfg.interval = PRINT_LINTSTATS_INTERVAL;
priv->plinkstats_cfg.netlink_evt = MFALSE;
/* Update arguments accordinly if there is more than two */
if (len >= 2 && args[1])
priv->plinkstats_cfg.filter = (t_u32)args[1];
if (len >= 3 && args[2])
priv->plinkstats_cfg.interval = (t_u16)args[2];
if (len >= 4 && args[3])
priv->plinkstats_cfg.netlink_evt = MTRUE;
/* Update drvdbg bit while plinkstats is enabled */
drvdbg |= MLSTATS;
woal_set_drvdbg(priv, drvdbg);
}
/**
* @brief Initialize link stats configuration based on plinkstats paramete
*
* @param priv A pointer to moal_private structure
*
* @return 0 -- success, otherwise fail
*/
// coverity[HIS_VOCF:SUPPRESS]
// coverity[HIS_RETURN:SUPPRESS]
int woal_priv_init_link_stats(moal_private *priv)
{
int ret = 0;
int plinkstats_arg[4] = {0};
int len = 0;
/* Parse and validate plinkstats arguments */
len = parse_plinkstats_args(priv->phandle->params.plinkstats,
plinkstats_arg);
/* Check if parsing failed */
if (len <= 0) {
PRINTM(MERROR, "Failed to parse plinkstats parameter\n");
return -EINVAL;
}
/* Validate argument count*/
if (len > 4) {
PRINTM(MERROR, "Too many arguments to plinkstats parameter\n");
ret = -EINVAL;
}
/* Validate argument values*/
if (plinkstats_arg[0] < 0 || plinkstats_arg[0] > 2 ||
plinkstats_arg[3] < 0 || plinkstats_arg[3] > 1) {
PRINTM(MERROR, "Invalid arguments for plinkstats parameter\n");
ret = -EINVAL;
}
if (!ret) {
switch (plinkstats_arg[0]) {
case 0: /* disable */
priv->plinkstats_cfg.enable = MFALSE;
/* Update drvdbg bit while plinkstats is disabled */
drvdbg &= ~MLSTATS;
woal_set_drvdbg(priv, drvdbg);
PRINTM(MMSG, "PLINKSTATS is disabled! \n");
break;
case 1: /* enable */
/* Init print_linkstats parameter according to the input
*/
woal_apply_plinkstats_config(priv, plinkstats_arg, len);
PRINTM(MMSG, "PLINKSTATS is Enabled \n");
break;
case 2: /* reset */
/* Reset link statistics */
woal_print_linkstats_info(priv, MTRUE);
PRINTM(MMSG, "PLINKSTATS is Restored \n");
break;
default: /* default for any error input */
PRINTM(MERROR, "Invalid PLINKSTATS parameter passed\n");
ret = -1;
break;
}
}
return ret;
}
/*
* This function registers the device with CFG802.11 subsystem.
*
@ -11792,6 +11989,7 @@ mlan_status woal_register_cfg80211(moal_private *priv)
wiphy->features |= NL80211_FEATURE_TDLS_CHANNEL_SWITCH;
#endif
#ifdef STA_CFG80211
#if CFG80211_VERSION_CODE > KERNEL_VERSION(4, 12, 14)
/* Enable support for offloading EAPOL handshakes for WPA/WPA2. */
if (!moal_extflg_isset(priv->phandle, EXT_HOST_MLME) &&
@ -11801,6 +11999,7 @@ mlan_status woal_register_cfg80211(moal_private *priv)
wiphy, NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK);
}
#endif
#endif
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
#define WLAN_EXT_FEATURE_DFS_OFFLOAD 25
@ -12268,16 +12467,20 @@ void woal_dnld_sta_6e_psd_table(moal_private *priv, t_u8 *resp_buf,
}
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[AP_MODE_IND].op_mode,
strlen(mode_psd_6G[AP_MODE_IND].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[AP_MODE_IND].psd_dbm,
strlen(mode_psd_6G[AP_MODE_IND].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[AP_MODE_IND].op_mode,
strlen(mode_psd_6G[AP_MODE_IND].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[AP_MODE_IND].psd_dbm,
strlen(mode_psd_6G[AP_MODE_IND].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
break;
}
/* Standard Power Mode */
@ -12306,16 +12509,20 @@ void woal_dnld_sta_6e_psd_table(moal_private *priv, t_u8 *resp_buf,
}
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[AP_MODE_SP].op_mode,
strlen(mode_psd_6G[AP_MODE_SP].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[AP_MODE_SP].psd_dbm,
strlen(mode_psd_6G[AP_MODE_SP].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[AP_MODE_SP].op_mode,
strlen(mode_psd_6G[AP_MODE_SP].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[AP_MODE_SP].psd_dbm,
strlen(mode_psd_6G[AP_MODE_SP].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
break;
}
/* Very Low Power Mode */
@ -12344,16 +12551,20 @@ void woal_dnld_sta_6e_psd_table(moal_private *priv, t_u8 *resp_buf,
}
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[AP_MODE_VLP].op_mode,
strlen(mode_psd_6G[AP_MODE_VLP].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[AP_MODE_VLP].psd_dbm,
strlen(mode_psd_6G[AP_MODE_VLP].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[AP_MODE_VLP].op_mode,
strlen(mode_psd_6G[AP_MODE_VLP].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[AP_MODE_VLP].psd_dbm,
strlen(mode_psd_6G[AP_MODE_VLP].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
break;
}
default:

View file

@ -3,7 +3,7 @@
* @brief This file contains the STA CFG80211 specific defines.
*
*
* Copyright 2011-2024 NXP
* Copyright 2011-2021, 2025 NXP
*
* This software file (the File) is distributed by NXP
* under the terms of the GNU General Public License Version 2, June 1991
@ -27,5 +27,7 @@
#define RSSI_DBM_TO_MDM(x) ((x)*100)
mlan_status woal_register_sta_cfg80211(struct net_device *dev, t_u8 bss_type);
int woal_priv_init_link_stats(moal_private *priv);
int parse_plinkstats_args(const char *input_str, int *parsed_values);
#endif /* _MOAL_STA_CFG80211_H_ */

View file

@ -4070,8 +4070,9 @@ static int woal_uap_ap_cfg_parse_data(moal_private *priv,
}
ap_cfg->ssid.ssid_len = strlen(value);
strncpy((char *)ap_cfg->ssid.ssid, value,
MIN(MLAN_MAX_SSID_LENGTH - 1,
strlen(value)));
MLAN_MAX_SSID_LENGTH - 1);
ap_cfg->ssid.ssid[MLAN_MAX_SSID_LENGTH - 1] =
'\0';
PRINTM(MINFO, "ssid=%s, len=%d\n",
ap_cfg->ssid.ssid,
(int)ap_cfg->ssid.ssid_len);

View file

@ -1415,16 +1415,20 @@ void woal_dnld_uap_6e_psd_table(moal_private *priv, const t_u8 *beacon_buf,
}
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[UAP_MODE_IND].op_mode,
strlen(mode_psd_6G[UAP_MODE_IND].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[UAP_MODE_IND].psd_dbm,
strlen(mode_psd_6G[UAP_MODE_IND].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[UAP_MODE_IND].op_mode,
strlen(mode_psd_6G[UAP_MODE_IND].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[UAP_MODE_IND].psd_dbm,
strlen(mode_psd_6G[UAP_MODE_IND].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
break;
}
/* Standard Power Mode */
@ -1459,16 +1463,20 @@ void woal_dnld_uap_6e_psd_table(moal_private *priv, const t_u8 *beacon_buf,
}
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[UAP_MODE_SP].op_mode,
strlen(mode_psd_6G[UAP_MODE_SP].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[UAP_MODE_SP].psd_dbm,
strlen(mode_psd_6G[UAP_MODE_SP].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[UAP_MODE_SP].op_mode,
strlen(mode_psd_6G[UAP_MODE_SP].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[UAP_MODE_SP].psd_dbm,
strlen(mode_psd_6G[UAP_MODE_SP].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
break;
}
/* Very Low Power Mode */
@ -1503,16 +1511,20 @@ void woal_dnld_uap_6e_psd_table(moal_private *priv, const t_u8 *beacon_buf,
}
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[UAP_MODE_VLP].op_mode,
strlen(mode_psd_6G[UAP_MODE_VLP].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_string,
mode_psd_6G[UAP_MODE_VLP].psd_dbm,
strlen(mode_psd_6G[UAP_MODE_VLP].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[UAP_MODE_VLP].op_mode,
strlen(mode_psd_6G[UAP_MODE_VLP].op_mode));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
strncat(priv->phandle->mode_psd_ru_string,
mode_psd_6G[UAP_MODE_VLP].psd_dbm,
strlen(mode_psd_6G[UAP_MODE_VLP].psd_dbm));
(sizeof(priv->phandle->mode_psd_string) -
strlen(priv->phandle->mode_psd_string) - 1));
break;
}
default:
@ -3652,6 +3664,7 @@ int woal_cfg80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
{
moal_private *priv = (moal_private *)woal_get_netdev_priv(dev);
int ret = 0;
t_u32 bandctrl = 0;
moal_private *sta_priv =
woal_get_priv_bss_type(priv->phandle, MLAN_BSS_TYPE_STA);
@ -3726,6 +3739,22 @@ int woal_cfg80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
ieee80211_frequency_to_channel(params->channel->center_freq);
#endif
#endif
if (priv->phandle->params.bandctrl) {
if (sta_priv) {
if ((priv->channel <= MAX_BG_CHANNEL)
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
&& (params->chandef.chan->band != NL80211_BAND_6GHZ)
#endif
) {
bandctrl = BANDCTRL_BLOCK_SCAN;
} else {
bandctrl = BANDCTRL_2G_ONLY;
}
woal_set_bandctrl(sta_priv, bandctrl);
}
}
/* bss config */
if (MLAN_STATUS_SUCCESS != woal_cfg80211_beacon_config(priv, params)) {
ret = -EFAULT;
@ -3931,9 +3960,8 @@ int woal_cfg80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
{
moal_private *priv = (moal_private *)woal_get_netdev_priv(dev);
int ret = 0;
#ifdef STA_SUPPORT
t_u32 bandctrl = 0;
moal_private *pmpriv = NULL;
#endif
#if CFG80211_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
moal_private *dfs_priv =
woal_get_priv_bss_type(priv->phandle, MLAN_BSS_TYPE_DFS);
@ -4059,6 +4087,14 @@ int woal_cfg80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
priv->multi_ap_flag = 0;
PRINTM(MMSG, "wlan: %s AP stopped\n", dev->name);
if (priv->phandle->params.bandctrl) {
pmpriv = woal_get_priv((moal_handle *)priv->phandle,
MLAN_BSS_ROLE_STA);
bandctrl = BANDCTRL_SET_BANDCFG;
woal_set_bandctrl(pmpriv, bandctrl);
}
done:
LEAVE();
return ret;

View file

@ -58,10 +58,8 @@ typedef struct {
/** Name of the USB driver */
static const char usbdriver_name[] = "usbxxx";
#ifdef USB_CUSTOMER_VIDPID
static struct usb_device_id *woal_usb_table_ext = NULL;
static usb_config_t customer_usb_config = {0x0};
#endif
/** This structure contains the device signature */
static struct usb_device_id woal_usb_table[] = {
@ -708,9 +706,7 @@ static t_u16 woal_update_card_type(t_void *card)
{
struct usb_card_rec *cardp_usb = (struct usb_card_rec *)card;
t_u16 card_type = 0;
#ifdef USB_CUSTOMER_VIDPID
char device_name[MAX_DEVICE_NAME];
#endif
/* Update card type */
#ifdef USB8897
@ -843,7 +839,6 @@ static t_u16 woal_update_card_type(t_void *card)
}
#endif
#ifdef USB_CUSTOMER_VIDPID
if (check_usb_ext_table_info(
device_name, &card_type,
woal_cpu_to_le16(cardp_usb->udev->descriptor.idProduct)) ==
@ -896,7 +891,6 @@ static t_u16 woal_update_card_type(t_void *card)
strlen(KERN_VERSION));
}
}
#endif
return card_type;
}
@ -934,12 +928,10 @@ static int woal_usb_probe(struct usb_interface *intf,
return -ENOMEM;
}
#ifdef USB_CUSTOMER_VIDPID
if (woal_usb_table_ext != NULL) {
PRINTM(MINFO, "Use usb table with customer vid pid\n");
usb_table = woal_usb_table_ext;
}
#endif
/* Check probe is for our device */
for (i = 0; usb_table[i].idVendor; i++) {
@ -1008,7 +1000,6 @@ static int woal_usb_probe(struct usb_interface *intf,
usb_cardp->boot_state = USB_FW_READY;
break;
#ifdef USB_CUSTOMER_VIDPID
default:
if (check_usb_ext_table_info(
NULL, NULL,
@ -1019,7 +1010,6 @@ static int woal_usb_probe(struct usb_interface *intf,
usb_cardp->boot_state = USB_FW_READY;
break;
#endif
}
/*To do, get card type*/
/* if
@ -1919,11 +1909,9 @@ mlan_status woal_usb_bus_register(void)
woal_usb_driver.id_table = woal_usb_table_skip_fwdnld;
}
#ifdef USB_CUSTOMER_VIDPID
if (woal_usb_table_ext != NULL) {
woal_usb_driver.id_table = woal_usb_table_ext;
}
#endif
/*
* API registers the NXP USB driver
* to the USB system
@ -1948,12 +1936,10 @@ void woal_usb_bus_unregister(void)
/* API unregisters the driver from USB subsystem */
usb_deregister(&woal_usb_driver);
#ifdef USB_CUSTOMER_VIDPID
if (woal_usb_table_ext != NULL) {
kfree(woal_usb_table_ext);
woal_usb_table_ext = NULL;
}
#endif
LEAVE();
return;
@ -2356,7 +2342,14 @@ done:
return ret;
}
#ifdef USB_CUSTOMER_VIDPID
/**
* @brief Parse a single line from USB configuration file
*
* @param line Input line to parse
* @param entry Array of USB configuration entries to populate
* @param current_entry_idx Pointer to current entry index
* @return 0 on success, negative error code on failure
*/
static int parse_config_line(char *line, usb_config_entry_t *entry,
t_u16 *current_entry_idx)
{
@ -2476,13 +2469,67 @@ static int parse_config_line(char *line, usb_config_entry_t *entry,
return 0;
}
/**
* @brief This function read a line in module parameter file
*
* @param data A pointer to module parameter data buffer
* @param size module parameter file size
* @param line_pos A pointer to offset of current line
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
static t_size parse_cfg_get_line(t_u8 *data, t_size size, t_u8 *line_pos)
{
t_u8 *src, *dest;
static t_s32 pos;
ENTER();
if ((pos >= (t_s32)size) || (data == NULL) ||
(line_pos == NULL)) { /* reach the end */
pos = 0; /* Reset position for rfkill */
LEAVE();
return -1;
}
memset(line_pos, 0, MAX_LINE_LEN);
src = data + pos;
dest = line_pos;
while (pos < (t_s32)size && *src != '\x0A' && *src != '\0') {
if ((dest - line_pos) >= (MAX_LINE_LEN - 1)) {
PRINTM(MERROR,
"error: input data size exceeds the dest buff limit\n");
LEAVE();
return -1;
}
if (*src != ' ' && *src != '\t') /* parse space */
*dest++ = *src++;
else
src++;
pos++;
}
/* parse new line */
pos++;
*dest = '\0';
LEAVE();
return strlen(line_pos);
}
/**
* @brief This function parses a USB configuration file to extract device
* entries and VID/PID pairs
*
* @param config_path A pointer to the configuration file path
* @param config A pointer to usb_config_t structure to store parsed
* configuration
* @return 0 on success, negative error code on failure
*/
static int parse_usb_config_file(const char *config_path, usb_config_t *config)
{
struct file *file;
t_u8 line[MAX_LINE_LEN];
loff_t pos = 0;
t_u8 line[MAX_LINE_LEN], *data = NULL;
t_u32 size;
int ret = 0;
t_u16 entry_idx = 0;
const struct firmware *config_data = NULL;
if (!config_path || !config) {
PRINTM(MERROR, "Invalid parameters\n");
@ -2491,40 +2538,22 @@ static int parse_usb_config_file(const char *config_path, usb_config_t *config)
memset(config, 0, sizeof(usb_config_t));
/* Open the configuration file */
file = filp_open(config_path, O_RDONLY, 0);
if (IS_ERR(file)) {
PRINTM(MERROR, "Failed to open config file: %s\n", config_path);
ret = PTR_ERR(file);
goto cleanup;
/* Load the configuration file */
ret = request_firmware(&config_data, config_path, NULL);
if (ret < 0 || (config_data == NULL)) {
PRINTM(MERROR, "Request config data: %s failed, error: %d\n",
config_path, ret);
return ret;
}
size = (t_u32)config_data->size;
// Casting is done to read and parse the data
// coverity[misra_c_2012_rule_11_8_violation:SUPPRESS]
data = (t_u8 *)config_data->data;
PRINTM(MINFO, "Parsing USB config file: %s\n", config_path);
/* Read file line by line */
while (1) {
int i = 0;
char c;
/* Read one line */
memset(line, 0, MAX_LINE_LEN);
while (i < MAX_LINE_LEN - 1) {
ret = kernel_read(file, &c, 1, &pos);
if (ret <= 0)
break;
if (c == '\n') {
line[i] = '\0';
break;
}
line[i++] = c;
}
if (ret <= 0 && i == 0)
break; /* End of file */
line[i] = '\0';
while ((int)parse_cfg_get_line(data, size, line) != -1) {
/* Parse the line */
ret = parse_config_line(line, config->entries, &entry_idx);
if (ret < 0) {
@ -2534,10 +2563,11 @@ static int parse_usb_config_file(const char *config_path, usb_config_t *config)
}
if (ret >= 0) {
int i, j;
config->total_entries = entry_idx;
/* Count total valid VID/PID pairs */
int i, j;
config->total_vid_pid_pairs = 0;
for (i = 0; i < config->total_entries; i++) {
for (j = 0; j < config->entries[i].vid_pid_count; j++) {
@ -2560,12 +2590,29 @@ static int parse_usb_config_file(const char *config_path, usb_config_t *config)
ret = 0;
}
filp_close(file, NULL);
if (config_data) {
release_firmware(config_data);
(void)parse_cfg_get_line(NULL, 0, NULL);
}
cleanup:
return ret;
}
/**
* extend_usb_table - Extend the USB device table with additional VID/PID pairs
* @table: Original USB device ID table
* @table_size: Size of the original table
* @config: USB configuration containing additional device entries
*
* This function creates an extended USB device table by combining the original
* table with additional VID/PID pairs from the configuration. It allocates a
* new table, copies the original entries, adds the new entries from config,
* and sets up the extended table for use.
*
* Return: 0 on success, negative error code on failure
* -EINVAL for invalid parameters or too many VID/PID pairs
* -ENOMEM for memory allocation failure
*/
static int extend_usb_table(struct usb_device_id *table, t_u32 table_size,
usb_config_t *config)
{
@ -2652,6 +2699,17 @@ static int extend_usb_table(struct usb_device_id *table, t_u32 table_size,
return 0;
}
/**
* woal_usb_init_extended_table - Initialize extended USB device table
* @config_path: Path to the USB configuration file
*
* This function extends the existing USB device table with additional
* VID/PID pairs from a configuration file. It first counts the original
* table size, parses the configuration file for new USB devices, and
* then extends the USB table with the additional entries.
*
* Return: 0 on success, negative error code on failure
*/
int woal_usb_init_extended_table(const char *config_path)
{
usb_config_t *config = &customer_usb_config;
@ -2690,6 +2748,18 @@ int woal_usb_init_extended_table(const char *config_path)
return 0;
}
/**
* check_usb_ext_table_info - Check USB extended table for device information
* @device_name: Buffer to store the device name (can be NULL)
* @card_type: Pointer to store the card type (can be NULL)
* @pid: Product ID to search for
*
* This function searches through the customer USB configuration table
* to find a matching product ID. If found, it retrieves the associated
* device name and card type information.
*
* Return: MLAN_STATUS_SUCCESS if device found, MLAN_STATUS_FAILURE otherwise
*/
mlan_status check_usb_ext_table_info(char *device_name, t_u16 *card_type,
t_u16 pid)
{
@ -2743,7 +2813,6 @@ mlan_status check_usb_ext_table_info(char *device_name, t_u16 *card_type,
return MLAN_STATUS_FAILURE;
}
#endif
static moal_if_ops usb_ops = {
.register_dev = woal_usb_register_dev,

View file

@ -264,11 +264,16 @@ struct usb_card_rec {
t_u8 second_mac;
};
#ifdef USB_CUSTOMER_VIDPID
#define MAX_CONFIG_ENTRIES 3
#define MAX_VID_PID_PAIRS 10
#define MAX_DEVICE_NAME 64
/**
* USB configuration entry structure
*
* Contains device information and associated VID/PID pairs for USB device
* identification and configuration.
*/
typedef struct {
char device_name[MAX_DEVICE_NAME];
t_u16 vid_pid_count; /* Actual number of VID/PID pairs found */
@ -278,12 +283,17 @@ typedef struct {
} vid_pid_pairs[MAX_VID_PID_PAIRS];
} usb_config_entry_t;
/**
* USB configuration table structure
*
* Contains the complete USB device configuration table with all entries
* and metadata about the total number of entries and VID/PID pairs.
*/
typedef struct {
usb_config_entry_t entries[MAX_CONFIG_ENTRIES];
t_u16 total_entries;
t_u16 total_vid_pid_pairs;
} usb_config_t;
#endif
void woal_kill_urbs(moal_handle *handle);
void woal_resubmit_urbs(moal_handle *handle);
@ -299,9 +309,7 @@ void woal_usb_bus_unregister(void);
mlan_status woal_usb_bus_register(void);
void woal_usb_free(struct usb_card_rec *cardp);
#ifdef USB_CUSTOMER_VIDPID
extern int woal_usb_init_extended_table(const char *config_path);
mlan_status check_usb_ext_table_info(char *device_name, t_u16 *card_type,
t_u16 pid);
#endif
#endif /*_MOAL_USB_H */