Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2023-04-19 10:51:04 +08:00
commit cfba336507
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
100 changed files with 1934 additions and 1805 deletions

View File

@ -1,2 +1,2 @@
LINUX_VERSION-5.15 = .106
LINUX_KERNEL_HASH-5.15.106 = 84e6934f828033570966e2a56fe8b72dc6e1409be296c66f4bf3c8ca6e3c8fe4
LINUX_VERSION-5.15 = .107
LINUX_KERNEL_HASH-5.15.107 = 19370e769045681f52cceedb14ecda97e89b1b058133a0c8ad45d35ffbc5afa8

View File

@ -177,8 +177,8 @@ else
( cd $(TARGET_DIR); find . | LC_ALL=C sort | $(STAGING_DIR_HOST)/bin/cpio --reproducible -o -H newc -R 0:0 > $(KERNEL_BUILD_DIR)/initrd.cpio )
endif
$(if $(SOURCE_DATE_EPOCH),touch -hcd "@$(SOURCE_DATE_EPOCH)" $(KERNEL_BUILD_DIR)/initrd.cpio)
$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),bzip2 -9 -c < $(KERNEL_BUILD_DIR)/initrd.cpio > $(KERNEL_BUILD_DIR)/initrd.cpio.bzip2)
$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),gzip -n -f -S .gzip -9n $(KERNEL_BUILD_DIR)/initrd.cpio)
$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),$(STAGING_DIR_HOST)/bin/bzip2 -9 -c < $(KERNEL_BUILD_DIR)/initrd.cpio > $(KERNEL_BUILD_DIR)/initrd.cpio.bzip2)
$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_GZIP),$(STAGING_DIR_HOST)/bin/libdeflate-gzip -n -f -S .gzip -12 $(KERNEL_BUILD_DIR)/initrd.cpio)
$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZ4),$(STAGING_DIR_HOST)/bin/lz4c -l -c1 -fz --favor-decSpeed $(KERNEL_BUILD_DIR)/initrd.cpio)
$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZMA),$(STAGING_DIR_HOST)/bin/lzma e -lc1 -lp2 -pb2 $(KERNEL_BUILD_DIR)/initrd.cpio $(KERNEL_BUILD_DIR)/initrd.cpio.lzma)
$(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZO),$(STAGING_DIR_HOST)/bin/lzop -9 -f $(KERNEL_BUILD_DIR)/initrd.cpio)

View File

@ -1446,8 +1446,7 @@ define KernelPackage/qrtr
DEPENDS:=@!LINUX_5_10
KCONFIG:=CONFIG_QRTR
FILES:= \
$(LINUX_DIR)/net/qrtr/qrtr.ko \
$(LINUX_DIR)/net/qrtr/ns.ko
$(LINUX_DIR)/net/qrtr/qrtr.ko
AUTOLOAD:=$(call AutoProbe,qrtr)
endef

View File

@ -10,11 +10,11 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=mac80211
PKG_VERSION:=6.1-rc8
PKG_RELEASE:=3
PKG_VERSION:=6.1.24
PKG_RELEASE:=1
# PKG_SOURCE_URL:=@KERNEL/linux/kernel/projects/backports/stable/v5.15.58/
PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources/
PKG_HASH:=7f3d96c2573183cd79d6a3ebe5e1b7b73c19d1326d443c85b69c4181f14e6e2b
PKG_HASH:=5d39aca7e34c33cb9b3e366117b2e86841b7bdd37933679d6b1e61be6b150648
PKG_SOURCE:=backports-$(PKG_VERSION).tar.xz
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/backports-$(PKG_VERSION)

View File

@ -14,7 +14,7 @@ Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -3500,6 +3500,16 @@ int ath10k_core_register(struct ath10k *
@@ -3516,6 +3516,16 @@ int ath10k_core_register(struct ath10k *
queue_work(ar->workqueue, &ar->register_work);

View File

@ -140,7 +140,7 @@ v13:
.patch_load_addr = QCA988X_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -144,6 +146,7 @@ static const struct ath10k_hw_params ath
@@ -146,6 +148,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9887_1_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9887 hw1.0",
@ -148,7 +148,7 @@ v13:
.patch_load_addr = QCA9887_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_ALL,
@@ -379,6 +382,7 @@ static const struct ath10k_hw_params ath
@@ -387,6 +390,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA99X0_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca99x0 hw2.0",
@ -156,7 +156,7 @@ v13:
.patch_load_addr = QCA99X0_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.otp_exe_param = 0x00000700,
@@ -424,6 +428,7 @@ static const struct ath10k_hw_params ath
@@ -433,6 +437,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9984_1_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9984/qca9994 hw1.0",
@ -164,7 +164,7 @@ v13:
.patch_load_addr = QCA9984_HW_1_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
@@ -476,6 +481,7 @@ static const struct ath10k_hw_params ath
@@ -486,6 +491,7 @@ static const struct ath10k_hw_params ath
.dev_id = QCA9888_2_0_DEVICE_ID,
.bus = ATH10K_BUS_PCI,
.name = "qca9888 hw2.0",
@ -172,7 +172,7 @@ v13:
.patch_load_addr = QCA9888_HW_2_0_PATCH_LOAD_ADDR,
.uart_pin = 7,
.cc_wraparound_type = ATH10K_HW_CC_WRAP_SHIFTED_EACH,
@@ -3215,6 +3221,10 @@ int ath10k_core_start(struct ath10k *ar,
@@ -3231,6 +3237,10 @@ int ath10k_core_start(struct ath10k *ar,
goto err_hif_stop;
}
@ -183,7 +183,7 @@ v13:
return 0;
err_hif_stop:
@@ -3473,9 +3483,18 @@ static void ath10k_core_register_work(st
@@ -3489,9 +3499,18 @@ static void ath10k_core_register_work(st
goto err_spectral_destroy;
}
@ -202,7 +202,7 @@ v13:
err_spectral_destroy:
ath10k_spectral_destroy(ar);
err_debug_destroy:
@@ -3521,6 +3540,8 @@ void ath10k_core_unregister(struct ath10
@@ -3537,6 +3556,8 @@ void ath10k_core_unregister(struct ath10
if (!test_bit(ATH10K_FLAG_CORE_REGISTERED, &ar->dev_flags))
return;

View File

@ -26,7 +26,7 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
#include <linux/property.h>
#include <linux/dmi.h>
#include <linux/ctype.h>
@@ -3391,6 +3392,8 @@ static int ath10k_core_probe_fw(struct a
@@ -3407,6 +3408,8 @@ static int ath10k_core_probe_fw(struct a
device_get_mac_address(ar->dev, ar->mac_addr);

View File

@ -56,7 +56,7 @@ Link: https://lore.kernel.org/r/20220923170235.18873-1-quic_adisi@quicinc.com
ath11k_err(ab, "failed to reconfigure driver on crash recovery\n");
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -1157,6 +1157,7 @@ int ath11k_core_check_smbios(struct ath1
@@ -1158,6 +1158,7 @@ int ath11k_core_check_smbios(struct ath1
void ath11k_core_halt(struct ath11k *ar);
int ath11k_core_resume(struct ath11k_base *ab);
int ath11k_core_suspend(struct ath11k_base *ab);
@ -66,7 +66,7 @@ Link: https://lore.kernel.org/r/20220923170235.18873-1-quic_adisi@quicinc.com
const char *filename);
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -3158,6 +3158,9 @@ static void ath11k_qmi_driver_event_work
@@ -3164,6 +3164,9 @@ static void ath11k_qmi_driver_event_work
case ATH11K_QMI_EVENT_SERVER_EXIT:
set_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags);
set_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags);

View File

@ -1,139 +0,0 @@
From f74878433d5ade360447da5d92e9c2e535780d80 Mon Sep 17 00:00:00 2001
From: Wen Gong <quic_wgong@quicinc.com>
Date: Wed, 28 Sep 2022 03:38:32 -0400
Subject: [PATCH] wifi: ath11k: fix warning in dma_free_coherent() of memory
chunks while recovery
Commit 26f3a021b37c ("ath11k: allocate smaller chunks of memory for
firmware") and commit f6f92968e1e5 ("ath11k: qmi: try to allocate a
big block of DMA memory first") change ath11k to allocate the memory
chunks for target twice while wlan load. It fails for the 1st time
because of large memory and then changed to allocate many small chunks
for the 2nd time sometimes as below log.
1st time failed:
[10411.640620] ath11k_pci 0000:05:00.0: qmi firmware request memory request
[10411.640625] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 6881280
[10411.640630] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 3784704
[10411.640658] ath11k_pci 0000:05:00.0: qmi dma allocation failed (6881280 B type 1), will try later with small size
[10411.640671] ath11k_pci 0000:05:00.0: qmi delays mem_request 2
[10411.640677] ath11k_pci 0000:05:00.0: qmi respond memory request delayed 1
2nd time success:
[10411.642004] ath11k_pci 0000:05:00.0: qmi firmware request memory request
[10411.642008] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642012] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642014] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642016] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642018] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642020] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642022] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642024] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642027] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642029] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
[10411.642031] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 458752
[10411.642033] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 131072
[10411.642035] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
[10411.642037] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
[10411.642039] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
[10411.642041] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
[10411.642043] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
[10411.642045] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 524288
[10411.642047] ath11k_pci 0000:05:00.0: qmi mem seg type 4 size 491520
[10411.642049] ath11k_pci 0000:05:00.0: qmi mem seg type 1 size 524288
And then commit 5962f370ce41 ("ath11k: Reuse the available memory after
firmware reload") skip the ath11k_qmi_free_resource() which frees the
memory chunks while recovery, after that, when run recovery test on
WCN6855, a warning happened every time as below and finally leads fail
for recovery.
[ 159.570318] BUG: Bad page state in process kworker/u16:5 pfn:33300
[ 159.570320] page:0000000096ffdbb9 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x33300
[ 159.570324] flags: 0xfffffc0000000(node=0|zone=1|lastcpupid=0x1fffff)
[ 159.570329] raw: 000fffffc0000000 0000000000000000 dead000000000122 0000000000000000
[ 159.570332] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
[ 159.570334] page dumped because: nonzero _refcount
[ 159.570440] firewire_ohci syscopyarea sysfillrect psmouse sdhci_pci ahci sysimgblt firewire_core fb_sys_fops libahci crc_itu_t cqhci drm sdhci e1000e wmi video
[ 159.570460] CPU: 2 PID: 217 Comm: kworker/u16:5 Kdump: loaded Tainted: G B 5.19.0-rc1-wt-ath+ #3
[ 159.570465] Hardware name: LENOVO 418065C/418065C, BIOS 83ET63WW (1.33 ) 07/29/2011
[ 159.570467] Workqueue: qmi_msg_handler qmi_data_ready_work [qmi_helpers]
[ 159.570475] Call Trace:
[ 159.570476] <TASK>
[ 159.570478] dump_stack_lvl+0x49/0x5f
[ 159.570486] dump_stack+0x10/0x12
[ 159.570493] bad_page+0xab/0xf0
[ 159.570502] check_free_page_bad+0x66/0x70
[ 159.570511] __free_pages_ok+0x530/0x9a0
[ 159.570517] ? __dev_printk+0x58/0x6b
[ 159.570525] ? _dev_printk+0x56/0x72
[ 159.570534] ? qmi_decode+0x119/0x470 [qmi_helpers]
[ 159.570543] __free_pages+0x91/0xd0
[ 159.570548] dma_free_contiguous+0x50/0x60
[ 159.570556] dma_direct_free+0xe5/0x140
[ 159.570564] dma_free_attrs+0x35/0x50
[ 159.570570] ath11k_qmi_msg_mem_request_cb+0x2ae/0x3c0 [ath11k]
[ 159.570620] qmi_invoke_handler+0xac/0xe0 [qmi_helpers]
[ 159.570630] qmi_handle_message+0x6d/0x180 [qmi_helpers]
[ 159.570643] qmi_data_ready_work+0x2ca/0x440 [qmi_helpers]
[ 159.570656] process_one_work+0x227/0x440
[ 159.570667] worker_thread+0x31/0x3d0
[ 159.570676] ? process_one_work+0x440/0x440
[ 159.570685] kthread+0xfe/0x130
[ 159.570692] ? kthread_complete_and_exit+0x20/0x20
[ 159.570701] ret_from_fork+0x22/0x30
[ 159.570712] </TASK>
The reason is because when wlan start to recovery, the type, size and
count is not same for the 1st and 2nd QMI_WLFW_REQUEST_MEM_IND message,
Then it leads the parameter size is not correct for the dma_free_coherent().
For the chunk[1], the actual dma size is 524288 which allocate in the
2nd time of the initial wlan load phase, and the size which pass to
dma_free_coherent() is 3784704 which is got in the 1st time of recovery
phase, then warning above happened.
Change to use prev_size of struct target_mem_chunk for the paramter of
dma_free_coherent() since prev_size is the real size of last load/recovery.
Also change to check both type and size of struct target_mem_chunk to
reuse the memory to avoid mismatch buffer size for target. Then the
warning disappear and recovery success. When the 1st QMI_WLFW_REQUEST_MEM_IND
for recovery arrived, the trunk[0] is freed in ath11k_qmi_alloc_target_mem_chunk()
and then dma_alloc_coherent() failed caused by large size, and then
trunk[1] is freed in ath11k_qmi_free_target_mem_chunk(), the left 18
trunks will be reuse for the 2nd QMI_WLFW_REQUEST_MEM_IND message.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
Fixes: 5962f370ce41 ("ath11k: Reuse the available memory after firmware reload")
Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220928073832.16251-1-quic_wgong@quicinc.com
---
drivers/net/wireless/ath/ath11k/qmi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -1961,7 +1961,7 @@ static void ath11k_qmi_free_target_mem_c
continue;
dma_free_coherent(ab->dev,
- ab->qmi.target_mem[i].size,
+ ab->qmi.target_mem[i].prev_size,
ab->qmi.target_mem[i].vaddr,
ab->qmi.target_mem[i].paddr);
ab->qmi.target_mem[i].vaddr = NULL;
@@ -1982,12 +1982,12 @@ static int ath11k_qmi_alloc_target_mem_c
* in such case, no need to allocate memory for FW again.
*/
if (chunk->vaddr) {
- if (chunk->prev_type == chunk->type ||
+ if (chunk->prev_type == chunk->type &&
chunk->prev_size == chunk->size)
continue;
/* cannot reuse the existing chunk */
- dma_free_coherent(ab->dev, chunk->size,
+ dma_free_coherent(ab->dev, chunk->prev_size,
chunk->vaddr, chunk->paddr);
chunk->vaddr = NULL;
}

View File

@ -1,225 +0,0 @@
From 3ff51d7416ee1ea2d771051a0ffa1ec8be054768 Mon Sep 17 00:00:00 2001
From: Aditya Kumar Singh <quic_adisi@quicinc.com>
Date: Wed, 5 Oct 2022 15:24:30 +0530
Subject: [PATCH 6/9] wifi: ath11k: fix firmware assert during bandwidth change
for peer sta
Currently, ath11k sends peer assoc command for each peer to
firmware when bandwidth changes. Peer assoc command is a
bulky command and if many clients are connected, this could
lead to firmware buffer getting overflowed leading to a firmware
assert.
However, during bandwidth change, only phymode and bandwidth
also can be updated by WMI set peer param command. This makes
the overall command light when compared to peer assoc and for
multi-client cases, firmware buffer overflow also does not
occur.
Remove sending peer assoc command during sta bandwidth change
and instead add sending WMI set peer param command for phymode
and bandwidth.
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01100-QCAHKSWPL_SILICONZ-1
Fixes: f187fe8e3bc65 ("ath11k: fix firmware crash during channel switch")
Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20221005095430.19890-1-quic_adisi@quicinc.com
---
drivers/net/wireless/ath/ath11k/core.h | 2 +
drivers/net/wireless/ath/ath11k/mac.c | 122 +++++++++++++++++--------
2 files changed, 87 insertions(+), 37 deletions(-)
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -505,6 +505,8 @@ struct ath11k_sta {
u64 ps_start_jiffies;
u64 ps_total_duration;
bool peer_current_ps_valid;
+
+ u32 bw_prev;
};
#define ATH11K_MIN_5G_FREQ 4150
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -4215,10 +4215,11 @@ static void ath11k_sta_rc_update_wk(stru
const u8 *ht_mcs_mask;
const u16 *vht_mcs_mask;
const u16 *he_mcs_mask;
- u32 changed, bw, nss, smps;
+ u32 changed, bw, nss, smps, bw_prev;
int err, num_vht_rates, num_he_rates;
const struct cfg80211_bitrate_mask *mask;
struct peer_assoc_params peer_arg;
+ enum wmi_phy_mode peer_phymode;
arsta = container_of(wk, struct ath11k_sta, update_wk);
sta = container_of((void *)arsta, struct ieee80211_sta, drv_priv);
@@ -4239,6 +4240,7 @@ static void ath11k_sta_rc_update_wk(stru
arsta->changed = 0;
bw = arsta->bw;
+ bw_prev = arsta->bw_prev;
nss = arsta->nss;
smps = arsta->smps;
@@ -4252,26 +4254,57 @@ static void ath11k_sta_rc_update_wk(stru
ath11k_mac_max_he_nss(he_mcs_mask)));
if (changed & IEEE80211_RC_BW_CHANGED) {
- /* Send peer assoc command before set peer bandwidth param to
- * avoid the mismatch between the peer phymode and the peer
- * bandwidth.
- */
- ath11k_peer_assoc_prepare(ar, arvif->vif, sta, &peer_arg, true);
+ /* Get the peer phymode */
+ ath11k_peer_assoc_h_phymode(ar, arvif->vif, sta, &peer_arg);
+ peer_phymode = peer_arg.peer_phymode;
+
+ ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac update sta %pM peer bw %d phymode %d\n",
+ sta->addr, bw, peer_phymode);
+
+ if (bw > bw_prev) {
+ /* BW is upgraded. In this case we send WMI_PEER_PHYMODE
+ * followed by WMI_PEER_CHWIDTH
+ */
+ ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac BW upgrade for sta %pM new BW %d, old BW %d\n",
+ sta->addr, bw, bw_prev);
+
+ err = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id,
+ WMI_PEER_PHYMODE, peer_phymode);
+
+ if (err) {
+ ath11k_warn(ar->ab, "failed to update STA %pM peer phymode %d: %d\n",
+ sta->addr, peer_phymode, err);
+ goto err_rc_bw_changed;
+ }
- peer_arg.is_assoc = false;
- err = ath11k_wmi_send_peer_assoc_cmd(ar, &peer_arg);
- if (err) {
- ath11k_warn(ar->ab, "failed to send peer assoc for STA %pM vdev %i: %d\n",
- sta->addr, arvif->vdev_id, err);
- } else if (wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) {
err = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id,
WMI_PEER_CHWIDTH, bw);
+
if (err)
ath11k_warn(ar->ab, "failed to update STA %pM peer bw %d: %d\n",
sta->addr, bw, err);
} else {
- ath11k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n",
- sta->addr, arvif->vdev_id);
+ /* BW is downgraded. In this case we send WMI_PEER_CHWIDTH
+ * followed by WMI_PEER_PHYMODE
+ */
+ ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "mac BW downgrade for sta %pM new BW %d,old BW %d\n",
+ sta->addr, bw, bw_prev);
+
+ err = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id,
+ WMI_PEER_CHWIDTH, bw);
+
+ if (err) {
+ ath11k_warn(ar->ab, "failed to update STA %pM peer bw %d: %d\n",
+ sta->addr, bw, err);
+ goto err_rc_bw_changed;
+ }
+
+ err = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id,
+ WMI_PEER_PHYMODE, peer_phymode);
+
+ if (err)
+ ath11k_warn(ar->ab, "failed to update STA %pM peer phymode %d: %d\n",
+ sta->addr, peer_phymode, err);
}
}
@@ -4352,6 +4385,7 @@ static void ath11k_sta_rc_update_wk(stru
}
}
+err_rc_bw_changed:
mutex_unlock(&ar->conf_mutex);
}
@@ -4505,6 +4539,34 @@ exit:
return ret;
}
+static u32 ath11k_mac_ieee80211_sta_bw_to_wmi(struct ath11k *ar,
+ struct ieee80211_sta *sta)
+{
+ u32 bw = WMI_PEER_CHWIDTH_20MHZ;
+
+ switch (sta->deflink.bandwidth) {
+ case IEEE80211_STA_RX_BW_20:
+ bw = WMI_PEER_CHWIDTH_20MHZ;
+ break;
+ case IEEE80211_STA_RX_BW_40:
+ bw = WMI_PEER_CHWIDTH_40MHZ;
+ break;
+ case IEEE80211_STA_RX_BW_80:
+ bw = WMI_PEER_CHWIDTH_80MHZ;
+ break;
+ case IEEE80211_STA_RX_BW_160:
+ bw = WMI_PEER_CHWIDTH_160MHZ;
+ break;
+ default:
+ ath11k_warn(ar->ab, "Invalid bandwidth %d for %pM\n",
+ sta->deflink.bandwidth, sta->addr);
+ bw = WMI_PEER_CHWIDTH_20MHZ;
+ break;
+ }
+
+ return bw;
+}
+
static int ath11k_mac_op_sta_state(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
@@ -4590,6 +4652,12 @@ static int ath11k_mac_op_sta_state(struc
if (ret)
ath11k_warn(ar->ab, "Failed to associate station: %pM\n",
sta->addr);
+
+ spin_lock_bh(&ar->data_lock);
+ /* Set arsta bw and prev bw */
+ arsta->bw = ath11k_mac_ieee80211_sta_bw_to_wmi(ar, sta);
+ arsta->bw_prev = arsta->bw;
+ spin_unlock_bh(&ar->data_lock);
} else if (old_state == IEEE80211_STA_ASSOC &&
new_state == IEEE80211_STA_AUTHORIZED) {
spin_lock_bh(&ar->ab->base_lock);
@@ -4713,28 +4781,8 @@ static void ath11k_mac_op_sta_rc_update(
spin_lock_bh(&ar->data_lock);
if (changed & IEEE80211_RC_BW_CHANGED) {
- bw = WMI_PEER_CHWIDTH_20MHZ;
-
- switch (sta->deflink.bandwidth) {
- case IEEE80211_STA_RX_BW_20:
- bw = WMI_PEER_CHWIDTH_20MHZ;
- break;
- case IEEE80211_STA_RX_BW_40:
- bw = WMI_PEER_CHWIDTH_40MHZ;
- break;
- case IEEE80211_STA_RX_BW_80:
- bw = WMI_PEER_CHWIDTH_80MHZ;
- break;
- case IEEE80211_STA_RX_BW_160:
- bw = WMI_PEER_CHWIDTH_160MHZ;
- break;
- default:
- ath11k_warn(ar->ab, "Invalid bandwidth %d in rc update for %pM\n",
- sta->deflink.bandwidth, sta->addr);
- bw = WMI_PEER_CHWIDTH_20MHZ;
- break;
- }
-
+ bw = ath11k_mac_ieee80211_sta_bw_to_wmi(ar, sta);
+ arsta->bw_prev = arsta->bw;
arsta->bw = bw;
}

View File

@ -1,39 +0,0 @@
From 3f9b09ccf7d5f23066b02881a737bee42def9d1a Mon Sep 17 00:00:00 2001
From: Baochen Qiang <quic_bqiang@quicinc.com>
Date: Mon, 10 Oct 2022 11:32:37 +0800
Subject: [PATCH 9/9] wifi: ath11k: Send PME message during wakeup from D3cold
We are seeing system stuck on some specific platforms due to
WLAN chip fails to wakeup from D3cold state.
With this flag, firmware will send PME message during wakeup
and this issue is gone.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3
Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20221010033237.415478-1-quic_bqiang@quicinc.com
---
drivers/net/wireless/ath/ath11k/qmi.c | 3 +++
1 file changed, 3 insertions(+)
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -19,6 +19,7 @@
#define SLEEP_CLOCK_SELECT_INTERNAL_BIT 0x02
#define HOST_CSTATE_BIT 0x04
#define PLATFORM_CAP_PCIE_GLOBAL_RESET 0x08
+#define PLATFORM_CAP_PCIE_PME_D3COLD 0x10
#define FW_BUILD_ID_MASK "QC_IMAGE_VERSION_STRING="
@@ -1752,6 +1753,8 @@ static int ath11k_qmi_host_cap_send(stru
if (ab->hw_params.global_reset)
req.nm_modem |= PLATFORM_CAP_PCIE_GLOBAL_RESET;
+ req.nm_modem |= PLATFORM_CAP_PCIE_PME_D3COLD;
+
ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi host cap request\n");
ret = qmi_txn_init(&ab->qmi.handle, &txn,

View File

@ -21,13 +21,13 @@ Link: https://lore.kernel.org/r/20221021090126.28626-1-quic_rbhattac@quicinc.com
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -3090,6 +3090,9 @@ static const struct qmi_msg_handler ath1
sizeof(struct qmi_wlfw_fw_init_done_ind_msg_v01),
.fn = ath11k_qmi_msg_fw_init_done_cb,
@@ -1702,6 +1702,9 @@ static struct qmi_elem_info qmi_wlfw_fw_
.data_type = QMI_EOTI,
.array_type = NO_ARRAY,
},
+
+ /* end of list */
+ {},
};
static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl,
static int ath11k_qmi_host_cap_send(struct ath11k_base *ab)

View File

@ -34,7 +34,7 @@ Link: https://lore.kernel.org/r/20221122132152.17771-4-quic_kathirve@quicinc.com
.rx_mac_buf_ring = false,
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -1146,6 +1146,9 @@ extern const struct service_to_pipe ath1
@@ -1145,6 +1145,9 @@ extern const struct service_to_pipe ath1
extern const struct ce_pipe_config ath11k_target_ce_config_wlan_qca6390[];
extern const struct service_to_pipe ath11k_target_service_to_ce_map_wlan_qca6390[];

View File

@ -1,79 +0,0 @@
From 950b43f8bd8a4d476d2da6d2a083a89bcd3c90d7 Mon Sep 17 00:00:00 2001
From: Nagarajan Maran <quic_nmaran@quicinc.com>
Date: Tue, 29 Nov 2022 19:55:32 +0530
Subject: [PATCH] wifi: ath11k: fix monitor mode bringup crash
When the interface is brought up in monitor mode, it leads
to NULL pointer dereference crash. This crash happens when
the packet type is extracted for a SKB. This extraction
which is present in the received msdu delivery path,is
not needed for the monitor ring packets since they are
all RAW packets. Hence appending the flags with
"RX_FLAG_ONLY_MONITOR" to skip that extraction.
Observed calltrace:
Unable to handle kernel NULL pointer dereference at virtual address
0000000000000064
Mem abort info:
ESR = 0x0000000096000004
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x04: level 0 translation fault
Data abort info:
ISV = 0, ISS = 0x00000004
CM = 0, WnR = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=0000000048517000
[0000000000000064] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
Modules linked in: ath11k_pci ath11k qmi_helpers
CPU: 2 PID: 1781 Comm: napi/-271 Not tainted
6.1.0-rc5-wt-ath-656295-gef907406320c-dirty #6
Hardware name: Qualcomm Technologies, Inc. IPQ8074/AP-HK10-C2 (DT)
pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : ath11k_hw_qcn9074_rx_desc_get_decap_type+0x34/0x60 [ath11k]
lr : ath11k_hw_qcn9074_rx_desc_get_decap_type+0x5c/0x60 [ath11k]
sp : ffff80000ef5bb10
x29: ffff80000ef5bb10 x28: 0000000000000000 x27: ffff000007baafa0
x26: ffff000014a91ed0 x25: 0000000000000000 x24: 0000000000000000
x23: ffff800002b77378 x22: ffff000014a91ec0 x21: ffff000006c8d600
x20: 0000000000000000 x19: ffff800002b77740 x18: 0000000000000006
x17: 736564203634343a x16: 656e694c20657079 x15: 0000000000000143
x14: 00000000ffffffea x13: ffff80000ef5b8b8 x12: ffff80000ef5b8c8
x11: ffff80000a591d30 x10: ffff80000a579d40 x9 : c0000000ffffefff
x8 : 0000000000000003 x7 : 0000000000017fe8 x6 : ffff80000a579ce8
x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
x2 : 3a35ec12ed7f8900 x1 : 0000000000000000 x0 : 0000000000000052
Call trace:
ath11k_hw_qcn9074_rx_desc_get_decap_type+0x34/0x60 [ath11k]
ath11k_dp_rx_deliver_msdu.isra.42+0xa4/0x3d0 [ath11k]
ath11k_dp_rx_mon_deliver.isra.43+0x2f8/0x458 [ath11k]
ath11k_dp_rx_process_mon_rings+0x310/0x4c0 [ath11k]
ath11k_dp_service_srng+0x234/0x338 [ath11k]
ath11k_pcic_ext_grp_napi_poll+0x30/0xb8 [ath11k]
__napi_poll+0x5c/0x190
napi_threaded_poll+0xf0/0x118
kthread+0xf4/0x110
ret_from_fork+0x10/0x20
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
Reported-by: Florian Schmidt <florian@fls.name>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=216573
Signed-off-by: Nagarajan Maran <quic_nmaran@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20221129142532.23421-1-quic_nmaran@quicinc.com
---
drivers/net/wireless/ath/ath11k/dp_rx.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -5022,6 +5022,7 @@ static int ath11k_dp_rx_mon_deliver(stru
} else {
rxs->flag |= RX_FLAG_ALLOW_SAME_PN;
}
+ rxs->flag |= RX_FLAG_ONLY_MONITOR;
ath11k_update_radiotap(ar, ppduinfo, mon_skb, rxs);
ath11k_dp_rx_deliver_msdu(ar, napi, mon_skb, rxs);

View File

@ -1,139 +0,0 @@
From 323d91d4684d238f6bc3693fed93caf795378fe0 Mon Sep 17 00:00:00 2001
From: Kalle Valo <quic_kvalo@quicinc.com>
Date: Thu, 22 Dec 2022 19:15:59 +0200
Subject: [PATCH] wifi: ath11k: debugfs: fix to work with multiple PCI devices
ath11k fails to load if there are multiple ath11k PCI devices with same name:
ath11k_pci 0000:01:00.0: Hardware name qcn9074 hw1.0
debugfs: Directory 'ath11k' with parent '/' already present!
ath11k_pci 0000:01:00.0: failed to create ath11k debugfs
ath11k_pci 0000:01:00.0: failed to create soc core: -17
ath11k_pci 0000:01:00.0: failed to init core: -17
ath11k_pci: probe of 0000:01:00.0 failed with error -17
Fix this by creating a directory for each ath11k device using schema
<bus>-<devname>, for example "pci-0000:06:00.0". This directory created under
the top-level ath11k directory, for example /sys/kernel/debug/ath11k.
The reference to the toplevel ath11k directory is not stored anymore within ath11k, instead
it's retrieved using debugfs_lookup(). If the directory does not exist it will
be created. After the last directory from the ath11k directory is removed, for
example when doing rmmod ath11k, the empty ath11k directory is left in place,
it's a minor cosmetic issue anyway.
Here's an example hierarchy with one WCN6855:
ath11k
`-- pci-0000:06:00.0
|-- mac0
| |-- dfs_block_radar_events
| |-- dfs_simulate_radar
| |-- ext_rx_stats
| |-- ext_tx_stats
| |-- fw_dbglog_config
| |-- fw_stats
| | |-- beacon_stats
| | |-- pdev_stats
| | `-- vdev_stats
| |-- htt_stats
| |-- htt_stats_reset
| |-- htt_stats_type
| `-- pktlog_filter
|-- simulate_fw_crash
`-- soc_dp_stats
I didn't have a test setup where I could connect multiple ath11k devices to the
same the host, so I have only tested this with one device.
Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3.6510.9
Tested-on: IPQ8074 hw2.0 AHB WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.5.0.1-01208-QCAHKSWPL_SILICONZ-1
Tested-by: Robert Marko <robert.marko@sartura.hr>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20221220121231.20120-1-kvalo@kernel.org
---
drivers/net/wireless/ath/ath11k/core.h | 1 -
drivers/net/wireless/ath/ath11k/debugfs.c | 48 +++++++++++++++++++----
2 files changed, 40 insertions(+), 9 deletions(-)
--- a/drivers/net/wireless/ath/ath11k/core.h
+++ b/drivers/net/wireless/ath/ath11k/core.h
@@ -921,7 +921,6 @@ struct ath11k_base {
enum ath11k_dfs_region dfs_region;
#ifdef CPTCFG_ATH11K_DEBUGFS
struct dentry *debugfs_soc;
- struct dentry *debugfs_ath11k;
#endif
struct ath11k_soc_dp_stats soc_stats;
--- a/drivers/net/wireless/ath/ath11k/debugfs.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs.c
@@ -976,10 +976,6 @@ int ath11k_debugfs_pdev_create(struct at
if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
return 0;
- ab->debugfs_soc = debugfs_create_dir(ab->hw_params.name, ab->debugfs_ath11k);
- if (IS_ERR(ab->debugfs_soc))
- return PTR_ERR(ab->debugfs_soc);
-
debugfs_create_file("simulate_fw_crash", 0600, ab->debugfs_soc, ab,
&fops_simulate_fw_crash);
@@ -1001,15 +997,51 @@ void ath11k_debugfs_pdev_destroy(struct
int ath11k_debugfs_soc_create(struct ath11k_base *ab)
{
- ab->debugfs_ath11k = debugfs_create_dir("ath11k", NULL);
+ struct dentry *root;
+ bool dput_needed;
+ char name[64];
+ int ret;
+
+ root = debugfs_lookup("ath11k", NULL);
+ if (!root) {
+ root = debugfs_create_dir("ath11k", NULL);
+ if (IS_ERR_OR_NULL(root))
+ return PTR_ERR(root);
+
+ dput_needed = false;
+ } else {
+ /* a dentry from lookup() needs dput() after we don't use it */
+ dput_needed = true;
+ }
+
+ scnprintf(name, sizeof(name), "%s-%s", ath11k_bus_str(ab->hif.bus),
+ dev_name(ab->dev));
+
+ ab->debugfs_soc = debugfs_create_dir(name, root);
+ if (IS_ERR_OR_NULL(ab->debugfs_soc)) {
+ ret = PTR_ERR(ab->debugfs_soc);
+ goto out;
+ }
+
+ ret = 0;
+
+out:
+ if (dput_needed)
+ dput(root);
- return PTR_ERR_OR_ZERO(ab->debugfs_ath11k);
+ return ret;
}
void ath11k_debugfs_soc_destroy(struct ath11k_base *ab)
{
- debugfs_remove_recursive(ab->debugfs_ath11k);
- ab->debugfs_ath11k = NULL;
+ debugfs_remove_recursive(ab->debugfs_soc);
+ ab->debugfs_soc = NULL;
+
+ /* We are not removing ath11k directory on purpose, even if it
+ * would be empty. This simplifies the directory handling and it's
+ * a minor cosmetic issue to leave an empty ath11k directory to
+ * debugfs.
+ */
}
EXPORT_SYMBOL(ath11k_debugfs_soc_destroy);

View File

@ -1,28 +0,0 @@
From ed3f83b3459a67a3ab9d806490ac304b567b1c2d Mon Sep 17 00:00:00 2001
From: Miaoqian Lin <linmq006@gmail.com>
Date: Mon, 2 Jan 2023 12:11:42 +0400
Subject: [PATCH] wifi: ath11k: Fix memory leak in ath11k_peer_rx_frag_setup
crypto_alloc_shash() allocates resources, which should be released by
crypto_free_shash(). When ath11k_peer_find() fails, there has memory
leak. Add missing crypto_free_shash() to fix this.
Fixes: 243874c64c81 ("ath11k: handle RX fragments")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230102081142.3937570-1-linmq006@gmail.com
---
drivers/net/wireless/ath/ath11k/dp_rx.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -3126,6 +3126,7 @@ int ath11k_peer_rx_frag_setup(struct ath
if (!peer) {
ath11k_warn(ab, "failed to find the peer to set up fragment info\n");
spin_unlock_bh(&ab->base_lock);
+ crypto_free_shash(tfm);
return -ENOENT;
}

View File

@ -32,12 +32,12 @@ Link: https://lore.kernel.org/r/20230201183201.14431-1-len.brown@intel.com
--- a/drivers/net/wireless/ath/ath11k/pci.c
+++ b/drivers/net/wireless/ath/ath11k/pci.c
@@ -981,7 +981,7 @@ static __maybe_unused int ath11k_pci_pm_
@@ -998,7 +998,7 @@ static __maybe_unused int ath11k_pci_pm_
if (ret)
ath11k_warn(ab, "failed to suspend core: %d\n", ret);
ath11k_warn(ab, "failed to resume core: %d\n", ret);
- return ret;
+ return 0;
}
static __maybe_unused int ath11k_pci_pm_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(ath11k_pci_pm_ops,

View File

@ -0,0 +1,130 @@
From patchwork Mon Apr 17 20:22:27 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Muna Sinada <quic_msinada@quicinc.com>
X-Patchwork-Id: 13214540
X-Patchwork-Delegate: kvalo@adurom.com
Return-Path: <linux-wireless-owner@vger.kernel.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
Received: from vger.kernel.org (vger.kernel.org [23.128.96.18])
by smtp.lore.kernel.org (Postfix) with ESMTP id 8C359C77B76
for <linux-wireless@archiver.kernel.org>;
Mon, 17 Apr 2023 20:26:40 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S230070AbjDQU0j (ORCPT
<rfc822;linux-wireless@archiver.kernel.org>);
Mon, 17 Apr 2023 16:26:39 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53306 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S229914AbjDQU0h (ORCPT
<rfc822;linux-wireless@vger.kernel.org>);
Mon, 17 Apr 2023 16:26:37 -0400
Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com
[205.220.180.131])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67CE24C33
for <linux-wireless@vger.kernel.org>;
Mon, 17 Apr 2023 13:26:24 -0700 (PDT)
Received: from pps.filterd (m0279873.ppops.net [127.0.0.1])
by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id
33HIsf5q010173;
Mon, 17 Apr 2023 20:22:47 GMT
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com;
h=from : to : cc :
subject : date : message-id : mime-version : content-type; s=qcppdkim1;
bh=FGtbeAR6pG0KxyEKVLIRzkq1RXlKfaVfRT1iixzMcII=;
b=jSdZBeFj4RAdCiUPrL/F9n+ufnpxT1pJNfZuA0tfEnUf54SCGUuHT5LtRdojYVh31YSS
aAGDRFvl7tIKqq/c6h4tm7SDdlhWF+MU3sH1YJNrwDeMAUZD+RnviJjo+GfgnEtp9+z7
PA75vGkpKiuMh6M8QFYB+/XxrJmx/XJBNESfMdAjBuMXnQf4S2yJ/IMwSxPkYKMU3lC6
DNnUAcgC/8wawYt8T1d8gKWq5CgWls4i1quveZghsbGUuL01i7SRXdKVianDJJsHEa0G
/brUp6LMMeJUgEI8wBfFAtcknzN0ADMVEqsJr+AHvQXnb1iHZyafl6BAeupXNS+Yi+fJ sw==
Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com
[129.46.96.20])
by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q171gh1hb-1
(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256
verify=NOT);
Mon, 17 Apr 2023 20:22:47 +0000
Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com
[10.47.209.196])
by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id
33HKMjHs007640
(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256
verify=NOT);
Mon, 17 Apr 2023 20:22:46 GMT
Received: from msinada-linux.qualcomm.com (10.80.80.8) by
nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server
(version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
15.2.986.42; Mon, 17 Apr 2023 13:22:44 -0700
From: Muna Sinada <quic_msinada@quicinc.com>
To: <ath11k@lists.infradead.org>
CC: <linux-wireless@vger.kernel.org>,
Muna Sinada <quic_msinada@quicinc.com>,
P Praneesh <quic_ppranees@quicinc.com>
Subject: [PATCH] wifi: ath11k: Remove disabling of 80+80 and 160 MHz
Date: Mon, 17 Apr 2023 13:22:27 -0700
Message-ID: <1681762947-13882-1-git-send-email-quic_msinada@quicinc.com>
X-Mailer: git-send-email 2.7.4
MIME-Version: 1.0
X-Originating-IP: [10.80.80.8]
X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To
nalasex01a.na.qualcomm.com (10.47.209.196)
X-QCInternal: smtphost
X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800
signatures=585085
X-Proofpoint-GUID: wqGG1zw0KpXNYk_yFYb16HwLWt9V-6o4
X-Proofpoint-ORIG-GUID: wqGG1zw0KpXNYk_yFYb16HwLWt9V-6o4
X-Proofpoint-Virus-Version: vendor=baseguard
engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22
definitions=2023-04-17_13,2023-04-17_01,2023-02-09_01
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0
priorityscore=1501 mlxscore=0
mlxlogscore=796 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0
clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0
classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000
definitions=main-2304170181
Precedence: bulk
List-ID: <linux-wireless.vger.kernel.org>
X-Mailing-List: linux-wireless@vger.kernel.org
This is a regression fix for 80+80 and 160 MHz support bits being
cleared, therefore not adverised. Remove disable of 80+80 and 160 MHz
capability flags and assign valid center frequency 2 similar to
VHT80_80.
Fixes: 38dfe775d0ab ("wifi: ath11k: push MU-MIMO params from hostapd to hardware")
Reported-by: Robert Marko <robert.marko@sartura.hr>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217299
Co-developed-by: P Praneesh <quic_ppranees@quicinc.com>
Signed-off-by: P Praneesh <quic_ppranees@quicinc.com>
Signed-off-by: Muna Sinada <quic_msinada@quicinc.com>
---
drivers/net/wireless/ath/ath11k/mac.c | 4 ----
drivers/net/wireless/ath/ath11k/wmi.c | 3 ++-
2 files changed, 2 insertions(+), 5 deletions(-)
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -5585,10 +5585,6 @@ static int ath11k_mac_copy_he_cap(struct
he_cap_elem->mac_cap_info[1] &=
IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK;
- he_cap_elem->phy_cap_info[0] &=
- ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
- he_cap_elem->phy_cap_info[0] &=
- ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
he_cap_elem->phy_cap_info[5] &=
~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK;
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -871,7 +871,8 @@ static void ath11k_wmi_put_wmi_channel(s
chan->band_center_freq2 = arg->channel.band_center_freq1;
- } else if (arg->channel.mode == MODE_11AC_VHT80_80) {
+ } else if ((arg->channel.mode == MODE_11AC_VHT80_80) ||
+ (arg->channel.mode == MODE_11AX_HE80_80)) {
chan->band_center_freq2 = arg->channel.band_center_freq2;
} else {
chan->band_center_freq2 = 0;

View File

@ -1,29 +0,0 @@
From e0edb3ac33694ab6a2705f7b053948a926520d81 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Tue, 28 Mar 2023 13:30:30 +0200
Subject: [PATCH] wifi: ath11k: restore 160MHz support
The blamed commit started clearing 80+80 and 160MHz support flags for 5G.
This is preventing those modes from being advertised and thus used causing
a regression, so until this is properly sorted out lets remove the flag
clearing to restore 160MHz support.
Fixes: 38dfe775d0ab ("wifi: ath11k: push MU-MIMO params from hostapd to hardware")
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
drivers/net/wireless/ath/ath11k/mac.c | 4 ----
1 file changed, 4 deletions(-)
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -5585,10 +5585,6 @@ static int ath11k_mac_copy_he_cap(struct
he_cap_elem->mac_cap_info[1] &=
IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_MASK;
- he_cap_elem->phy_cap_info[0] &=
- ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_160MHZ_IN_5G;
- he_cap_elem->phy_cap_info[0] &=
- ~IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G;
he_cap_elem->phy_cap_info[5] &=
~IEEE80211_HE_PHY_CAP5_BEAMFORMEE_NUM_SND_DIM_UNDER_80MHZ_MASK;

View File

@ -271,7 +271,7 @@ Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
#endif
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -6979,24 +6979,12 @@ static void ath11k_wmi_htc_tx_complete(s
@@ -6980,24 +6980,12 @@ static void ath11k_wmi_htc_tx_complete(s
wake_up(&wmi->tx_ce_desc_wq);
}
@ -296,7 +296,7 @@ Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
int ret = 0, pdev_idx, i, j;
struct ath11k *ar;
@@ -7058,17 +7046,7 @@ static int ath11k_reg_chan_list_event(st
@@ -7059,17 +7047,7 @@ static int ath11k_reg_chan_list_event(st
(char *)reg_info->alpha2, 2))
goto mem_free;

View File

@ -10,7 +10,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -710,8 +710,36 @@ static struct wireless_dev *brcmf_cfg802
@@ -713,8 +713,36 @@ static struct wireless_dev *brcmf_cfg802
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct brcmf_pub *drvr = cfg->pub;
struct wireless_dev *wdev;

View File

@ -14,7 +14,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org>
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -2973,6 +2973,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip
@@ -2976,6 +2976,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip
* preference in cfg struct to apply this to
* FW later while initializing the dongle
*/

View File

@ -49,7 +49,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
struct brcmf_mp_device *settings)
{
@@ -105,6 +135,8 @@ void brcmf_of_probe(struct device *dev,
@@ -106,6 +136,8 @@ void brcmf_of_probe(struct device *dev,
of_node_put(root);
}

View File

@ -24,7 +24,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
#include "of.h"
static int brcmf_of_get_country_codes(struct device *dev,
@@ -167,3 +168,38 @@ void brcmf_of_probe(struct device *dev,
@@ -168,3 +169,38 @@ void brcmf_of_probe(struct device *dev,
sdio->oob_irq_nr = irq;
sdio->oob_irq_flags = irqf;
}
@ -111,7 +111,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
#define TXCTL_CREDITS 2
static void pkt_align(struct sk_buff *p, int len, int align)
@@ -4192,6 +4196,9 @@ static const struct brcmf_bus_ops brcmf_
@@ -4193,6 +4197,9 @@ static const struct brcmf_bus_ops brcmf_
#define BRCMF_SDIO_FW_NVRAM 1
#define BRCMF_SDIO_FW_CLM 2
@ -121,7 +121,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
static void brcmf_sdio_firmware_callback(struct device *dev, int err,
struct brcmf_fw_request *fwreq)
{
@@ -4207,6 +4214,22 @@ static void brcmf_sdio_firmware_callback
@@ -4208,6 +4215,22 @@ static void brcmf_sdio_firmware_callback
brcmf_dbg(TRACE, "Enter: dev=%s, err=%d\n", dev_name(dev), err);
@ -144,7 +144,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
if (err)
goto fail;
@@ -4417,7 +4440,7 @@ brcmf_sdio_prepare_fw_request(struct brc
@@ -4418,7 +4441,7 @@ brcmf_sdio_prepare_fw_request(struct brc
fwreq = brcmf_fw_alloc_request(bus->ci->chip, bus->ci->chiprev,
brcmf_sdio_fwnames,
@ -153,7 +153,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
fwnames, ARRAY_SIZE(fwnames));
if (!fwreq)
return NULL;
@@ -4437,6 +4460,9 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
@@ -4438,6 +4461,9 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
struct brcmf_sdio *bus;
struct workqueue_struct *wq;
struct brcmf_fw_request *fwreq;
@ -163,7 +163,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.com>
brcmf_dbg(TRACE, "Enter\n");
@@ -4519,6 +4545,21 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
@@ -4520,6 +4546,21 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
brcmf_dbg(INFO, "completed!!\n");

View File

@ -12,7 +12,7 @@
};
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -17232,7 +17232,9 @@ static struct genl_family nl80211_fam __
@@ -17233,7 +17233,9 @@ static struct genl_family nl80211_fam __
.n_ops = ARRAY_SIZE(nl80211_ops),
.small_ops = nl80211_small_ops,
.n_small_ops = ARRAY_SIZE(nl80211_small_ops),

View File

@ -1,7 +1,7 @@
--- a/backport-include/linux/skbuff.h
+++ b/backport-include/linux/skbuff.h
@@ -140,4 +140,8 @@ static inline u64 skb_get_kcov_handle(st
}
@@ -144,4 +144,8 @@ static inline u64 skb_get_kcov_handle(st
#define napi_build_skb build_skb
#endif
+#if LINUX_VERSION_IS_LESS(5,11,0)

View File

@ -11,7 +11,7 @@
err_wiphy_new:
--- a/drivers/net/wireless/marvell/libertas/main.c
+++ b/drivers/net/wireless/marvell/libertas/main.c
@@ -934,6 +934,7 @@ struct lbs_private *lbs_add_card(void *c
@@ -935,6 +935,7 @@ struct lbs_private *lbs_add_card(void *c
goto err_adapter;
}

View File

@ -9,8 +9,8 @@ Used for AP+STA support in OpenWrt - preserve AP mode keys across STA reconnect
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1512,7 +1512,6 @@ static int ieee80211_stop_ap(struct wiph
link_conf->ftmr_params = NULL;
@@ -1519,7 +1519,6 @@ static int ieee80211_stop_ap(struct wiph
link_conf->bssid_indicator = 0;
__sta_info_flush(sdata, true);
- ieee80211_free_keys(sdata, true);

View File

@ -8,7 +8,7 @@ Subject: [PATCH] mac80211: allow scans in access point mode (for site survey)
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2720,6 +2720,8 @@ static int ieee80211_scan(struct wiphy *
@@ -2727,6 +2727,8 @@ static int ieee80211_scan(struct wiphy *
*/
fallthrough;
case NL80211_IFTYPE_AP:

View File

@ -23,7 +23,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3976,7 +3976,7 @@ struct ieee80211_txq *ieee80211_next_txq
@@ -3984,7 +3984,7 @@ struct ieee80211_txq *ieee80211_next_txq
if (deficit < 0)
sta->airtime[txqi->txq.ac].deficit +=
@ -32,7 +32,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (deficit < 0 || !aql_check) {
list_move_tail(&txqi->schedule_order,
@@ -4119,7 +4119,8 @@ bool ieee80211_txq_may_transmit(struct i
@@ -4127,7 +4127,8 @@ bool ieee80211_txq_may_transmit(struct i
}
sta = container_of(iter->txq.sta, struct sta_info, sta);
if (ieee80211_sta_deficit(sta, ac) < 0)
@ -42,7 +42,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
list_move_tail(&iter->schedule_order, &local->active_txqs[ac]);
}
@@ -4127,7 +4128,7 @@ bool ieee80211_txq_may_transmit(struct i
@@ -4135,7 +4136,7 @@ bool ieee80211_txq_may_transmit(struct i
if (sta->airtime[ac].deficit >= 0)
goto out;

View File

@ -51,16 +51,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
*
* Drivers can optionally delegate responsibility for scheduling queues to
* mac80211, to take advantage of airtime fairness accounting. In this case, to
@@ -1826,7 +1827,7 @@ struct ieee80211_vif_cfg {
* for this interface.
* @drv_priv: data area for driver use, will always be aligned to
* sizeof(void \*).
- * @txq: the multicast data TX queue (if driver uses the TXQ abstraction)
+ * @txq: the multicast data TX queue
* @txqs_stopped: per AC flag to indicate that intermediate TXQs are stopped,
* protected by fq->lock.
* @offload_flags: 802.3 -> 802.11 enapsulation offload flags, see
@@ -2252,8 +2253,8 @@ struct ieee80211_link_sta {
@@ -2248,8 +2249,8 @@ struct ieee80211_link_sta {
* For non MLO STA it will point to the deflink data. For MLO STA
* ieee80211_sta_recalc_aggregates() must be called to update it.
* @support_p2p_ps: indicates whether the STA supports P2P PS mechanism or not.
@ -71,7 +62,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
* @deflink: This holds the default link STA information, for non MLO STA all link
* specific STA information is accessed through @deflink or through
* link[0] which points to address of @deflink. For MLO Link STA
@@ -5691,7 +5692,7 @@ void ieee80211_key_replay(struct ieee802
@@ -5687,7 +5688,7 @@ void ieee80211_key_replay(struct ieee802
* @hw: pointer as obtained from ieee80211_alloc_hw().
* @queue: queue number (counted from zero).
*
@ -80,7 +71,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
*/
void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue);
@@ -5700,7 +5701,7 @@ void ieee80211_wake_queue(struct ieee802
@@ -5696,7 +5697,7 @@ void ieee80211_wake_queue(struct ieee802
* @hw: pointer as obtained from ieee80211_alloc_hw().
* @queue: queue number (counted from zero).
*
@ -89,7 +80,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
*/
void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue);
@@ -5709,7 +5710,7 @@ void ieee80211_stop_queue(struct ieee802
@@ -5705,7 +5706,7 @@ void ieee80211_stop_queue(struct ieee802
* @hw: pointer as obtained from ieee80211_alloc_hw().
* @queue: queue number (counted from zero).
*
@ -98,7 +89,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
*
* Return: %true if the queue is stopped. %false otherwise.
*/
@@ -5720,7 +5721,7 @@ int ieee80211_queue_stopped(struct ieee8
@@ -5716,7 +5717,7 @@ int ieee80211_queue_stopped(struct ieee8
* ieee80211_stop_queues - stop all queues
* @hw: pointer as obtained from ieee80211_alloc_hw().
*
@ -107,7 +98,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
*/
void ieee80211_stop_queues(struct ieee80211_hw *hw);
@@ -5728,7 +5729,7 @@ void ieee80211_stop_queues(struct ieee80
@@ -5724,7 +5725,7 @@ void ieee80211_stop_queues(struct ieee80
* ieee80211_wake_queues - wake all queues
* @hw: pointer as obtained from ieee80211_alloc_hw().
*
@ -116,7 +107,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
*/
void ieee80211_wake_queues(struct ieee80211_hw *hw);
@@ -6950,6 +6951,18 @@ static inline struct sk_buff *ieee80211_
@@ -6946,6 +6947,18 @@ static inline struct sk_buff *ieee80211_
}
/**

View File

@ -26,7 +26,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
.add_interface = adm8211_add_interface,
--- a/drivers/net/wireless/ath/ar5523/ar5523.c
+++ b/drivers/net/wireless/ath/ar5523/ar5523.c
@@ -1355,6 +1355,7 @@ static const struct ieee80211_ops ar5523
@@ -1361,6 +1361,7 @@ static const struct ieee80211_ops ar5523
.start = ar5523_start,
.stop = ar5523_stop,
.tx = ar5523_tx,
@ -36,7 +36,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
.remove_interface = ar5523_remove_interface,
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -8539,6 +8539,7 @@ err_fallback:
@@ -8587,6 +8587,7 @@ err_fallback:
static const struct ieee80211_ops ath11k_ops = {
.tx = ath11k_mac_op_tx,
@ -126,7 +126,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
.add_interface = brcms_ops_add_interface,
--- a/drivers/net/wireless/intel/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/3945-mac.c
@@ -3435,6 +3435,7 @@ static const struct attribute_group il39
@@ -3439,6 +3439,7 @@ static const struct attribute_group il39
static struct ieee80211_ops il3945_mac_ops __ro_after_init = {
.tx = il3945_mac_tx,
@ -136,7 +136,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
.add_interface = il_mac_add_interface,
--- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
@@ -6304,6 +6304,7 @@ il4965_tx_queue_set_status(struct il_pri
@@ -6308,6 +6308,7 @@ il4965_tx_queue_set_status(struct il_pri
static const struct ieee80211_ops il4965_mac_ops = {
.tx = il4965_mac_tx,
@ -306,7 +306,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
.add_interface = rtl8187_add_interface,
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -6561,6 +6561,7 @@ static void rtl8xxxu_stop(struct ieee802
@@ -6548,6 +6548,7 @@ static void rtl8xxxu_stop(struct ieee802
static const struct ieee80211_ops rtl8xxxu_ops = {
.tx = rtl8xxxu_tx,

View File

@ -11,7 +11,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -4339,9 +4339,6 @@ static int ieee80211_get_txq_stats(struc
@@ -4346,9 +4346,6 @@ static int ieee80211_get_txq_stats(struc
struct ieee80211_sub_if_data *sdata;
int ret = 0;
@ -48,7 +48,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
}
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -1056,10 +1056,8 @@ void ieee80211_sta_debugfs_add(struct st
@@ -1057,10 +1057,8 @@ void ieee80211_sta_debugfs_add(struct st
DEBUGFS_ADD_COUNTER(rx_fragments, deflink.rx_stats.fragments);
DEBUGFS_ADD_COUNTER(tx_filtered, deflink.status_stats.filtered);
@ -63,7 +63,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
NL80211_EXT_FEATURE_AQL))
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -2290,7 +2290,6 @@ void ieee80211_wake_queue_by_reason(stru
@@ -2294,7 +2294,6 @@ void ieee80211_wake_queue_by_reason(stru
void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
enum queue_stop_reason reason,
bool refcounted);
@ -73,7 +73,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
void ieee80211_add_pending_skbs(struct ieee80211_local *local,
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -458,12 +458,6 @@ static void ieee80211_do_stop(struct iee
@@ -460,12 +460,6 @@ static void ieee80211_do_stop(struct iee
if (cancel_scan)
ieee80211_scan_cancel(local);
@ -86,7 +86,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
ieee80211_roc_purge(local, sdata);
switch (sdata->vif.type) {
@@ -811,13 +805,6 @@ static void ieee80211_uninit(struct net_
@@ -813,13 +807,6 @@ static void ieee80211_uninit(struct net_
ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev));
}
@ -100,7 +100,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
static void
ieee80211_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{
@@ -831,7 +818,6 @@ static const struct net_device_ops ieee8
@@ -833,7 +820,6 @@ static const struct net_device_ops ieee8
.ndo_start_xmit = ieee80211_subif_start_xmit,
.ndo_set_rx_mode = ieee80211_set_multicast_list,
.ndo_set_mac_address = ieee80211_change_mac,
@ -108,7 +108,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
.ndo_get_stats64 = ieee80211_get_stats64,
};
@@ -939,7 +925,6 @@ static const struct net_device_ops ieee8
@@ -941,7 +927,6 @@ static const struct net_device_ops ieee8
.ndo_start_xmit = ieee80211_subif_start_xmit_8023,
.ndo_set_rx_mode = ieee80211_set_multicast_list,
.ndo_set_mac_address = ieee80211_change_mac,
@ -116,7 +116,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
.ndo_get_stats64 = ieee80211_get_stats64,
.ndo_fill_forward_path = ieee80211_netdev_fill_forward_path,
};
@@ -1441,35 +1426,6 @@ int ieee80211_do_open(struct wireless_de
@@ -1443,35 +1428,6 @@ int ieee80211_do_open(struct wireless_de
ieee80211_recalc_ps(local);
@ -152,7 +152,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
set_bit(SDATA_STATE_RUNNING, &sdata->state);
return 0;
@@ -1499,17 +1455,12 @@ static void ieee80211_if_setup(struct ne
@@ -1501,17 +1457,12 @@ static void ieee80211_if_setup(struct ne
{
ether_setup(dev);
dev->priv_flags &= ~IFF_TX_SKB_SHARING;
@ -171,7 +171,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
static void ieee80211_iface_process_skb(struct ieee80211_local *local,
struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb)
@@ -2094,9 +2045,7 @@ int ieee80211_if_add(struct ieee80211_lo
@@ -2096,9 +2047,7 @@ int ieee80211_if_add(struct ieee80211_lo
struct net_device *ndev = NULL;
struct ieee80211_sub_if_data *sdata = NULL;
struct txq_info *txqi;
@ -181,7 +181,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
ASSERT_RTNL();
@@ -2119,30 +2068,18 @@ int ieee80211_if_add(struct ieee80211_lo
@@ -2121,30 +2070,18 @@ int ieee80211_if_add(struct ieee80211_lo
sizeof(void *));
int txq_size = 0;
@ -346,7 +346,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
free:
sta_info_free_link(&sta->deflink);
#ifdef CPTCFG_MAC80211_MESH
@@ -1959,9 +1954,6 @@ ieee80211_sta_ps_deliver_response(struct
@@ -1960,9 +1955,6 @@ ieee80211_sta_ps_deliver_response(struct
* TIM recalculation.
*/
@ -356,7 +356,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
for (tid = 0; tid < ARRAY_SIZE(sta->sta.txq); tid++) {
if (!sta->sta.txq[tid] ||
!(driver_release_tids & BIT(tid)) ||
@@ -2446,7 +2438,7 @@ static void sta_set_tidstats(struct sta_
@@ -2447,7 +2439,7 @@ static void sta_set_tidstats(struct sta_
tidstats->tx_msdu_failed = sta->deflink.status_stats.msdu_failed[tid];
}
@ -365,7 +365,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
spin_lock_bh(&local->fq.lock);
rcu_read_lock();
@@ -2774,9 +2766,6 @@ unsigned long ieee80211_sta_last_active(
@@ -2775,9 +2767,6 @@ unsigned long ieee80211_sta_last_active(
static void sta_update_codel_params(struct sta_info *sta, u32 thr)
{
@ -387,7 +387,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
* Set the WLAN_TDLS_TEARDOWN flag to indicate a teardown in progress.
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1599,9 +1599,6 @@ int ieee80211_txq_setup_flows(struct iee
@@ -1600,9 +1600,6 @@ int ieee80211_txq_setup_flows(struct iee
bool supp_vht = false;
enum nl80211_band band;
@ -397,7 +397,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
ret = fq_init(fq, 4096);
if (ret)
return ret;
@@ -1649,9 +1646,6 @@ void ieee80211_txq_teardown_flows(struct
@@ -1650,9 +1647,6 @@ void ieee80211_txq_teardown_flows(struct
{
struct fq *fq = &local->fq;
@ -407,7 +407,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
kfree(local->cvars);
local->cvars = NULL;
@@ -1668,8 +1662,7 @@ static bool ieee80211_queue_skb(struct i
@@ -1669,8 +1663,7 @@ static bool ieee80211_queue_skb(struct i
struct ieee80211_vif *vif;
struct txq_info *txqi;
@ -417,7 +417,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
return false;
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
@@ -4185,12 +4178,7 @@ void __ieee80211_subif_start_xmit(struct
@@ -4193,12 +4186,7 @@ void __ieee80211_subif_start_xmit(struct
if (IS_ERR(sta))
sta = NULL;
@ -431,7 +431,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
ieee80211_aggr_check(sdata, sta, skb);
sk_pacing_shift_update(skb->sk, sdata->local->hw.tx_sk_pacing_shift);
@@ -4501,11 +4489,7 @@ static void ieee80211_8023_xmit(struct i
@@ -4509,11 +4497,7 @@ static void ieee80211_8023_xmit(struct i
struct tid_ampdu_tx *tid_tx;
u8 tid;
@ -444,7 +444,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) &&
test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))
@@ -4759,9 +4743,6 @@ void ieee80211_tx_pending(struct tasklet
@@ -4767,9 +4751,6 @@ void ieee80211_tx_pending(struct tasklet
if (!txok)
break;
}
@ -454,7 +454,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
}
spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
@@ -5954,10 +5935,9 @@ int ieee80211_tx_control_port(struct wip
@@ -5962,10 +5943,9 @@ int ieee80211_tx_control_port(struct wip
}
if (!IS_ERR(sta)) {
@ -468,7 +468,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
* for MLO STA, the SA should be the AP MLD address, but
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -446,39 +446,6 @@ void ieee80211_wake_txqs(struct tasklet_
@@ -444,39 +444,6 @@ void ieee80211_wake_txqs(struct tasklet_
spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
}
@ -508,7 +508,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
static void __ieee80211_wake_queue(struct ieee80211_hw *hw, int queue,
enum queue_stop_reason reason,
bool refcounted,
@@ -509,11 +476,7 @@ static void __ieee80211_wake_queue(struc
@@ -507,11 +474,7 @@ static void __ieee80211_wake_queue(struc
/* someone still has this queue stopped */
return;
@ -521,7 +521,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
tasklet_schedule(&local->tx_pending_tasklet);
/*
@@ -523,12 +486,10 @@ static void __ieee80211_wake_queue(struc
@@ -521,12 +484,10 @@ static void __ieee80211_wake_queue(struc
* release someone's lock, but it is fine because all the callers of
* __ieee80211_wake_queue call it right before releasing the lock.
*/
@ -538,17 +538,44 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
}
void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue,
@@ -585,10 +546,6 @@ static void __ieee80211_stop_queue(struc
for (ac = 0; ac < n_acs; ac++) {
if (sdata->vif.hw_queue[ac] == queue ||
sdata->vif.cab_queue == queue) {
- if (!local->ops->wake_tx_queue) {
- netif_stop_subqueue(sdata->dev, ac);
- continue;
- }
spin_lock(&local->fq.lock);
sdata->vif.txqs_stopped[ac] = true;
spin_unlock(&local->fq.lock);
@@ -554,8 +515,6 @@ static void __ieee80211_stop_queue(struc
bool refcounted)
{
struct ieee80211_local *local = hw_to_local(hw);
- struct ieee80211_sub_if_data *sdata;
- int n_acs = IEEE80211_NUM_ACS;
trace_stop_queue(local, queue, reason);
@@ -567,27 +526,7 @@ static void __ieee80211_stop_queue(struc
else
local->q_stop_reasons[queue][reason]++;
- if (__test_and_set_bit(reason, &local->queue_stop_reasons[queue]))
- return;
-
- if (local->hw.queues < IEEE80211_NUM_ACS)
- n_acs = 1;
-
- rcu_read_lock();
- list_for_each_entry_rcu(sdata, &local->interfaces, list) {
- int ac;
-
- if (!sdata->dev)
- continue;
-
- for (ac = 0; ac < n_acs; ac++) {
- if (!local->ops->wake_tx_queue &&
- (sdata->vif.hw_queue[ac] == queue ||
- sdata->vif.cab_queue == queue))
- netif_stop_subqueue(sdata->dev, ac);
- }
- }
- rcu_read_unlock();
+ set_bit(reason, &local->queue_stop_reasons[queue]);
}
void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue,
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -122,6 +122,9 @@ u16 ieee80211_select_queue_80211(struct
@ -561,7 +588,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
if ((info->control.flags & IEEE80211_TX_CTRL_DONT_REORDER) ||
local->hw.queues < IEEE80211_NUM_ACS)
return 0;
@@ -141,12 +144,15 @@ u16 ieee80211_select_queue_80211(struct
@@ -141,13 +144,16 @@ u16 ieee80211_select_queue_80211(struct
return ieee80211_downgrade_queue(sdata, NULL, skb);
}
@ -570,6 +597,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
+ struct sta_info *sta, struct sk_buff *skb)
{
const struct ethhdr *eth = (void *)skb->data;
struct mac80211_qos_map *qos_map;
bool qos;
@ -577,9 +605,9 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+ skb_get_hash(skb);
+
/* all mesh/ocb stations are required to support WME */
if (sta && (sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
sdata->vif.type == NL80211_IFTYPE_OCB))
@@ -176,59 +182,6 @@ u16 __ieee80211_select_queue(struct ieee
if ((sdata->vif.type == NL80211_IFTYPE_MESH_POINT &&
!is_multicast_ether_addr(eth->h_dest)) ||
@@ -178,59 +184,6 @@ u16 __ieee80211_select_queue(struct ieee
return ieee80211_downgrade_queue(sdata, sta, skb);
}

View File

@ -1,410 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Tue, 13 Dec 2022 21:03:19 +0100
Subject: [PATCH] wifi: mac80211: fix initialization of rx->link and
rx->link_sta
There are some codepaths that do not initialize rx->link_sta properly. This
causes a crash in places which assume that rx->link_sta is valid if rx->sta
is valid.
One known instance is triggered by __ieee80211_rx_h_amsdu being called from
fast-rx.
Since the initialization of rx->link and rx->link_sta is rather convoluted
and duplicated in many places, clean it up by using a helper function to
set it.
Fixes: ccdde7c74ffd ("wifi: mac80211: properly implement MLO key handling")
Fixes: b320d6c456ff ("wifi: mac80211: use correct rx link_sta instead of default")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -4067,6 +4067,58 @@ static void ieee80211_invoke_rx_handlers
#undef CALL_RXH
}
+static bool
+ieee80211_rx_is_valid_sta_link_id(struct ieee80211_sta *sta, u8 link_id)
+{
+ if (!sta->mlo)
+ return false;
+
+ return !!(sta->valid_links & BIT(link_id));
+}
+
+static bool ieee80211_rx_data_set_link(struct ieee80211_rx_data *rx,
+ u8 link_id)
+{
+ rx->link_id = link_id;
+ rx->link = rcu_dereference(rx->sdata->link[link_id]);
+
+ if (!rx->sta || !rx->sta->sta.mlo)
+ return rx->link;
+
+ if (!ieee80211_rx_is_valid_sta_link_id(&rx->sta->sta, link_id))
+ return false;
+
+ rx->link_sta = rcu_dereference(rx->sta->link[link_id]);
+
+ return rx->link && rx->link_sta;
+}
+
+static bool ieee80211_rx_data_set_sta(struct ieee80211_rx_data *rx,
+ struct ieee80211_sta *pubsta,
+ int link_id)
+{
+ struct sta_info *sta;
+
+ sta = container_of(pubsta, struct sta_info, sta);
+
+ rx->link_id = link_id;
+ rx->sta = sta;
+
+ if (sta) {
+ rx->local = sta->sdata->local;
+ if (!rx->sdata)
+ rx->sdata = sta->sdata;
+ rx->link_sta = &sta->deflink;
+ }
+
+ if (link_id < 0)
+ rx->link = &rx->sdata->deflink;
+ else if (!ieee80211_rx_data_set_link(rx, link_id))
+ return false;
+
+ return true;
+}
+
/*
* This function makes calls into the RX path, therefore
* it has to be invoked under RCU read lock.
@@ -4075,16 +4127,19 @@ void ieee80211_release_reorder_timeout(s
{
struct sk_buff_head frames;
struct ieee80211_rx_data rx = {
- .sta = sta,
- .sdata = sta->sdata,
- .local = sta->local,
/* This is OK -- must be QoS data frame */
.security_idx = tid,
.seqno_idx = tid,
- .link_id = -1,
};
struct tid_ampdu_rx *tid_agg_rx;
- u8 link_id;
+ int link_id = -1;
+
+ /* FIXME: statistics won't be right with this */
+ if (sta->sta.valid_links)
+ link_id = ffs(sta->sta.valid_links) - 1;
+
+ if (!ieee80211_rx_data_set_sta(&rx, &sta->sta, link_id))
+ return;
tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
if (!tid_agg_rx)
@@ -4104,10 +4159,6 @@ void ieee80211_release_reorder_timeout(s
};
drv_event_callback(rx.local, rx.sdata, &event);
}
- /* FIXME: statistics won't be right with this */
- link_id = sta->sta.valid_links ? ffs(sta->sta.valid_links) - 1 : 0;
- rx.link = rcu_dereference(sta->sdata->link[link_id]);
- rx.link_sta = rcu_dereference(sta->link[link_id]);
ieee80211_rx_handlers(&rx, &frames);
}
@@ -4123,7 +4174,6 @@ void ieee80211_mark_rx_ba_filtered_frame
/* This is OK -- must be QoS data frame */
.security_idx = tid,
.seqno_idx = tid,
- .link_id = -1,
};
int i, diff;
@@ -4134,10 +4184,8 @@ void ieee80211_mark_rx_ba_filtered_frame
sta = container_of(pubsta, struct sta_info, sta);
- rx.sta = sta;
- rx.sdata = sta->sdata;
- rx.link = &rx.sdata->deflink;
- rx.local = sta->local;
+ if (!ieee80211_rx_data_set_sta(&rx, pubsta, -1))
+ return;
rcu_read_lock();
tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]);
@@ -4524,15 +4572,6 @@ void ieee80211_check_fast_rx_iface(struc
mutex_unlock(&local->sta_mtx);
}
-static bool
-ieee80211_rx_is_valid_sta_link_id(struct ieee80211_sta *sta, u8 link_id)
-{
- if (!sta->mlo)
- return false;
-
- return !!(sta->valid_links & BIT(link_id));
-}
-
static void ieee80211_rx_8023(struct ieee80211_rx_data *rx,
struct ieee80211_fast_rx *fast_rx,
int orig_len)
@@ -4643,7 +4682,6 @@ static bool ieee80211_invoke_fast_rx(str
struct sk_buff *skb = rx->skb;
struct ieee80211_hdr *hdr = (void *)skb->data;
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
- struct sta_info *sta = rx->sta;
int orig_len = skb->len;
int hdrlen = ieee80211_hdrlen(hdr->frame_control);
int snap_offs = hdrlen;
@@ -4655,7 +4693,6 @@ static bool ieee80211_invoke_fast_rx(str
u8 da[ETH_ALEN];
u8 sa[ETH_ALEN];
} addrs __aligned(2);
- struct link_sta_info *link_sta;
struct ieee80211_sta_rx_stats *stats;
/* for parallel-rx, we need to have DUP_VALIDATED, otherwise we write
@@ -4758,18 +4795,10 @@ static bool ieee80211_invoke_fast_rx(str
drop:
dev_kfree_skb(skb);
- if (rx->link_id >= 0) {
- link_sta = rcu_dereference(sta->link[rx->link_id]);
- if (!link_sta)
- return true;
- } else {
- link_sta = &sta->deflink;
- }
-
if (fast_rx->uses_rss)
- stats = this_cpu_ptr(link_sta->pcpu_rx_stats);
+ stats = this_cpu_ptr(rx->link_sta->pcpu_rx_stats);
else
- stats = &link_sta->rx_stats;
+ stats = &rx->link_sta->rx_stats;
stats->dropped++;
return true;
@@ -4787,8 +4816,8 @@ static bool ieee80211_prepare_and_rx_han
struct ieee80211_local *local = rx->local;
struct ieee80211_sub_if_data *sdata = rx->sdata;
struct ieee80211_hdr *hdr = (void *)skb->data;
- struct link_sta_info *link_sta = NULL;
- struct ieee80211_link_data *link;
+ struct link_sta_info *link_sta = rx->link_sta;
+ struct ieee80211_link_data *link = rx->link;
rx->skb = skb;
@@ -4810,35 +4839,6 @@ static bool ieee80211_prepare_and_rx_han
if (!ieee80211_accept_frame(rx))
return false;
- if (rx->link_id >= 0) {
- link = rcu_dereference(rx->sdata->link[rx->link_id]);
-
- /* we might race link removal */
- if (!link)
- return true;
- rx->link = link;
-
- if (rx->sta) {
- rx->link_sta =
- rcu_dereference(rx->sta->link[rx->link_id]);
- if (!rx->link_sta)
- return true;
- }
- } else {
- if (rx->sta)
- rx->link_sta = &rx->sta->deflink;
-
- rx->link = &sdata->deflink;
- }
-
- if (unlikely(!is_multicast_ether_addr(hdr->addr1) &&
- rx->link_id >= 0 && rx->sta && rx->sta->sta.mlo)) {
- link_sta = rcu_dereference(rx->sta->link[rx->link_id]);
-
- if (WARN_ON_ONCE(!link_sta))
- return true;
- }
-
if (!consume) {
struct skb_shared_hwtstamps *shwt;
@@ -4858,7 +4858,7 @@ static bool ieee80211_prepare_and_rx_han
shwt->hwtstamp = skb_hwtstamps(skb)->hwtstamp;
}
- if (unlikely(link_sta)) {
+ if (unlikely(rx->sta && rx->sta->sta.mlo)) {
/* translate to MLD addresses */
if (ether_addr_equal(link->conf->addr, hdr->addr1))
ether_addr_copy(hdr->addr1, rx->sdata->vif.addr);
@@ -4888,6 +4888,7 @@ static void __ieee80211_rx_handle_8023(s
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
struct ieee80211_fast_rx *fast_rx;
struct ieee80211_rx_data rx;
+ int link_id = -1;
memset(&rx, 0, sizeof(rx));
rx.skb = skb;
@@ -4904,12 +4905,8 @@ static void __ieee80211_rx_handle_8023(s
if (!pubsta)
goto drop;
- rx.sta = container_of(pubsta, struct sta_info, sta);
- rx.sdata = rx.sta->sdata;
-
- if (status->link_valid &&
- !ieee80211_rx_is_valid_sta_link_id(pubsta, status->link_id))
- goto drop;
+ if (status->link_valid)
+ link_id = status->link_id;
/*
* TODO: Should the frame be dropped if the right link_id is not
@@ -4918,19 +4915,8 @@ static void __ieee80211_rx_handle_8023(s
* link_id is used only for stats purpose and updating the stats on
* the deflink is fine?
*/
- if (status->link_valid)
- rx.link_id = status->link_id;
-
- if (rx.link_id >= 0) {
- struct ieee80211_link_data *link;
-
- link = rcu_dereference(rx.sdata->link[rx.link_id]);
- if (!link)
- goto drop;
- rx.link = link;
- } else {
- rx.link = &rx.sdata->deflink;
- }
+ if (!ieee80211_rx_data_set_sta(&rx, pubsta, link_id))
+ goto drop;
fast_rx = rcu_dereference(rx.sta->fast_rx);
if (!fast_rx)
@@ -4948,6 +4934,8 @@ static bool ieee80211_rx_for_interface(s
{
struct link_sta_info *link_sta;
struct ieee80211_hdr *hdr = (void *)skb->data;
+ struct sta_info *sta;
+ int link_id = -1;
/*
* Look up link station first, in case there's a
@@ -4957,24 +4945,19 @@ static bool ieee80211_rx_for_interface(s
*/
link_sta = link_sta_info_get_bss(rx->sdata, hdr->addr2);
if (link_sta) {
- rx->sta = link_sta->sta;
- rx->link_id = link_sta->link_id;
+ sta = link_sta->sta;
+ link_id = link_sta->link_id;
} else {
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
- rx->sta = sta_info_get_bss(rx->sdata, hdr->addr2);
- if (rx->sta) {
- if (status->link_valid &&
- !ieee80211_rx_is_valid_sta_link_id(&rx->sta->sta,
- status->link_id))
- return false;
-
- rx->link_id = status->link_valid ? status->link_id : -1;
- } else {
- rx->link_id = -1;
- }
+ sta = sta_info_get_bss(rx->sdata, hdr->addr2);
+ if (status->link_valid)
+ link_id = status->link_id;
}
+ if (!ieee80211_rx_data_set_sta(rx, &sta->sta, link_id))
+ return false;
+
return ieee80211_prepare_and_rx_handle(rx, skb, consume);
}
@@ -5033,19 +5016,15 @@ static void __ieee80211_rx_handle_packet
if (ieee80211_is_data(fc)) {
struct sta_info *sta, *prev_sta;
- u8 link_id = status->link_id;
+ int link_id = -1;
- if (pubsta) {
- rx.sta = container_of(pubsta, struct sta_info, sta);
- rx.sdata = rx.sta->sdata;
+ if (status->link_valid)
+ link_id = status->link_id;
- if (status->link_valid &&
- !ieee80211_rx_is_valid_sta_link_id(pubsta, link_id))
+ if (pubsta) {
+ if (!ieee80211_rx_data_set_sta(&rx, pubsta, link_id))
goto out;
- if (status->link_valid)
- rx.link_id = status->link_id;
-
/*
* In MLO connection, fetch the link_id using addr2
* when the driver does not pass link_id in status.
@@ -5063,7 +5042,7 @@ static void __ieee80211_rx_handle_packet
if (!link_sta)
goto out;
- rx.link_id = link_sta->link_id;
+ ieee80211_rx_data_set_link(&rx, link_sta->link_id);
}
if (ieee80211_prepare_and_rx_handle(&rx, skb, true))
@@ -5079,30 +5058,27 @@ static void __ieee80211_rx_handle_packet
continue;
}
- if ((status->link_valid &&
- !ieee80211_rx_is_valid_sta_link_id(&prev_sta->sta,
- link_id)) ||
- (!status->link_valid && prev_sta->sta.mlo))
+ rx.sdata = prev_sta->sdata;
+ if (!ieee80211_rx_data_set_sta(&rx, &prev_sta->sta,
+ link_id))
+ goto out;
+
+ if (!status->link_valid && prev_sta->sta.mlo)
continue;
- rx.link_id = status->link_valid ? link_id : -1;
- rx.sta = prev_sta;
- rx.sdata = prev_sta->sdata;
ieee80211_prepare_and_rx_handle(&rx, skb, false);
prev_sta = sta;
}
if (prev_sta) {
- if ((status->link_valid &&
- !ieee80211_rx_is_valid_sta_link_id(&prev_sta->sta,
- link_id)) ||
- (!status->link_valid && prev_sta->sta.mlo))
+ rx.sdata = prev_sta->sdata;
+ if (!ieee80211_rx_data_set_sta(&rx, &prev_sta->sta,
+ link_id))
goto out;
- rx.link_id = status->link_valid ? link_id : -1;
- rx.sta = prev_sta;
- rx.sdata = prev_sta->sdata;
+ if (!status->link_valid && prev_sta->sta.mlo)
+ goto out;
if (ieee80211_prepare_and_rx_handle(&rx, skb, true))
return;

View File

@ -1,25 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Wed, 14 Dec 2022 13:46:38 +0100
Subject: [PATCH] wifi: mac80211: fix MLO + AP_VLAN check
Instead of preventing adding AP_VLAN to MLO enabled APs, this check was
preventing adding more than one 4-addr AP_VLAN regardless of the MLO status.
Fix this by adding missing extra checks.
Fixes: ae960ee90bb1 ("wifi: mac80211: prevent VLANs on MLDs")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -364,7 +364,9 @@ static int ieee80211_check_concurrent_if
/* No support for VLAN with MLO yet */
if (iftype == NL80211_IFTYPE_AP_VLAN &&
- nsdata->wdev.use_4addr)
+ sdata->wdev.use_4addr &&
+ nsdata->vif.type == NL80211_IFTYPE_AP &&
+ nsdata->vif.valid_links)
return -EOPNOTSUPP;
/*

View File

@ -70,7 +70,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
* @driver_flags: flags/capabilities the driver has for this interface,
* these need to be set (or cleared) when the interface is added
* or, if supported by the driver, the interface type is changed
@@ -1848,6 +1852,7 @@ struct ieee80211_vif {
@@ -1846,6 +1850,7 @@ struct ieee80211_vif {
struct ieee80211_txq *txq;
@ -90,7 +90,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1355,7 +1355,11 @@ static struct txq_info *ieee80211_get_tx
@@ -1356,7 +1356,11 @@ static struct txq_info *ieee80211_get_tx
static void ieee80211_set_skb_enqueue_time(struct sk_buff *skb)
{
@ -103,7 +103,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
}
static u32 codel_skb_len_func(const struct sk_buff *skb)
@@ -3578,55 +3582,79 @@ ieee80211_xmit_fast_finish(struct ieee80
@@ -3579,55 +3583,79 @@ ieee80211_xmit_fast_finish(struct ieee80
return TX_CONTINUE;
}
@ -219,7 +219,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* will not be crypto-handled beyond what we do here, so use false
* as the may-encrypt argument for the resize to not account for
@@ -3635,10 +3663,8 @@ static bool ieee80211_xmit_fast(struct i
@@ -3636,10 +3664,8 @@ static bool ieee80211_xmit_fast(struct i
if (unlikely(ieee80211_skb_resize(sdata, skb,
max_t(int, extra_head + hw_headroom -
skb_headroom(skb), 0),
@ -232,7 +232,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
memcpy(&eth, skb->data, ETH_HLEN - 2);
hdr = skb_push(skb, extra_head);
@@ -3652,7 +3678,7 @@ static bool ieee80211_xmit_fast(struct i
@@ -3653,7 +3679,7 @@ static bool ieee80211_xmit_fast(struct i
info->control.vif = &sdata->vif;
info->flags = IEEE80211_TX_CTL_FIRST_FRAGMENT |
IEEE80211_TX_CTL_DONTFRAG |
@ -241,7 +241,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
info->control.flags = IEEE80211_TX_CTRL_FAST_XMIT |
u32_encode_bits(IEEE80211_LINK_UNSPECIFIED,
IEEE80211_TX_CTRL_MLO_LINK);
@@ -3676,16 +3702,14 @@ static bool ieee80211_xmit_fast(struct i
@@ -3677,16 +3703,14 @@ static bool ieee80211_xmit_fast(struct i
tx.key = fast_tx->key;
if (ieee80211_queue_skb(local, sdata, sta, skb))
@ -261,7 +261,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss,
@@ -3693,6 +3717,56 @@ static bool ieee80211_xmit_fast(struct i
@@ -3694,6 +3718,56 @@ static bool ieee80211_xmit_fast(struct i
__skb_queue_tail(&tx.skbs, skb);
ieee80211_tx_frags(local, &sdata->vif, sta, &tx.skbs, false);
@ -318,7 +318,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
return true;
}
@@ -4193,31 +4267,14 @@ void __ieee80211_subif_start_xmit(struct
@@ -4201,31 +4275,14 @@ void __ieee80211_subif_start_xmit(struct
goto out;
}
@ -358,7 +358,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
}
skb_list_walk_safe(skb, skb, next) {
@@ -4435,9 +4492,11 @@ normal:
@@ -4443,9 +4500,11 @@ normal:
return NETDEV_TX_OK;
}
@ -373,7 +373,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
{
struct ieee80211_local *local = sdata->local;
struct ieee80211_tx_control control = {};
@@ -4446,14 +4505,6 @@ static bool ieee80211_tx_8023(struct iee
@@ -4454,14 +4513,6 @@ static bool ieee80211_tx_8023(struct iee
unsigned long flags;
int q = info->hw_queue;
@ -388,7 +388,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
if (local->queue_stop_reasons[q] ||
@@ -4480,6 +4531,26 @@ static bool ieee80211_tx_8023(struct iee
@@ -4488,6 +4539,26 @@ static bool ieee80211_tx_8023(struct iee
return true;
}
@ -415,7 +415,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,
struct net_device *dev, struct sta_info *sta,
struct ieee80211_key *key, struct sk_buff *skb)
@@ -4487,9 +4558,13 @@ static void ieee80211_8023_xmit(struct i
@@ -4495,9 +4566,13 @@ static void ieee80211_8023_xmit(struct i
struct ieee80211_tx_info *info;
struct ieee80211_local *local = sdata->local;
struct tid_ampdu_tx *tid_tx;
@ -430,7 +430,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (unlikely(test_bit(SCAN_SW_SCANNING, &local->scanning)) &&
test_bit(SDATA_STATE_OFFCHANNEL, &sdata->state))
@@ -4499,9 +4574,6 @@ static void ieee80211_8023_xmit(struct i
@@ -4507,9 +4582,6 @@ static void ieee80211_8023_xmit(struct i
if (unlikely(!skb))
return;
@ -440,7 +440,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
ieee80211_aggr_check(sdata, sta, skb);
tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK;
@@ -4515,22 +4587,20 @@ static void ieee80211_8023_xmit(struct i
@@ -4523,22 +4595,20 @@ static void ieee80211_8023_xmit(struct i
return;
}
@ -471,7 +471,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss,
@@ -4542,6 +4612,24 @@ static void ieee80211_8023_xmit(struct i
@@ -4550,6 +4620,24 @@ static void ieee80211_8023_xmit(struct i
if (key)
info->control.hw_key = &key->conf;
@ -496,7 +496,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
ieee80211_tx_8023(sdata, skb, sta, false);
return;
@@ -4583,6 +4671,7 @@ netdev_tx_t ieee80211_subif_start_xmit_8
@@ -4591,6 +4679,7 @@ netdev_tx_t ieee80211_subif_start_xmit_8
key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
goto skip_offload;

View File

@ -1,35 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Wed, 15 Feb 2023 15:11:54 +0100
Subject: [PATCH] wifi: mac80211: fix qos on mesh interfaces
When ieee80211_select_queue is called for mesh, the sta pointer is usually
NULL, since the nexthop is looked up much later in the tx path.
Explicitly check for unicast address in that case in order to make qos work
again.
Fixes: 50e2ab392919 ("wifi: mac80211: fix queue selection for mesh/OCB interfaces")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -147,6 +147,7 @@ u16 ieee80211_select_queue_80211(struct
u16 ieee80211_select_queue(struct ieee80211_sub_if_data *sdata,
struct sta_info *sta, struct sk_buff *skb)
{
+ const struct ethhdr *eth = (void *)skb->data;
struct mac80211_qos_map *qos_map;
bool qos;
@@ -154,8 +155,9 @@ u16 ieee80211_select_queue(struct ieee80
skb_get_hash(skb);
/* all mesh/ocb stations are required to support WME */
- if (sta && (sdata->vif.type == NL80211_IFTYPE_MESH_POINT ||
- sdata->vif.type == NL80211_IFTYPE_OCB))
+ if ((sdata->vif.type == NL80211_IFTYPE_MESH_POINT &&
+ !is_multicast_ether_addr(eth->h_dest)) ||
+ (sdata->vif.type == NL80211_IFTYPE_OCB && sta))
qos = true;
else if (sta)
qos = sta->sta.wme;

View File

@ -11,7 +11,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -695,7 +695,7 @@ struct ieee80211_if_mesh {
@@ -696,7 +696,7 @@ struct ieee80211_if_mesh {
struct mesh_stats mshstats;
struct mesh_config mshcfg;
atomic_t estab_plinks;

View File

@ -40,7 +40,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* Maximum number of broadcast/multicast frames to buffer when some of the
* associated stations are using power saving. */
@@ -655,6 +656,19 @@ struct mesh_table {
@@ -656,6 +657,19 @@ struct mesh_table {
atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */
};
@ -60,7 +60,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
struct ieee80211_if_mesh {
struct timer_list housekeeping_timer;
struct timer_list mesh_path_timer;
@@ -733,6 +747,7 @@ struct ieee80211_if_mesh {
@@ -734,6 +748,7 @@ struct ieee80211_if_mesh {
struct mesh_table mpp_paths; /* Store paths for MPP&MAP */
int mesh_paths_generation;
int mpp_paths_generation;
@ -68,7 +68,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
};
#ifdef CPTCFG_MAC80211_MESH
@@ -1998,6 +2013,11 @@ int ieee80211_tx_control_port(struct wip
@@ -2002,6 +2017,11 @@ int ieee80211_tx_control_port(struct wip
int link_id, u64 *cookie);
int ieee80211_probe_mesh_link(struct wiphy *wiphy, struct net_device *dev,
const u8 *buf, size_t len);
@ -728,7 +728,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3021,6 +3021,9 @@ void ieee80211_check_fast_xmit(struct st
@@ -3022,6 +3022,9 @@ void ieee80211_check_fast_xmit(struct st
if (!ieee80211_hw_check(&local->hw, SUPPORT_FAST_XMIT))
return;
@ -738,7 +738,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* Locking here protects both the pointer itself, and against concurrent
* invocations winning data access races to, e.g., the key pointer that
* is used.
@@ -3402,6 +3405,9 @@ static bool ieee80211_amsdu_aggregate(st
@@ -3403,6 +3406,9 @@ static bool ieee80211_amsdu_aggregate(st
if (sdata->vif.offload_flags & IEEE80211_OFFLOAD_ENCAP_ENABLED)
return false;
@ -748,7 +748,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (skb_is_gso(skb))
return false;
@@ -3634,10 +3640,11 @@ free:
@@ -3635,10 +3641,11 @@ free:
return NULL;
}
@ -764,7 +764,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
{
struct ieee80211_local *local = sdata->local;
struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
@@ -3646,7 +3653,6 @@ static void __ieee80211_xmit_fast(struct
@@ -3647,7 +3654,6 @@ static void __ieee80211_xmit_fast(struct
ieee80211_tx_result r;
int hw_headroom = sdata->local->hw.extra_tx_headroom;
int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2);
@ -772,7 +772,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
skb = skb_share_check(skb, GFP_ATOMIC);
if (unlikely(!skb))
@@ -3666,11 +3672,10 @@ static void __ieee80211_xmit_fast(struct
@@ -3667,11 +3673,10 @@ static void __ieee80211_xmit_fast(struct
ENCRYPT_NO)))
goto free;
@ -786,7 +786,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
info = IEEE80211_SKB_CB(skb);
memset(info, 0, sizeof(*info));
@@ -3689,7 +3694,8 @@ static void __ieee80211_xmit_fast(struct
@@ -3690,7 +3695,8 @@ static void __ieee80211_xmit_fast(struct
#endif
if (hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
@ -796,7 +796,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
*ieee80211_get_qos_ctl(hdr) = tid;
}
@@ -3732,6 +3738,7 @@ static bool ieee80211_xmit_fast(struct i
@@ -3733,6 +3739,7 @@ static bool ieee80211_xmit_fast(struct i
struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
struct tid_ampdu_tx *tid_tx = NULL;
struct sk_buff *next;
@ -804,7 +804,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
u8 tid = IEEE80211_NUM_TIDS;
/* control port protocol needs a lot of special handling */
@@ -3757,6 +3764,8 @@ static bool ieee80211_xmit_fast(struct i
@@ -3758,6 +3765,8 @@ static bool ieee80211_xmit_fast(struct i
}
}
@ -813,7 +813,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
/* after this point (skb is modified) we cannot return false */
skb = ieee80211_tx_skb_fixup(skb, ieee80211_sdata_netdev_features(sdata));
if (!skb)
@@ -3764,7 +3773,8 @@ static bool ieee80211_xmit_fast(struct i
@@ -3765,7 +3774,8 @@ static bool ieee80211_xmit_fast(struct i
skb_list_walk_safe(skb, skb, next) {
skb_mark_not_on_list(skb);
@ -823,7 +823,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
}
return true;
@@ -4244,8 +4254,15 @@ void __ieee80211_subif_start_xmit(struct
@@ -4252,8 +4262,15 @@ void __ieee80211_subif_start_xmit(struct
return;
}
@ -839,7 +839,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (ieee80211_lookup_ra_sta(sdata, skb, &sta))
goto out_free;
@@ -4255,8 +4272,6 @@ void __ieee80211_subif_start_xmit(struct
@@ -4263,8 +4280,6 @@ void __ieee80211_subif_start_xmit(struct
skb_set_queue_mapping(skb, ieee80211_select_queue(sdata, sta, skb));
ieee80211_aggr_check(sdata, sta, skb);

View File

@ -106,7 +106,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
rx_accept:
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -2018,6 +2018,8 @@ void __ieee80211_xmit_fast(struct ieee80
@@ -2022,6 +2022,8 @@ void __ieee80211_xmit_fast(struct ieee80
struct ieee80211_fast_tx *fast_tx,
struct sk_buff *skb, bool ampdu,
const u8 *da, const u8 *sa);

View File

@ -44,7 +44,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
/**
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1251,6 +1251,21 @@ static int ieee80211_start_ap(struct wip
@@ -1252,6 +1252,21 @@ static int ieee80211_start_ap(struct wip
prev_beacon_int = link_conf->beacon_int;
link_conf->beacon_int = params->beacon_interval;

View File

@ -44,7 +44,7 @@ Signed-off-by: Johannes Berg <johannes.berg@intel.com>
/**
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1280,6 +1280,21 @@ static int ieee80211_start_ap(struct wip
@@ -1281,6 +1281,21 @@ static int ieee80211_start_ap(struct wip
changed |= BSS_CHANGED_HE_BSS_COLOR;
}

View File

@ -13,7 +13,7 @@ Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -5968,6 +5968,18 @@ void ieee80211_queue_delayed_work(struct
@@ -5964,6 +5964,18 @@ void ieee80211_queue_delayed_work(struct
unsigned long delay);
/**
@ -34,7 +34,7 @@ Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
* @tid: the TID to BA on.
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -552,6 +552,23 @@ void ieee80211_tx_ba_session_handle_star
@@ -554,6 +554,23 @@ void ieee80211_tx_ba_session_handle_star
ieee80211_send_addba_with_timeout(sta, tid_tx);
}

View File

@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -4572,6 +4572,12 @@ void ieee80211_check_fast_rx(struct sta_
@@ -4564,6 +4564,12 @@ void ieee80211_check_fast_rx(struct sta_
}
break;
@ -23,7 +23,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
default:
goto clear;
}
@@ -4780,6 +4786,7 @@ static bool ieee80211_invoke_fast_rx(str
@@ -4772,6 +4778,7 @@ static bool ieee80211_invoke_fast_rx(str
struct sk_buff *skb = rx->skb;
struct ieee80211_hdr *hdr = (void *)skb->data;
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
@ -31,7 +31,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
int orig_len = skb->len;
int hdrlen = ieee80211_hdrlen(hdr->frame_control);
int snap_offs = hdrlen;
@@ -4841,7 +4848,8 @@ static bool ieee80211_invoke_fast_rx(str
@@ -4833,7 +4840,8 @@ static bool ieee80211_invoke_fast_rx(str
snap_offs += IEEE80211_CCMP_HDR_LEN;
}
@ -41,7 +41,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (!pskb_may_pull(skb, snap_offs + sizeof(*payload)))
return false;
@@ -4880,13 +4888,29 @@ static bool ieee80211_invoke_fast_rx(str
@@ -4872,13 +4880,29 @@ static bool ieee80211_invoke_fast_rx(str
/* do the header conversion - first grab the addresses */
ether_addr_copy(addrs.da, skb->data + fast_rx->da_offs);
ether_addr_copy(addrs.sa, skb->data + fast_rx->sa_offs);

View File

@ -12,7 +12,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -4196,6 +4196,10 @@ struct ieee80211_prep_tx_info {
@@ -4192,6 +4192,10 @@ struct ieee80211_prep_tx_info {
* Note that a sta can also be inserted or removed with valid links,
* i.e. passed to @sta_add/@sta_state with sta->valid_links not zero.
* In fact, cannot change from having valid_links and not having them.
@ -23,7 +23,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
*/
struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -4551,6 +4555,11 @@ struct ieee80211_ops {
@@ -4547,6 +4551,11 @@ struct ieee80211_ops {
struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
u16 old_links, u16 new_links);
@ -63,7 +63,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
u16 old_links, u16 new_links,
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1935,7 +1935,8 @@ void ieee80211_color_change_finalize_wor
@@ -1939,7 +1939,8 @@ void ieee80211_color_collision_detection
/* interface handling */
#define MAC80211_SUPPORTED_FEATURES_TX (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
NETIF_F_HW_CSUM | NETIF_F_SG | \

View File

@ -1,25 +0,0 @@
From: Felix Fietkau <nbd@nbd.name>
Date: Fri, 24 Mar 2023 13:04:17 +0100
Subject: [PATCH] wifi: mac80211: fix invalid drv_sta_pre_rcu_remove calls for
non-uploaded sta
Avoid potential data corruption issues caused by uninitialized driver
private data structures.
Reported-by: Brian Coverstone <brian@mainsequence.net>
Fixes: 6a9d1b91f34d ("mac80211: add pre-RCU-sync sta removal driver operation")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -1241,7 +1241,8 @@ static int __must_check __sta_info_destr
list_del_rcu(&sta->list);
sta->removed = true;
- drv_sta_pre_rcu_remove(local, sta->sdata, sta);
+ if (sta->uploaded)
+ drv_sta_pre_rcu_remove(local, sta->sdata, sta);
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
rcu_access_pointer(sdata->u.vlan.sta) == sta)

View File

@ -123,7 +123,7 @@ Reviewed-by: Peer, Ilan <ilan.peer@intel.com>
info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
return TX_CONTINUE;
}
@@ -1325,7 +1325,7 @@ static struct txq_info *ieee80211_get_tx
@@ -1326,7 +1326,7 @@ static struct txq_info *ieee80211_get_tx
if (!(info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) &&
unlikely(!ieee80211_is_data_present(hdr->frame_control))) {
if ((!ieee80211_is_mgmt(hdr->frame_control) ||

View File

@ -12,7 +12,7 @@ Reviewed-by: Greenman, Gregory <gregory.greenman@intel.com>
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -3922,6 +3922,10 @@ struct ieee80211_prep_tx_info {
@@ -3918,6 +3918,10 @@ struct ieee80211_prep_tx_info {
* Note that vif can be NULL.
* The callback can sleep.
*
@ -23,7 +23,7 @@ Reviewed-by: Greenman, Gregory <gregory.greenman@intel.com>
* @channel_switch: Drivers that need (or want) to offload the channel
* switch operation for CSAs received from the AP may implement this
* callback. They must then call ieee80211_chswitch_done() to indicate
@@ -4376,6 +4380,8 @@ struct ieee80211_ops {
@@ -4372,6 +4376,8 @@ struct ieee80211_ops {
#endif
void (*flush)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
u32 queues, bool drop);

View File

@ -0,0 +1,62 @@
From: Ryder Lee <ryder.lee@mediatek.com>
Date: Sat, 18 Feb 2023 01:49:25 +0800
Subject: [PATCH] wifi: mac80211: add LDPC related flags in ieee80211_bss_conf
This is utilized to pass LDPC configurations from user space
(i.e. hostapd) to driver.
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Link: https://lore.kernel.org/r/1de696aaa34efd77a926eb657b8c0fda05aaa177.1676628065.git.ryder.lee@mediatek.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -653,6 +653,9 @@ struct ieee80211_fils_discovery {
* write-protected by sdata_lock and local->mtx so holding either is fine
* for read access.
* @color_change_color: the bss color that will be used after the change.
+ * @ht_ldpc: in AP mode, indicates interface has HT LDPC capability.
+ * @vht_ldpc: in AP mode, indicates interface has VHT LDPC capability.
+ * @he_ldpc: in AP mode, indicates interface has HE LDPC capability.
* @vht_su_beamformer: in AP mode, does this BSS support operation as an VHT SU
* beamformer
* @vht_su_beamformee: in AP mode, does this BSS support operation as an VHT SU
@@ -744,6 +747,9 @@ struct ieee80211_bss_conf {
bool color_change_active;
u8 color_change_color;
+ bool ht_ldpc;
+ bool vht_ldpc;
+ bool he_ldpc;
bool vht_su_beamformer;
bool vht_su_beamformee;
bool vht_mu_beamformer;
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1252,7 +1252,15 @@ static int ieee80211_start_ap(struct wip
prev_beacon_int = link_conf->beacon_int;
link_conf->beacon_int = params->beacon_interval;
+ if (params->ht_cap)
+ link_conf->ht_ldpc =
+ params->ht_cap->cap_info &
+ cpu_to_le16(IEEE80211_HT_CAP_LDPC_CODING);
+
if (params->vht_cap) {
+ link_conf->vht_ldpc =
+ params->vht_cap->vht_cap_info &
+ cpu_to_le32(IEEE80211_VHT_CAP_RXLDPC);
link_conf->vht_su_beamformer =
params->vht_cap->vht_cap_info &
cpu_to_le32(IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE);
@@ -1282,6 +1290,9 @@ static int ieee80211_start_ap(struct wip
}
if (params->he_cap) {
+ link_conf->he_ldpc =
+ params->he_cap->phy_cap_info[1] &
+ IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD;
link_conf->he_su_beamformer =
params->he_cap->phy_cap_info[3] &
IEEE80211_HE_PHY_CAP3_SU_BEAMFORMER;

View File

@ -18,7 +18,7 @@
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1671,6 +1671,7 @@ enum ieee80211_smps_mode {
@@ -1677,6 +1677,7 @@ enum ieee80211_smps_mode {
*
* @power_level: requested transmit power (in dBm), backward compatibility
* value only that is set to the minimum of all interfaces
@ -26,7 +26,7 @@
*
* @chandef: the channel definition to tune to
* @radar_enabled: whether radar detection is enabled
@@ -1691,6 +1692,7 @@ enum ieee80211_smps_mode {
@@ -1697,6 +1698,7 @@ enum ieee80211_smps_mode {
struct ieee80211_conf {
u32 flags;
int power_level, dynamic_ps_timeout;
@ -57,7 +57,7 @@
__NL80211_ATTR_AFTER_LAST,
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3028,6 +3028,19 @@ static int ieee80211_get_tx_power(struct
@@ -3046,6 +3046,19 @@ static int ieee80211_get_tx_power(struct
return 0;
}
@ -77,7 +77,7 @@
static void ieee80211_rfkill_poll(struct wiphy *wiphy)
{
struct ieee80211_local *local = wiphy_priv(wiphy);
@@ -4911,6 +4924,7 @@ const struct cfg80211_ops mac80211_confi
@@ -4953,6 +4966,7 @@ const struct cfg80211_ops mac80211_confi
.set_wiphy_params = ieee80211_set_wiphy_params,
.set_tx_power = ieee80211_set_tx_power,
.get_tx_power = ieee80211_get_tx_power,
@ -87,7 +87,7 @@
CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1535,6 +1535,7 @@ struct ieee80211_local {
@@ -1538,6 +1538,7 @@ struct ieee80211_local {
int dynamic_ps_forced_timeout;
int user_power_level; /* in dBm, for all interfaces */

View File

@ -8,16 +8,16 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mwlwifi
PKG_RELEASE=3
PKG_RELEASE=1
PKG_LICENSE:=ISC
PKG_LICENSE_FILES:=
PKG_SOURCE_URL:=https://github.com/kaloz/mwlwifi
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2020-02-06
PKG_SOURCE_VERSION:=a2fd00bb74c35820dfe233d762690c0433a87ef5
PKG_MIRROR_HASH:=0eda0e774a87e58e611d6436350e1cf2be3de50fddde334909a07a15b0c9862b
PKG_SOURCE_DATE:=2023-03-11
PKG_SOURCE_VERSION:=c916ac13376d1b0801f3f787277fa47ce6b694eb
PKG_MIRROR_HASH:=b95001b60fe5c28f08be5a52b65276d99877be57e567ad7afab95860f6aff57d
PKG_MAINTAINER:=Imre Kaloz <kaloz@openwrt.org>
PKG_BUILD_PARALLEL:=1

View File

@ -1,35 +0,0 @@
From 182391a3c96ff6ad79bbba0758338a16a66abbd8 Mon Sep 17 00:00:00 2001
From: DENG Qingfang <dengqf6@mail2.sysu.edu.cn>
Date: Wed, 12 Feb 2020 14:18:58 +0800
Subject: [PATCH] Fix driver loading with backports 5.3+
Commit 747796b2f126 did not solve the issue that it crashes when an older kernel
with a newer backport tries loading it, because it only detects kernel version.
As net/cfg80211.h in 5.3+ defines VENDOR_CMD_RAW_DATA, use it as a condition.
Signed-off-by: DENG Qingfang <dqfext@gmail.com>
---
vendor_cmd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/vendor_cmd.c
+++ b/vendor_cmd.c
@@ -92,7 +92,7 @@ static const struct wiphy_vendor_command
.subcmd = MWL_VENDOR_CMD_SET_BF_TYPE},
.flags = WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mwl_vendor_cmd_set_bf_type,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0))
+#ifdef VENDOR_CMD_RAW_DATA
.policy = mwl_vendor_attr_policy,
#endif
},
@@ -101,7 +101,7 @@ static const struct wiphy_vendor_command
.subcmd = MWL_VENDOR_CMD_GET_BF_TYPE},
.flags = WIPHY_VENDOR_CMD_NEED_NETDEV,
.doit = mwl_vendor_cmd_get_bf_type,
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0))
+#ifdef VENDOR_CMD_RAW_DATA
.policy = mwl_vendor_attr_policy,
#endif
}

View File

@ -1,32 +0,0 @@
From 392f8e9d798acff3079e753dd881e272f6150d74 Mon Sep 17 00:00:00 2001
From: Robert Marko <robert.marko@sartura.hr>
Date: Wed, 30 Mar 2022 19:32:38 +0200
Subject: [PATCH] mwlwifi: remove MODULE_SUPPORTED_DEVICE
Kernel 5.12 finally removed all MODULE_SUPPORTED_DEVICE references and
support for it as it was never actually implemented and was safe to
drop it completely.
So, do the same in order to compile in 5.12 and newer.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
hif/pcie/pcie.c | 2 --
1 file changed, 2 deletions(-)
--- a/hif/pcie/pcie.c
+++ b/hif/pcie/pcie.c
@@ -31,7 +31,6 @@
#include "hif/pcie/rx_ndp.h"
#define PCIE_DRV_DESC "Marvell Mac80211 Wireless PCIE Network Driver"
-#define PCIE_DEV_NAME "Marvell 802.11ac PCIE Adapter"
#define MAX_WAIT_FW_COMPLETE_ITERATIONS 10000
#define CHECK_BA_TRAFFIC_TIME 300 /* msec */
@@ -1641,5 +1640,4 @@ MODULE_DESCRIPTION(PCIE_DRV_DESC);
MODULE_VERSION(PCIE_DRV_VERSION);
MODULE_AUTHOR("Marvell Semiconductor, Inc.");
MODULE_LICENSE("GPL v2");
-MODULE_SUPPORTED_DEVICE(PCIE_DEV_NAME);
MODULE_DEVICE_TABLE(pci, pcie_id_tbl);

View File

@ -1,39 +0,0 @@
From 16e51cb83f9fa1717383c9d67f5531df7348347c Mon Sep 17 00:00:00 2001
From: Robert Marko <robert.marko@sartura.hr>
Date: Wed, 30 Mar 2022 19:51:56 +0200
Subject: [PATCH] mwlwifi: replace get/set_fs() calls
Since kernel 5.9 the get/set_fs() call implementation have started to get
dropped from individual architectures, ARM64 one got dropped in 5.11.
Replace the get/set_fs() calls with force_uaccess_begin/end() to allow
compiling on newer kernels.
There is no need to add kernel version checks as the replacement functions
are available since kernel 5.9.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
---
hif/pcie/pcie.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--- a/hif/pcie/pcie.c
+++ b/hif/pcie/pcie.c
@@ -1293,8 +1293,7 @@ static void pcie_bf_mimo_ctrl_decode(str
char *buf = &str_buf[0];
mm_segment_t oldfs;
- oldfs = get_fs();
- set_fs(KERNEL_DS);
+ oldfs = force_uaccess_begin();
buf += sprintf(buf, "\nMAC: %pM\n", bf_mimo_ctrl->rec_mac);
buf += sprintf(buf, "SU_0_MU_1: %d\n", bf_mimo_ctrl->type);
@@ -1314,7 +1313,7 @@ static void pcie_bf_mimo_ctrl_decode(str
filename, (unsigned int)fp_data);
}
- set_fs(oldfs);
+ force_uaccess_end(oldfs);
}
static void pcie_process_account(struct ieee80211_hw *hw)

View File

@ -19,7 +19,7 @@ Signed-off-by: Robert Marko <robert.marko@sartura.hr>
--- a/hif/pcie/pcie.c
+++ b/hif/pcie/pcie.c
@@ -570,7 +570,8 @@ static struct device_node *pcie_get_devi
@@ -573,7 +573,8 @@ static struct device_node *pcie_get_devi
struct device_node *dev_node;
dev_node = pci_bus_to_OF_node(pcie_priv->pdev->bus);

View File

@ -1,6 +1,6 @@
--- a/core.c
+++ b/core.c
@@ -692,7 +692,7 @@ static void mwl_chnl_switch_event(struct
@@ -706,7 +706,7 @@ static void mwl_chnl_switch_event(struct
vif = container_of((void *)mwl_vif, struct ieee80211_vif,
drv_priv);
@ -11,7 +11,7 @@
spin_unlock_bh(&priv->vif_lock);
--- a/debugfs.c
+++ b/debugfs.c
@@ -462,9 +462,9 @@ static ssize_t mwl_debugfs_vif_read(stru
@@ -455,9 +455,9 @@ static ssize_t mwl_debugfs_vif_read(stru
switch (vif->type) {
case NL80211_IFTYPE_AP:
len += scnprintf(p + len, size - len, "type: ap\n");
@ -24,7 +24,7 @@
len += scnprintf(p + len, size - len,
"ssid: %s\n", ssid);
len += scnprintf(p + len, size - len,
@@ -486,8 +486,8 @@ static ssize_t mwl_debugfs_vif_read(stru
@@ -479,8 +479,8 @@ static ssize_t mwl_debugfs_vif_read(stru
"type: unknown\n");
break;
}
@ -35,7 +35,7 @@
len += scnprintf(p + len, size - len,
"channel: %d: width: %d\n",
chan_def->chan->hw_value,
@@ -573,28 +573,28 @@ static ssize_t mwl_debugfs_sta_read(stru
@@ -564,28 +564,28 @@ static ssize_t mwl_debugfs_sta_read(stru
"amsdu cap: 0x%02x\n",
sta_info->amsdu_ctrl.cap);
}
@ -99,7 +99,7 @@
if (priv->chip_type == MWL8997)
ether_addr_copy(pcmd->start_cmd.bssid, mwl_vif->bssid);
pcmd->start_cmd.bss_type = 1;
@@ -2085,7 +2086,7 @@ int mwl_fwcmd_set_beacon(struct ieee8021
@@ -2091,7 +2092,7 @@ int mwl_fwcmd_set_beacon(struct ieee8021
if (mwl_fwcmd_set_wsc_ie(hw, b_inf->ie_wsc_len, b_inf->ie_wsc_ptr))
goto err;
@ -108,7 +108,7 @@
goto err;
if (b_inf->cap_info & WLAN_CAPABILITY_SPECTRUM_MGMT)
@@ -2147,38 +2148,38 @@ int mwl_fwcmd_set_new_stn_add(struct iee
@@ -2153,38 +2154,38 @@ int mwl_fwcmd_set_new_stn_add(struct iee
ether_addr_copy(pcmd->mac_addr, sta->addr);
if (hw->conf.chandef.chan->band == NL80211_BAND_2GHZ)
@ -161,7 +161,7 @@
}
pcmd->is_qos_sta = sta->wme;
@@ -2234,38 +2235,38 @@ int mwl_fwcmd_set_new_stn_add_sc4(struct
@@ -2240,38 +2241,38 @@ int mwl_fwcmd_set_new_stn_add_sc4(struct
ether_addr_copy(pcmd->mac_addr, sta->addr);
if (hw->conf.chandef.chan->band == NL80211_BAND_2GHZ)
@ -214,7 +214,7 @@
}
pcmd->is_qos_sta = sta->wme;
@@ -2782,9 +2783,9 @@ int mwl_fwcmd_create_ba(struct ieee80211
@@ -2788,9 +2789,9 @@ int mwl_fwcmd_create_ba(struct ieee80211
pcmd->ba_info.create_params.flags = cpu_to_le32(ba_flags);
pcmd->ba_info.create_params.queue_id = stream->idx;
pcmd->ba_info.create_params.param_info =
@ -226,7 +226,7 @@
IEEE80211_HT_AMPDU_PARM_DENSITY);
if (direction == BA_FLAG_DIRECTION_UP) {
pcmd->ba_info.create_params.reset_seq_no = 0;
@@ -2794,9 +2795,9 @@ int mwl_fwcmd_create_ba(struct ieee80211
@@ -2800,9 +2801,9 @@ int mwl_fwcmd_create_ba(struct ieee80211
pcmd->ba_info.create_params.current_seq = cpu_to_le16(0);
}
if (priv->chip_type == MWL8964 &&
@ -288,7 +288,7 @@
{
switch (vif->type) {
case NL80211_IFTYPE_AP:
@@ -583,10 +583,10 @@ static int mwl_mac80211_sta_add(struct i
@@ -584,10 +584,10 @@ static int mwl_mac80211_sta_add(struct i
if (vif->type == NL80211_IFTYPE_MESH_POINT)
sta_info->is_mesh_node = true;
@ -301,7 +301,7 @@
sta_info->amsdu_ctrl.cap = MWL_AMSDU_SIZE_8K;
else
sta_info->amsdu_ctrl.cap = MWL_AMSDU_SIZE_4K;
@@ -668,7 +668,7 @@ static int mwl_mac80211_sta_remove(struc
@@ -669,7 +669,7 @@ static int mwl_mac80211_sta_remove(struc
static int mwl_mac80211_conf_tx(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
@ -310,15 +310,7 @@
const struct ieee80211_tx_queue_params *params)
{
struct mwl_priv *priv = hw->priv;
@@ -768,6 +768,7 @@ static int mwl_mac80211_ampdu_action(str
spin_lock_bh(&priv->stream_lock);
break;
}
+ break;
case IEEE80211_AMPDU_RX_STOP:
if (priv->chip_type == MWL8964) {
struct mwl_ampdu_stream tmp;
@@ -930,4 +931,5 @@ const struct ieee80211_ops mwl_mac80211_
@@ -928,4 +928,5 @@ const struct ieee80211_ops mwl_mac80211_
.pre_channel_switch = mwl_mac80211_chnl_switch,
.sw_scan_start = mwl_mac80211_sw_scan_start,
.sw_scan_complete = mwl_mac80211_sw_scan_complete,
@ -370,7 +362,7 @@
case TX_RATE_FORMAT_LEGACY:
--- a/hif/pcie/tx.c
+++ b/hif/pcie/tx.c
@@ -157,7 +157,7 @@ static int pcie_txbd_ring_create(struct
@@ -153,7 +153,7 @@ static int pcie_txbd_ring_create(struct
wiphy_info(priv->hw->wiphy,
"TX ring: - base: %p, pbase: 0x%x, len: %d\n",
pcie_priv->txbd_ring_vbase,
@ -379,7 +371,7 @@
pcie_priv->txbd_ring_size);
for (num = 0; num < PCIE_MAX_TXRX_BD; num++) {
@@ -1153,7 +1153,7 @@ void pcie_tx_xmit(struct ieee80211_hw *h
@@ -1091,7 +1091,7 @@ void pcie_tx_xmit(struct ieee80211_hw *h
index = SYSADPT_TX_WMM_QUEUES - index - 1;
txpriority = index;

View File

@ -0,0 +1,35 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=yafut
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=https://github.com/kempniu/yafut.git
PKG_SOURCE_DATE:=2023-03-31
PKG_SOURCE_VERSION:=16435e89d449f953712983315e1a89cdb678620d
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=LICENSE
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
CMAKE_INSTALL:=1
define Package/yafut
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Yet Another File UTility
DEPENDS:=@NAND_SUPPORT
endef
define Package/yafut/description
A program for copying files from/to Yaffs file systems from userspace.
endef
define Package/yafut/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/yafut $(1)/usr/bin
endef
$(eval $(call BuildPackage,yafut))

View File

@ -9,6 +9,7 @@ endef
define Device/mikrotik_nor
$(Device/mikrotik)
DEVICE_PACKAGES := -yafut
IMAGE/sysupgrade.bin := append-kernel | kernel2minor -s 1024 -e | \
pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | \
check-size | append-metadata
@ -16,8 +17,5 @@ endef
define Device/mikrotik_nand
$(Device/mikrotik)
IMAGE/sysupgrade.bin = append-kernel | kernel2minor -s 2048 -e -c | \
sysupgrade-tar kernel=$$$$@ | append-metadata
DEVICE_PACKAGES := nand-utils
DEFAULT := n
IMAGE/sysupgrade.bin = append-kernel | sysupgrade-tar | append-metadata
endef

View File

@ -392,6 +392,12 @@ define Device/aruba_ap-105
DEVICE_MODEL := AP-105
IMAGE_SIZE := 16000k
DEVICE_PACKAGES := kmod-i2c-gpio kmod-tpm-i2c-atmel
LOADER_TYPE := bin
LOADER_FLASH_OFFS := 0x42000
COMPILE := loader-$(1).bin
COMPILE/loader-$(1).bin := loader-okli-compile
KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x4f4b4c49 | loader-okli $(1) 8128 | uImage none
KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | uImage none
endef
TARGET_DEVICES += aruba_ap-105

View File

@ -7,8 +7,7 @@ platform_check_image() {
return 0
}
RAMFS_COPY_BIN='fw_printenv fw_setenv nandwrite'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
RAMFS_COPY_BIN='yafut'
platform_do_upgrade_mikrotik_nand() {
CI_KERNPART=none
@ -21,8 +20,7 @@ platform_do_upgrade_mikrotik_nand() {
board_dir=${board_dir%/}
[ -n "$board_dir" ] || return
mtd erase kernel
tar xf "$1" ${board_dir}/kernel -O | nandwrite -o "$fw_mtd" -
tar xf "$1" ${board_dir}/kernel -O | yafut -d "$fw_mtd" -w -i - -o kernel -m 0755 || return
nand_do_upgrade "$1"
}

View File

@ -3,7 +3,7 @@ FEATURES += minor nand
KERNELNAME := vmlinux vmlinuz
IMAGES_DIR := ../../..
DEFAULT_PACKAGES += wpad-basic-openssl
DEFAULT_PACKAGES += wpad-basic-openssl yafut
define Target/Description
Build firmware images for MikroTik devices based on Qualcomm Atheros

View File

@ -15,7 +15,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1618,6 +1618,109 @@ command_cleanup:
@@ -1622,6 +1622,109 @@ command_cleanup:
}
/*
@ -125,7 +125,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.org>
* non-error returns are a promise to giveback() the urb later
* we drop ownership so next owner (or urb unlink) can get it
*/
@@ -5457,6 +5560,7 @@ static const struct hc_driver xhci_hc_dr
@@ -5461,6 +5564,7 @@ static const struct hc_driver xhci_hc_dr
.endpoint_reset = xhci_endpoint_reset,
.check_bandwidth = xhci_check_bandwidth,
.reset_bandwidth = xhci_reset_bandwidth,

View File

@ -226,7 +226,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
}
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -876,8 +876,8 @@ static void xhci_clear_command_ring(stru
@@ -880,8 +880,8 @@ static void xhci_clear_command_ring(stru
seg = ring->deq_seg;
do {
memset(seg->trbs, 0,
@ -237,7 +237,7 @@ Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
cpu_to_le32(~TRB_CYCLE);
seg = seg->next;
} while (seg != ring->deq_seg);
@@ -888,7 +888,7 @@ static void xhci_clear_command_ring(stru
@@ -892,7 +892,7 @@ static void xhci_clear_command_ring(stru
ring->enq_seg = ring->deq_seg;
ring->enqueue = ring->dequeue;

View File

@ -40,7 +40,7 @@ it on BCM4708 family.
/* called during probe() after chip reset completes */
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -157,6 +157,49 @@ int xhci_start(struct xhci_hcd *xhci)
@@ -158,6 +158,49 @@ int xhci_start(struct xhci_hcd *xhci)
return ret;
}
@ -90,7 +90,7 @@ it on BCM4708 family.
/*
* Reset a halted HC.
*
@@ -607,10 +650,20 @@ static int xhci_init(struct usb_hcd *hcd
@@ -611,10 +654,20 @@ static int xhci_init(struct usb_hcd *hcd
static int xhci_run_finished(struct xhci_hcd *xhci)
{
@ -114,7 +114,7 @@ it on BCM4708 family.
xhci->shared_hcd->state = HC_STATE_RUNNING;
xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
@@ -620,6 +673,10 @@ static int xhci_run_finished(struct xhci
@@ -624,6 +677,10 @@ static int xhci_run_finished(struct xhci
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB3 roothub");
return 0;

View File

@ -0,0 +1,34 @@
#!/bin/sh
[ -e /lib/firmware/$FIRMWARE ] && exit 0
. /lib/functions/caldata.sh
caldata_extract_swap() {
local part=$1
local offset=$2
local count=$3
local mtd
mtd=$(find_mtd_chardev $part)
[ -n "$mtd" ] || caldata_die "no mtd device found for partition $part"
offset=$(($offset / 2))
count=$(($count / 2))
dd if=$mtd of=/lib/firmware/$FIRMWARE bs=2 skip=$offset count=$count conv=swab 2>/dev/null || \
caldata_die "failed to extract calibration data from $mtd"
}
case "$FIRMWARE" in
"ath9k-eeprom-pci-0000:00:01.0.bin")
case "$(board_name)" in
huawei,hg556a-b)
caldata_extract_swap "cal_data" 0x1e000 0xeb8
;;
*)
caldata_die "board $board is not supported yet"
;;
esac
;;
esac

View File

@ -119,20 +119,14 @@
};
};
ath9k-fixup {
compatible = "brcm,ath9k-fixup";
reg = <0x30000000 0x8000000>;
ath9k-leds {
compatible = "gpio-leds";
pci-dev = <1>;
nvmem-cells = <&macaddr_cfe_6a0>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
ath,eeprom = <&cal_data 0x1e000>;
ath,endian-check;
ath,led-pin = <2>;
ath,led-active-high;
wlan {
label = "red:wlan";
gpios = <&ath9k 2 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "phy0tpt";
};
};
};
@ -164,6 +158,20 @@
&pci {
status = "okay";
ath9k: wifi@1,0 {
compatible = "pci168c,0029";
reg = <0x0800 0 0 0 0>;
qca,no-eeprom;
nvmem-cells = <&macaddr_cfe_6a0>;
nvmem-cell-names = "mac-address";
mac-address-increment = <1>;
#gpio-cells = <2>;
gpio-controller;
};
};
&pflash {
@ -207,6 +215,16 @@
status = "okay";
};
&cal_data {
compatible = "nvmem-cells";
#address-cells = <1>;
#size-cells = <1>;
cal_data_1e000: cal@1e000 {
reg = <0x1e000 0xeb8>;
};
};
&cfe {
compatible = "nvmem-cells";
#address-cells = <1>;

View File

@ -283,16 +283,14 @@
pci: pci@fffe1000 {
compatible = "brcm,bcm6348-pci";
reg = <0xfffe1000 0x200>,
<0x08000000 0x10000>;
reg-names = "pci",
"pci-io";
reg = <0xfffe1000 0x200>;
#address-cells = <3>;
#size-cells = <2>;
device_type = "pci";
bus-range = <0x00 0x01>;
ranges = <0x2000000 0 0x30000000 0x30000000 0 0x8000000>;
ranges = <0x2000000 0 0x30000000 0x30000000 0 0x8000000>,
<0x1000000 0 0x08000000 0x08000000 0 0x0010000>;
linux,pci-probe-only = <1>;
interrupt-parent = <&periph_intc>;

View File

@ -412,16 +412,14 @@
pci: pci@10001000 {
compatible = "brcm,bcm6348-pci";
reg = <0x10001000 0x200>,
<0x08000000 0x10000>;
reg-names = "pci",
"pci-io";
reg = <0x10001000 0x200>;
#address-cells = <3>;
#size-cells = <2>;
device_type = "pci";
bus-range = <0x00 0x01>;
ranges = <0x2000000 0 0x30000000 0x30000000 0 0x8000000>;
ranges = <0x2000000 0 0x30000000 0x30000000 0 0x8000000>,
<0x1000000 0 0x08000000 0x08000000 0 0x0010000>;
linux,pci-probe-only = <1>;
interrupt-parent = <&periph_intc>;

View File

@ -1,242 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* ATH9K Fixup Driver
*
* Copyright (C) 2020 Álvaro Fernández Rojas <noltari@gmail.com>
* Copyright (C) 2014 Jonas Gorski <jonas.gorski@gmail.com>
* Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
* Copyright (C) 2008 Florian Fainelli <f.fainelli@gmail.com>
*/
#include <linux/delay.h>
#include <linux/etherdevice.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/mtd/mtd.h>
#include <linux/of_net.h>
#include <linux/of_platform.h>
#include <linux/pci.h>
#include <linux/types.h>
#include <linux/ath9k_platform.h>
#define ATH9K_MAX_FIXUPS 2
#define ATH9K_DEF_LED_PIN -1
#define ATH9K_DEF_PCI_DEV 255
struct ath9k_fixup {
struct device *dev;
struct resource *mem_res;
u32 pci_dev;
u8 mac[ETH_ALEN];
struct ath9k_platform_data pdata;
};
static int ath9k_num_fixups;
static struct ath9k_fixup *ath9k_fixups[ATH9K_MAX_FIXUPS];
static void ath9k_pci_fixup(struct pci_dev *dev)
{
void __iomem *mem;
struct ath9k_fixup *priv = NULL;
struct ath9k_platform_data *pdata = NULL;
struct pci_dev *bridge = pci_upstream_bridge(dev);
u16 *cal_data = NULL;
u16 cmd;
u32 bar0;
u32 val;
unsigned i;
int rc;
for (i = 0; i < ath9k_num_fixups; i++) {
if (ath9k_fixups[i]->pci_dev != PCI_SLOT(dev->devfn))
continue;
priv = ath9k_fixups[i];
cal_data = priv->pdata.eeprom_data;
pdata = &priv->pdata;
break;
}
if (cal_data == NULL)
return;
if (*cal_data != 0xa55a) {
pr_err("pci %s: invalid calibration data\n", pci_name(dev));
return;
}
pr_info("pci %s: fixup device configuration\n", pci_name(dev));
val = priv->mem_res->start;
mem = ioremap(priv->mem_res->start, resource_size(priv->mem_res));
if (!mem) {
pr_err("pci %s: ioremap error\n", pci_name(dev));
return;
}
if (bridge) {
rc = pci_enable_device(bridge);
if (rc < 0)
pr_err("pci %s: bridge enable error\n", pci_name(dev));
}
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0);
pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0);
pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, val);
pci_read_config_word(dev, PCI_COMMAND, &cmd);
cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
pci_write_config_word(dev, PCI_COMMAND, cmd);
/* set offset to first reg address */
cal_data += 3;
while(*cal_data != 0xffff) {
u32 reg;
reg = *cal_data++;
val = *cal_data++;
val |= (*cal_data++) << 16;
writel(val, mem + reg);
udelay(100);
}
pci_read_config_dword(dev, PCI_VENDOR_ID, &val);
dev->vendor = val & 0xffff;
dev->device = (val >> 16) & 0xffff;
pci_read_config_dword(dev, PCI_CLASS_REVISION, &val);
dev->revision = val & 0xff;
dev->class = val >> 8; /* upper 3 bytes */
pci_read_config_word(dev, PCI_COMMAND, &cmd);
cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
pci_write_config_word(dev, PCI_COMMAND, cmd);
pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, bar0);
if (bridge)
pci_disable_device(bridge);
iounmap(mem);
dev->dev.platform_data = pdata;
}
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, ath9k_pci_fixup);
static int ath9k_mtd_eeprom(struct ath9k_fixup *priv)
{
struct device *dev = priv->dev;
struct device_node *node = dev->of_node;
struct device_node *mtd_np = NULL;
struct mtd_info *the_mtd;
phandle phandle;
size_t eeprom_readlen;
const char *part;
const __be32 *list;
int ret, i;
list = of_get_property(node, "ath,eeprom", &i);
if (!list || (i != (2 * sizeof(*list))))
return -ENODEV;
phandle = be32_to_cpup(list++);
if (phandle)
mtd_np = of_find_node_by_phandle(phandle);
if (!mtd_np)
return -ENODEV;
part = of_get_property(mtd_np, "label", NULL);
if (!part)
part = mtd_np->name;
the_mtd = get_mtd_device_nm(part);
if (IS_ERR(the_mtd))
return -ENODEV;
ret = mtd_read(the_mtd, be32_to_cpup(list),
ATH9K_PLAT_EEP_MAX_WORDS * sizeof(u16),
&eeprom_readlen, (void *) priv->pdata.eeprom_data);
put_mtd_device(the_mtd);
if (ret)
return ret;
return 0;
}
static int ath9k_fixup_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct ath9k_fixup *priv;
struct resource *res;
int ret;
if (ath9k_num_fixups >= ATH9K_MAX_FIXUPS)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res)
return -EINVAL;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->dev = dev;
priv->mem_res = res;
ret = of_property_read_u32(node, "pci-dev", &priv->pci_dev);
if (ret)
priv->pci_dev = ATH9K_DEF_PCI_DEV;
ret = ath9k_mtd_eeprom(priv);
if (ret)
return ret;
priv->pdata.endian_check = of_property_read_bool(node,
"ath,endian-check");
ret = of_property_read_s32(node, "ath,led-pin", &priv->pdata.led_pin);
if (ret)
priv->pdata.led_pin = ATH9K_DEF_LED_PIN;
priv->pdata.led_active_high = of_property_read_bool(node,
"ath,led-active-high");
of_get_mac_address(node, priv->mac);
if (is_valid_ether_addr(priv->mac)) {
dev_info(dev, "mtd mac %pM\n", priv->mac);
} else {
random_ether_addr(priv->mac);
dev_info(dev, "random mac %pM\n", priv->mac);
}
priv->pdata.macaddr = priv->mac;
ath9k_fixups[ath9k_num_fixups] = priv;
ath9k_num_fixups++;
return 0;
}
static const struct of_device_id ath9k_fixup_of_match[] = {
{ .compatible = "brcm,ath9k-fixup" },
{ /* sentinel */ }
};
static struct platform_driver ath9k_fixup_driver = {
.probe = ath9k_fixup_probe,
.driver = {
.name = "ath9k-fixup",
.of_match_table = ath9k_fixup_of_match,
},
};
int __init ath9k_fixup_init(void)
{
int ret = platform_driver_register(&ath9k_fixup_driver);
if (ret)
pr_err("ath9k_fixup: Error registering platform driver!\n");
return ret;
}
late_initcall(ath9k_fixup_init);

View File

@ -335,10 +335,7 @@ static struct pci_ops bcm6348_pci_ops = {
.write = bcm6348_pci_write,
};
static struct resource bcm6348_pci_io_resource = {
.name = "BCM6348 PCI IO space",
.flags = IORESOURCE_IO,
};
static struct resource bcm6348_pci_io_resource;
static struct resource bcm6348_pci_mem_resource;
static struct resource bcm6348_pci_busn_resource;
@ -732,26 +729,13 @@ static int bcm6348_pci_probe(struct platform_device *pdev)
of_pci_check_probe_only();
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pci");
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->pci = devm_ioremap_resource(dev, res);
if (IS_ERR(priv->pci))
return PTR_ERR(priv->pci);
priv->pcmcia = priv->pci + PCMCIA_OFFSET;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pci-io");
if (!res)
return -EINVAL;
#ifdef CONFIG_CARDBUS
bcm6348_pci_io_resource.start = res->start;
bcm6348_pci_io_resource.end = res->end - (resource_size(res) >> 1);
bcm6348_cb_io_resource.start = res->start + (resource_size(res) >> 1);
bcm6348_cb_io_resource.end = res->end;
#else
bcm6348_pci_io_resource.start = res->start;
bcm6348_pci_io_resource.end = res->end;
#endif
priv->irq = platform_get_irq(pdev, 0);
if (!priv->irq)
return -ENODEV;
@ -773,6 +757,12 @@ static int bcm6348_pci_probe(struct platform_device *pdev)
of_pci_parse_bus_range(np, &bcm6348_pci_busn_resource);
pci_add_resource(&resources, &bcm6348_pci_busn_resource);
#ifdef CONFIG_CARDBUS
bcm6348_cb_io_resource.start = bcm6348_pci_io_resource.start + (resource_size(&bcm6348_pci_io_resource) >> 1);
bcm6348_cb_io_resource.end = bcm6348_pci_io_resource.end;
bcm6348_pci_io_resource.end = bcm6348_pci_io_resource.end - (resource_size(&bcm6348_pci_io_resource) >> 1);
#endif
/*
* Configuration accesses are done through IO space, remap 4
* first bytes to access it from CPU.

View File

@ -324,7 +324,7 @@ define Device/sercomm-nand
endef
### Package helpers ###
ATH9K_PACKAGES := kmod-ath9k wpad-basic-openssl
ATH9K_PACKAGES := kmod-ath9k kmod-owl-loader wpad-basic-openssl
B43_PACKAGES := kmod-b43 wpad-basic-openssl
USB1_PACKAGES := kmod-usb-ohci kmod-usb-ledtrig-usbport
USB2_PACKAGES := $(USB1_PACKAGES) kmod-usb2

View File

@ -3,4 +3,4 @@
@@ -1,2 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += setup.o irq.o dma.o
+obj-y += ath9k-fixup.o b43-sprom.o
+obj-y += b43-sprom.o

View File

@ -612,7 +612,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mem_cgroup_id_remove(memcg);
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4778,6 +4778,27 @@ static inline void mm_account_fault(stru
@@ -4792,6 +4792,27 @@ static inline void mm_account_fault(stru
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, regs, address);
}
@ -640,7 +640,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
/*
* By the time we get here, we already hold the mm semaphore
*
@@ -4809,11 +4830,15 @@ vm_fault_t handle_mm_fault(struct vm_are
@@ -4823,11 +4844,15 @@ vm_fault_t handle_mm_fault(struct vm_are
if (flags & FAULT_FLAG_USER)
mem_cgroup_enter_user_fault();

View File

@ -92,7 +92,7 @@ Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mark_page_accessed(page);
}
rss[mm_counter(page)]--;
@@ -4781,8 +4781,8 @@ static inline void mm_account_fault(stru
@@ -4795,8 +4795,8 @@ static inline void mm_account_fault(stru
#ifdef CONFIG_LRU_GEN
static void lru_gen_enter_fault(struct vm_area_struct *vma)
{

View File

@ -0,0 +1,73 @@
From e237285113963bd1dd2e925770aa8b3aa8a1894c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= <kernel@kempniu.pl>
Date: Wed, 29 Jun 2022 14:57:34 +0200
Subject: [PATCH 1/4] mtd: track maximum number of bitflips for each read
request
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
mtd_read_oob() callers are currently oblivious to the details of ECC
errors detected during the read operation - they only learn (through the
return value) whether any corrected bitflips or uncorrectable errors
occurred. More detailed ECC information can be useful to user-space
applications for making better-informed choices about moving data
around.
Extend struct mtd_oob_ops with a pointer to a newly-introduced struct
mtd_req_stats and set its 'max_bitflips' field to the maximum number of
bitflips found in a single ECC step during the read operation performed
by mtd_read_oob(). This is a prerequisite for ultimately passing that
value back to user space.
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220629125737.14418-2-kernel@kempniu.pl
---
drivers/mtd/mtdcore.c | 5 +++++
include/linux/mtd/mtd.h | 5 +++++
2 files changed, 10 insertions(+)
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1669,6 +1669,9 @@ int mtd_read_oob(struct mtd_info *mtd, l
if (!master->_read_oob && (!master->_read || ops->oobbuf))
return -EOPNOTSUPP;
+ if (ops->stats)
+ memset(ops->stats, 0, sizeof(*ops->stats));
+
if (mtd->flags & MTD_SLC_ON_MLC_EMULATION)
ret_code = mtd_io_emulated_slc(mtd, from, true, ops);
else
@@ -1686,6 +1689,8 @@ int mtd_read_oob(struct mtd_info *mtd, l
return ret_code;
if (mtd->ecc_strength == 0)
return 0; /* device lacks ecc */
+ if (ops->stats)
+ ops->stats->max_bitflips = ret_code;
return ret_code >= mtd->bitflip_threshold ? -EUCLEAN : 0;
}
EXPORT_SYMBOL_GPL(mtd_read_oob);
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -40,6 +40,10 @@ struct mtd_erase_region_info {
unsigned long *lockmap; /* If keeping bitmap of locks */
};
+struct mtd_req_stats {
+ unsigned int max_bitflips;
+};
+
/**
* struct mtd_oob_ops - oob operation operands
* @mode: operation mode
@@ -70,6 +74,7 @@ struct mtd_oob_ops {
uint32_t ooboffs;
uint8_t *datbuf;
uint8_t *oobbuf;
+ struct mtd_req_stats *stats;
};
#define MTD_MAX_OOBFREE_ENTRIES_LARGE 32

View File

@ -0,0 +1,325 @@
From e97709c9d18903f5acd5fbe2985dd054da0432b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= <kernel@kempniu.pl>
Date: Wed, 29 Jun 2022 14:57:35 +0200
Subject: [PATCH 2/4] mtd: always initialize 'stats' in struct mtd_oob_ops
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
As the 'stats' field in struct mtd_oob_ops is used in conditional
expressions, ensure it is always zero-initialized in all such structures
to prevent random stack garbage from being interpreted as a pointer.
Strictly speaking, this problem currently only needs to be fixed for
struct mtd_oob_ops structures subsequently passed to mtd_read_oob().
However, this commit goes a step further and makes all instances of
struct mtd_oob_ops in the tree zero-initialized, in hope of preventing
future problems, e.g. if struct mtd_req_stats gets extended with write
statistics at some point.
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220629125737.14418-3-kernel@kempniu.pl
---
drivers/mtd/inftlcore.c | 6 +++---
drivers/mtd/mtdswap.c | 6 +++---
drivers/mtd/nand/onenand/onenand_base.c | 4 ++--
drivers/mtd/nand/onenand/onenand_bbt.c | 2 +-
drivers/mtd/nand/raw/nand_bbt.c | 8 ++++----
drivers/mtd/nand/raw/sm_common.c | 2 +-
drivers/mtd/nftlcore.c | 6 +++---
drivers/mtd/sm_ftl.c | 4 ++--
drivers/mtd/ssfdc.c | 2 +-
drivers/mtd/tests/nandbiterrs.c | 2 +-
drivers/mtd/tests/oobtest.c | 8 ++++----
drivers/mtd/tests/readtest.c | 2 +-
fs/jffs2/wbuf.c | 6 +++---
13 files changed, 29 insertions(+), 29 deletions(-)
--- a/drivers/mtd/inftlcore.c
+++ b/drivers/mtd/inftlcore.c
@@ -136,7 +136,7 @@ static void inftl_remove_dev(struct mtd_
int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len,
size_t *retlen, uint8_t *buf)
{
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int res;
ops.mode = MTD_OPS_PLACE_OOB;
@@ -156,7 +156,7 @@ int inftl_read_oob(struct mtd_info *mtd,
int inftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len,
size_t *retlen, uint8_t *buf)
{
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int res;
ops.mode = MTD_OPS_PLACE_OOB;
@@ -176,7 +176,7 @@ int inftl_write_oob(struct mtd_info *mtd
static int inftl_write(struct mtd_info *mtd, loff_t offs, size_t len,
size_t *retlen, uint8_t *buf, uint8_t *oob)
{
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int res;
ops.mode = MTD_OPS_PLACE_OOB;
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -323,7 +323,7 @@ static int mtdswap_read_markers(struct m
struct mtdswap_oobdata *data, *data2;
int ret;
loff_t offset;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
offset = mtdswap_eb_offset(d, eb);
@@ -370,7 +370,7 @@ static int mtdswap_write_marker(struct m
struct mtdswap_oobdata n;
int ret;
loff_t offset;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
ops.ooboffs = 0;
ops.oobbuf = (uint8_t *)&n;
@@ -879,7 +879,7 @@ static unsigned int mtdswap_eblk_passes(
loff_t base, pos;
unsigned int *p1 = (unsigned int *)d->page_buf;
unsigned char *p2 = (unsigned char *)d->oob_buf;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int ret;
ops.mode = MTD_OPS_AUTO_OOB;
--- a/drivers/mtd/nand/onenand/onenand_base.c
+++ b/drivers/mtd/nand/onenand/onenand_base.c
@@ -2935,7 +2935,7 @@ static int do_otp_write(struct mtd_info
struct onenand_chip *this = mtd->priv;
unsigned char *pbuf = buf;
int ret;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
/* Force buffer page aligned */
if (len < mtd->writesize) {
@@ -2977,7 +2977,7 @@ static int do_otp_lock(struct mtd_info *
size_t *retlen, u_char *buf)
{
struct onenand_chip *this = mtd->priv;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int ret;
if (FLEXONENAND(this)) {
--- a/drivers/mtd/nand/onenand/onenand_bbt.c
+++ b/drivers/mtd/nand/onenand/onenand_bbt.c
@@ -61,7 +61,7 @@ static int create_bbt(struct mtd_info *m
int startblock;
loff_t from;
size_t readlen, ooblen;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int rgn;
printk(KERN_INFO "Scanning device for bad blocks\n");
--- a/drivers/mtd/nand/raw/nand_bbt.c
+++ b/drivers/mtd/nand/raw/nand_bbt.c
@@ -313,7 +313,7 @@ static int scan_read_oob(struct nand_chi
size_t len)
{
struct mtd_info *mtd = nand_to_mtd(this);
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int res, ret = 0;
ops.mode = MTD_OPS_PLACE_OOB;
@@ -354,7 +354,7 @@ static int scan_write_bbt(struct nand_ch
uint8_t *buf, uint8_t *oob)
{
struct mtd_info *mtd = nand_to_mtd(this);
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
ops.mode = MTD_OPS_PLACE_OOB;
ops.ooboffs = 0;
@@ -416,7 +416,7 @@ static int scan_block_fast(struct nand_c
{
struct mtd_info *mtd = nand_to_mtd(this);
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int ret, page_offset;
ops.ooblen = mtd->oobsize;
@@ -756,7 +756,7 @@ static int write_bbt(struct nand_chip *t
uint8_t rcode = td->reserved_block_code;
size_t retlen, len = 0;
loff_t to;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
ops.ooblen = mtd->oobsize;
ops.ooboffs = 0;
--- a/drivers/mtd/nand/raw/sm_common.c
+++ b/drivers/mtd/nand/raw/sm_common.c
@@ -99,7 +99,7 @@ static const struct mtd_ooblayout_ops oo
static int sm_block_markbad(struct nand_chip *chip, loff_t ofs)
{
struct mtd_info *mtd = nand_to_mtd(chip);
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
struct sm_oob oob;
int ret;
--- a/drivers/mtd/nftlcore.c
+++ b/drivers/mtd/nftlcore.c
@@ -124,7 +124,7 @@ int nftl_read_oob(struct mtd_info *mtd,
size_t *retlen, uint8_t *buf)
{
loff_t mask = mtd->writesize - 1;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int res;
ops.mode = MTD_OPS_PLACE_OOB;
@@ -145,7 +145,7 @@ int nftl_write_oob(struct mtd_info *mtd,
size_t *retlen, uint8_t *buf)
{
loff_t mask = mtd->writesize - 1;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int res;
ops.mode = MTD_OPS_PLACE_OOB;
@@ -168,7 +168,7 @@ static int nftl_write(struct mtd_info *m
size_t *retlen, uint8_t *buf, uint8_t *oob)
{
loff_t mask = mtd->writesize - 1;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int res;
ops.mode = MTD_OPS_PLACE_OOB;
--- a/drivers/mtd/sm_ftl.c
+++ b/drivers/mtd/sm_ftl.c
@@ -239,7 +239,7 @@ static int sm_read_sector(struct sm_ftl
uint8_t *buffer, struct sm_oob *oob)
{
struct mtd_info *mtd = ftl->trans->mtd;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
struct sm_oob tmp_oob;
int ret = -EIO;
int try = 0;
@@ -323,7 +323,7 @@ static int sm_write_sector(struct sm_ftl
int zone, int block, int boffset,
uint8_t *buffer, struct sm_oob *oob)
{
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
struct mtd_info *mtd = ftl->trans->mtd;
int ret;
--- a/drivers/mtd/ssfdc.c
+++ b/drivers/mtd/ssfdc.c
@@ -163,7 +163,7 @@ static int read_physical_sector(struct m
/* Read redundancy area (wrapper to MTD_READ_OOB */
static int read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf)
{
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int ret;
ops.mode = MTD_OPS_RAW;
--- a/drivers/mtd/tests/nandbiterrs.c
+++ b/drivers/mtd/tests/nandbiterrs.c
@@ -99,7 +99,7 @@ static int write_page(int log)
static int rewrite_page(int log)
{
int err = 0;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
if (log)
pr_info("rewrite page\n");
--- a/drivers/mtd/tests/oobtest.c
+++ b/drivers/mtd/tests/oobtest.c
@@ -56,7 +56,7 @@ static void do_vary_offset(void)
static int write_eraseblock(int ebnum)
{
int i;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int err = 0;
loff_t addr = (loff_t)ebnum * mtd->erasesize;
@@ -165,7 +165,7 @@ static size_t memffshow(loff_t addr, lof
static int verify_eraseblock(int ebnum)
{
int i;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int err = 0;
loff_t addr = (loff_t)ebnum * mtd->erasesize;
size_t bitflips;
@@ -260,7 +260,7 @@ static int verify_eraseblock(int ebnum)
static int verify_eraseblock_in_one_go(int ebnum)
{
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int err = 0;
loff_t addr = (loff_t)ebnum * mtd->erasesize;
size_t len = mtd->oobavail * pgcnt;
@@ -338,7 +338,7 @@ static int __init mtd_oobtest_init(void)
int err = 0;
unsigned int i;
uint64_t tmp;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
loff_t addr = 0, addr0;
printk(KERN_INFO "\n");
--- a/drivers/mtd/tests/readtest.c
+++ b/drivers/mtd/tests/readtest.c
@@ -47,7 +47,7 @@ static int read_eraseblock_by_page(int e
err = ret;
}
if (mtd->oobsize) {
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
ops.mode = MTD_OPS_PLACE_OOB;
ops.len = 0;
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -1035,7 +1035,7 @@ int jffs2_check_oob_empty(struct jffs2_s
{
int i, ret;
int cmlen = min_t(int, c->oobavail, OOB_CM_SIZE);
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
ops.mode = MTD_OPS_AUTO_OOB;
ops.ooblen = NR_OOB_SCAN_PAGES * c->oobavail;
@@ -1076,7 +1076,7 @@ int jffs2_check_oob_empty(struct jffs2_s
int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c,
struct jffs2_eraseblock *jeb)
{
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int ret, cmlen = min_t(int, c->oobavail, OOB_CM_SIZE);
ops.mode = MTD_OPS_AUTO_OOB;
@@ -1101,7 +1101,7 @@ int jffs2_write_nand_cleanmarker(struct
struct jffs2_eraseblock *jeb)
{
int ret;
- struct mtd_oob_ops ops;
+ struct mtd_oob_ops ops = { };
int cmlen = min_t(int, c->oobavail, OOB_CM_SIZE);
ops.mode = MTD_OPS_AUTO_OOB;

View File

@ -0,0 +1,172 @@
From 2ed18d818d1f7492172f8dd5904344c7d367e8ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= <kernel@kempniu.pl>
Date: Wed, 29 Jun 2022 14:57:36 +0200
Subject: [PATCH 3/4] mtd: add ECC error accounting for each read request
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Extend struct mtd_req_stats with two new fields holding the number of
corrected bitflips and uncorrectable errors detected during a read
operation. This is a prerequisite for ultimately passing those counters
to user space, where they can be useful to applications for making
better-informed choices about moving data around.
Unlike 'max_bitflips' (which is set - in a common code path - to the
return value of a function called while the MTD device's mutex is held),
these counters have to be maintained in each MTD driver which defines
the '_read_oob' callback because the statistics need to be calculated
while the MTD device's mutex is held.
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220629125737.14418-4-kernel@kempniu.pl
---
drivers/mtd/devices/docg3.c | 8 ++++++++
drivers/mtd/nand/onenand/onenand_base.c | 12 ++++++++++++
drivers/mtd/nand/raw/nand_base.c | 10 ++++++++++
drivers/mtd/nand/spi/core.c | 10 ++++++++++
include/linux/mtd/mtd.h | 2 ++
5 files changed, 42 insertions(+)
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -871,6 +871,7 @@ static int doc_read_oob(struct mtd_info
u8 *buf = ops->datbuf;
size_t len, ooblen, nbdata, nboob;
u8 hwecc[DOC_ECC_BCH_SIZE], eccconf1;
+ struct mtd_ecc_stats old_stats;
int max_bitflips = 0;
if (buf)
@@ -895,6 +896,7 @@ static int doc_read_oob(struct mtd_info
ret = 0;
skip = from % DOC_LAYOUT_PAGE_SIZE;
mutex_lock(&docg3->cascade->lock);
+ old_stats = mtd->ecc_stats;
while (ret >= 0 && (len > 0 || ooblen > 0)) {
calc_block_sector(from - skip, &block0, &block1, &page, &ofs,
docg3->reliable);
@@ -966,6 +968,12 @@ static int doc_read_oob(struct mtd_info
}
out:
+ if (ops->stats) {
+ ops->stats->uncorrectable_errors +=
+ mtd->ecc_stats.failed - old_stats.failed;
+ ops->stats->corrected_bitflips +=
+ mtd->ecc_stats.corrected - old_stats.corrected;
+ }
mutex_unlock(&docg3->cascade->lock);
return ret;
err_in_read:
--- a/drivers/mtd/nand/onenand/onenand_base.c
+++ b/drivers/mtd/nand/onenand/onenand_base.c
@@ -1440,6 +1440,7 @@ static int onenand_read_oob(struct mtd_i
struct mtd_oob_ops *ops)
{
struct onenand_chip *this = mtd->priv;
+ struct mtd_ecc_stats old_stats;
int ret;
switch (ops->mode) {
@@ -1453,12 +1454,23 @@ static int onenand_read_oob(struct mtd_i
}
onenand_get_device(mtd, FL_READING);
+
+ old_stats = mtd->ecc_stats;
+
if (ops->datbuf)
ret = ONENAND_IS_4KB_PAGE(this) ?
onenand_mlc_read_ops_nolock(mtd, from, ops) :
onenand_read_ops_nolock(mtd, from, ops);
else
ret = onenand_read_oob_nolock(mtd, from, ops);
+
+ if (ops->stats) {
+ ops->stats->uncorrectable_errors +=
+ mtd->ecc_stats.failed - old_stats.failed;
+ ops->stats->corrected_bitflips +=
+ mtd->ecc_stats.corrected - old_stats.corrected;
+ }
+
onenand_release_device(mtd);
return ret;
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -3815,6 +3815,7 @@ static int nand_read_oob(struct mtd_info
struct mtd_oob_ops *ops)
{
struct nand_chip *chip = mtd_to_nand(mtd);
+ struct mtd_ecc_stats old_stats;
int ret;
ops->retlen = 0;
@@ -3826,11 +3827,20 @@ static int nand_read_oob(struct mtd_info
nand_get_device(chip);
+ old_stats = mtd->ecc_stats;
+
if (!ops->datbuf)
ret = nand_do_read_oob(chip, from, ops);
else
ret = nand_do_read_ops(chip, from, ops);
+ if (ops->stats) {
+ ops->stats->uncorrectable_errors +=
+ mtd->ecc_stats.failed - old_stats.failed;
+ ops->stats->corrected_bitflips +=
+ mtd->ecc_stats.corrected - old_stats.corrected;
+ }
+
nand_release_device(chip);
return ret;
}
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -629,6 +629,7 @@ static int spinand_mtd_read(struct mtd_i
{
struct spinand_device *spinand = mtd_to_spinand(mtd);
struct nand_device *nand = mtd_to_nanddev(mtd);
+ struct mtd_ecc_stats old_stats;
unsigned int max_bitflips = 0;
struct nand_io_iter iter;
bool disable_ecc = false;
@@ -640,6 +641,8 @@ static int spinand_mtd_read(struct mtd_i
mutex_lock(&spinand->lock);
+ old_stats = mtd->ecc_stats;
+
nanddev_io_for_each_page(nand, NAND_PAGE_READ, from, ops, &iter) {
if (disable_ecc)
iter.req.mode = MTD_OPS_RAW;
@@ -662,6 +665,13 @@ static int spinand_mtd_read(struct mtd_i
ops->oobretlen += iter.req.ooblen;
}
+ if (ops->stats) {
+ ops->stats->uncorrectable_errors +=
+ mtd->ecc_stats.failed - old_stats.failed;
+ ops->stats->corrected_bitflips +=
+ mtd->ecc_stats.corrected - old_stats.corrected;
+ }
+
mutex_unlock(&spinand->lock);
if (ecc_failed && !ret)
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -41,6 +41,8 @@ struct mtd_erase_region_info {
};
struct mtd_req_stats {
+ unsigned int uncorrectable_errors;
+ unsigned int corrected_bitflips;
unsigned int max_bitflips;
};

View File

@ -0,0 +1,321 @@
From 2c9745d36e04ac27161acd78514f647b9b587ad4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= <kernel@kempniu.pl>
Date: Wed, 29 Jun 2022 14:57:37 +0200
Subject: [PATCH 4/4] mtdchar: add MEMREAD ioctl
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
User-space applications making use of MTD devices via /dev/mtd*
character devices currently have limited capabilities for reading data:
- only deprecated methods of accessing OOB layout information exist,
- there is no way to explicitly specify MTD operation mode to use; it
is auto-selected based on the MTD file mode (MTD_FILE_MODE_*) set
for the character device; in particular, this prevents using
MTD_OPS_AUTO_OOB for reads,
- all existing user-space interfaces which cause mtd_read() or
mtd_read_oob() to be called (via mtdchar_read() and
mtdchar_read_oob(), respectively) return success even when those
functions return -EUCLEAN or -EBADMSG; this renders user-space
applications using these interfaces unaware of any corrected
bitflips or uncorrectable ECC errors detected during reads.
Note that the existing MEMWRITE ioctl allows the MTD operation mode to
be explicitly set, allowing user-space applications to write page data
and OOB data without requiring them to know anything about the OOB
layout of the MTD device they are writing to (MTD_OPS_AUTO_OOB). Also,
the MEMWRITE ioctl does not mangle the return value of mtd_write_oob().
Add a new ioctl, MEMREAD, which addresses the above issues. It is
intended to be a read-side counterpart of the existing MEMWRITE ioctl.
Similarly to the latter, the read operation is performed in a loop which
processes at most mtd->erasesize bytes in each iteration. This is done
to prevent unbounded memory allocations caused by calling kmalloc() with
the 'size' argument taken directly from the struct mtd_read_req provided
by user space. However, the new ioctl is implemented so that the values
it returns match those that would have been returned if just a single
mtd_read_oob() call was issued to handle the entire read operation in
one go.
Note that while just returning -EUCLEAN or -EBADMSG to user space would
already be a valid and useful indication of the ECC algorithm detecting
errors during a read operation, that signal would not be granular enough
to cover all use cases. For example, knowing the maximum number of
bitflips detected in a single ECC step during a read operation performed
on a given page may be useful when dealing with an MTD partition whose
ECC layout varies across pages (e.g. a partition consisting of a
bootloader area using a "custom" ECC layout followed by data pages using
a "standard" ECC layout). To address that, include ECC statistics in
the structure returned to user space by the new MEMREAD ioctl.
Link: https://www.infradead.org/pipermail/linux-mtd/2016-April/067085.html
Suggested-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Michał Kępień <kernel@kempniu.pl>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220629125737.14418-5-kernel@kempniu.pl
---
drivers/mtd/mtdchar.c | 139 +++++++++++++++++++++++++++++++++++++
include/uapi/mtd/mtd-abi.h | 64 +++++++++++++++--
2 files changed, 198 insertions(+), 5 deletions(-)
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -621,6 +621,137 @@ static int mtdchar_write_ioctl(struct mt
return ret;
}
+static int mtdchar_read_ioctl(struct mtd_info *mtd,
+ struct mtd_read_req __user *argp)
+{
+ struct mtd_info *master = mtd_get_master(mtd);
+ struct mtd_read_req req;
+ void __user *usr_data, *usr_oob;
+ uint8_t *datbuf = NULL, *oobbuf = NULL;
+ size_t datbuf_len, oobbuf_len;
+ size_t orig_len, orig_ooblen;
+ int ret = 0;
+
+ if (copy_from_user(&req, argp, sizeof(req)))
+ return -EFAULT;
+
+ orig_len = req.len;
+ orig_ooblen = req.ooblen;
+
+ usr_data = (void __user *)(uintptr_t)req.usr_data;
+ usr_oob = (void __user *)(uintptr_t)req.usr_oob;
+
+ if (!master->_read_oob)
+ return -EOPNOTSUPP;
+
+ if (!usr_data)
+ req.len = 0;
+
+ if (!usr_oob)
+ req.ooblen = 0;
+
+ req.ecc_stats.uncorrectable_errors = 0;
+ req.ecc_stats.corrected_bitflips = 0;
+ req.ecc_stats.max_bitflips = 0;
+
+ req.len &= 0xffffffff;
+ req.ooblen &= 0xffffffff;
+
+ if (req.start + req.len > mtd->size) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ datbuf_len = min_t(size_t, req.len, mtd->erasesize);
+ if (datbuf_len > 0) {
+ datbuf = kvmalloc(datbuf_len, GFP_KERNEL);
+ if (!datbuf) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ }
+
+ oobbuf_len = min_t(size_t, req.ooblen, mtd->erasesize);
+ if (oobbuf_len > 0) {
+ oobbuf = kvmalloc(oobbuf_len, GFP_KERNEL);
+ if (!oobbuf) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ }
+
+ while (req.len > 0 || (!usr_data && req.ooblen > 0)) {
+ struct mtd_req_stats stats;
+ struct mtd_oob_ops ops = {
+ .mode = req.mode,
+ .len = min_t(size_t, req.len, datbuf_len),
+ .ooblen = min_t(size_t, req.ooblen, oobbuf_len),
+ .datbuf = datbuf,
+ .oobbuf = oobbuf,
+ .stats = &stats,
+ };
+
+ /*
+ * Shorten non-page-aligned, eraseblock-sized reads so that the
+ * read ends on an eraseblock boundary. This is necessary in
+ * order to prevent OOB data for some pages from being
+ * duplicated in the output of non-page-aligned reads requiring
+ * multiple mtd_read_oob() calls to be completed.
+ */
+ if (ops.len == mtd->erasesize)
+ ops.len -= mtd_mod_by_ws(req.start + ops.len, mtd);
+
+ ret = mtd_read_oob(mtd, (loff_t)req.start, &ops);
+
+ req.ecc_stats.uncorrectable_errors +=
+ stats.uncorrectable_errors;
+ req.ecc_stats.corrected_bitflips += stats.corrected_bitflips;
+ req.ecc_stats.max_bitflips =
+ max(req.ecc_stats.max_bitflips, stats.max_bitflips);
+
+ if (ret && !mtd_is_bitflip_or_eccerr(ret))
+ break;
+
+ if (copy_to_user(usr_data, ops.datbuf, ops.retlen) ||
+ copy_to_user(usr_oob, ops.oobbuf, ops.oobretlen)) {
+ ret = -EFAULT;
+ break;
+ }
+
+ req.start += ops.retlen;
+ req.len -= ops.retlen;
+ usr_data += ops.retlen;
+
+ req.ooblen -= ops.oobretlen;
+ usr_oob += ops.oobretlen;
+ }
+
+ /*
+ * As multiple iterations of the above loop (and therefore multiple
+ * mtd_read_oob() calls) may be necessary to complete the read request,
+ * adjust the final return code to ensure it accounts for all detected
+ * ECC errors.
+ */
+ if (!ret || mtd_is_bitflip(ret)) {
+ if (req.ecc_stats.uncorrectable_errors > 0)
+ ret = -EBADMSG;
+ else if (req.ecc_stats.corrected_bitflips > 0)
+ ret = -EUCLEAN;
+ }
+
+out:
+ req.len = orig_len - req.len;
+ req.ooblen = orig_ooblen - req.ooblen;
+
+ if (copy_to_user(argp, &req, sizeof(req)))
+ ret = -EFAULT;
+
+ kvfree(datbuf);
+ kvfree(oobbuf);
+
+ return ret;
+}
+
static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
{
struct mtd_file_info *mfi = file->private_data;
@@ -643,6 +774,7 @@ static int mtdchar_ioctl(struct file *fi
case MEMGETINFO:
case MEMREADOOB:
case MEMREADOOB64:
+ case MEMREAD:
case MEMISLOCKED:
case MEMGETOOBSEL:
case MEMGETBADBLOCK:
@@ -817,6 +949,13 @@ static int mtdchar_ioctl(struct file *fi
break;
}
+ case MEMREAD:
+ {
+ ret = mtdchar_read_ioctl(mtd,
+ (struct mtd_read_req __user *)arg);
+ break;
+ }
+
case MEMLOCK:
{
struct erase_info_user einfo;
--- a/include/uapi/mtd/mtd-abi.h
+++ b/include/uapi/mtd/mtd-abi.h
@@ -55,9 +55,9 @@ struct mtd_oob_buf64 {
* @MTD_OPS_RAW: data are transferred as-is, with no error correction;
* this mode implies %MTD_OPS_PLACE_OOB
*
- * These modes can be passed to ioctl(MEMWRITE) and are also used internally.
- * See notes on "MTD file modes" for discussion on %MTD_OPS_RAW vs.
- * %MTD_FILE_MODE_RAW.
+ * These modes can be passed to ioctl(MEMWRITE) and ioctl(MEMREAD); they are
+ * also used internally. See notes on "MTD file modes" for discussion on
+ * %MTD_OPS_RAW vs. %MTD_FILE_MODE_RAW.
*/
enum {
MTD_OPS_PLACE_OOB = 0,
@@ -91,6 +91,53 @@ struct mtd_write_req {
__u8 padding[7];
};
+/**
+ * struct mtd_read_req_ecc_stats - ECC statistics for a read operation
+ *
+ * @uncorrectable_errors: the number of uncorrectable errors that happened
+ * during the read operation
+ * @corrected_bitflips: the number of bitflips corrected during the read
+ * operation
+ * @max_bitflips: the maximum number of bitflips detected in any single ECC
+ * step for the data read during the operation; this information
+ * can be used to decide whether the data stored in a specific
+ * region of the MTD device should be moved somewhere else to
+ * avoid data loss.
+ */
+struct mtd_read_req_ecc_stats {
+ __u32 uncorrectable_errors;
+ __u32 corrected_bitflips;
+ __u32 max_bitflips;
+};
+
+/**
+ * struct mtd_read_req - data structure for requesting a read operation
+ *
+ * @start: start address
+ * @len: length of data buffer (only lower 32 bits are used)
+ * @ooblen: length of OOB buffer (only lower 32 bits are used)
+ * @usr_data: user-provided data buffer
+ * @usr_oob: user-provided OOB buffer
+ * @mode: MTD mode (see "MTD operation modes")
+ * @padding: reserved, must be set to 0
+ * @ecc_stats: ECC statistics for the read operation
+ *
+ * This structure supports ioctl(MEMREAD) operations, allowing data and/or OOB
+ * reads in various modes. To read from OOB-only, set @usr_data == NULL, and to
+ * read data-only, set @usr_oob == NULL. However, setting both @usr_data and
+ * @usr_oob to NULL is not allowed.
+ */
+struct mtd_read_req {
+ __u64 start;
+ __u64 len;
+ __u64 ooblen;
+ __u64 usr_data;
+ __u64 usr_oob;
+ __u8 mode;
+ __u8 padding[7];
+ struct mtd_read_req_ecc_stats ecc_stats;
+};
+
#define MTD_ABSENT 0
#define MTD_RAM 1
#define MTD_ROM 2
@@ -207,6 +254,12 @@ struct otp_info {
#define MEMWRITE _IOWR('M', 24, struct mtd_write_req)
/* Erase a given range of user data (must be in mode %MTD_FILE_MODE_OTP_USER) */
#define OTPERASE _IOW('M', 25, struct otp_info)
+/*
+ * Most generic read interface; can read in-band and/or out-of-band in various
+ * modes (see "struct mtd_read_req"). This ioctl is not supported for flashes
+ * without OOB, e.g., NOR flash.
+ */
+#define MEMREAD _IOWR('M', 26, struct mtd_read_req)
/*
* Obsolete legacy interface. Keep it in order not to break userspace
@@ -270,8 +323,9 @@ struct mtd_ecc_stats {
* Note: %MTD_FILE_MODE_RAW provides the same functionality as %MTD_OPS_RAW -
* raw access to the flash, without error correction or autoplacement schemes.
* Wherever possible, the MTD_OPS_* mode will override the MTD_FILE_MODE_* mode
- * (e.g., when using ioctl(MEMWRITE)), but in some cases, the MTD_FILE_MODE is
- * used out of necessity (e.g., `write()', ioctl(MEMWRITEOOB64)).
+ * (e.g., when using ioctl(MEMWRITE) or ioctl(MEMREAD)), but in some cases, the
+ * MTD_FILE_MODE is used out of necessity (e.g., `write()',
+ * ioctl(MEMWRITEOOB64)).
*/
enum mtd_file_modes {
MTD_FILE_MODE_NORMAL = MTD_OTP_OFF,

View File

@ -87,7 +87,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
stmmac_clear_tx_descriptors(priv, queue);
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
@@ -7407,6 +7402,25 @@ int stmmac_suspend(struct device *dev)
@@ -7411,6 +7406,25 @@ int stmmac_suspend(struct device *dev)
}
EXPORT_SYMBOL_GPL(stmmac_suspend);
@ -113,7 +113,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
/**
* stmmac_reset_queues_param - reset queue parameters
* @priv: device pointer
@@ -7417,22 +7431,11 @@ static void stmmac_reset_queues_param(st
@@ -7421,22 +7435,11 @@ static void stmmac_reset_queues_param(st
u32 tx_cnt = priv->plat->tx_queues_to_use;
u32 queue;

View File

@ -1199,7 +1199,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
ch = &priv->channel[queue];
if (!rx_q->xsk_pool && !tx_q->xsk_pool)
@@ -6914,8 +6918,8 @@ int stmmac_reinit_ringparam(struct net_d
@@ -6918,8 +6922,8 @@ int stmmac_reinit_ringparam(struct net_d
if (netif_running(dev))
stmmac_release(dev);
@ -1210,7 +1210,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
if (netif_running(dev))
ret = stmmac_open(dev);
@@ -7353,7 +7357,7 @@ int stmmac_suspend(struct device *dev)
@@ -7357,7 +7361,7 @@ int stmmac_suspend(struct device *dev)
stmmac_disable_all_queues(priv);
for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
@ -1219,7 +1219,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
if (priv->eee_enabled) {
priv->tx_path_in_lpi_mode = false;
@@ -7404,7 +7408,7 @@ EXPORT_SYMBOL_GPL(stmmac_suspend);
@@ -7408,7 +7412,7 @@ EXPORT_SYMBOL_GPL(stmmac_suspend);
static void stmmac_reset_rx_queue(struct stmmac_priv *priv, u32 queue)
{
@ -1228,7 +1228,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
rx_q->cur_rx = 0;
rx_q->dirty_rx = 0;
@@ -7412,7 +7416,7 @@ static void stmmac_reset_rx_queue(struct
@@ -7416,7 +7420,7 @@ static void stmmac_reset_rx_queue(struct
static void stmmac_reset_tx_queue(struct stmmac_priv *priv, u32 queue)
{

View File

@ -1150,7 +1150,7 @@ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
dma_desc_error:
return ret;
}
@@ -7499,7 +7615,7 @@ int stmmac_resume(struct device *dev)
@@ -7503,7 +7619,7 @@ int stmmac_resume(struct device *dev)
stmmac_reset_queues_param(priv);
stmmac_free_tx_skbufs(priv);

View File

@ -235,7 +235,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
if (!pe)
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3962,6 +3962,8 @@ static const struct seq_operations vmall
@@ -3964,6 +3964,8 @@ static const struct seq_operations vmall
static int __init proc_vmalloc_init(void)
{

View File

@ -264,7 +264,7 @@ Subject: [PATCH] mtd: mtdsplit support
* one chunk. Do that by default.
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -613,6 +613,24 @@ static inline void mtd_align_erase_req(s
@@ -620,6 +620,24 @@ static inline void mtd_align_erase_req(s
req->len += mtd->erasesize - mod;
}
@ -289,7 +289,7 @@ Subject: [PATCH] mtd: mtdsplit support
static inline uint32_t mtd_div_by_ws(uint64_t sz, struct mtd_info *mtd)
{
if (mtd->writesize_shift)
@@ -686,6 +704,13 @@ extern struct mtd_info *of_get_mtd_devic
@@ -693,6 +711,13 @@ extern struct mtd_info *of_get_mtd_devic
extern struct mtd_info *get_mtd_device_nm(const char *name);
extern void put_mtd_device(struct mtd_info *mtd);

View File

@ -234,7 +234,7 @@ Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -243,6 +243,8 @@ struct mtd_info {
@@ -250,6 +250,8 @@ struct mtd_info {
* information below if they desire
*/
uint32_t erasesize;

View File

@ -31,7 +31,7 @@ Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -896,6 +896,7 @@ static const struct nand_ops spinand_ops
@@ -906,6 +906,7 @@ static const struct nand_ops spinand_ops
};
static const struct spinand_manufacturer *spinand_manufacturers[] = {

View File

@ -47,7 +47,7 @@ Submitted-by: Daniel Danzberger <daniel@dd-wrt.com>
obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -898,6 +898,7 @@ static const struct nand_ops spinand_ops
@@ -908,6 +908,7 @@ static const struct nand_ops spinand_ops
static const struct spinand_manufacturer *spinand_manufacturers[] = {
&esmt_c8_spinand_manufacturer,
&gigadevice_spinand_manufacturer,

View File

@ -18,7 +18,7 @@ Link: https://lore.kernel.org/linux-mtd/20220127091808.1043392-8-miquel.raynal@b
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1211,14 +1211,6 @@ static int spinand_init(struct spinand_d
@@ -1221,14 +1221,6 @@ static int spinand_init(struct spinand_d
if (ret)
goto err_free_bufs;
@ -33,7 +33,7 @@ Link: https://lore.kernel.org/linux-mtd/20220127091808.1043392-8-miquel.raynal@b
ret = nanddev_init(nand, &spinand_ops, THIS_MODULE);
if (ret)
goto err_manuf_cleanup;
@@ -1253,6 +1245,14 @@ static int spinand_init(struct spinand_d
@@ -1263,6 +1255,14 @@ static int spinand_init(struct spinand_d
mtd->ecc_strength = nanddev_get_ecc_conf(nand)->strength;
mtd->ecc_step_size = nanddev_get_ecc_conf(nand)->step_size;

View File

@ -53,7 +53,7 @@ Link: https://lore.kernel.org/linux-mtd/20220127091808.1043392-9-miquel.raynal@b
while (nbytes) {
ret = spi_mem_dirmap_write(wdesc, column, nbytes, buf);
@@ -865,6 +871,31 @@ static int spinand_create_dirmap(struct
@@ -875,6 +881,31 @@ static int spinand_create_dirmap(struct
spinand->dirmaps[plane].rdesc = desc;

View File

@ -1,6 +1,6 @@
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -714,7 +714,7 @@ static int spinand_mtd_write(struct mtd_
@@ -724,7 +724,7 @@ static int spinand_mtd_write(struct mtd_
static bool spinand_isbad(struct nand_device *nand, const struct nand_pos *pos)
{
struct spinand_device *spinand = nand_to_spinand(nand);
@ -9,7 +9,7 @@
struct nand_page_io_req req = {
.pos = *pos,
.ooblen = sizeof(marker),
@@ -725,7 +725,7 @@ static bool spinand_isbad(struct nand_de
@@ -735,7 +735,7 @@ static bool spinand_isbad(struct nand_de
spinand_select_target(spinand, pos->target);
spinand_read_page(spinand, &req);

View File

@ -8,7 +8,7 @@
static int spinand_read_reg_op(struct spinand_device *spinand, u8 reg, u8 *val)
{
@@ -1333,6 +1334,7 @@ static int spinand_probe(struct spi_mem
@@ -1343,6 +1344,7 @@ static int spinand_probe(struct spi_mem
if (ret)
return ret;
@ -16,7 +16,7 @@
ret = mtd_device_register(mtd, NULL, 0);
if (ret)
goto err_spinand_cleanup;
@@ -1340,6 +1342,7 @@ static int spinand_probe(struct spi_mem
@@ -1350,6 +1352,7 @@ static int spinand_probe(struct spi_mem
return 0;
err_spinand_cleanup:
@ -24,7 +24,7 @@
spinand_cleanup(spinand);
return ret;
@@ -1358,6 +1361,7 @@ static int spinand_remove(struct spi_mem
@@ -1368,6 +1371,7 @@ static int spinand_remove(struct spi_mem
if (ret)
return ret;

View File

@ -23,7 +23,7 @@ Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com>
obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -929,6 +929,7 @@ static const struct nand_ops spinand_ops
@@ -939,6 +939,7 @@ static const struct nand_ops spinand_ops
static const struct spinand_manufacturer *spinand_manufacturers[] = {
&esmt_c8_spinand_manufacturer,

View File

@ -11,7 +11,7 @@ Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -967,6 +967,56 @@ static int spinand_manufacturer_match(st
@@ -977,6 +977,56 @@ static int spinand_manufacturer_match(st
return -ENOTSUPP;
}
@ -68,7 +68,7 @@ Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
static int spinand_id_detect(struct spinand_device *spinand)
{
u8 *id = spinand->id.data;
@@ -1217,6 +1267,10 @@ static int spinand_init(struct spinand_d
@@ -1227,6 +1277,10 @@ static int spinand_init(struct spinand_d
if (!spinand->scratchbuf)
return -ENOMEM;

View File

@ -12,7 +12,7 @@ Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -1008,7 +1008,10 @@ int spinand_cal_read(void *priv, u32 *ad
@@ -1018,7 +1018,10 @@ int spinand_cal_read(void *priv, u32 *ad
if (ret)
return ret;

View File

@ -20,6 +20,9 @@ endif
ifneq ($(CONFIG_SDK)$(CONFIG_PACKAGE_kmod-b43)$(CONFIG_BRCMSMAC_USE_FW_FROM_WL),)
BUILD_B43_TOOLS = y
endif
ifneq ($(CONFIG_SDK)$(CONFIG_TARGET_INITRAMFS_COMPRESSION_BZIP2),)
BUILD_BZIP2_TOOLS = y
endif
ifneq ($(CONFIG_SDK)$(CONFIG_TARGET_INITRAMFS_COMPRESSION_LZ4),)
BUILD_LZ4_TOOLS = y
endif
@ -66,6 +69,7 @@ tools-y += zlib
tools-y += zstd
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS),y) += liblzo
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_B43_TOOLS),y) += b43-tools
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_BZIP2_TOOLS),y) += bzip2
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_ISL),y) += isl
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_LZ4_TOOLS),y) += lz4
tools-$(if $(CONFIG_BUILD_ALL_HOST_TOOLS)$(BUILD_LZO_TOOLS),y) += lzop

52
tools/bzip2/Makefile Normal file
View File

@ -0,0 +1,52 @@
#
# Copyright (C) 2022 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bzip2
PKG_VERSION:=1.0.8
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://sourceware.org/pub/bzip2
PKG_HASH:=ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269
PKG_LICENSE:=bzip2-1.0.8
PKG_LICENSE_FILES:=LICENSE
PKG_CPE_ID:=cpe:/a:bzip:bzip2
HOST_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/host-build.mk
HOSTCC := $(HOSTCC_NOCACHE)
HOST_CFLAGS += $(HOST_FPIC)
HOST_MAKE_FLAGS+= \
CFLAGS="$(HOST_CFLAGS)" \
LDFLAGS="$(HOST_LDFLAGS)" \
ENABLE_BIN_SHARED=1 \
ENABLE_BIN_STATIC=0 \
ENABLE_LIB_SHARED=1 \
ENABLE_LIB_STATIC=1 \
ENABLE_DEV=1 \
ENABLE_DOCS=1 \
ENABLE_TESTS=0 \
PREFIX="$(HOST_BUILD_PREFIX)"
define Host/Configure
endef
define Host/Uninstall
$(call Host/Compile/Default,uninstall)
$(call Host/Compile/Default,clean)
endef
define Host/Clean
endef
$(eval $(call HostBuild))

View File

@ -0,0 +1,27 @@
--- a/bzip2.c
+++ b/bzip2.c
@@ -69,7 +69,6 @@
#if BZ_UNIX
# include <fcntl.h>
# include <sys/types.h>
-# include <utime.h>
# include <unistd.h>
# include <sys/stat.h>
# include <sys/times.h>
@@ -1051,12 +1050,12 @@ void applySavedTimeInfoToOutputFile ( Ch
{
# if BZ_UNIX
IntNative retVal;
- struct utimbuf uTimBuf;
+ struct timespec uTimBuf[2] = {};
- uTimBuf.actime = fileMetaInfo.st_atime;
- uTimBuf.modtime = fileMetaInfo.st_mtime;
+ uTimBuf[0].tv_sec = fileMetaInfo.st_atime;
+ uTimBuf[1].tv_sec = fileMetaInfo.st_mtime;
- retVal = utime ( dstName, &uTimBuf );
+ retVal = utimensat ( AT_FDCWD, dstName, uTimBuf , 0 );
ERROR_IF_NOT_ZERO ( retVal );
# endif
}

View File

@ -0,0 +1,401 @@
--- a/bzip2.c
+++ b/bzip2.c
@@ -54,7 +54,7 @@
#include <math.h>
#include <errno.h>
#include <ctype.h>
-#include "bzlib.h"
+#include <bzlib.h>
#define ERROR_IF_EOF(i) { if ((i) == EOF) ioError(); }
#define ERROR_IF_NOT_ZERO(i) { if ((i) != 0) ioError(); }
--- a/bzlib_private.h
+++ b/bzlib_private.h
@@ -30,7 +30,7 @@
#include <string.h>
#endif
-#include "bzlib.h"
+#include <bzlib.h>
--- a/Makefile
+++ b/Makefile
@@ -21,11 +21,38 @@
LDFLAGS=
BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS_COMMON=-Wall -Winline -O2 -g $(BIGFILES) -I.
+CFLAGS_NOPIC=$(filter-out -O%,$(CFLAGS)) $(CFLAGS_COMMON)
+CFLAGS_PIC=$(filter-out -O%,$(CFLAGS)) -fpic -fPIC $(CFLAGS_COMMON)
# Where you want it installed when you do 'make install'
-PREFIX=/usr/local
-
+PREFIX?=/usr/local
+ENABLE_BIN_STATIC?=1
+ENABLE_BIN_SHARED?=1
+ENABLE_LIB_STATIC?=1
+ENABLE_LIB_SHARED?=1
+ENABLE_DEV?=1
+ENABLE_DOCS?=1
+ENABLE_TESTS?=1
+
+ifeq ($(ENABLE_BIN_STATIC),1)
+ ENABLE_BIN=1
+ ifneq ($(ENABLE_LIB_STATIC),1)
+ ENABLE_LIB_STATIC=1
+ endif
+endif
+ifeq ($(ENABLE_BIN_SHARED),1)
+ ENABLE_BIN=1
+ ifneq ($(ENABLE_LIB_SHARED),1)
+ ENABLE_LIB_STATIC=1
+ endif
+endif
+ifeq ($(ENABLE_LIB_STATIC),1)
+ ENABLE_LIB=1
+endif
+ifeq ($(ENABLE_LIB_SHARED),1)
+ ENABLE_LIB=1
+endif
OBJS= blocksort.o \
huffman.o \
@@ -35,15 +62,38 @@
decompress.o \
bzlib.o
-all: libbz2.a bzip2 bzip2recover test
-
-bzip2: libbz2.a bzip2.o
- $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
+TGTS_all:=
+TGTS_bzip2:=bzip2.o
+TGTS_check:=
+TGTS_install:=
+ifeq ($(ENABLE_LIB),1)
+ TGTS_all+=libbz2
+ TGTS_bzip2+=libbz2
+endif
+ifeq ($(ENABLE_BIN),1)
+ TGTS_all+=bzip2 bzip2recover
+ TGTS_install+=bzip2 bzip2recover
+endif
+ifeq ($(ENABLE_TESTS),1)
+ TGTS_all+=test
+ TGTS_check+=test
+endif
+
+all: $(TGTS_all)
+
+bzip2: $(TGTS_bzip2)
+ifeq ($(ENABLE_BIN_STATIC),1)
+ $(CC) $(CFLAGS_NOPIC) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
+endif
+ifeq ($(ENABLE_BIN_SHARED),1)
+ $(CC) $(CFLAGS_PIC) -o bzip2-shared bzip2.o libbz2.so.1.0
+endif
bzip2recover: bzip2recover.o
- $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o
+ $(CC) $(CFLAGS_NOPIC) $(LDFLAGS) -o bzip2recover bzip2recover.o
-libbz2.a: $(OBJS)
+libbz2: $(OBJS)
+ifeq ($(ENABLE_LIB_STATIC),1)
rm -f libbz2.a
$(AR) cq libbz2.a $(OBJS)
@if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \
@@ -51,8 +101,18 @@
echo $(RANLIB) libbz2.a ; \
$(RANLIB) libbz2.a ; \
fi
+endif
+ifeq ($(ENABLE_LIB_SHARED),1)
+ $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 $(LDFLAGS) -o libbz2.so.1.0.8 $(OBJS)
+ rm -f libbz2.so.1.0
+ rm -f libbz2.so.1
+ rm -f libbz2.so
+ ln -s libbz2.so.1.0.8 libbz2.so.1.0
+ ln -s libbz2.so.1.0 libbz2.so.1
+ ln -s libbz2.so.1 libbz2.so
+endif
-check: test
+check: $(TGTS_check)
test: bzip2
@cat words1
./bzip2 -1 < sample1.ref > sample1.rb2
@@ -69,69 +129,153 @@
cmp sample3.tst sample3.ref
@cat words3
-install: bzip2 bzip2recover
+install: $(TGTS_install)
+ifeq ($(ENABLE_BIN),1)
if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi
+endif
+ifeq ($(ENABLE_LIB),1)
if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
+endif
+ifeq ($(ENABLE_DEV),1)
+ if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
+endif
+ifeq ($(ENABLE_DOCS),1)
if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi
if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi
- if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
+endif
+ifeq ($(ENABLE_BIN),1)
+ ifeq ($(ENABLE_BIN_STATIC),1)
cp -f bzip2 $(PREFIX)/bin/bzip2
- cp -f bzip2 $(PREFIX)/bin/bunzip2
- cp -f bzip2 $(PREFIX)/bin/bzcat
+ chmod a+rx $(PREFIX)/bin/bzip2
+ endif
+ ifeq ($(ENABLE_BIN_SHARED),1)
+ ifeq ($(ENABLE_BIN_STATIC),1)
+ cp -f bzip2-shared $(PREFIX)/bin/bzip2-shared
+ chmod a+rx $(PREFIX)/bin/bzip2-shared
+ else
+ cp -f bzip2-shared $(PREFIX)/bin/bzip2
+ endif
+ endif
+ rm -f $(PREFIX)/bin/bunzip2
+ rm -f $(PREFIX)/bin/bzcat
+ ( cd $(PREFIX)/bin && ln -s bzip2 bunzip2 )
+ ( cd $(PREFIX)/bin && ln -s bzip2 bzcat )
+ rm -f $(PREFIX)/bin/bunzip2-shared
+ rm -f $(PREFIX)/bin/bzcat-shared
+ ifeq ($(ENABLE_BIN_SHARED),1)
+ ifeq ($(ENABLE_BIN_STATIC),1)
+ ( cd $(PREFIX)/bin && ln -s bzip2-shared bunzip2-shared )
+ ( cd $(PREFIX)/bin && ln -s bzip2-shared bzcat-shared )
+ endif
+ endif
cp -f bzip2recover $(PREFIX)/bin/bzip2recover
- chmod a+x $(PREFIX)/bin/bzip2
- chmod a+x $(PREFIX)/bin/bunzip2
- chmod a+x $(PREFIX)/bin/bzcat
- chmod a+x $(PREFIX)/bin/bzip2recover
- cp -f bzip2.1 $(PREFIX)/man/man1
- chmod a+r $(PREFIX)/man/man1/bzip2.1
- cp -f bzlib.h $(PREFIX)/include
- chmod a+r $(PREFIX)/include/bzlib.h
- cp -f libbz2.a $(PREFIX)/lib
- chmod a+r $(PREFIX)/lib/libbz2.a
+ chmod a+rx $(PREFIX)/bin/bzip2recover
cp -f bzgrep $(PREFIX)/bin/bzgrep
- ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
- ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
- chmod a+x $(PREFIX)/bin/bzgrep
+ chmod a+rx $(PREFIX)/bin/bzgrep
+ rm -f $(PREFIX)/bin/bzegrep
+ rm -f $(PREFIX)/bin/bzfgrep
+ ( cd $(PREFIX)/bin && ln -s bzgrep bzegrep )
+ ( cd $(PREFIX)/bin && ln -s bzgrep bzfgrep )
cp -f bzmore $(PREFIX)/bin/bzmore
- ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
- chmod a+x $(PREFIX)/bin/bzmore
+ chmod a+rx $(PREFIX)/bin/bzmore
+ rm -f $(PREFIX)/bin/bzless
+ ( cd $(PREFIX)/bin && ln -s bzmore bzless )
+ rm -f $(PREFIX)/bin/bzcmp
cp -f bzdiff $(PREFIX)/bin/bzdiff
- ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
- chmod a+x $(PREFIX)/bin/bzdiff
- cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
- chmod a+r $(PREFIX)/man/man1/bzgrep.1
- chmod a+r $(PREFIX)/man/man1/bzmore.1
- chmod a+r $(PREFIX)/man/man1/bzdiff.1
+ chmod a+rx $(PREFIX)/bin/bzdiff
+ ( cd $(PREFIX)/bin && ln -s bzdiff bzcmp )
+endif
+ifeq ($(ENABLE_DEV),1)
+ cp -f bzlib.h $(PREFIX)/include
+ chmod a+r $(PREFIX)/include/bzlib.h
+endif
+ifeq ($(ENABLE_DOCS),1)
+ cp -f bzip2.1 bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1
echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1
echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1
echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1
+ chmod a+r $(PREFIX)/man/man1/bzip2.1
+ chmod a+r $(PREFIX)/man/man1/bzgrep.1
+ chmod a+r $(PREFIX)/man/man1/bzmore.1
+ chmod a+r $(PREFIX)/man/man1/bzdiff.1
+ chmod a+r $(PREFIX)/man/man1/bzegrep.1
+ chmod a+r $(PREFIX)/man/man1/bzfgrep.1
+ chmod a+r $(PREFIX)/man/man1/bzless.1
+ chmod a+r $(PREFIX)/man/man1/bzcmp.1
+endif
+ifeq ($(ENABLE_LIB_SHARED),1)
+ cp -f libbz2.so.1.0.8 $(PREFIX)/lib
+ chmod a+r $(PREFIX)/lib/libbz2.so.1.0.8
+ rm -f $(PREFIX)/lib/libbz2.so.1.0
+ rm -f $(PREFIX)/lib/libbz2.so.1
+ rm -f $(PREFIX)/lib/libbz2.so
+ ( cd $(PREFIX)/lib && ln -s libbz2.so.1.0.8 libbz2.so.1.0 )
+ ( cd $(PREFIX)/lib && ln -s libbz2.so.1.0 libbz2.so.1 )
+ ( cd $(PREFIX)/lib && ln -s libbz2.so.1 libbz2.so )
+endif
+ifeq ($(ENABLE_LIB_STATIC),1)
+ cp -f libbz2.a $(PREFIX)/lib
+ chmod a+r $(PREFIX)/lib/libbz2.a
+endif
+
+uninstall:
+ rm -f $(PREFIX)/bin/bzip2
+ rm -f $(PREFIX)/bin/bzip2-shared
+ rm -f $(PREFIX)/bin/bunzip2
+ rm -f $(PREFIX)/bin/bzcat
+ rm -f $(PREFIX)/bin/bunzip2-shared
+ rm -f $(PREFIX)/bin/bzcat-shared
+ rm -f $(PREFIX)/bin/bzip2recover
+ rm -f $(PREFIX)/bin/bzgrep
+ rm -f $(PREFIX)/bin/bzegrep
+ rm -f $(PREFIX)/bin/bzfgrep
+ rm -f $(PREFIX)/bin/bzmore
+ rm -f $(PREFIX)/bin/bzless
+ rm -f $(PREFIX)/bin/bzdiff
+ rm -f $(PREFIX)/bin/bzcmp
+ rm -f $(PREFIX)/include/bzlib.h
+ rm -f $(PREFIX)/lib/libbz2.so.1.0.8
+ rm -f $(PREFIX)/lib/libbz2.so.1.0
+ rm -f $(PREFIX)/lib/libbz2.so.1
+ rm -f $(PREFIX)/lib/libbz2.so
+ rm -f $(PREFIX)/lib/libbz2.a
+ rm -f $(PREFIX)/man/man1/bzip2.1
+ rm -f $(PREFIX)/man/man1/bzgrep.1
+ rm -f $(PREFIX)/man/man1/bzmore.1
+ rm -f $(PREFIX)/man/man1/bzdiff.1
+ rm -f $(PREFIX)/man/man1/bzegrep.1
+ rm -f $(PREFIX)/man/man1/bzfgrep.1
+ rm -f $(PREFIX)/man/man1/bzless.1
+ rm -f $(PREFIX)/man/man1/bzcmp.1
+ (rmdir $(PREFIX)/bin $(PREFIX)/include $(PREFIX)/lib $(PREFIX)/man/man1 $(PREFIX)/man || true ) 2> /dev/null
clean:
- rm -f *.o libbz2.a bzip2 bzip2recover \
+ rm -f $(OBJS) bzip2.o \
+ libbz2.so.1.0.8 libbz2.so.1.0 libbz2.so.1 libbz2.so \
+ libbz2.a bzip2 bzip2-shared bzip2recover \
sample1.rb2 sample2.rb2 sample3.rb2 \
sample1.tst sample2.tst sample3.tst
blocksort.o: blocksort.c
@cat words0
- $(CC) $(CFLAGS) -c blocksort.c
+ $(CC) $(CFLAGS_NOPIC) -c blocksort.c
huffman.o: huffman.c
- $(CC) $(CFLAGS) -c huffman.c
+ $(CC) $(CFLAGS_NOPIC) -c huffman.c
crctable.o: crctable.c
- $(CC) $(CFLAGS) -c crctable.c
+ $(CC) $(CFLAGS_NOPIC) -c crctable.c
randtable.o: randtable.c
- $(CC) $(CFLAGS) -c randtable.c
+ $(CC) $(CFLAGS_NOPIC) -c randtable.c
compress.o: compress.c
- $(CC) $(CFLAGS) -c compress.c
+ $(CC) $(CFLAGS_NOPIC) -c compress.c
decompress.o: decompress.c
- $(CC) $(CFLAGS) -c decompress.c
+ $(CC) $(CFLAGS_NOPIC) -c decompress.c
bzlib.o: bzlib.c
- $(CC) $(CFLAGS) -c bzlib.c
+ $(CC) $(CFLAGS_NOPIC) -c bzlib.c
bzip2.o: bzip2.c
- $(CC) $(CFLAGS) -c bzip2.c
+ $(CC) $(CFLAGS_NOPIC) -c bzip2.c
bzip2recover.o: bzip2recover.c
- $(CC) $(CFLAGS) -c bzip2recover.c
+ $(CC) $(CFLAGS_NOPIC) -c bzip2recover.c
distclean: clean
@@ -189,7 +333,6 @@
$(DISTNAME)/bzmore.1 \
$(DISTNAME)/bzgrep \
$(DISTNAME)/bzgrep.1 \
- $(DISTNAME)/Makefile-libbz2_so \
$(DISTNAME)/bz-common.xsl \
$(DISTNAME)/bz-fo.xsl \
$(DISTNAME)/bz-html.xsl \
--- a/Makefile-libbz2_so
+++ b/Makefile-libbz2_so
@@ -1,59 +0,0 @@
-
-# This Makefile builds a shared version of the library,
-# libbz2.so.1.0.8, with soname libbz2.so.1.0,
-# at least on x86-Linux (RedHat 7.2),
-# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).
-# Please see the README file for some important info
-# about building the library like this.
-
-# ------------------------------------------------------------------
-# This file is part of bzip2/libbzip2, a program and library for
-# lossless, block-sorting data compression.
-#
-# bzip2/libbzip2 version 1.0.8 of 13 July 2019
-# Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
-#
-# Please read the WARNING, DISCLAIMER and PATENTS sections in the
-# README file.
-#
-# This program is released under the terms of the license contained
-# in the file LICENSE.
-# ------------------------------------------------------------------
-
-
-SHELL=/bin/sh
-CC=gcc
-BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
-
-OBJS= blocksort.o \
- huffman.o \
- crctable.o \
- randtable.o \
- compress.o \
- decompress.o \
- bzlib.o
-
-all: $(OBJS)
- $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.8 $(OBJS)
- $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.8
- rm -f libbz2.so.1.0
- ln -s libbz2.so.1.0.8 libbz2.so.1.0
-
-clean:
- rm -f $(OBJS) bzip2.o libbz2.so.1.0.8 libbz2.so.1.0 bzip2-shared
-
-blocksort.o: blocksort.c
- $(CC) $(CFLAGS) -c blocksort.c
-huffman.o: huffman.c
- $(CC) $(CFLAGS) -c huffman.c
-crctable.o: crctable.c
- $(CC) $(CFLAGS) -c crctable.c
-randtable.o: randtable.c
- $(CC) $(CFLAGS) -c randtable.c
-compress.o: compress.c
- $(CC) $(CFLAGS) -c compress.c
-decompress.o: decompress.c
- $(CC) $(CFLAGS) -c decompress.c
-bzlib.o: bzlib.c
- $(CC) $(CFLAGS) -c bzlib.c
--- a/unzcrash.c
+++ b/unzcrash.c
@@ -30,7 +30,7 @@
#include <stdio.h>
#include <assert.h>
-#include "bzlib.h"
+#include <bzlib.h>
#define M_BLOCK 1000000

View File

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=cmake
PKG_VERSION:=3.26.0
PKG_VERSION:=3.26.3
PKG_VERSION_MAJOR:=$(word 1,$(subst ., ,$(PKG_VERSION))).$(word 2,$(subst ., ,$(PKG_VERSION)))
PKG_RELEASE:=1
PKG_CPE_ID:=cpe:/a:kitware:cmake
@ -15,7 +15,7 @@ PKG_CPE_ID:=cpe:/a:kitware:cmake
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/Kitware/CMake/releases/download/v$(PKG_VERSION)/ \
https://cmake.org/files/v$(PKG_VERSION_MAJOR)/
PKG_HASH:=4256613188857e95700621f7cdaaeb954f3546a9249e942bc2f9b3c26e381365
PKG_HASH:=bbd8d39217509d163cb544a40d6428ac666ddc83e22905d3e52c925781f0f659
HOST_BUILD_PARALLEL:=1
HOST_CONFIGURE_PARALLEL:=1

View File

@ -3,18 +3,16 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=dwarves
PKG_VERSION:=1.24
PKG_RELEASE:=$(AUTORELEASE)
PKG_VERSION:=1.25
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://fedorapeople.org/~acme/dwarves/
PKG_HASH:=576bc112b95937dfbcd347c423696ee9e1992a338fdca1acacca736fd95f69c2
PKG_HASH:=e7d45955f6f4eca25a4c8c3bd6611059b35dc217e45976681d7db170fccdec4a
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=COPYING
HOST_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/cmake.mk

View File

@ -11,9 +11,9 @@ PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/firmware-utils.git
PKG_SOURCE_DATE:=2023-04-09
PKG_SOURCE_VERSION:=6a58f456109008620dd15267a7ff0594095e0d77
PKG_MIRROR_HASH:=ce2df83e2ef548f5ffab972dd6f78ce274a382543284aecf09b88237566120e4
PKG_SOURCE_DATE:=2023-04-17
PKG_SOURCE_VERSION:=e8191eb7efc2804d33feb18573c96e632a6c1086
PKG_MIRROR_HASH:=5b82fe3aee4b2baffe5e612f182b0fcd09a646aa09ec16b6cadde26749d9e2dc
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/cmake.mk