1# Copyright (c) 2024 Nordic Semiconductor ASA
2# SPDX-License-Identifier: Apache-2.0
3
4if(NOT CONFIG_WIFI_NRF70)
5  return()
6endif()
7zephyr_interface_library_named(nrf-wifi-interface)
8zephyr_library()
9
10set(NRF_WIFI_DIR ${ZEPHYR_CURRENT_MODULE_DIR})
11
12# Translate the configuration to the OS agnostic code
13target_compile_definitions(
14  nrf-wifi-interface
15  INTERFACE
16  $<$<BOOL:${CONFIG_NRF_WIFI_LOW_POWER}>:NRF_WIFI_LOW_POWER>
17  $<$<BOOL:${CONFIG_NRF_WIFI_RPU_RECOVERY}>:NRF_WIFI_RPU_RECOVERY>
18  $<$<BOOL:${CONFIG_NRF_WIFI_AP_DEAD_DETECT_TIMEOUT}>:NRF_WIFI_AP_DEAD_DETECT_TIMEOUT=${CONFIG_NRF_WIFI_AP_DEAD_DETECT_TIMEOUT}>
19  $<$<BOOL:${CONFIG_NRF_WIFI_IFACE_MTU}>:NRF_WIFI_IFACE_MTU=${CONFIG_NRF_WIFI_IFACE_MTU}>
20  $<$<BOOL:${CONFIG_NRF70_STA_MODE}>:NRF70_STA_MODE>
21  $<$<BOOL:${CONFIG_NRF70_DATA_TX}>:NRF70_DATA_TX>
22  $<$<BOOL:${CONFIG_NRF70_RAW_DATA_TX}>:NRF70_RAW_DATA_TX>
23  $<$<BOOL:${CONFIG_NRF70_RAW_DATA_RX}>:NRF70_RAW_DATA_RX>
24  $<$<BOOL:${CONFIG_NRF70_PROMISC_DATA_RX}>:NRF70_PROMISC_DATA_RX>
25  $<$<BOOL:${CONFIG_NRF70_TX_DONE_WQ_ENABLED}>:NRF70_TX_DONE_WQ_ENABLED>
26  $<$<BOOL:${CONFIG_NRF70_RX_WQ_ENABLED}>:NRF70_RX_WQ_ENABLED>
27  $<$<BOOL:${CONFIG_NRF70_UTIL}>:NRF70_UTIL>
28  $<$<BOOL:${CONFIG_NRF70_RADIO_TEST}>:NRF70_RADIO_TEST>
29  $<$<BOOL:${CONFIG_NRF70_OFFLOADED_RAW_TX}>:NRF70_OFFLOADED_RAW_TX>
30  $<$<BOOL:${CONFIG_NRF70_TCP_IP_CHECKSUM_OFFLOAD}>:NRF70_TCP_IP_CHECKSUM_OFFLOAD>
31  $<$<BOOL:${CONFIG_NRF70_RPU_EXTEND_TWT_SP}>:NRF70_RPU_EXTEND_TWT_SP>
32  $<$<BOOL:${CONFIG_NRF70_SYSTEM_WITH_RAW_MODES}>:NRF70_SYSTEM_WITH_RAW_MODES>
33  $<$<BOOL:${CONFIG_NRF70_SCAN_ONLY}>:NRF70_SCAN_ONLY>
34  $<$<BOOL:${CONFIG_NRF70_SYSTEM_MODE}>:NRF70_SYSTEM_MODE>
35  $<$<BOOL:${CONFIG_NRF70_2_4G_ONLY}>:NRF70_2_4G_ONLY>
36  $<$<BOOL:${CONFIG_NRF70_LOG_VERBOSE}>:NRF70_LOG_VERBOSE>
37  $<$<BOOL:${CONFIG_NRF70_AP_MODE}>:NRF70_AP_MODE>
38  $<$<BOOL:${CONFIG_NRF_WIFI_MGMT_BUFF_OFFLOAD}>:NRF_WIFI_MGMT_BUFF_OFFLOAD>
39  $<$<BOOL:${CONFIG_NRF_WIFI_FEAT_KEEPALIVE}>:NRF_WIFI_FEAT_KEEPALIVE>
40  $<$<BOOL:${CONFIG_NRF_WIFI_FEAT_KEEPALIVE}>:NRF_WIFI_KEEPALIVE_PERIOD_S=${CONFIG_NRF_WIFI_KEEPALIVE_PERIOD_S}>
41  $<$<BOOL:${CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS}>:WIFI_MGMT_RAW_SCAN_RESULTS>
42  $<$<BOOL:${CONFIG_NRF_WIFI_COEX_DISABLE_PRIORITY_WINDOW_FOR_SCAN}>:NRF_WIFI_COEX_DISABLE_PRIORITY_WINDOW_FOR_SCAN>
43  NRF70_RX_NUM_BUFS=${CONFIG_NRF70_RX_NUM_BUFS}
44  NRF70_MAX_TX_TOKENS=${CONFIG_NRF70_MAX_TX_TOKENS}
45  NRF70_RX_MAX_DATA_SIZE=${CONFIG_NRF70_RX_MAX_DATA_SIZE}
46  NRF70_MAX_TX_PENDING_QLEN=${CONFIG_NRF70_MAX_TX_PENDING_QLEN}
47  NRF70_RPU_PS_IDLE_TIMEOUT_MS=${CONFIG_NRF70_RPU_PS_IDLE_TIMEOUT_MS}
48  NRF70_BAND_2G_LOWER_EDGE_BACKOFF_DSSS=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_DSSS}
49  NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HT}
50  NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_2G_LOWER_EDGE_BACKOFF_HE}
51  NRF70_BAND_2G_UPPER_EDGE_BACKOFF_DSSS=${CONFIG_NRF70_BAND_2G_UPPER_EDGE_BACKOFF_DSSS}
52  NRF70_BAND_2G_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_2G_UPPER_EDGE_BACKOFF_HT}
53  NRF70_BAND_2G_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_2G_UPPER_EDGE_BACKOFF_HE}
54  NRF70_BAND_UNII_1_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_1_LOWER_EDGE_BACKOFF_HT}
55  NRF70_BAND_UNII_1_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_1_LOWER_EDGE_BACKOFF_HE}
56  NRF70_BAND_UNII_1_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_1_UPPER_EDGE_BACKOFF_HT}
57  NRF70_BAND_UNII_1_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_1_UPPER_EDGE_BACKOFF_HE}
58  NRF70_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HT}
59  NRF70_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HE}
60  NRF70_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HT}
61  NRF70_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HE}
62  NRF70_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HT}
63  NRF70_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HE}
64  NRF70_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HT}
65  NRF70_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HE}
66  NRF70_BAND_UNII_3_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_3_LOWER_EDGE_BACKOFF_HT}
67  NRF70_BAND_UNII_3_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_3_LOWER_EDGE_BACKOFF_HE}
68  NRF70_BAND_UNII_3_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_3_UPPER_EDGE_BACKOFF_HT}
69  NRF70_BAND_UNII_3_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_3_UPPER_EDGE_BACKOFF_HE}
70  NRF70_BAND_UNII_4_LOWER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_4_LOWER_EDGE_BACKOFF_HT}
71  NRF70_BAND_UNII_4_LOWER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_4_LOWER_EDGE_BACKOFF_HE}
72  NRF70_BAND_UNII_4_UPPER_EDGE_BACKOFF_HT=${CONFIG_NRF70_BAND_UNII_4_UPPER_EDGE_BACKOFF_HT}
73  NRF70_BAND_UNII_4_UPPER_EDGE_BACKOFF_HE=${CONFIG_NRF70_BAND_UNII_4_UPPER_EDGE_BACKOFF_HE}
74  NRF70_PCB_LOSS_2G=${CONFIG_NRF70_PCB_LOSS_2G}
75  NRF70_PCB_LOSS_5G_BAND1=${CONFIG_NRF70_PCB_LOSS_5G_BAND1}
76  NRF70_PCB_LOSS_5G_BAND2=${CONFIG_NRF70_PCB_LOSS_5G_BAND2}
77  NRF70_PCB_LOSS_5G_BAND3=${CONFIG_NRF70_PCB_LOSS_5G_BAND3}
78  NRF70_ANT_GAIN_2G=${CONFIG_NRF70_ANT_GAIN_2G}
79  NRF70_ANT_GAIN_5G_BAND1=${CONFIG_NRF70_ANT_GAIN_5G_BAND1}
80  NRF70_ANT_GAIN_5G_BAND2=${CONFIG_NRF70_ANT_GAIN_5G_BAND2}
81  NRF70_ANT_GAIN_5G_BAND3=${CONFIG_NRF70_ANT_GAIN_5G_BAND3}
82  NRF_WIFI_PS_INT_PS=${CONFIG_NRF_WIFI_PS_INT_PS}
83  NRF_WIFI_RPU_RECOVERY_PS_ACTIVE_TIMEOUT_MS=${CONFIG_NRF_WIFI_RPU_RECOVERY_PS_ACTIVE_TIMEOUT_MS}
84  NRF_WIFI_DISPLAY_SCAN_BSS_LIMIT=${CONFIG_NRF_WIFI_DISPLAY_SCAN_BSS_LIMIT}
85)
86
87target_include_directories(
88  nrf-wifi-interface
89  INTERFACE
90  ${CMAKE_CURRENT_LIST_DIR}
91  ${CMAKE_CURRENT_SOURCE_DIR}/../bus
92  ${NRF_WIFI_DIR}/utils/inc
93  ${NRF_WIFI_DIR}/os_if/inc
94  ${NRF_WIFI_DIR}/bus_if/bus/qspi/inc
95  ${NRF_WIFI_DIR}/bus_if/bal/inc
96  ${NRF_WIFI_DIR}/fw_if/umac_if/inc
97  ${NRF_WIFI_DIR}/fw_load/mips/fw/inc
98  ${NRF_WIFI_DIR}/hw_if/hal/inc
99  ${NRF_WIFI_DIR}/hw_if/hal/inc/fw
100  ${NRF_WIFI_DIR}/fw_if/umac_if/inc/fw
101)
102
103if(CONFIG_NRF70_RADIO_TEST)
104  target_include_directories(nrf-wifi-interface INTERFACE
105    ${NRF_WIFI_DIR}/fw_if/umac_if/inc/radio_test
106  )
107elseif(CONFIG_NRF70_OFFLOADED_RAW_TX)
108  target_include_directories(nrf-wifi-interface INTERFACE
109    ${NRF_WIFI_DIR}/fw_if/umac_if/inc/offload_raw_tx
110    off_raw_tx/inc
111  )
112else()
113  target_include_directories(nrf-wifi-interface INTERFACE
114    ${NRF_WIFI_DIR}/fw_if/umac_if/inc/default
115  )
116endif()
117
118zephyr_library_sources(
119  ${NRF_WIFI_DIR}/os_if/src/osal.c
120  ${NRF_WIFI_DIR}/utils/src/list.c
121  ${NRF_WIFI_DIR}/utils/src/queue.c
122  ${NRF_WIFI_DIR}/utils/src/util.c
123  ${NRF_WIFI_DIR}/hw_if/hal/src/hal_api.c
124  ${NRF_WIFI_DIR}/hw_if/hal/src/hal_fw_patch_loader.c
125  ${NRF_WIFI_DIR}/hw_if/hal/src/hal_interrupt.c
126  ${NRF_WIFI_DIR}/hw_if/hal/src/hal_mem.c
127  ${NRF_WIFI_DIR}/hw_if/hal/src/hal_reg.c
128  ${NRF_WIFI_DIR}/hw_if/hal/src/hpqm.c
129  ${NRF_WIFI_DIR}/hw_if/hal/src/pal.c
130  ${NRF_WIFI_DIR}/bus_if/bal/src/bal.c
131  ${NRF_WIFI_DIR}/bus_if/bus/qspi/src/qspi.c
132  ${NRF_WIFI_DIR}/fw_if/umac_if/src/cmd.c
133  ${NRF_WIFI_DIR}/fw_if/umac_if/src/event.c
134  ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_api_common.c
135)
136
137if(CONFIG_NRF70_RADIO_TEST)
138  zephyr_library_sources(
139    ${NRF_WIFI_DIR}/fw_if/umac_if/src/radio_test/fmac_api.c
140    ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
141  )
142elseif(CONFIG_NRF70_OFFLOADED_RAW_TX)
143  zephyr_library_sources(
144    ${NRF_WIFI_DIR}/fw_if/umac_if/src/offload_raw_tx/fmac_api.c
145    ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
146  )
147else()
148  zephyr_library_sources(
149    ${NRF_WIFI_DIR}/fw_if/umac_if/src/rx.c
150    ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_vif.c
151    ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
152    ${NRF_WIFI_DIR}/fw_if/umac_if/src/default/fmac_api.c
153  )
154endif()
155
156zephyr_library_sources_ifdef(CONFIG_NRF70_DATA_TX
157  ${NRF_WIFI_DIR}/fw_if/umac_if/src/tx.c
158  ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c
159)
160
161zephyr_library_sources_ifdef(CONFIG_NRF70_STA_MODE
162  ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c
163  ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
164)
165
166zephyr_library_sources_ifdef(CONFIG_NRF70_PROMISC_DATA_RX
167  ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_promisc.c
168)
169
170zephyr_library_sources_ifdef(CONFIG_NRF70_AP_MODE
171  ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_ap.c
172)
173
174# Without WPA supplicant we only support scan
175zephyr_library_sources_ifdef(CONFIG_NRF70_STA_MODE
176  ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_peer.c
177  ${NRF_WIFI_DIR}/fw_if/umac_if/src/fmac_util.c
178)
179
180zephyr_library_sources(
181  shim.c
182  timer.c
183  work.c
184)
185
186target_link_libraries(zephyr_interface INTERFACE nrf-wifi-interface)
187target_link_libraries(nrf_wifi PRIVATE nrf70-buslib)
188