wifi: ath12k: Modularize driver into common and Wi-Fi 7 specific components

Split the ath12k driver into two kernel modules:

 - ath12k.ko for shared logic across multiple targets
 - ath12k_wifi7.ko for Wi-Fi 7 specific configuration and routines

The common module (ath12k.ko) must be loaded prior to any device-specific
module, as the latter depends on exported symbols from the former.

As part of this restructuring, Wi-Fi 7 specific files are moved into a
dedicated `wifi7/` directory and built as a separate module. Common
symbols are exported accordingly, with further adjustments planned
in upcoming patches to support architecture-dependent separation.

This modularization improves maintainability and scalability by enabling
clean separation of hardware-specific logic from the shared driver core.

                                          +-----------------+
                                          |                 |
                                          |   ath12k.ko     |
                                          |    (common)     |
        +---------------+                 |                 |
        |               |                 +-----------------+
        |   ath12k.ko   | ===========>
        |               |                 +------------------+
        +---------------+                 |                  |
                                          | ath12k_wifi7.ko  |
                                          | (wifi7 family)   |
                                          |                  |
                                          +------------------+

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0.c5-00481-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3
Tested-on: IPQ5332 hw1.0 AHB WLAN.WBE.1.3.1-00130-QCAHKSWPL_SILICONZ-1

Signed-off-by: Kiran Venkatappa <quic_kiranv@quicinc.com>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Reviewed-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
Link: https://patch.msgid.link/20250812-ath12k-mod-v1-10-8c9b0eb9335d@quicinc.com
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
This commit is contained in:
Kiran Venkatappa 2025-08-12 22:39:36 +05:30 committed by Jeff Johnson
parent 83cd89a955
commit a720270452
23 changed files with 65 additions and 33 deletions

View File

@ -1,12 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause-Clear
obj-$(CONFIG_ATH12K) += ath12k.o
ath12k-y += core.o \
core_wifi7.o \
hal.o \
hal_tx.o \
hal_rx.o \
wmi.o \
wmi_wifi7.o \
mac.o \
reg.o \
htc.o \
@ -16,19 +14,18 @@ ath12k-y += core.o \
dp_rx.o \
debug.o \
ce.o \
ce_wifi7.o \
peer.o \
dbring.o \
hw_wifi7.o \
mhi.o \
mhi_wifi7.o \
pci.o \
pci_wifi7.o \
dp_mon.o \
fw.o \
p2p.o
ath12k-$(CONFIG_ATH12K_AHB) += ahb.o ahb_wifi7.o
ath12k-$(CONFIG_ATH12K_AHB) += ahb.o
obj-$(CONFIG_ATH12K) += wifi7/
ath12k-$(CONFIG_ATH12K_DEBUGFS) += debugfs.o debugfs_htt_stats.o debugfs_sta.o
ath12k-$(CONFIG_ACPI) += acpi.o
ath12k-$(CONFIG_ATH12K_TRACING) += trace.o

View File

@ -1183,6 +1183,7 @@ int ath12k_ahb_register_driver(const enum ath12k_device_family device_id,
return platform_driver_register(ahb_driver);
}
EXPORT_SYMBOL(ath12k_ahb_register_driver);
void ath12k_ahb_unregister_driver(const enum ath12k_device_family device_id)
{
@ -1198,3 +1199,4 @@ void ath12k_ahb_unregister_driver(const enum ath12k_device_family device_id)
platform_driver_unregister(ahb_driver);
ath12k_ahb_family_drivers[device_id] = NULL;
}
EXPORT_SYMBOL(ath12k_ahb_unregister_driver);

View File

@ -632,6 +632,7 @@ u32 ath12k_core_get_max_peers_per_radio(struct ath12k_base *ab)
{
return ath12k_core_get_max_station_per_radio(ab) + TARGET_NUM_VDEVS(ab);
}
EXPORT_SYMBOL(ath12k_core_get_max_peers_per_radio);
struct reserved_mem *ath12k_core_get_reserved_mem(struct ath12k_base *ab,
int index)
@ -1740,6 +1741,7 @@ enum ath12k_qmi_mem_mode ath12k_core_get_memory_mode(struct ath12k_base *ab)
return ATH12K_QMI_MEMORY_MODE_DEFAULT;
}
EXPORT_SYMBOL(ath12k_core_get_memory_mode);
int ath12k_core_pre_init(struct ath12k_base *ab)
{
@ -2272,3 +2274,6 @@ struct ath12k_base *ath12k_core_alloc(struct device *dev, size_t priv_size,
kfree(ab);
return NULL;
}
MODULE_DESCRIPTION("Driver support for Qualcomm Technologies WLAN devices");
MODULE_LICENSE("Dual BSD/GPL");

View File

@ -21,6 +21,7 @@ void ath12k_info(struct ath12k_base *ab, const char *fmt, ...)
/* TODO: Trace the log */
va_end(args);
}
EXPORT_SYMBOL(ath12k_info);
void ath12k_err(struct ath12k_base *ab, const char *fmt, ...)
{
@ -35,6 +36,7 @@ void ath12k_err(struct ath12k_base *ab, const char *fmt, ...)
/* TODO: Trace the log */
va_end(args);
}
EXPORT_SYMBOL(ath12k_err);
void __ath12k_warn(struct device *dev, const char *fmt, ...)
{
@ -49,6 +51,7 @@ void __ath12k_warn(struct device *dev, const char *fmt, ...)
/* TODO: Trace the log */
va_end(args);
}
EXPORT_SYMBOL(__ath12k_warn);
#ifdef CONFIG_ATH12K_DEBUG
@ -72,6 +75,7 @@ void __ath12k_dbg(struct ath12k_base *ab, enum ath12k_debug_mask mask,
va_end(args);
}
EXPORT_SYMBOL(__ath12k_dbg);
void ath12k_dbg_dump(struct ath12k_base *ab,
enum ath12k_debug_mask mask,

View File

@ -1901,6 +1901,7 @@ void ath12k_dp_htt_htc_t2h_msg_handler(struct ath12k_base *ab,
dev_kfree_skb_any(skb);
}
EXPORT_SYMBOL(ath12k_dp_htt_htc_t2h_msg_handler);
static int ath12k_dp_rx_msdu_coalesce(struct ath12k *ar,
struct sk_buff_head *msdu_list,
@ -4383,6 +4384,7 @@ int ath12k_dp_rxdma_ring_sel_config_qcn9274(struct ath12k_base *ab)
return ret;
}
EXPORT_SYMBOL(ath12k_dp_rxdma_ring_sel_config_qcn9274);
int ath12k_dp_rxdma_ring_sel_config_wcn7850(struct ath12k_base *ab)
{
@ -4425,6 +4427,7 @@ int ath12k_dp_rxdma_ring_sel_config_wcn7850(struct ath12k_base *ab)
return ret;
}
EXPORT_SYMBOL(ath12k_dp_rxdma_ring_sel_config_wcn7850);
int ath12k_dp_rx_htt_setup(struct ath12k_base *ab)
{

View File

@ -746,6 +746,7 @@ const struct hal_rx_ops hal_rx_qcn9274_ops = {
.rx_desc_get_desc_size = ath12k_hw_qcn9274_get_rx_desc_size,
.rx_desc_get_msdu_src_link_id = ath12k_hw_qcn9274_rx_desc_get_msdu_src_link,
};
EXPORT_SYMBOL(hal_rx_qcn9274_ops);
static bool ath12k_hw_qcn9274_compact_rx_desc_get_first_msdu(struct hal_rx_desc *desc)
{
@ -1093,6 +1094,7 @@ const struct hal_ops hal_qcn9274_ops = {
.rxdma_ring_wmask_rx_msdu_end = ath12k_hal_qcn9274_rx_msdu_end_wmask_get,
.get_hal_rx_compact_ops = ath12k_hal_qcn9274_get_hal_rx_compact_ops,
};
EXPORT_SYMBOL(hal_qcn9274_ops);
static bool ath12k_hw_wcn7850_rx_desc_get_first_msdu(struct hal_rx_desc *desc)
{
@ -1552,6 +1554,7 @@ const struct hal_rx_ops hal_rx_wcn7850_ops = {
.rx_desc_get_desc_size = ath12k_hw_wcn7850_get_rx_desc_size,
.rx_desc_get_msdu_src_link_id = ath12k_hw_wcn7850_rx_desc_get_msdu_src_link,
};
EXPORT_SYMBOL(hal_rx_wcn7850_ops);
const struct hal_ops hal_wcn7850_ops = {
.create_srng_config = ath12k_hal_srng_create_config_wcn7850,
@ -1560,6 +1563,7 @@ const struct hal_ops hal_wcn7850_ops = {
.rxdma_ring_wmask_rx_msdu_end = NULL,
.get_hal_rx_compact_ops = NULL,
};
EXPORT_SYMBOL(hal_wcn7850_ops);
static int ath12k_hal_alloc_cont_rdp(struct ath12k_base *ab)
{

View File

@ -2,6 +2,7 @@
/*
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
* Copyright (c) 2021-2022, 2024 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include <linux/skbuff.h>
#include <linux/ctype.h>
@ -376,6 +377,7 @@ void ath12k_htc_rx_completion_handler(struct ath12k_base *ab,
out:
kfree_skb(skb);
}
EXPORT_SYMBOL(ath12k_htc_rx_completion_handler);
static void ath12k_htc_control_rx_complete(struct ath12k_base *ab,
struct sk_buff *skb)

View File

@ -1175,6 +1175,7 @@ u32 ath12k_pci_read32(struct ath12k_base *ab, u32 offset)
ab_pci->pci_ops->release(ab);
return val;
}
EXPORT_SYMBOL(ath12k_pci_read32);
void ath12k_pci_write32(struct ath12k_base *ab, u32 offset, u32 value)
{
@ -1795,6 +1796,7 @@ int ath12k_pci_register_driver(const enum ath12k_device_family device_id,
return pci_register_driver(pci_driver);
}
EXPORT_SYMBOL(ath12k_pci_register_driver);
void ath12k_pci_unregister_driver(const enum ath12k_device_family device_id)
{
@ -1805,3 +1807,4 @@ void ath12k_pci_unregister_driver(const enum ath12k_device_family device_id)
pci_unregister_driver(&ath12k_pci_family_drivers[device_id]->driver);
ath12k_pci_family_drivers[device_id] = NULL;
}
EXPORT_SYMBOL(ath12k_pci_unregister_driver);

View File

@ -23,6 +23,7 @@ struct ath12k_ml_peer *ath12k_peer_ml_find(struct ath12k_hw *ah, const u8 *addr)
return NULL;
}
EXPORT_SYMBOL(ath12k_peer_ml_find);
struct ath12k_peer *ath12k_peer_find(struct ath12k_base *ab, int vdev_id,
const u8 *addr)
@ -78,6 +79,7 @@ struct ath12k_peer *ath12k_peer_find_by_addr(struct ath12k_base *ab,
return NULL;
}
EXPORT_SYMBOL(ath12k_peer_find_by_addr);
static struct ath12k_peer *ath12k_peer_find_by_ml_id(struct ath12k_base *ab,
int ml_peer_id)

View File

@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause-Clear
obj-$(CONFIG_ATH12K) += ath12k_wifi7.o
ath12k_wifi7-y += core.o \
pci.o \
wmi.o \
mhi.o \
ce.o \
hw.o
ath12k_wifi7-$(CONFIG_ATH12K_AHB) += ahb.o

View File

@ -7,11 +7,11 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/soc/qcom/mdt_loader.h>
#include "../ahb.h"
#include "ahb.h"
#include "ahb_wifi7.h"
#include "debug.h"
#include "hif.h"
#include "hw_wifi7.h"
#include "../debug.h"
#include "../hif.h"
#include "hw.h"
static const struct of_device_id ath12k_wifi7_ahb_of_match[] = {
{ .compatible = "qcom,ipq5332-wifi",

View File

@ -8,10 +8,10 @@
#include <linux/bitops.h>
#include <linux/bitfield.h>
#include "core.h"
#include "../core.h"
#include "../ce.h"
#include "ce.h"
#include "ce_wifi7.h"
#include "dp_rx.h"
#include "../dp_rx.h"
/* Copy Engine (CE) configs for QCN9274 */
/* Target firmware's Copy Engine configuration. */

View File

@ -5,10 +5,10 @@
*/
#include <linux/module.h>
#include "ahb.h"
#include "../ahb.h"
#include "../pci.h"
#include "pci.h"
#include "pci_wifi7.h"
#include "ahb_wifi7.h"
#include "ahb.h"
static int ahb_err, pci_err;

View File

@ -8,17 +8,17 @@
#include <linux/bitops.h>
#include <linux/bitfield.h>
#include "debug.h"
#include "core.h"
#include "../debug.h"
#include "../core.h"
#include "../ce.h"
#include "ce.h"
#include "ce_wifi7.h"
#include "../hw.h"
#include "hw.h"
#include "hw_wifi7.h"
#include "../mhi.h"
#include "mhi.h"
#include "dp_rx.h"
#include "peer.h"
#include "wmi_wifi7.h"
#include "mhi_wifi7.h"
#include "../dp_rx.h"
#include "../peer.h"
#include "wmi.h"
static const guid_t wcn7850_uuid = GUID_INIT(0xf634f534, 0x6147, 0x11ec,
0x90, 0xd6, 0x02, 0x42,

View File

@ -4,8 +4,8 @@
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include "../mhi.h"
#include "mhi.h"
#include "mhi_wifi7.h"
static const struct mhi_channel_config ath12k_mhi_channels_qcn9274[] = {
{

View File

@ -6,12 +6,12 @@
#include <linux/pci.h>
#include "../pci.h"
#include "pci.h"
#include "pci_wifi7.h"
#include "core.h"
#include "hif.h"
#include "mhi.h"
#include "hw_wifi7.h"
#include "../core.h"
#include "../hif.h"
#include "../mhi.h"
#include "hw.h"
#define QCN9274_DEVICE_ID 0x1109
#define WCN7850_DEVICE_ID 0x1107

View File

@ -4,8 +4,8 @@
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#include "core.h"
#include "wmi_wifi7.h"
#include "../core.h"
#include "wmi.h"
void ath12k_wmi_init_qcn9274(struct ath12k_base *ab,
struct ath12k_wmi_resource_config_arg *config)