├── .checkpatch.conf ├── .clang-format ├── .github └── workflows │ ├── build.yml │ ├── checkpatch.yml │ ├── clang-format.yml │ ├── gitlint.yml │ └── manifest.yml ├── .gitignore ├── .gitlint ├── CODEOWNERS ├── LICENSE ├── Makefile ├── README.md ├── boards └── RPi4B_interposer │ ├── 400783_pcb_laminate_specification.pdf │ ├── Gerber.zip │ ├── pca64167_BOM.pdf │ └── pca64167_schematic_and_pcb.pdf ├── dts ├── bindings │ ├── nordic,nrf70-spi.yaml │ └── nordic,nrf70.yaml └── nrf70_rpi_interposer.dts ├── inc ├── ap.h ├── cfg80211_if.h ├── driver_linux.h ├── fmac_dbgfs_if.h ├── fmac_main.h ├── linux_util.h ├── main.h ├── net_stack.h ├── p2p.h ├── shim.h └── sta.h ├── scripts ├── ci │ └── codeowners.py └── requirements-fixed.txt ├── src ├── cfg80211_if.c ├── debugfs │ ├── main.c │ ├── radio_test.c │ ├── stats.c │ ├── wlan_fmac_twt.c │ └── wlan_fmac_ver.c ├── linux_util.c ├── main.c ├── netdev.c ├── shim.c ├── spi │ ├── inc │ │ ├── rpu_hw_if.h │ │ └── spi_if.h │ └── src │ │ ├── device.c │ │ ├── rpu_hw_if.c │ │ └── spi_if.c └── wiphy.c └── west.yml /.checkpatch.conf: -------------------------------------------------------------------------------- 1 | --summary-file 2 | --show-types 3 | --max-line-length=80 4 | --min-conf-desc-length=1 5 | --no-tree 6 | --show-file 7 | 8 | --ignore SPDX_LICENSE_TAG 9 | --ignore C99_COMMENT_TOLERANCE 10 | --ignore COMPLEX_MACRO 11 | --ignore MAINTAINERS_STYLE -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0 2 | # 3 | # clang-format configuration file. Intended for clang-format >= 11. 4 | # 5 | # For more information, see: 6 | # 7 | # Documentation/process/clang-format.rst 8 | # https://clang.llvm.org/docs/ClangFormat.html 9 | # https://clang.llvm.org/docs/ClangFormatStyleOptions.html 10 | # 11 | --- 12 | AccessModifierOffset: -4 13 | AlignAfterOpenBracket: Align 14 | AlignConsecutiveAssignments: false 15 | AlignConsecutiveDeclarations: false 16 | AlignEscapedNewlines: Left 17 | AlignOperands: true 18 | AlignTrailingComments: false 19 | AllowAllParametersOfDeclarationOnNextLine: false 20 | AllowShortBlocksOnASingleLine: false 21 | AllowShortCaseLabelsOnASingleLine: false 22 | AllowShortFunctionsOnASingleLine: None 23 | AllowShortIfStatementsOnASingleLine: false 24 | AllowShortLoopsOnASingleLine: false 25 | AlwaysBreakAfterDefinitionReturnType: None 26 | AlwaysBreakAfterReturnType: None 27 | AlwaysBreakBeforeMultilineStrings: false 28 | AlwaysBreakTemplateDeclarations: false 29 | BinPackArguments: true 30 | BinPackParameters: true 31 | BraceWrapping: 32 | AfterClass: false 33 | AfterControlStatement: false 34 | AfterEnum: false 35 | AfterFunction: true 36 | AfterNamespace: true 37 | AfterObjCDeclaration: false 38 | AfterStruct: false 39 | AfterUnion: false 40 | AfterExternBlock: false 41 | BeforeCatch: false 42 | BeforeElse: false 43 | IndentBraces: false 44 | SplitEmptyFunction: true 45 | SplitEmptyRecord: true 46 | SplitEmptyNamespace: true 47 | BreakBeforeBinaryOperators: None 48 | BreakBeforeBraces: Custom 49 | BreakBeforeInheritanceComma: false 50 | BreakBeforeTernaryOperators: false 51 | BreakConstructorInitializersBeforeComma: false 52 | BreakConstructorInitializers: BeforeComma 53 | BreakAfterJavaFieldAnnotations: false 54 | BreakStringLiterals: false 55 | ColumnLimit: 80 56 | CommentPragmas: '^ IWYU pragma:' 57 | CompactNamespaces: false 58 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 59 | ConstructorInitializerIndentWidth: 8 60 | ContinuationIndentWidth: 8 61 | Cpp11BracedListStyle: false 62 | DerivePointerAlignment: false 63 | DisableFormat: false 64 | ExperimentalAutoDetectBinPacking: false 65 | FixNamespaceComments: false 66 | 67 | # Taken from: 68 | # git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ tools/ \ 69 | # | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \ 70 | # | LC_ALL=C sort -u 71 | ForEachMacros: 72 | - '__ata_qc_for_each' 73 | - '__bio_for_each_bvec' 74 | - '__bio_for_each_segment' 75 | - '__evlist__for_each_entry' 76 | - '__evlist__for_each_entry_continue' 77 | - '__evlist__for_each_entry_from' 78 | - '__evlist__for_each_entry_reverse' 79 | - '__evlist__for_each_entry_safe' 80 | - '__for_each_mem_range' 81 | - '__for_each_mem_range_rev' 82 | - '__for_each_thread' 83 | - '__hlist_for_each_rcu' 84 | - '__map__for_each_symbol_by_name' 85 | - '__perf_evlist__for_each_entry' 86 | - '__perf_evlist__for_each_entry_reverse' 87 | - '__perf_evlist__for_each_entry_safe' 88 | - '__rq_for_each_bio' 89 | - '__shost_for_each_device' 90 | - 'apei_estatus_for_each_section' 91 | - 'ata_for_each_dev' 92 | - 'ata_for_each_link' 93 | - 'ata_qc_for_each' 94 | - 'ata_qc_for_each_raw' 95 | - 'ata_qc_for_each_with_internal' 96 | - 'ax25_for_each' 97 | - 'ax25_uid_for_each' 98 | - 'bio_for_each_bvec' 99 | - 'bio_for_each_bvec_all' 100 | - 'bio_for_each_folio_all' 101 | - 'bio_for_each_integrity_vec' 102 | - 'bio_for_each_segment' 103 | - 'bio_for_each_segment_all' 104 | - 'bio_list_for_each' 105 | - 'bip_for_each_vec' 106 | - 'bond_for_each_slave' 107 | - 'bond_for_each_slave_rcu' 108 | - 'bpf__perf_for_each_map' 109 | - 'bpf__perf_for_each_map_named' 110 | - 'bpf_for_each_spilled_reg' 111 | - 'bpf_object__for_each_map' 112 | - 'bpf_object__for_each_program' 113 | - 'bpf_object__for_each_safe' 114 | - 'bpf_perf_object__for_each' 115 | - 'btree_for_each_safe128' 116 | - 'btree_for_each_safe32' 117 | - 'btree_for_each_safe64' 118 | - 'btree_for_each_safel' 119 | - 'card_for_each_dev' 120 | - 'cgroup_taskset_for_each' 121 | - 'cgroup_taskset_for_each_leader' 122 | - 'cpufreq_for_each_efficient_entry_idx' 123 | - 'cpufreq_for_each_entry' 124 | - 'cpufreq_for_each_entry_idx' 125 | - 'cpufreq_for_each_valid_entry' 126 | - 'cpufreq_for_each_valid_entry_idx' 127 | - 'css_for_each_child' 128 | - 'css_for_each_descendant_post' 129 | - 'css_for_each_descendant_pre' 130 | - 'damon_for_each_region' 131 | - 'damon_for_each_region_safe' 132 | - 'damon_for_each_scheme' 133 | - 'damon_for_each_scheme_safe' 134 | - 'damon_for_each_target' 135 | - 'damon_for_each_target_safe' 136 | - 'data__for_each_file' 137 | - 'data__for_each_file_new' 138 | - 'data__for_each_file_start' 139 | - 'device_for_each_child_node' 140 | - 'displayid_iter_for_each' 141 | - 'dma_fence_array_for_each' 142 | - 'dma_fence_chain_for_each' 143 | - 'dma_fence_unwrap_for_each' 144 | - 'dma_resv_for_each_fence' 145 | - 'dma_resv_for_each_fence_unlocked' 146 | - 'do_for_each_ftrace_op' 147 | - 'drm_atomic_crtc_for_each_plane' 148 | - 'drm_atomic_crtc_state_for_each_plane' 149 | - 'drm_atomic_crtc_state_for_each_plane_state' 150 | - 'drm_atomic_for_each_plane_damage' 151 | - 'drm_client_for_each_connector_iter' 152 | - 'drm_client_for_each_modeset' 153 | - 'drm_connector_for_each_possible_encoder' 154 | - 'drm_for_each_bridge_in_chain' 155 | - 'drm_for_each_connector_iter' 156 | - 'drm_for_each_crtc' 157 | - 'drm_for_each_crtc_reverse' 158 | - 'drm_for_each_encoder' 159 | - 'drm_for_each_encoder_mask' 160 | - 'drm_for_each_fb' 161 | - 'drm_for_each_legacy_plane' 162 | - 'drm_for_each_plane' 163 | - 'drm_for_each_plane_mask' 164 | - 'drm_for_each_privobj' 165 | - 'drm_mm_for_each_hole' 166 | - 'drm_mm_for_each_node' 167 | - 'drm_mm_for_each_node_in_range' 168 | - 'drm_mm_for_each_node_safe' 169 | - 'dsa_switch_for_each_available_port' 170 | - 'dsa_switch_for_each_cpu_port' 171 | - 'dsa_switch_for_each_port' 172 | - 'dsa_switch_for_each_port_continue_reverse' 173 | - 'dsa_switch_for_each_port_safe' 174 | - 'dsa_switch_for_each_user_port' 175 | - 'dsa_tree_for_each_user_port' 176 | - 'dso__for_each_symbol' 177 | - 'dsos__for_each_with_build_id' 178 | - 'elf_hash_for_each_possible' 179 | - 'elf_section__for_each_rel' 180 | - 'elf_section__for_each_rela' 181 | - 'elf_symtab__for_each_symbol' 182 | - 'evlist__for_each_cpu' 183 | - 'evlist__for_each_entry' 184 | - 'evlist__for_each_entry_continue' 185 | - 'evlist__for_each_entry_from' 186 | - 'evlist__for_each_entry_reverse' 187 | - 'evlist__for_each_entry_safe' 188 | - 'flow_action_for_each' 189 | - 'for_each_acpi_dev_match' 190 | - 'for_each_active_dev_scope' 191 | - 'for_each_active_drhd_unit' 192 | - 'for_each_active_iommu' 193 | - 'for_each_active_route' 194 | - 'for_each_aggr_pgid' 195 | - 'for_each_available_child_of_node' 196 | - 'for_each_bench' 197 | - 'for_each_bio' 198 | - 'for_each_board_func_rsrc' 199 | - 'for_each_btf_ext_rec' 200 | - 'for_each_btf_ext_sec' 201 | - 'for_each_bvec' 202 | - 'for_each_card_auxs' 203 | - 'for_each_card_auxs_safe' 204 | - 'for_each_card_components' 205 | - 'for_each_card_dapms' 206 | - 'for_each_card_pre_auxs' 207 | - 'for_each_card_prelinks' 208 | - 'for_each_card_rtds' 209 | - 'for_each_card_rtds_safe' 210 | - 'for_each_card_widgets' 211 | - 'for_each_card_widgets_safe' 212 | - 'for_each_cgroup_storage_type' 213 | - 'for_each_child_of_node' 214 | - 'for_each_clear_bit' 215 | - 'for_each_clear_bit_from' 216 | - 'for_each_clear_bitrange' 217 | - 'for_each_clear_bitrange_from' 218 | - 'for_each_cmd' 219 | - 'for_each_cmsghdr' 220 | - 'for_each_collection' 221 | - 'for_each_comp_order' 222 | - 'for_each_compatible_node' 223 | - 'for_each_component_dais' 224 | - 'for_each_component_dais_safe' 225 | - 'for_each_console' 226 | - 'for_each_console_srcu' 227 | - 'for_each_cpu' 228 | - 'for_each_cpu_and' 229 | - 'for_each_cpu_wrap' 230 | - 'for_each_dapm_widgets' 231 | - 'for_each_dedup_cand' 232 | - 'for_each_dev_addr' 233 | - 'for_each_dev_scope' 234 | - 'for_each_dma_cap_mask' 235 | - 'for_each_dpcm_be' 236 | - 'for_each_dpcm_be_rollback' 237 | - 'for_each_dpcm_be_safe' 238 | - 'for_each_dpcm_fe' 239 | - 'for_each_drhd_unit' 240 | - 'for_each_dss_dev' 241 | - 'for_each_efi_memory_desc' 242 | - 'for_each_efi_memory_desc_in_map' 243 | - 'for_each_element' 244 | - 'for_each_element_extid' 245 | - 'for_each_element_id' 246 | - 'for_each_endpoint_of_node' 247 | - 'for_each_event' 248 | - 'for_each_event_tps' 249 | - 'for_each_evictable_lru' 250 | - 'for_each_fib6_node_rt_rcu' 251 | - 'for_each_fib6_walker_rt' 252 | - 'for_each_free_mem_pfn_range_in_zone' 253 | - 'for_each_free_mem_pfn_range_in_zone_from' 254 | - 'for_each_free_mem_range' 255 | - 'for_each_free_mem_range_reverse' 256 | - 'for_each_func_rsrc' 257 | - 'for_each_group_device' 258 | - 'for_each_group_evsel' 259 | - 'for_each_group_member' 260 | - 'for_each_hstate' 261 | - 'for_each_if' 262 | - 'for_each_inject_fn' 263 | - 'for_each_insn' 264 | - 'for_each_insn_prefix' 265 | - 'for_each_intid' 266 | - 'for_each_iommu' 267 | - 'for_each_ip_tunnel_rcu' 268 | - 'for_each_irq_nr' 269 | - 'for_each_lang' 270 | - 'for_each_link_codecs' 271 | - 'for_each_link_cpus' 272 | - 'for_each_link_platforms' 273 | - 'for_each_lru' 274 | - 'for_each_matching_node' 275 | - 'for_each_matching_node_and_match' 276 | - 'for_each_mem_pfn_range' 277 | - 'for_each_mem_range' 278 | - 'for_each_mem_range_rev' 279 | - 'for_each_mem_region' 280 | - 'for_each_member' 281 | - 'for_each_memory' 282 | - 'for_each_migratetype_order' 283 | - 'for_each_missing_reg' 284 | - 'for_each_net' 285 | - 'for_each_net_continue_reverse' 286 | - 'for_each_net_rcu' 287 | - 'for_each_netdev' 288 | - 'for_each_netdev_continue' 289 | - 'for_each_netdev_continue_rcu' 290 | - 'for_each_netdev_continue_reverse' 291 | - 'for_each_netdev_feature' 292 | - 'for_each_netdev_in_bond_rcu' 293 | - 'for_each_netdev_rcu' 294 | - 'for_each_netdev_reverse' 295 | - 'for_each_netdev_safe' 296 | - 'for_each_new_connector_in_state' 297 | - 'for_each_new_crtc_in_state' 298 | - 'for_each_new_mst_mgr_in_state' 299 | - 'for_each_new_plane_in_state' 300 | - 'for_each_new_plane_in_state_reverse' 301 | - 'for_each_new_private_obj_in_state' 302 | - 'for_each_new_reg' 303 | - 'for_each_node' 304 | - 'for_each_node_by_name' 305 | - 'for_each_node_by_type' 306 | - 'for_each_node_mask' 307 | - 'for_each_node_state' 308 | - 'for_each_node_with_cpus' 309 | - 'for_each_node_with_property' 310 | - 'for_each_nonreserved_multicast_dest_pgid' 311 | - 'for_each_of_allnodes' 312 | - 'for_each_of_allnodes_from' 313 | - 'for_each_of_cpu_node' 314 | - 'for_each_of_pci_range' 315 | - 'for_each_old_connector_in_state' 316 | - 'for_each_old_crtc_in_state' 317 | - 'for_each_old_mst_mgr_in_state' 318 | - 'for_each_old_plane_in_state' 319 | - 'for_each_old_private_obj_in_state' 320 | - 'for_each_oldnew_connector_in_state' 321 | - 'for_each_oldnew_crtc_in_state' 322 | - 'for_each_oldnew_mst_mgr_in_state' 323 | - 'for_each_oldnew_plane_in_state' 324 | - 'for_each_oldnew_plane_in_state_reverse' 325 | - 'for_each_oldnew_private_obj_in_state' 326 | - 'for_each_online_cpu' 327 | - 'for_each_online_node' 328 | - 'for_each_online_pgdat' 329 | - 'for_each_path' 330 | - 'for_each_pci_bridge' 331 | - 'for_each_pci_dev' 332 | - 'for_each_pcm_streams' 333 | - 'for_each_physmem_range' 334 | - 'for_each_populated_zone' 335 | - 'for_each_possible_cpu' 336 | - 'for_each_present_cpu' 337 | - 'for_each_prime_number' 338 | - 'for_each_prime_number_from' 339 | - 'for_each_probe_cache_entry' 340 | - 'for_each_process' 341 | - 'for_each_process_thread' 342 | - 'for_each_prop_codec_conf' 343 | - 'for_each_prop_dai_codec' 344 | - 'for_each_prop_dai_cpu' 345 | - 'for_each_prop_dlc_codecs' 346 | - 'for_each_prop_dlc_cpus' 347 | - 'for_each_prop_dlc_platforms' 348 | - 'for_each_property_of_node' 349 | - 'for_each_reg' 350 | - 'for_each_reg_filtered' 351 | - 'for_each_registered_fb' 352 | - 'for_each_requested_gpio' 353 | - 'for_each_requested_gpio_in_range' 354 | - 'for_each_reserved_mem_range' 355 | - 'for_each_reserved_mem_region' 356 | - 'for_each_rtd_codec_dais' 357 | - 'for_each_rtd_components' 358 | - 'for_each_rtd_cpu_dais' 359 | - 'for_each_rtd_dais' 360 | - 'for_each_script' 361 | - 'for_each_sec' 362 | - 'for_each_set_bit' 363 | - 'for_each_set_bit_from' 364 | - 'for_each_set_bitrange' 365 | - 'for_each_set_bitrange_from' 366 | - 'for_each_set_clump8' 367 | - 'for_each_sg' 368 | - 'for_each_sg_dma_page' 369 | - 'for_each_sg_page' 370 | - 'for_each_sgtable_dma_page' 371 | - 'for_each_sgtable_dma_sg' 372 | - 'for_each_sgtable_page' 373 | - 'for_each_sgtable_sg' 374 | - 'for_each_shell_test' 375 | - 'for_each_sibling_event' 376 | - 'for_each_subelement' 377 | - 'for_each_subelement_extid' 378 | - 'for_each_subelement_id' 379 | - 'for_each_sublist' 380 | - 'for_each_subsystem' 381 | - 'for_each_supported_activate_fn' 382 | - 'for_each_supported_inject_fn' 383 | - 'for_each_test' 384 | - 'for_each_thread' 385 | - 'for_each_token' 386 | - 'for_each_unicast_dest_pgid' 387 | - 'for_each_vsi' 388 | - 'for_each_wakeup_source' 389 | - 'for_each_zone' 390 | - 'for_each_zone_zonelist' 391 | - 'for_each_zone_zonelist_nodemask' 392 | - 'func_for_each_insn' 393 | - 'fwnode_for_each_available_child_node' 394 | - 'fwnode_for_each_child_node' 395 | - 'fwnode_graph_for_each_endpoint' 396 | - 'gadget_for_each_ep' 397 | - 'genradix_for_each' 398 | - 'genradix_for_each_from' 399 | - 'hash_for_each' 400 | - 'hash_for_each_possible' 401 | - 'hash_for_each_possible_rcu' 402 | - 'hash_for_each_possible_rcu_notrace' 403 | - 'hash_for_each_possible_safe' 404 | - 'hash_for_each_rcu' 405 | - 'hash_for_each_safe' 406 | - 'hashmap__for_each_entry' 407 | - 'hashmap__for_each_entry_safe' 408 | - 'hashmap__for_each_key_entry' 409 | - 'hashmap__for_each_key_entry_safe' 410 | - 'hctx_for_each_ctx' 411 | - 'hists__for_each_format' 412 | - 'hists__for_each_sort_list' 413 | - 'hlist_bl_for_each_entry' 414 | - 'hlist_bl_for_each_entry_rcu' 415 | - 'hlist_bl_for_each_entry_safe' 416 | - 'hlist_for_each' 417 | - 'hlist_for_each_entry' 418 | - 'hlist_for_each_entry_continue' 419 | - 'hlist_for_each_entry_continue_rcu' 420 | - 'hlist_for_each_entry_continue_rcu_bh' 421 | - 'hlist_for_each_entry_from' 422 | - 'hlist_for_each_entry_from_rcu' 423 | - 'hlist_for_each_entry_rcu' 424 | - 'hlist_for_each_entry_rcu_bh' 425 | - 'hlist_for_each_entry_rcu_notrace' 426 | - 'hlist_for_each_entry_safe' 427 | - 'hlist_for_each_entry_srcu' 428 | - 'hlist_for_each_safe' 429 | - 'hlist_nulls_for_each_entry' 430 | - 'hlist_nulls_for_each_entry_from' 431 | - 'hlist_nulls_for_each_entry_rcu' 432 | - 'hlist_nulls_for_each_entry_safe' 433 | - 'i3c_bus_for_each_i2cdev' 434 | - 'i3c_bus_for_each_i3cdev' 435 | - 'idr_for_each_entry' 436 | - 'idr_for_each_entry_continue' 437 | - 'idr_for_each_entry_continue_ul' 438 | - 'idr_for_each_entry_ul' 439 | - 'in_dev_for_each_ifa_rcu' 440 | - 'in_dev_for_each_ifa_rtnl' 441 | - 'inet_bind_bucket_for_each' 442 | - 'inet_lhash2_for_each_icsk' 443 | - 'inet_lhash2_for_each_icsk_continue' 444 | - 'inet_lhash2_for_each_icsk_rcu' 445 | - 'interval_tree_for_each_double_span' 446 | - 'interval_tree_for_each_span' 447 | - 'intlist__for_each_entry' 448 | - 'intlist__for_each_entry_safe' 449 | - 'iopt_for_each_contig_area' 450 | - 'kcore_copy__for_each_phdr' 451 | - 'key_for_each' 452 | - 'key_for_each_safe' 453 | - 'klp_for_each_func' 454 | - 'klp_for_each_func_safe' 455 | - 'klp_for_each_func_static' 456 | - 'klp_for_each_object' 457 | - 'klp_for_each_object_safe' 458 | - 'klp_for_each_object_static' 459 | - 'kunit_suite_for_each_test_case' 460 | - 'kvm_for_each_memslot' 461 | - 'kvm_for_each_memslot_in_gfn_range' 462 | - 'kvm_for_each_vcpu' 463 | - 'libbpf_nla_for_each_attr' 464 | - 'list_for_each' 465 | - 'list_for_each_codec' 466 | - 'list_for_each_codec_safe' 467 | - 'list_for_each_continue' 468 | - 'list_for_each_entry' 469 | - 'list_for_each_entry_continue' 470 | - 'list_for_each_entry_continue_rcu' 471 | - 'list_for_each_entry_continue_reverse' 472 | - 'list_for_each_entry_from' 473 | - 'list_for_each_entry_from_rcu' 474 | - 'list_for_each_entry_from_reverse' 475 | - 'list_for_each_entry_lockless' 476 | - 'list_for_each_entry_rcu' 477 | - 'list_for_each_entry_reverse' 478 | - 'list_for_each_entry_safe' 479 | - 'list_for_each_entry_safe_continue' 480 | - 'list_for_each_entry_safe_from' 481 | - 'list_for_each_entry_safe_reverse' 482 | - 'list_for_each_entry_srcu' 483 | - 'list_for_each_from' 484 | - 'list_for_each_prev' 485 | - 'list_for_each_prev_safe' 486 | - 'list_for_each_safe' 487 | - 'llist_for_each' 488 | - 'llist_for_each_entry' 489 | - 'llist_for_each_entry_safe' 490 | - 'llist_for_each_safe' 491 | - 'map__for_each_symbol' 492 | - 'map__for_each_symbol_by_name' 493 | - 'map_for_each_event' 494 | - 'map_for_each_metric' 495 | - 'maps__for_each_entry' 496 | - 'maps__for_each_entry_safe' 497 | - 'mci_for_each_dimm' 498 | - 'media_device_for_each_entity' 499 | - 'media_device_for_each_intf' 500 | - 'media_device_for_each_link' 501 | - 'media_device_for_each_pad' 502 | - 'msi_for_each_desc' 503 | - 'nanddev_io_for_each_page' 504 | - 'netdev_for_each_lower_dev' 505 | - 'netdev_for_each_lower_private' 506 | - 'netdev_for_each_lower_private_rcu' 507 | - 'netdev_for_each_mc_addr' 508 | - 'netdev_for_each_uc_addr' 509 | - 'netdev_for_each_upper_dev_rcu' 510 | - 'netdev_hw_addr_list_for_each' 511 | - 'nft_rule_for_each_expr' 512 | - 'nla_for_each_attr' 513 | - 'nla_for_each_nested' 514 | - 'nlmsg_for_each_attr' 515 | - 'nlmsg_for_each_msg' 516 | - 'nr_neigh_for_each' 517 | - 'nr_neigh_for_each_safe' 518 | - 'nr_node_for_each' 519 | - 'nr_node_for_each_safe' 520 | - 'of_for_each_phandle' 521 | - 'of_property_for_each_string' 522 | - 'of_property_for_each_u32' 523 | - 'pci_bus_for_each_resource' 524 | - 'pci_dev_for_each_resource' 525 | - 'pcl_for_each_chunk' 526 | - 'pcl_for_each_segment' 527 | - 'pcm_for_each_format' 528 | - 'perf_config_items__for_each_entry' 529 | - 'perf_config_sections__for_each_entry' 530 | - 'perf_config_set__for_each_entry' 531 | - 'perf_cpu_map__for_each_cpu' 532 | - 'perf_evlist__for_each_entry' 533 | - 'perf_evlist__for_each_entry_reverse' 534 | - 'perf_evlist__for_each_entry_safe' 535 | - 'perf_evlist__for_each_evsel' 536 | - 'perf_evlist__for_each_mmap' 537 | - 'perf_hpp_list__for_each_format' 538 | - 'perf_hpp_list__for_each_format_safe' 539 | - 'perf_hpp_list__for_each_sort_list' 540 | - 'perf_hpp_list__for_each_sort_list_safe' 541 | - 'perf_pmu__for_each_hybrid_pmu' 542 | - 'ping_portaddr_for_each_entry' 543 | - 'ping_portaddr_for_each_entry_rcu' 544 | - 'plist_for_each' 545 | - 'plist_for_each_continue' 546 | - 'plist_for_each_entry' 547 | - 'plist_for_each_entry_continue' 548 | - 'plist_for_each_entry_safe' 549 | - 'plist_for_each_safe' 550 | - 'pnp_for_each_card' 551 | - 'pnp_for_each_dev' 552 | - 'protocol_for_each_card' 553 | - 'protocol_for_each_dev' 554 | - 'queue_for_each_hw_ctx' 555 | - 'radix_tree_for_each_slot' 556 | - 'radix_tree_for_each_tagged' 557 | - 'rb_for_each' 558 | - 'rbtree_postorder_for_each_entry_safe' 559 | - 'rdma_for_each_block' 560 | - 'rdma_for_each_port' 561 | - 'rdma_umem_for_each_dma_block' 562 | - 'resort_rb__for_each_entry' 563 | - 'resource_list_for_each_entry' 564 | - 'resource_list_for_each_entry_safe' 565 | - 'rhl_for_each_entry_rcu' 566 | - 'rhl_for_each_rcu' 567 | - 'rht_for_each' 568 | - 'rht_for_each_entry' 569 | - 'rht_for_each_entry_from' 570 | - 'rht_for_each_entry_rcu' 571 | - 'rht_for_each_entry_rcu_from' 572 | - 'rht_for_each_entry_safe' 573 | - 'rht_for_each_from' 574 | - 'rht_for_each_rcu' 575 | - 'rht_for_each_rcu_from' 576 | - 'rq_for_each_bvec' 577 | - 'rq_for_each_segment' 578 | - 'rq_list_for_each' 579 | - 'rq_list_for_each_safe' 580 | - 'scsi_for_each_prot_sg' 581 | - 'scsi_for_each_sg' 582 | - 'sctp_for_each_hentry' 583 | - 'sctp_skb_for_each' 584 | - 'sec_for_each_insn' 585 | - 'sec_for_each_insn_continue' 586 | - 'sec_for_each_insn_from' 587 | - 'shdma_for_each_chan' 588 | - 'shost_for_each_device' 589 | - 'sk_for_each' 590 | - 'sk_for_each_bound' 591 | - 'sk_for_each_entry_offset_rcu' 592 | - 'sk_for_each_from' 593 | - 'sk_for_each_rcu' 594 | - 'sk_for_each_safe' 595 | - 'sk_nulls_for_each' 596 | - 'sk_nulls_for_each_from' 597 | - 'sk_nulls_for_each_rcu' 598 | - 'snd_array_for_each' 599 | - 'snd_pcm_group_for_each_entry' 600 | - 'snd_soc_dapm_widget_for_each_path' 601 | - 'snd_soc_dapm_widget_for_each_path_safe' 602 | - 'snd_soc_dapm_widget_for_each_sink_path' 603 | - 'snd_soc_dapm_widget_for_each_source_path' 604 | - 'strlist__for_each_entry' 605 | - 'strlist__for_each_entry_safe' 606 | - 'sym_for_each_insn' 607 | - 'sym_for_each_insn_continue_reverse' 608 | - 'symbols__for_each_entry' 609 | - 'tb_property_for_each' 610 | - 'tcf_act_for_each_action' 611 | - 'tcf_exts_for_each_action' 612 | - 'udp_portaddr_for_each_entry' 613 | - 'udp_portaddr_for_each_entry_rcu' 614 | - 'usb_hub_for_each_child' 615 | - 'v4l2_device_for_each_subdev' 616 | - 'v4l2_m2m_for_each_dst_buf' 617 | - 'v4l2_m2m_for_each_dst_buf_safe' 618 | - 'v4l2_m2m_for_each_src_buf' 619 | - 'v4l2_m2m_for_each_src_buf_safe' 620 | - 'virtio_device_for_each_vq' 621 | - 'while_for_each_ftrace_op' 622 | - 'xa_for_each' 623 | - 'xa_for_each_marked' 624 | - 'xa_for_each_range' 625 | - 'xa_for_each_start' 626 | - 'xas_for_each' 627 | - 'xas_for_each_conflict' 628 | - 'xas_for_each_marked' 629 | - 'xbc_array_for_each_value' 630 | - 'xbc_for_each_key_value' 631 | - 'xbc_node_for_each_array_value' 632 | - 'xbc_node_for_each_child' 633 | - 'xbc_node_for_each_key_value' 634 | - 'xbc_node_for_each_subkey' 635 | - 'zorro_for_each_dev' 636 | 637 | IncludeBlocks: Preserve 638 | IncludeCategories: 639 | - Regex: '.*' 640 | Priority: 1 641 | IncludeIsMainRegex: '(Test)?$' 642 | IndentCaseLabels: false 643 | IndentGotoLabels: false 644 | IndentPPDirectives: None 645 | IndentWidth: 8 646 | IndentWrappedFunctionNames: false 647 | JavaScriptQuotes: Leave 648 | JavaScriptWrapImports: true 649 | KeepEmptyLinesAtTheStartOfBlocks: false 650 | MacroBlockBegin: '' 651 | MacroBlockEnd: '' 652 | MaxEmptyLinesToKeep: 1 653 | NamespaceIndentation: None 654 | ObjCBinPackProtocolList: Auto 655 | ObjCBlockIndentWidth: 8 656 | ObjCSpaceAfterProperty: true 657 | ObjCSpaceBeforeProtocolList: true 658 | 659 | # Taken from git's rules 660 | PenaltyBreakAssignment: 10 661 | PenaltyBreakBeforeFirstCallParameter: 30 662 | PenaltyBreakComment: 10 663 | PenaltyBreakFirstLessLess: 0 664 | PenaltyBreakString: 10 665 | PenaltyExcessCharacter: 100 666 | PenaltyReturnTypeOnItsOwnLine: 60 667 | 668 | PointerAlignment: Right 669 | ReflowComments: false 670 | SortIncludes: false 671 | SortUsingDeclarations: false 672 | SpaceAfterCStyleCast: false 673 | SpaceAfterTemplateKeyword: true 674 | SpaceBeforeAssignmentOperators: true 675 | SpaceBeforeCtorInitializerColon: true 676 | SpaceBeforeInheritanceColon: true 677 | SpaceBeforeParens: ControlStatementsExceptForEachMacros 678 | SpaceBeforeRangeBasedForLoopColon: true 679 | SpaceInEmptyParentheses: false 680 | SpacesBeforeTrailingComments: 1 681 | SpacesInAngles: false 682 | SpacesInContainerLiterals: false 683 | SpacesInCStyleCastParentheses: false 684 | SpacesInParentheses: false 685 | SpacesInSquareBrackets: false 686 | Standard: Cpp03 687 | TabWidth: 8 688 | UseTab: Always 689 | ... 690 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Linux build 2 | 3 | on: 4 | pull_request: 5 | branches: [ "main" ] 6 | 7 | jobs: 8 | build: 9 | 10 | # Latest kernel versions won't work for nRF70 driver (this has 5.15) 11 | runs-on: ubuntu-20.04 12 | 13 | steps: 14 | - name: Update PATH for west 15 | run: | 16 | echo "$HOME/.local/bin" >> $GITHUB_PATH 17 | 18 | - name: Checkout code 19 | uses: actions/checkout@v3 20 | with: 21 | ref: ${{ github.event.pull_request.head.sha }} 22 | fetch-depth: 0 23 | 24 | - name: cache-pip 25 | uses: actions/cache@v3 26 | with: 27 | path: ~/.cache/pip 28 | key: ${{ runner.os }}-doc-pip 29 | 30 | - name: Install dependencies 31 | run: | 32 | sudo apt install device-tree-compiler 33 | 34 | - name: Install python dependencies 35 | run: | 36 | pip3 install setuptools 37 | pip3 install wheel 38 | pip3 install python-magic lxml junitparser gitlint pylint pykwalify yamllint 39 | pip3 install west 40 | 41 | - name: west setup 42 | env: 43 | BASE_REF: ${{ github.base_ref }} 44 | run: | 45 | git config --global user.email "you@example.com" 46 | git config --global user.name "Your Name" 47 | git remote -v 48 | west init -l . || true 49 | west update 2>&1 1> west.update.log || west update 2>&1 1> west.update2.log 50 | 51 | - name: make 52 | env: 53 | BASE_REF: ${{ github.base_ref }} 54 | run: | 55 | sudo apt install linux-headers-$(uname -r) 56 | make clean all 2>&1 1> make.log 57 | make clean all LOW_POWER=1 2>&1 1> make_lpm.log 58 | make clean all MODE=RADIO-TEST 2>&1 1> make_rt.log 59 | 60 | - name: upload-results 61 | uses: actions/upload-artifact@v3 62 | # Always collect artifacts, even if the build failed 63 | if: always() 64 | continue-on-error: true 65 | with: 66 | name: build-results 67 | path: | 68 | make.log 69 | make_lpm.log 70 | make_rt.log 71 | west.update.log 72 | west.update2.log 73 | -------------------------------------------------------------------------------- /.github/workflows/checkpatch.yml: -------------------------------------------------------------------------------- 1 | name: checkpatch review 2 | on: 3 | pull_request: 4 | branches: [ "main" ] 5 | jobs: 6 | checkpatch: 7 | name: checkpatch review 8 | runs-on: ubuntu-22.04 9 | steps: 10 | - name: 'Calculate PR commits + 1' 11 | run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> $GITHUB_ENV 12 | - uses: actions/checkout@v3 13 | with: 14 | ref: ${{ github.event.pull_request.head.sha }} 15 | fetch-depth: ${{ env.PR_FETCH_DEPTH }} 16 | - name: Info 17 | run: | 18 | echo "Repository: $GITHUB_REPOSITORY" 19 | echo "Workspace: $GITHUB_WORKSPACE" 20 | pwd 21 | ls -la `pwd` 22 | git log --oneline --graph 23 | - name: Run checkpatch review 24 | uses: webispy/checkpatch-action@master 25 | env: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | -------------------------------------------------------------------------------- /.github/workflows/clang-format.yml: -------------------------------------------------------------------------------- 1 | name: Source Code Formatting Check 2 | on: 3 | pull_request: 4 | branches: [ "main" ] 5 | jobs: 6 | formatting-check: 7 | name: Formatting Check 8 | runs-on: ubuntu-22.04 9 | steps: 10 | - uses: actions/checkout@v3 11 | - name: Run clang-format style check for C/C++/Protobuf programs. 12 | uses: jidicula/clang-format-action@v4.11.0 13 | with: 14 | clang-format-version: '16' 15 | -------------------------------------------------------------------------------- /.github/workflows/gitlint.yml: -------------------------------------------------------------------------------- 1 | name: gitlint 2 | on: 3 | pull_request: 4 | branches: [ "main" ] 5 | jobs: 6 | gitlint: 7 | name: git lint 8 | runs-on: ubuntu-22.04 9 | steps: 10 | - uses: actions/checkout@v3 11 | with: 12 | ref: ${{ github.event.pull_request.head.sha }} 13 | path: nrf70-linux-driver 14 | fetch-depth: 0 15 | - name: cache-pip 16 | uses: actions/cache@v3 17 | with: 18 | path: ~/.cache/pip 19 | key: ${{ runner.os }}-doc-pip 20 | - name: Info 21 | working-directory: nrf70-linux-driver 22 | run: | 23 | echo "Repository: $GITHUB_REPOSITORY" 24 | echo "Workspace: $GITHUB_WORKSPACE" 25 | pwd 26 | ls -la `pwd` 27 | git log --oneline --graph 28 | - name: Install python dependencies 29 | working-directory: nrf70-linux-driver 30 | run: | 31 | pip3 install -U pip 32 | pip3 install -U setuptools 33 | pip3 install -U wheel 34 | grep -E "python-magic|junitparser|lxml|gitlint|pylint|pykwalify|yamllint" scripts/requirements-fixed.txt | xargs pip3 install -U 35 | - name: Clone Zephyr downstream 36 | env: 37 | BASE_REF: ${{ github.base_ref }} 38 | working-directory: nrf70-linux-driver 39 | run: | 40 | git config --global user.email "you@example.com" 41 | git config --global user.name "Your Name" 42 | git remote -v 43 | git log -1 origin/main 44 | # Ensure there's no merge commits in the PR 45 | [[ "$(git rev-list --merges --count origin/${BASE_REF}..)" == "0" ]] || \ 46 | (echo "::error ::Merge commits not allowed, rebase instead";false) 47 | 48 | git rebase origin/${BASE_REF} 49 | # debug 50 | git log --pretty=oneline | head -n 10 51 | # Clone downstream Zephyr (no west needed as we only need the scripts) 52 | git clone https://github.com/nrfconnect/sdk-zephyr 53 | 54 | - name: Install and run gitlint 55 | working-directory: nrf70-linux-driver 56 | run: | 57 | pip install gitlint 58 | gitlint --commits ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} 59 | 60 | - name: Run CODEOWNERS test 61 | id: codeowners 62 | working-directory: nrf70-linux-driver 63 | env: 64 | BASE_REF: ${{ github.base_ref }} 65 | if: contains(github.event.pull_request.user.login, 'dependabot[bot]') != true 66 | run: | 67 | ./scripts/ci/codeowners.py -c origin/${BASE_REF}.. 68 | -------------------------------------------------------------------------------- /.github/workflows/manifest.yml: -------------------------------------------------------------------------------- 1 | name: Manifest 2 | 3 | on: 4 | pull_request_target: 5 | 6 | permissions: 7 | contents: read 8 | pull-requests: write 9 | 10 | jobs: 11 | contribs: 12 | runs-on: ubuntu-latest 13 | name: Manifest 14 | steps: 15 | - name: Checkout the code 16 | uses: actions/checkout@v4 17 | with: 18 | path: nrf_linux 19 | ref: ${{ github.event.pull_request.head.sha }} 20 | fetch-depth: 0 21 | persist-credentials: false 22 | 23 | - name: Manifest 24 | uses: zephyrproject-rtos/action-manifest@16c4cfa380ae2b6fa3daddb1a35032e69422a20f 25 | with: 26 | github-token: ${{ secrets.TKC_GITHUB_TOKEN }} 27 | manifest-path: 'west.yml' 28 | checkout-path: 'nrf_linux' 29 | label-prefix: 'manifest-' 30 | verbosity-level: '1' 31 | 32 | # Add one label per line. 'manifest' always adds the label 'manifest'. 33 | # 'CI-all-test:zephyr;nrfxlib,' adds the 'CI-all-test' label when the 34 | # zephyr module or the nrfxlib module is changed. Each line is comma- 35 | # separated. 36 | labels: > 37 | manifest 38 | manifest-nrfxlib:nrfxlib 39 | dnm-labels: 'DNM' 40 | 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0-only 2 | # 3 | # NOTE! Don't add files that are generated in specific 4 | # subdirectories here. Add them in the ".gitignore" file 5 | # in that subdirectory instead. 6 | # 7 | # NOTE! Please use 'git ls-files -i -c --exclude-per-directory=.gitignore' 8 | # command after changing this file, to see if there are 9 | # any tracked files which get ignored after the change. 10 | # 11 | # Normal rules (sorted alphabetically) 12 | # 13 | .* 14 | *.a 15 | *.asn1.[ch] 16 | *.bin 17 | *.bz2 18 | *.c.[012]*.* 19 | *.dt.yaml 20 | *.dtb 21 | *.dtbo 22 | *.dtb.S 23 | *.dtbo.S 24 | *.dwo 25 | *.elf 26 | *.gcno 27 | *.gz 28 | *.i 29 | *.ko 30 | *.lex.c 31 | *.ll 32 | *.lst 33 | *.lz4 34 | *.lzma 35 | *.lzo 36 | *.mod 37 | *.mod.c 38 | *.o 39 | *.o.* 40 | *.patch 41 | *.rmeta 42 | *.rpm 43 | *.rsi 44 | *.s 45 | *.so 46 | *.so.dbg 47 | *.su 48 | *.symtypes 49 | *.symversions 50 | *.tab.[ch] 51 | *.tar 52 | *.xz 53 | *.zst 54 | Module.symvers 55 | modules.order 56 | 57 | # 58 | # Top-level generic files 59 | # 60 | /modules-only.symvers 61 | /vmlinux 62 | /vmlinux.32 63 | /vmlinux.map 64 | /vmlinux.symvers 65 | /vmlinux-gdb.py 66 | /vmlinuz 67 | /System.map 68 | /Module.markers 69 | /modules.builtin 70 | /modules.builtin.modinfo 71 | /modules.nsdeps 72 | 73 | # 74 | # RPM spec file (make rpm-pkg) 75 | # 76 | /*.spec 77 | /rpmbuild/ 78 | 79 | # 80 | # Debian directory (make deb-pkg) 81 | # 82 | /debian/ 83 | 84 | # 85 | # Snap directory (make snap-pkg) 86 | # 87 | /snap/ 88 | 89 | # 90 | # tar directory (make tar*-pkg) 91 | # 92 | /tar-install/ 93 | 94 | # 95 | # We don't want to ignore the following even if they are dot-files 96 | # 97 | !.clang-format 98 | !.cocciconfig 99 | !.get_maintainer.ignore 100 | !.gitattributes 101 | !.gitignore 102 | !.github 103 | !.kunitconfig 104 | !.mailmap 105 | !.rustfmt.toml 106 | 107 | # 108 | # Generated include files 109 | # 110 | /include/config/ 111 | /include/generated/ 112 | /arch/*/include/generated/ 113 | 114 | # stgit generated dirs 115 | patches-* 116 | 117 | # quilt's files 118 | patches 119 | series 120 | 121 | # ctags files 122 | tags 123 | TAGS 124 | 125 | # cscope files 126 | cscope.* 127 | ncscope.* 128 | 129 | # gnu global files 130 | GPATH 131 | GRTAGS 132 | GSYMS 133 | GTAGS 134 | 135 | # id-utils files 136 | ID 137 | 138 | *.orig 139 | *~ 140 | \#*# 141 | 142 | # 143 | # Leavings from module signing 144 | # 145 | extra_certificates 146 | signing_key.pem 147 | signing_key.priv 148 | signing_key.x509 149 | x509.genkey 150 | 151 | # Kconfig presets 152 | /all.config 153 | /alldef.config 154 | /allmod.config 155 | /allno.config 156 | /allrandom.config 157 | /allyes.config 158 | 159 | # Kconfig savedefconfig output 160 | /defconfig 161 | 162 | # Kdevelop4 163 | *.kdev4 164 | 165 | # Clang's compilation database file 166 | /compile_commands.json 167 | 168 | # Documentation toolchain 169 | sphinx_*/ 170 | 171 | # Rust analyzer configuration 172 | /rust-project.json 173 | -------------------------------------------------------------------------------- /.gitlint: -------------------------------------------------------------------------------- 1 | # All these sections are optional, edit this file as you like. 2 | [general] 3 | ignore=title-trailing-punctuation, T3, title-max-length, T1, body-hard-tab, B3, B1 4 | # verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this 5 | verbosity = 3 6 | # By default gitlint will ignore merge commits. Set to 'false' to disable. 7 | ignore-merge-commits=false 8 | ignore-revert-commits=false 9 | ignore-fixup-commits=false 10 | ignore-squash-commits=false 11 | # Enable debug mode (prints more output). Disabled by default 12 | debug = false 13 | 14 | # Set the extra-path where gitlint will search for user defined rules 15 | # See http://jorisroovers.github.io/gitlint/user_defined_rules for details 16 | extra-path=sdk-zephyr/scripts/gitlint 17 | 18 | [title-max-length-no-revert] 19 | line-length=75 20 | 21 | [body-min-line-count] 22 | min-line-count=1 23 | 24 | [body-max-line-count] 25 | max-line-count=200 26 | 27 | [title-starts-with-subsystem] 28 | regex = ^(?!subsys:)(([^:]+):)(\s([^:]+):)*\s(.+)$ 29 | 30 | [title-must-not-contain-word] 31 | # Comma-separated list of words that should not occur in the title. Matching is case 32 | # insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING" 33 | # will not cause a violation, but "WIP: my title" will. 34 | words=wip 35 | 36 | [title-match-regex] 37 | # python like regex (https://docs.python.org/2/library/re.html) that the 38 | # commit-msg title must be matched to. 39 | # Note that the regex can contradict with other rules if not used correctly 40 | # (e.g. title-must-not-contain-word). 41 | #regex=^US[0-9]* 42 | 43 | [max-line-length-with-exceptions] 44 | # B1 = body-max-line-length 45 | line-length=72 46 | 47 | [body-min-length] 48 | min-length=3 49 | 50 | [body-is-missing] 51 | # Whether to ignore this rule on merge commits (which typically only have a title) 52 | # default = True 53 | ignore-merge-commits=false 54 | 55 | [body-changed-file-mention] 56 | # List of files that need to be explicitly mentioned in the body when they are changed 57 | # This is useful for when developers often erroneously edit certain files or git submodules. 58 | # By specifying this rule, developers can only change the file when they explicitly reference 59 | # it in the commit message. 60 | #files=gitlint/rules.py,README.md 61 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # CODEOWNERS for autoreview assigning in github 2 | 3 | * @sachinthegreen @ajayparida @krish2718 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Variables with default values 2 | KROOT ?= /lib/modules/`uname -r`/build 3 | MODE?= STA 4 | LOW_POWER?= 0 5 | MACHINE := $(shell uname -m) 6 | RPI_DTS = dts/nrf70_rpi_interposer.dts 7 | 8 | # Private portion 9 | # Check if the machine is a Raspberry Pi, doesn't cover cross-compilation and other cases 10 | IS_RPI := $(shell [ "$(MACHINE)" = "armv7l" ] && \ 11 | grep -q "Raspberry Pi" /proc/device-tree/model && \ 12 | echo 1 || echo 0) 13 | 14 | DRV_FUNC_NAME = _wifi_fmac 15 | 16 | # If mode != STA throw error 17 | ifeq (, $(filter STA RADIO-TEST, $(MODE))) 18 | $(error Invalid MODE=$(MODE) specified. Valid values are STA, RADIO-TEST) 19 | endif 20 | 21 | ifeq ($(MODE), STA) 22 | DRV_MODE_NAME = _sta 23 | else ifeq ($(MODE), RADIO-TEST) 24 | ccflags-y += -DCONFIG_NRF700X_RADIO_TEST 25 | DRV_MODE_NAME = _radio_test 26 | else ifeq ($(MODE), AP) 27 | DRV_MODE_NAME = _ap 28 | endif 29 | 30 | ifeq ($(LOW_POWER), 1) 31 | ccflags-y += -DCONFIG_NRF_WIFI_LOW_POWER 32 | endif 33 | 34 | OSAL_DIR = ../nrfxlib/nrf_wifi 35 | ROOT_INC_DIR = $(shell cd $(PWD); cd $(OSAL_DIR); pwd) 36 | LINUX_SHIM_INC_DIR = $(shell cd $(PWD); pwd) 37 | LINUX_SHIM_DIR = . 38 | 39 | # Common Includes 40 | ccflags-y += -I$(LINUX_SHIM_INC_DIR)/inc 41 | ccflags-y += -I$(LINUX_SHIM_INC_DIR)/src/spi/inc 42 | ccflags-y += -I$(ROOT_INC_DIR)/utils/inc 43 | ccflags-y += -I$(ROOT_INC_DIR)/os_if/inc 44 | ccflags-y += -I$(ROOT_INC_DIR)/bus_if/bal/inc 45 | ccflags-y += -I$(ROOT_INC_DIR)/hw_if/hal/inc 46 | ccflags-y += -I$(ROOT_INC_DIR)/hw_if/hal/inc/fw 47 | ccflags-y += -I$(ROOT_INC_DIR)/fw_if/umac_if/inc 48 | ifeq ($(MODE), RADIO-TEST) 49 | ccflags-y += -I$(ROOT_INC_DIR)/fw_if/umac_if/inc/radio_test 50 | else 51 | ccflags-y += -I$(ROOT_INC_DIR)/fw_if/umac_if/inc/default 52 | endif 53 | ccflags-y += -I$(ROOT_INC_DIR)/fw_if/umac_if/inc/fw 54 | ccflags-y += -I$(ROOT_INC_DIR)/bus_if/bus/spi/inc 55 | 56 | # Common Objects 57 | OBJS += $(OSAL_DIR)/utils/src/list.o 58 | OBJS += $(OSAL_DIR)/utils/src/queue.o 59 | OBJS += $(OSAL_DIR)/utils/src/util.o 60 | OBJS += $(OSAL_DIR)/os_if/src/osal.o 61 | OBJS += $(OSAL_DIR)/bus_if/bal/src/bal.o 62 | OBJS += $(OSAL_DIR)/hw_if/hal/src/hal_mem.o 63 | OBJS += $(OSAL_DIR)/hw_if/hal/src/hal_reg.o 64 | OBJS += $(OSAL_DIR)/hw_if/hal/src/hal_api.o 65 | OBJS += $(OSAL_DIR)/hw_if/hal/src/hal_interrupt.o 66 | OBJS += $(OSAL_DIR)/hw_if/hal/src/pal.o 67 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/cmd.o 68 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/event.o 69 | ifeq ($(MODE), RADIO-TEST) 70 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/radio_test/fmac_api.o 71 | else 72 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/default/fmac_api.o 73 | endif 74 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/fmac_api_common.o 75 | 76 | OBJS += $(OSAL_DIR)/hw_if/hal/src/hal_fw_patch_loader.o 77 | OBJS += $(OSAL_DIR)/bus_if/bus/spi/src/spi.o 78 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/fmac_util.o 79 | 80 | ifneq ($(MODE), RADIO-TEST) 81 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/rx.o 82 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/tx.o 83 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/fmac_vif.o 84 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/fmac_peer.o 85 | endif 86 | ifeq ($(MODE), AP) 87 | OBJS += $(OSAL_DIR)/fw_if/umac_if/src/fmac_ap.o 88 | endif 89 | 90 | OBJS += $(LINUX_SHIM_DIR)/src/netdev.o 91 | OBJS += $(LINUX_SHIM_DIR)/src/linux_util.o 92 | OBJS += $(LINUX_SHIM_DIR)/src/main.o 93 | OBJS += $(LINUX_SHIM_DIR)/src/shim.o 94 | ifeq ($(MODE), RADIO-TEST) 95 | OBJS += $(LINUX_SHIM_DIR)/src/debugfs/radio_test.o 96 | else 97 | OBJS += $(LINUX_SHIM_DIR)/src/debugfs/main.o 98 | endif 99 | OBJS += $(LINUX_SHIM_DIR)/src/cfg80211_if.o 100 | OBJS += $(LINUX_SHIM_DIR)/src/wiphy.o 101 | OBJS += $(LINUX_SHIM_DIR)/src/debugfs/stats.o 102 | OBJS += $(LINUX_SHIM_DIR)/src/debugfs/wlan_fmac_ver.o 103 | ifneq ($(MODE), RADIO-TEST) 104 | OBJS += $(LINUX_SHIM_DIR)/src/debugfs/wlan_fmac_twt.o 105 | endif 106 | 107 | OBJS += $(LINUX_SHIM_DIR)/src/spi/src/rpu_hw_if.o 108 | OBJS += $(LINUX_SHIM_DIR)/src/spi/src/device.o 109 | OBJS += $(LINUX_SHIM_DIR)/src/spi/src/spi_if.o 110 | 111 | 112 | # RAW scan feature is mandatory to work with cfg80211 113 | ccflags-y += \ 114 | -DCONFIG_NRF700X_MAX_TX_TOKENS=10\ 115 | -DCONFIG_NRF700X_MAX_TX_AGGREGATION=12 \ 116 | -DCONFIG_NRF700X_RX_NUM_BUFS=63 \ 117 | -DCONFIG_NRF700X_RX_MAX_DATA_SIZE=1600 \ 118 | -DCONFIG_WIFI_MGMT_RAW_SCAN_RESULTS \ 119 | -DCONFIG_NRF700X_ANT_GAIN_2G=0 \ 120 | -DCONFIG_NRF700X_ANT_GAIN_5G_BAND1=0 \ 121 | -DCONFIG_NRF700X_ANT_GAIN_5G_BAND2=0 \ 122 | -DCONFIG_NRF700X_ANT_GAIN_5G_BAND3=0 \ 123 | -DCONFIG_NRF700X_BAND_2G_LOWER_EDGE_BACKOFF_DSSS=0 \ 124 | -DCONFIG_NRF700X_BAND_2G_LOWER_EDGE_BACKOFF_HT=0 \ 125 | -DCONFIG_NRF700X_BAND_2G_LOWER_EDGE_BACKOFF_HE=0 \ 126 | -DCONFIG_NRF700X_BAND_2G_UPPER_EDGE_BACKOFF_DSSS=0 \ 127 | -DCONFIG_NRF700X_BAND_2G_UPPER_EDGE_BACKOFF_HT=0 \ 128 | -DCONFIG_NRF700X_BAND_2G_UPPER_EDGE_BACKOFF_HE=0 \ 129 | -DCONFIG_NRF700X_BAND_UNII_1_LOWER_EDGE_BACKOFF_HT=0 \ 130 | -DCONFIG_NRF700X_BAND_UNII_1_LOWER_EDGE_BACKOFF_HE=0 \ 131 | -DCONFIG_NRF700X_BAND_UNII_1_UPPER_EDGE_BACKOFF_HT=0 \ 132 | -DCONFIG_NRF700X_BAND_UNII_1_UPPER_EDGE_BACKOFF_HE=0 \ 133 | -DCONFIG_NRF700X_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HT=0 \ 134 | -DCONFIG_NRF700X_BAND_UNII_2A_LOWER_EDGE_BACKOFF_HE=0 \ 135 | -DCONFIG_NRF700X_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HT=0 \ 136 | -DCONFIG_NRF700X_BAND_UNII_2A_UPPER_EDGE_BACKOFF_HE=0 \ 137 | -DCONFIG_NRF700X_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HT=0 \ 138 | -DCONFIG_NRF700X_BAND_UNII_2C_LOWER_EDGE_BACKOFF_HE=0 \ 139 | -DCONFIG_NRF700X_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HT=0 \ 140 | -DCONFIG_NRF700X_BAND_UNII_2C_UPPER_EDGE_BACKOFF_HE=0 \ 141 | -DCONFIG_NRF700X_BAND_UNII_3_LOWER_EDGE_BACKOFF_HT=0 \ 142 | -DCONFIG_NRF700X_BAND_UNII_3_LOWER_EDGE_BACKOFF_HE=0 \ 143 | -DCONFIG_NRF700X_BAND_UNII_3_UPPER_EDGE_BACKOFF_HT=0 \ 144 | -DCONFIG_NRF700X_BAND_UNII_3_UPPER_EDGE_BACKOFF_HE=0 \ 145 | -DCONFIG_NRF700X_BAND_UNII_4_LOWER_EDGE_BACKOFF_HT=0 \ 146 | -DCONFIG_NRF700X_BAND_UNII_4_LOWER_EDGE_BACKOFF_HE=0 \ 147 | -DCONFIG_NRF700X_BAND_UNII_4_UPPER_EDGE_BACKOFF_HT=0 \ 148 | -DCONFIG_NRF700X_BAND_UNII_4_UPPER_EDGE_BACKOFF_HE=0 \ 149 | -DCONFIG_NRF700X_REG_DOMAIN=\"00\" \ 150 | -DCONFIG_NRF700X_TX_MAX_DATA_SIZE=1600 \ 151 | -DCONFIG_NRF_WIFI_IFACE_MTU=1500 \ 152 | -DCONFIG_NRF700X_MAX_TX_PENDING_QLEN=48 \ 153 | -DCONFIG_NRF700X_RPU_PS_IDLE_TIMEOUT_MS=10 154 | 155 | ifneq ($(MODE), RADIO-TEST) 156 | ccflags-y += -DCONFIG_NRF700X_DATA_TX 157 | ccflags-y += -DCONFIG_NRF700X_STA_MODE 158 | ccflags-y += -DCONFIG_NRF700X_TCP_IP_CHECKSUM_OFFLOAD 159 | endif 160 | 161 | OBJS += $(OSAL_DIR)/hw_if/hal/src/hpqm.o 162 | 163 | # Driver debugging 164 | # Use one of DBG(4)/INF(3)/ERR(1) 165 | ccflags-y += -DCONFIG_WIFI_NRF700X_LOG_LEVEL=3 166 | 167 | # Scan only mode, disabled by default 168 | # ccflags-y += -DCONFIG_NRF700X_SCAN_ONLY 169 | 170 | ccflags-y += -DCONFIG_NRF_WIFI_BEAMFORMING=1 171 | 172 | # shipped tells the build system to not try to build this file 173 | ifeq ($(MODE), RADIO-TEST) 174 | FW_PATCH_BIN=${ROOT_INC_DIR}/fw_bins/radio_test/nrf70.bin 175 | OBJS += ${OSAL_DIR}/fw_bins/radio_test/fw_patch_bin.o 176 | else 177 | FW_PATCH_BIN=${ROOT_INC_DIR}/fw_bins/default/nrf70.bin 178 | OBJS += ${OSAL_DIR}/fw_bins/default/fw_patch_bin.o 179 | ccflags-y += -DCONFIG_NRF700X_SYSTEM_MODE 180 | endif 181 | 182 | ccflags-y += -Werror 183 | 184 | NAME = nrf$(DRV_FUNC_NAME)$(DRV_MODE_NAME) 185 | 186 | obj-m += $(NAME).o 187 | 188 | $(NAME)-objs= $(OBJS) 189 | 190 | # Cross-compiler variables 191 | CROSS_COMPILE ?= 192 | ARCH ?= $(shell uname -m) 193 | 194 | all: $(if $(filter-out 0,$(IS_RPI)),dt) gen_patch_bin 195 | @make -C $(KROOT) M=$(PWD) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) modules 196 | 197 | dt: 198 | dtc -@ -I dts -O dtb -o $(basename $(RPI_DTS)).dtbo $(RPI_DTS) 199 | 200 | gen_patch_bin: 201 | cd $(shell dirname ${FW_PATCH_BIN}); \ 202 | ld -r -b binary -o fw_patch_bin.o_shipped nrf70.bin; \ 203 | touch .fw_patch_bin.o.cmd 204 | 205 | clean: 206 | @make -C $(KROOT) M=$(PWD) clean 207 | @find $(OSAL_DIR) -name "*.o*" | xargs rm -f 208 | rm -f fw_patch_bin.o 209 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nRF70 series Linux SPI reference driver 2 | Linux driver for the nRF70 series Wi-Fi SoC family from Nordic Semiconductor. The driver is based on the [nRF Connect SDK](https://www.nordicsemi.com/Software-and-tools/Software/nRF-Connect-SDK) and is compatible with the [Linux SPI framework](https://www.kernel.org/doc/html/latest/driver-api/spi.html). 3 | 4 | This driver is a reference implementation and is not intended for production use. It is provided as-is and is not supported by Nordic Semiconductor ASA. It can be used in any Linux environment to evaluate the nRF70 series Wi-Fi SoC family. 5 | 6 | ## Supported hardware 7 | The driver supports the following nRF70 series Wi-Fi SoCs: 8 | - [nRF7002](https://www.nordicsemi.com/Products/nRF7002) 9 | - [nRF7001](https://www.nordicsemi.com/Products/nRF7001) 10 | 11 | ## Supported features 12 | The driver supports the following features: 13 | - Wi-Fi STA mode 14 | - Wi-Fi 6 (802.11ax) 1x1 operation 15 | - Dual-band (2.4 GHz and 5 GHz) operation (Depending on the nRF70 series Wi-Fi SoC variant) 16 | - WPA2-PSK security 17 | - WPA3-SAE security 18 | - Wi-Fi RADIO-TEST mode 19 | 20 | # Getting started 21 | The driver can be used with any Linux based products, but it is tested on a Raspberry Pi4B running the Ubuntu 22.04 LTS operating system. Support for other Linux distributions is not part of the scope of this project. 22 | ## Prerequisites 23 | 24 | ### Hardware 25 | The following hardware is required to run the driver: 26 | - Raspberry Pi4B 27 | - nRF7002 or nRF7001 Evaluation Kit (without Host MCU) 28 | - An Interposer board to connect the nRF70 series Wi-Fi SoC to the Raspberry Pi4B header. 29 | >Note: The Interposer board is not included in the nRF7002 or nRF7001 Evaluation Kit and will need to be manufactured separately. The reference board design files for the same can be found [`here`](https://github.com/NordicPlayground/nrf70-linux-driver/tree/main/boards/RPi4B_interposer). 30 | - A microSD card (at least 32GB) with Ubuntu 22.04 LTS installed 31 | 32 | ### Software 33 | The following software is required to run the driver: 34 | - Ubuntu 22.04.03 LTS (64-bit) comes with `5.15.0-1037-raspi` Linux kernel 35 | 36 | ### Install dependencies 37 | The following dependencies are required to build the driver, install them using `apt`: 38 | - [`west`](https://docs.zephyrproject.org/latest/guides/west/install.html) 39 | - [`device-tree-compiler`](https://packages.ubuntu.com/focal/device-tree-compiler) 40 | - [`build-essential`](https://packages.ubuntu.com/focal/build-essential) 41 | - [`wpa_supplicant`](https://packages.ubuntu.com/focal/wpa-supplicant) 42 | - Make sure that the `wpa_supplicant` version is `2.10` or newer 43 | - [`wpa_passphrase`](https://packages.ubuntu.com/focal/wpa-passphrase) 44 | - [`iw`](https://packages.ubuntu.com/focal/iw) 45 | 46 | # Build and run the driver 47 | ## Build the driver 48 | 1. To get the latest version of the driver clone the repository using `west`: 49 | ```bash 50 | west init -m git@github.com:NordicPlayground/nrf70-linux-driver.git --mr main 51 | ``` 52 | 53 | If you have downloaded a released version of the driver in a zipped format, do the following after unzipping the folder: 54 | ```bash 55 | west init -l . 56 | ``` 57 | 58 | 2. Update west projects 59 | ```bash 60 | west update 61 | ``` 62 | 3. Build the driver 63 | ```bash 64 | make clean all 65 | ``` 66 | 67 | ### Driver feature configuration 68 | 69 | nRF70 driver has feature flags to enable/disable certain features. These flags can be controlled via the command line arguments to the `make` command. The following flags are available: 70 | 71 | | Flag | Description | Default | 72 | | --- | --- | --- | 73 | | `MODE` | Supported modes are `STA` and `RADIO-TEST` | `STA` | 74 | | `LOW_POWER` | Enable low power mode | `0` | 75 | 76 | #### Examples 77 | 78 | 1. Build the driver in STA mode with low power enabled 79 | ```bash 80 | make clean all MODE=STA LOW_POWER=1 81 | ``` 82 | 83 | Ensure that the `nrf_wifi_fmac_sta.ko` and `dts/nrf70_rpi_interposer.dtbo` files are generated. 84 | ## Run the driver 85 | 1. Load the DTS overlay 86 | 87 | a. Permanent loading: Configure the Raspberry Pi4B to load the DTS overlay at boot time (Recommended for production) 88 | ```bash 89 | sudo cp dts/nrf70_rpi_interposer.dtbo /boot/firmware/overlays/ 90 | # Update config.txt 91 | sudo vim /boot/firmware/config.txt 92 | # Add below line at the end of the file 93 | dtoverlay=nrf70_rpi_interposer 94 | sudo reboot 95 | ``` 96 | b. Runtime loading: Load the DTS overlay at runtime (Helpful for development) 97 | ```bash 98 | sudo dtoverlay dts/nrf70_rpi_interposer.dtbo 99 | ``` 100 | 101 | Note 1: Using this procedure, the DTS overlay must be loaded every time the Raspberry Pi4B is rebooted. 102 | 103 | Note 2: Using this procedure, in the `dmesg` ignore the warnings `OF: overlay: WARNING: memory leak will occur if overlay removed, property: ******`, these are expected as we are dynamically loading the DTS. 104 | 2. Load the driver 105 | ```bash 106 | sudo insmod nrf_wifi_fmac_sta.ko 107 | ``` 108 | 109 | Note 1: Using this procedure, the driver must be loaded every time the Raspberry Pi4B is rebooted. 110 | 111 | Note 2: Using this procedure, in the `dmesg` ignore the warnings `nrf_wifi_fmac_sta: loading out-of-tree module taints kernel`, these are expected as we are loading a out-of-tree module. 112 | 113 | 3. Verify that the driver is loaded 114 | ```bash 115 | lsmod | grep nrf_wifi_fmac_sta 116 | ``` 117 | 4. Verify network interfaces 118 | ```bash 119 | ip link show 120 | ``` 121 | The driver should create a new network interface called `nrf_wifi`. 122 | 5. Verify Wi-Fi interface using `iw` 123 | ```bash 124 | iw dev nrf_wifi info 125 | ``` 126 | 6. Check the kernel log for driver output 127 | ```bash 128 | dmesg 129 | ``` 130 | 131 | ## Connect to a Wi-Fi network 132 | 1. Prepare a WPA supplicant configuration file 133 | ```bash 134 | wpa_passphrase > wpa_supplicant.conf 135 | ``` 136 | 2. Connect to the Wi-Fi network 137 | ```bash 138 | sudo wpa_supplicant -i nrf_wifi -c wpa_supplicant.conf -B 139 | ``` 140 | 3. Verify that the Wi-Fi interface is connected 141 | ```bash 142 | iw dev nrf_wifi link 143 | ``` 144 | 4. Run a DHCP client to get an IP address 145 | ```bash 146 | sudo dhclient nrf_wifi 147 | ``` 148 | 5. Verify that the Wi-Fi interface has an IP address 149 | ```bash 150 | ip addr show nrf_wifi 151 | ``` 152 | 6. Verify that the Wi-Fi interface has internet access 153 | ```bash 154 | ping -I nrf_wifi google.com 155 | ``` 156 | 157 | ## Disconnect from a Wi-Fi network 158 | 1. Kill the WPA supplicant 159 | ```bash 160 | sudo killall wpa_supplicant 161 | ``` 162 | 2. Verify that the Wi-Fi interface is disconnected 163 | ```bash 164 | iw dev nrf_wifi link 165 | ``` 166 | ## Remove the driver 167 | 1. Remove the driver 168 | ```bash 169 | sudo rmmod nrf_wifi_fmac_sta 170 | ``` 171 | # Debugging 172 | ## Run the WPA supplicant in debug mode 173 | 1. Stop the WPA supplicant 174 | ```bash 175 | sudo killall wpa_supplicant 176 | ``` 177 | 2. Run the WPA supplicant in debug mode 178 | ```bash 179 | sudo wpa_supplicant -i nrf_wifi -c wpa_supplicant.conf -dd -f /tmp/wpa_supplicant.log 180 | ``` 181 | 3. Share the `/tmp/wpa_supplicant.log` file along with configuration file `wpa_supplicant.conf` for debugging purposes. 182 | 183 | ## Collect `dmesg` 184 | 1. Collect the kernel log 185 | ```bash 186 | dmesg > dmesg.log 187 | ``` 188 | 2. Collect the kernel log from all previous boots to give a complete picture of the system 189 | ```bash 190 | cat /var/log/kern.log* > kern.log 191 | ``` 192 | 193 | ## Collect Sniffer logs 194 | 195 | The procedure to collect sniffer logs is outside the scope of this document as it depends heavily on the environment and the sniffer used. 196 | 197 | ## Driver feature configuration with RADIO-TEST mode with low power enabled 198 | 199 | RADIO-TEST mode is used to characterize TX/RX functionalities of RPU with different test sets. 200 | 201 | 1. To build the driver with RADIO-TEST mode 202 | ```bash 203 | make clean all MODE=RADIO-TEST LOW_POWER=1 204 | ``` 205 | Ensure that the `rf_wifi_fmac_radio_test.ko` and `dts/nrf70_rpi_interposer.dtbo` files are generated. 206 | 2. Load the driver 207 | ```bash 208 | sudo insmod nrf_wifi_fmac_radio_test.ko 209 | ``` 210 | 3. The commands used for radio test can be found [`here`](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/wifi/radio_test/radio_test_subcommands.html). 211 | 4. To set different test parameters `debugfs` is used 212 | 213 | > For nRF70 Series device to transmit 10000 packets (TX transmit count) with the required modulation, TX power and channel 214 | (e.g. 11g, 54 Mbps, channel 11): 215 | ```bash 216 | # echo init=11 > /sys/kernel/debug/nrf/wifi/conf 217 | # echo tx_pkt_tput_mode=0 > /sys/kernel/debug/nrf/wifi/conf 218 | # echo tx_pkt_rate=54 > /sys/kernel/debug/nrf/wifi/conf 219 | # echo tx_pkt_len=1024 > /sys/kernel/debug/nrf/wifi/conf 220 | # echo tx_pkt_gap=100 > /sys/kernel/debug/nrf/wifi/conf 221 | # echo tx_pkt_num=10000 > /sys/kernel/debug/nrf/wifi/conf 222 | # echo tx=1 > /sys/kernel/debug/nrf/wifi/conf 223 | ``` 224 | Once set check the configuration settings in `/sys/kernel/debug/nrf/wifi/conf`. Typically the configuration will be as below 225 | ```bash 226 | # cat /sys/kernel/debug/nrf/wifi/conf 227 | ************* Configured Parameters *********** 228 | phy_calib_rxdc = 1 229 | phy_calib_txdc = 1 230 | phy_calib_txpow = 0 231 | phy_calib_rxiq = 1 232 | phy_calib_txiq = 1 233 | he_ltf = 2 234 | he_gi = 2 235 | tx_pkt_tput_mode = 0 236 | tx_pkt_sgi = 0 237 | tx_pkt_preamble = 1 238 | tx_pkt_mcs = 0 239 | tx_pkt_rate = 54 240 | tx_pkt_gap = 100 241 | tx_pkt_num = 10000 242 | tx_pkt_len = 1024 243 | tx_power = 30 244 | ru_tone = 26 245 | ru_index = 1 246 | rx_capture_length = 0 247 | rx_lna_gain = 0 248 | rx_bb_gain = 0 249 | tx_tone_freq = 0 250 | xo_val = 38 251 | init = 11 252 | tx = 0 253 | rx = 0 254 | tx_pkt_cw = 15 255 | reg_domain = 00 256 | bypass_reg_domain = 0 257 | ``` 258 | 6. To view the test results 259 | ```bash 260 | # cat /sys/kernel/debug/nrf/wifi/stats 261 | ``` 262 | Typically the results will be as below after running the test. 263 | 264 | ```bash 265 | # cat /sys/kernel/debug/nrf/wifi/stats 266 | ************* PHY STATS *********** 267 | rssi_avg = -64 dBm 268 | ofdm_crc32_pass_cnt=5140 269 | ofdm_crc32_fail_cnt=3952 270 | dsss_crc32_pass_cnt=31786 271 | dsss_crc32_fail_cnt=2265 272 | ``` 273 | # Known issues 274 | 275 | 1. Target Wake Time (TWT) feature is not supported yet. 276 | 277 | 2. Intermittent issues when running UDP/TCP throughputs: 278 | 279 | - Firmware lockup (on the nRF70 series device) 280 | - Linux kernel crash 281 | 282 | 3. Sometimes below warning is observed in the `dmesg` 283 | 284 | - `NOHZ tick-stop error: Non-RCU local softirq work is pending, handler #08!!!` 285 | -------------------------------------------------------------------------------- /boards/RPi4B_interposer/400783_pcb_laminate_specification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicPlayground/nrf70-linux-driver/387d631e435f67d876caac6c306b2339382e5a44/boards/RPi4B_interposer/400783_pcb_laminate_specification.pdf -------------------------------------------------------------------------------- /boards/RPi4B_interposer/Gerber.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicPlayground/nrf70-linux-driver/387d631e435f67d876caac6c306b2339382e5a44/boards/RPi4B_interposer/Gerber.zip -------------------------------------------------------------------------------- /boards/RPi4B_interposer/pca64167_BOM.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicPlayground/nrf70-linux-driver/387d631e435f67d876caac6c306b2339382e5a44/boards/RPi4B_interposer/pca64167_BOM.pdf -------------------------------------------------------------------------------- /boards/RPi4B_interposer/pca64167_schematic_and_pcb.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NordicPlayground/nrf70-linux-driver/387d631e435f67d876caac6c306b2339382e5a44/boards/RPi4B_interposer/pca64167_schematic_and_pcb.pdf -------------------------------------------------------------------------------- /dts/bindings/nordic,nrf70-spi.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Nordic Semiconductor ASA 2 | # SPDX-License-Identifier: GPL-2.0 3 | %YAML 1.2 4 | --- 5 | $id: http://devicetree.org/schemas/spi/nordic,nrf70-spi.yaml# 6 | $schema: http://devicetree.org/meta-schemas/core.yaml# 7 | 8 | title: Nordic nRF70 series Wi-Fi SoC 9 | 10 | allOf: 11 | - $ref: spi-controller.yaml 12 | - $ref: nordic,nrf70-spi.yaml 13 | 14 | maintainers: 15 | - Ajay Parida 16 | 17 | 18 | description: This is a representation of the nRF70 series Wi-Fi evaluation kit 19 | (PCA10090) and nRF70 series Wi-Fi module (PCA10095) SPI controller. 20 | 21 | properties: 22 | compatible: 23 | enum: 24 | - nordic,nrf70-spi 25 | 26 | -------------------------------------------------------------------------------- /dts/bindings/nordic,nrf70.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Nordic Semiconductor ASA 2 | # SPDX-License-Identifier: GPL-2.0 3 | %YAML 1.2 4 | --- 5 | $id: http://devicetree.org/schemas/spi/nordic,nrf70.yaml# 6 | $schema: http://devicetree.org/meta-schemas/core.yaml# 7 | 8 | title: Nordic nRF70 series Wi-Fi SoC common bindings 9 | 10 | maintainers: 11 | - Ajay Parida 12 | 13 | properties: 14 | iovdd-ctrl-gpios: 15 | type: phandle-array 16 | required: true 17 | description: | 18 | GPIO of the SOC controlling IO VDD Control pin of the nRF70 19 | bucken-gpios: 20 | type: phandle-array 21 | required: true 22 | description: | 23 | GPIO of the SOC controlling BUCK_EN pin of the nRF70 24 | host-irq-gpios: 25 | type: phandle-array 26 | required: true 27 | description: | 28 | GPIO of the SOC controlling the HOST IRQ pin of the nRF70 29 | -------------------------------------------------------------------------------- /dts/nrf70_rpi_interposer.dts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | /dts-v1/; 8 | /plugin/; 9 | 10 | / { 11 | compatible = "brcm,bcm2835"; 12 | fragment@0 { 13 | target = <&spidev0>; 14 | __overlay__ { 15 | status = "disabled"; 16 | }; 17 | }; 18 | 19 | fragment@1 { 20 | target = <&spi0>; 21 | __overlay__ { 22 | status = "okay"; 23 | #address-cells = <1>; 24 | #size-cells = <0>; 25 | cs-gpios = <&gpio 8 1>; 26 | 27 | nrf7002_ek: nrf7002@0 { 28 | compatible = "nordic,nrf70-spi"; 29 | reg = <0x0>; 30 | spi-max-frequency = <112000000>; 31 | spi-bits-per-word = <8>; 32 | status = "okay"; 33 | bucken-gpio = <&gpio 18 0>; 34 | iovdd-gpio = <&gpio 17 0>; 35 | irq-gpio = <&gpio 4 0>; 36 | }; 37 | }; 38 | }; 39 | }; 40 | -------------------------------------------------------------------------------- /inc/ap.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_NRF700X_RADIO_TEST 2 | /* 3 | * Copyright (c) 2023 Nordic Semiconductor ASA 4 | * 5 | * SPDX-License-Identifier: GPL-2.0 6 | */ 7 | 8 | struct nrf_wifi_cfg80211_mgmt_registration { 9 | struct list_head list; 10 | struct wireless_dev *wdev; 11 | u32 nlportid; 12 | int match_len; 13 | __le16 frame_type; 14 | u8 match[]; 15 | }; 16 | 17 | struct cookie_info { 18 | struct list_head list; 19 | unsigned long long host_cookie; 20 | unsigned long long rpu_cookie; 21 | }; 22 | 23 | int ap_event_cookie(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx, int event_num, 24 | void *event_info); 25 | 26 | int ap_event_rx_mgmt(void *dev, int event_num, void *event_info); 27 | 28 | int ap_event_tx_status(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx, void *dev, 29 | int event_num, void *event_info); 30 | 31 | int ap_event_set_interface(void *dev, int event_num, void *event_info); 32 | 33 | int nrf_wifi_cfg80211_chg_bcn(struct wiphy *wiphy, struct net_device *netdev, 34 | struct cfg80211_beacon_data *params); 35 | 36 | int nrf_wifi_cfg80211_chg_bss(struct wiphy *wiphy, struct net_device *netdev, 37 | struct bss_parameters *params); 38 | 39 | int nrf_wifi_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *netdev, 40 | struct cfg80211_ap_settings *params); 41 | 42 | int nrf_wifi_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *netdev); 43 | 44 | int nrf_wifi_cfg80211_chg_vif(struct wiphy *wiphy, struct net_device *netdev, 45 | enum nl80211_iftype type, 46 | struct vif_params *params); 47 | 48 | int nrf_wifi_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, 49 | struct cfg80211_mgmt_tx_params *params, 50 | u64 *cookie); 51 | 52 | int nrf_wifi_cfg80211_del_sta(struct wiphy *wiphy, struct net_device *netdev, 53 | struct station_del_parameters *params); 54 | 55 | int nrf_wifi_cfg80211_add_sta(struct wiphy *wiphy, struct net_device *netdev, 56 | const u8 *mac, struct station_parameters *params); 57 | 58 | int nrf_wifi_cfg80211_chg_sta(struct wiphy *wiphy, struct net_device *netdev, 59 | const u8 *mac, struct station_parameters *params); 60 | 61 | int nrf_wifi_cfg80211_set_txq_params(struct wiphy *wiphy, 62 | struct net_device *netdev, 63 | struct ieee80211_txq_params *params); 64 | 65 | void nrf_wifi_cfg80211_mgmt_frame_reg(struct wiphy *wiphy, 66 | struct wireless_dev *wdev, 67 | struct mgmt_frame_regs *upd); 68 | 69 | int nrf_wifi_cfg80211_probe_client(struct wiphy *wiphy, 70 | struct net_device *netdev, const u8 *peer, 71 | u64 *cookie); 72 | struct wireless_dev *nrf_wifi_cfg80211_add_vif(struct wiphy *wiphy, 73 | const char *name, 74 | unsigned char name_assign_type, 75 | enum nl80211_iftype type, 76 | struct vif_params *params); 77 | 78 | int nrf_wifi_cfg80211_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev); 79 | #endif /* !CONFIG_NRF700X_RADIO_TEST */ 80 | -------------------------------------------------------------------------------- /inc/cfg80211_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #ifndef __CFG80211_IF_H__ 8 | #define __CFG80211_IF_H__ 9 | 10 | #include 11 | #include "main.h" 12 | #include "fmac_main.h" 13 | 14 | struct wiphy *cfg80211_if_init(void); 15 | void cfg80211_if_deinit(struct wiphy *wiphy); 16 | 17 | void nrf_wifi_cfg80211_scan_start_callbk_fn( 18 | void *os_vif_ctx, 19 | struct nrf_wifi_umac_event_trigger_scan *scan_start_event, 20 | unsigned int event_len); 21 | void nrf_wifi_cfg80211_scan_res_callbk_fn( 22 | void *os_vif_ctx, struct nrf_wifi_umac_event_new_scan_results *scan_res, 23 | unsigned int event_len, bool more_res); 24 | void nrf_wifi_cfg80211_scan_done_callbk_fn( 25 | void *os_vif_ctx, 26 | struct nrf_wifi_umac_event_trigger_scan *scan_done_event, 27 | unsigned int event_len); 28 | void nrf_wifi_cfg80211_scan_abort_callbk_fn( 29 | void *os_vif_ctx, 30 | struct nrf_wifi_umac_event_trigger_scan *scan_done_event, 31 | unsigned int event_len); 32 | void nrf_wifi_cfg80211_auth_resp_callbk_fn( 33 | void *os_vif_ctx, struct nrf_wifi_umac_event_mlme *auth_resp_event, 34 | unsigned int event_len); 35 | void nrf_wifi_cfg80211_assoc_resp_callbk_fn( 36 | void *os_vif_ctx, struct nrf_wifi_umac_event_mlme *assoc_resp_event, 37 | unsigned int event_len); 38 | void nrf_wifi_cfg80211_deauth_callbk_fn( 39 | void *os_vif_ctx, struct nrf_wifi_umac_event_mlme *deauth_event, 40 | unsigned int event_len); 41 | void nrf_wifi_cfg80211_disassoc_callbk_fn( 42 | void *os_vif_ctx, struct nrf_wifi_umac_event_mlme *disassoc_event, 43 | unsigned int event_len); 44 | void nrf_wifi_cfg80211_mgmt_rx_callbk_fn( 45 | void *os_vif_ctx, struct nrf_wifi_umac_event_mlme *mgmt_rx_event, 46 | unsigned int event_len); 47 | void nrf_wifi_cfg80211_tx_status_callbk_fn( 48 | void *os_vif_ctx, struct nrf_wifi_umac_event_mlme *mgmt_rx_event, 49 | unsigned int event_len); 50 | void nrf_wifi_cfg80211_unprot_mlme_mgmt_rx_callbk_fn( 51 | void *os_vif_ctx, struct nrf_wifi_umac_event_mlme *unprot_mlme_event, 52 | unsigned int event_len); 53 | void nrf_wifi_cfg80211_roc_callbk_fn( 54 | void *os_vif_ctx, struct nrf_wifi_event_remain_on_channel *roc_event, 55 | unsigned int event_len); 56 | void nrf_wifi_cfg80211_roc_cancel_callbk_fn( 57 | void *os_vif_ctx, 58 | struct nrf_wifi_event_remain_on_channel *roc_cancel_event, 59 | unsigned int event_len); 60 | void nrf_wifi_cfg80211_rx_bcn_prb_rsp_callbk_fn(void *os_vif_ctx, void *frm, 61 | unsigned short frequency, 62 | short signal); 63 | #endif /* __CFG80211_IF_H__ */ 64 | -------------------------------------------------------------------------------- /inc/driver_linux.h: -------------------------------------------------------------------------------- 1 | #ifdef RPU_MODE_EXPLORER 2 | /* 3 | * Copyright (c) 2023 Nordic Semiconductor ASA 4 | * 5 | * SPDX-License-Identifier: GPL-2.0 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "fmac_main.h" 13 | 14 | #include "hal_api.h" 15 | #include "fmac_api.h" 16 | 17 | #include "vcu118.h" 18 | 19 | #endif /* RPU_MODE_EXPLORER */ 20 | -------------------------------------------------------------------------------- /inc/fmac_dbgfs_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #ifndef __DBGFS_IF_H__ 8 | #define __DBGFS_IF_H__ 9 | 10 | #include "main.h" 11 | 12 | #include "fmac_main.h" 13 | 14 | #define MAX_CONF_BUF_SIZE 500 15 | #define MAX_ERR_STR_SIZE 80 16 | 17 | int nrf_wifi_dbgfs_init(void); 18 | void nrf_wifi_dbgfs_deinit(void); 19 | int nrf_wifi_wlan_fmac_dbgfs_init(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 20 | void nrf_wifi_wlan_fmac_dbgfs_deinit(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 21 | int nrf_wifi_wlan_fmac_dbgfs_stats_init(struct dentry *root, 22 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 23 | void nrf_wifi_wlan_fmac_dbgfs_stats_deinit(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 24 | int nrf_wifi_wlan_fmac_dbgfs_ver_init(struct dentry *root, 25 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 26 | void nrf_wifi_wlan_fmac_dbgfs_ver_deinit(void); 27 | int nrf_wifi_wlan_fmac_dbgfs_twt_init(struct dentry *root, 28 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 29 | void nrf_wifi_wlan_fmac_dbgfs_twt_deinit(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 30 | int nrf_wifi_wlan_fmac_dbgfs_conf_init(struct dentry *root, 31 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 32 | void nrf_wifi_wlan_fmac_dbgfs_conf_deinit(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 33 | #ifdef CONFIG_NRF700X_RADIO_TEST 34 | int nrf_wifi_wlan_fmac_dbgfs_radio_test_init( 35 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 36 | void nrf_wifi_wlan_fmac_dbgfs_radio_test_deinit( 37 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 38 | int nrf_wifi_wlan_fmac_dbgfs_radio_test_conf_init( 39 | struct dentry *root, struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 40 | #endif /* CONFIG_NRF700X_RADIO_TEST */ 41 | #endif /* __DBGFS_IF_H__ */ 42 | -------------------------------------------------------------------------------- /inc/fmac_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #ifndef __FMAC_MAIN_H__ 8 | #define __FMAC_MAIN_H__ 9 | 10 | #include 11 | #include "fmac_structs.h" 12 | #include "sta.h" 13 | #include "ap.h" 14 | #include "p2p.h" 15 | #include "host_rpu_umac_if.h" 16 | #ifdef RPU_MODE_EXPLORER 17 | #include "driver_linux.h" 18 | #endif /* RPU_MODE_EXPLORER */ 19 | 20 | struct nrf_wifi_fmac_vif_ctx_lnx { 21 | struct nrf_wifi_ctx_lnx *rpu_ctx; 22 | struct net_device *netdev; 23 | struct wireless_dev *wdev; 24 | struct cfg80211_bss *bss; 25 | struct cfg80211_scan_request *nrf_wifi_scan_req; 26 | 27 | unsigned char if_idx; 28 | 29 | /* event responses */ 30 | struct nrf_wifi_sta_info *station_info; 31 | struct nrf_wifi_chan_definition *chan_def; 32 | int tx_power; 33 | int event_tx_power; 34 | int event_set_if; 35 | int status_set_if; 36 | struct p2p_info p2p; 37 | unsigned long rssi_record_timestamp_us; 38 | signed short rssi; 39 | #ifdef CONFIG_NRF700X_DATA_TX 40 | void *data_txq; 41 | struct work_struct ws_data_tx; 42 | struct work_struct ws_queue_monitor; 43 | unsigned long long num_tx_pkt; 44 | #endif 45 | }; 46 | 47 | struct nrf_wifi_fmac_vif_ctx_lnx * 48 | nrf_wifi_wlan_fmac_add_vif(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx, 49 | const char *name, char *mac_addr, 50 | enum nl80211_iftype if_type); 51 | void nrf_wifi_wlan_fmac_del_vif(struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx); 52 | #endif /* __FMAC_MAIN_H__ */ 53 | -------------------------------------------------------------------------------- /inc/linux_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #ifndef __UTIL_H__ 8 | #define __UTIL_H__ 9 | int hex_str_to_val(unsigned char *hex_arr, unsigned int hex_arr_sz, 10 | unsigned char *str); 11 | #endif /* __UTIL_H__ */ 12 | -------------------------------------------------------------------------------- /inc/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #ifndef __MAIN_H__ 8 | #define __MAIN_H__ 9 | 10 | #include 11 | #include "rpu_if.h" 12 | #ifdef DEBUG_MODE_SUPPORT 13 | #include "host_rpu_umac_if.h" 14 | #endif 15 | 16 | #include 17 | #include "fmac_structs.h" 18 | 19 | #define NRF_WIFI_FMAC_DRV_VER "1.0.0.0" 20 | 21 | enum connect_status { 22 | DISCONNECTED, 23 | CONNECTED, 24 | }; 25 | 26 | struct twt_params { 27 | unsigned char twt_flow_id; 28 | unsigned char neg_type; 29 | int setup_cmd; 30 | unsigned char ap_trigger_frame; 31 | unsigned char is_implicit; 32 | unsigned char twt_flow_type; 33 | unsigned char twt_target_wake_interval_exponent; 34 | unsigned short twt_target_wake_interval_mantissa; 35 | unsigned long long target_wake_time; 36 | unsigned short nominal_min_twt_wake_duration; 37 | }; 38 | 39 | struct rpu_twt_params { 40 | //unsigned char target_wake_time[8]; //should it be changed to unsigned long long 41 | enum connect_status status; 42 | struct twt_params twt_cmd; 43 | struct twt_params twt_event; 44 | int twt_event_info_avail; 45 | char twt_setup_cmd[250]; 46 | int teardown_reason; 47 | int teardown_event_cnt; 48 | }; 49 | 50 | struct nrf_wifi_ctx_lnx { 51 | void *rpu_ctx; 52 | struct nrf_wifi_fmac_vif_ctx_lnx *def_vif_ctx; 53 | struct wiphy *wiphy; 54 | 55 | struct dentry *dbgfs_rpu_root; 56 | struct dentry *dbgfs_wlan_root; 57 | struct dentry *dbgfs_wlan_stats_root; 58 | struct dentry *dbgfs_wlan_conf_root; 59 | struct rpu_conf_params conf_params; 60 | #ifdef CONFIG_NRF700X_RADIO_TEST 61 | bool rf_test_run; 62 | unsigned char rf_test; 63 | unsigned char *rx_cap_buf; 64 | #endif /* CONFIG_NRF700X_RADIO_TEST */ 65 | #ifdef DEBUG_MODE_SUPPORT 66 | struct nrf_wifi_umac_set_beacon_info info; 67 | struct rpu_btcoex btcoex; 68 | #endif 69 | struct list_head cookie_list; 70 | struct dentry *dbgfs_nrf_wifi_twt_root; 71 | struct rpu_twt_params twt_params; 72 | }; 73 | 74 | struct nrf_wifi_drv_priv_lnx { 75 | struct dentry *dbgfs_root; 76 | struct dentry *dbgfs_ver_root; 77 | struct nrf_wifi_fmac_priv *fmac_priv; 78 | bool drv_init; 79 | }; 80 | 81 | struct nrf_wifi_ctx_lnx *nrf_wifi_fmac_dev_add_lnx(void); 82 | void nrf_wifi_fmac_dev_rem_lnx(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 83 | enum nrf_wifi_status 84 | nrf_wifi_fmac_dev_init_lnx(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 85 | void nrf_wifi_fmac_dev_deinit_lnx(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx); 86 | #endif /* __MAIN_H__ */ 87 | -------------------------------------------------------------------------------- /inc/net_stack.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #ifndef __NET_STACK_H__ 8 | #define __NET_STACK_H__ 9 | 10 | #include "main.h" 11 | #include "fmac_main.h" 12 | 13 | #ifndef CONFIG_NRF700X_RADIO_TEST 14 | 15 | struct nrf_wifi_fmac_vif_ctx_lnx * 16 | nrf_wifi_netdev_add_vif(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx, 17 | const char *if_name, struct wireless_dev *wdev, 18 | char *mac_addr); 19 | 20 | void nrf_wifi_netdev_del_vif(struct net_device *netdev); 21 | 22 | void nrf_wifi_netdev_frame_rx_callbk_fn(void *vif_ctx, void *frm); 23 | 24 | enum nrf_wifi_status nrf_wifi_netdev_if_state_chg_callbk_fn( 25 | void *vif_ctx, enum nrf_wifi_fmac_if_carr_state if_state); 26 | #endif /* !CONFIG_NRF700X_RADIO_TEST */ 27 | #endif /* __NET_STACK_H__ */ 28 | -------------------------------------------------------------------------------- /inc/p2p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | /* 8 | * @dev_addr: P2P device address. 9 | * @int_addr: P2P interface address. 10 | * @remain_on_channel: contains copy of struct used by cfg80211. 11 | * @remain_on_channel_cookie: cookie counter for remain on channel cmd 12 | */ 13 | struct p2p_info { 14 | u8 dev_addr[ETH_ALEN]; 15 | u8 int_addr[ETH_ALEN]; 16 | struct ieee80211_channel remain_on_channel; 17 | u64 remain_on_channel_cookie; 18 | }; 19 | 20 | int nrf_wifi_cfg80211_start_p2p_dev(struct wiphy *wiphy, 21 | struct wireless_dev *wdev); 22 | 23 | void nrf_wifi_cfg80211_stop_p2p_dev(struct wiphy *wiphy, 24 | struct wireless_dev *wdev); 25 | 26 | int nrf_wifi_cfg80211_remain_on_channel(struct wiphy *wiphy, 27 | struct wireless_dev *wdev, 28 | struct ieee80211_channel *chan, 29 | unsigned int duration, 30 | unsigned long long *cookie); 31 | 32 | int nrf_wifi_cfg80211_cancel_remain_on_channel(struct wiphy *wiphy, 33 | struct wireless_dev *wdev, 34 | unsigned long long cookie); 35 | 36 | int p2p_event(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx, void *network_dev, 37 | void *params); 38 | -------------------------------------------------------------------------------- /inc/shim.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #ifndef __SHIM_H__ 8 | #define __SHIM_H__ 9 | 10 | struct shim_llist_node { 11 | struct list_head head; 12 | void *data; 13 | }; 14 | 15 | struct shim_llist { 16 | struct list_head head; 17 | unsigned int len; 18 | }; 19 | 20 | struct shim_intr_priv { 21 | void *intr_callbk_data; 22 | int (*intr_callbk_fn)(void *intr_callbk_data); 23 | struct work_struct work; 24 | }; 25 | 26 | struct work_item { 27 | struct work_struct work; 28 | unsigned long data; 29 | void (*callback)(unsigned long data); 30 | }; 31 | 32 | /** 33 | * struct shim_bus_spi_priv - Structure to hold context information for the Linux OS 34 | * shim. 35 | * 36 | * This structure maintains the context information necessary for the operation 37 | * of the Linux shim. Some of the elements of the structure need to be 38 | * initialized during the initialization of the Linux shim while others need to 39 | * be kept updated over the duration of the Linux shim operation. 40 | */ 41 | struct shim_bus_spi_priv { 42 | struct work_struct drv_reg; 43 | struct spi_driver *spi_drv; 44 | const struct spi_device_id *spi_dev_id; 45 | struct spi_device *spi_dev; 46 | struct gpio_desc *iovdd; 47 | struct gpio_desc *bucken; 48 | struct gpio_desc *host_irq; 49 | void *spdev; 50 | struct workqueue_struct *wq; 51 | struct shim_intr_priv intr_priv; 52 | bool irq_enabled; 53 | bool dev_added; 54 | bool dev_init; 55 | }; 56 | 57 | /** 58 | * struct shim_bus_spi_dev_ctx - Structure to hold context information for the Linux 59 | * specific Linux SPI device context. 60 | * @pcie_priv: Pointer to Linux specific PCIe driver context. 61 | */ 62 | struct shim_bus_spi_dev_ctx { 63 | struct shim_bus_spi_priv *lnx_spi_priv; 64 | void *osal_spi_dev_ctx; 65 | struct nrf_wifi_ctx_lnx *lnx_rpu_ctx; 66 | struct nrf_wifi_osal_host_map host_map; 67 | char *dev_name; 68 | bool is_msi; 69 | }; 70 | 71 | #endif /* __SHIM_H__ */ 72 | -------------------------------------------------------------------------------- /inc/sta.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_NRF700X_RADIO_TEST 2 | /* 3 | * Copyright (c) 2023 Nordic Semiconductor ASA 4 | * 5 | * SPDX-License-Identifier: GPL-2.0 6 | */ 7 | 8 | int nrf_wifi_cfg80211_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow); 9 | 10 | int nrf_wifi_cfg80211_resume(struct wiphy *wiphy); 11 | 12 | void nrf_wifi_cfg80211_set_wakeup(struct wiphy *wiphy, bool enabled); 13 | 14 | int nrf_wifi_cfg80211_set_qos_map(struct wiphy *wiphy, struct net_device *dev, 15 | struct cfg80211_qos_map *qos_map); 16 | 17 | int nrf_wifi_cfg80211_set_power_mgmt(struct wiphy *wiphy, 18 | struct net_device *dev, bool enabled, 19 | int timeout); 20 | 21 | int nrf_wifi_cfg80211_scan(struct wiphy *wiphy, 22 | struct cfg80211_scan_request *req); 23 | 24 | int nrf_wifi_cfg80211_auth(struct wiphy *wiphy, struct net_device *netdev, 25 | struct cfg80211_auth_request *req); 26 | 27 | int nrf_wifi_cfg80211_assoc(struct wiphy *wiphy, struct net_device *dev, 28 | struct cfg80211_assoc_request *req); 29 | 30 | int nrf_wifi_cfg80211_deauth(struct wiphy *wiphy, struct net_device *dev, 31 | struct cfg80211_deauth_request *req); 32 | 33 | int nrf_wifi_cfg80211_disassoc(struct wiphy *wiphy, struct net_device *dev, 34 | struct cfg80211_disassoc_request *req); 35 | 36 | int nrf_wifi_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev, 37 | u8 key_index, bool pairwise, const u8 *mac_addr, 38 | struct key_params *params); 39 | 40 | int nrf_wifi_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev, 41 | u8 key_idx, bool pairwise, const u8 *mac_addr); 42 | 43 | int nrf_wifi_cfg80211_set_def_key(struct wiphy *wiphy, 44 | struct net_device *netdev, u8 key_index, 45 | bool unicast, bool multicast); 46 | 47 | int nrf_wifi_cfg80211_set_def_mgmt_key(struct wiphy *wiphy, 48 | struct net_device *netdev, u8 key_index); 49 | 50 | int nrf_wifi_cfg80211_get_tx_power(struct wiphy *wiphy, 51 | struct wireless_dev *wdev, int *dbm); 52 | 53 | int nrf_wifi_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev, 54 | const u8 *mac, struct station_info *sinfo); 55 | 56 | int nrf_wifi_cfg80211_get_channel(struct wiphy *wiphy, 57 | struct wireless_dev *wdev, 58 | struct cfg80211_chan_def *chandef); 59 | 60 | int nrf_wifi_cfg80211_set_wiphy_params(struct wiphy *wiphy, 61 | unsigned int changed); 62 | #endif /* !CONFIG_NRF700X_RADIO_TEST */ 63 | -------------------------------------------------------------------------------- /scripts/ci/codeowners.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # Copyright (c) 2018,2020 Intel Corporation 5 | # Copyright (c) 2022 Nordic Semiconductor ASA 6 | 7 | import argparse 8 | import collections 9 | import logging 10 | import os 11 | from pathlib import Path 12 | import re 13 | import subprocess 14 | import sys 15 | import shlex 16 | 17 | logger = None 18 | 19 | failures = 0 20 | 21 | def err(msg): 22 | cmd = sys.argv[0] # Empty if missing 23 | if cmd: 24 | cmd += ": " 25 | sys.exit(f"{cmd}fatal error: {msg}") 26 | 27 | 28 | def cmd2str(cmd): 29 | # Formats the command-line arguments in the iterable 'cmd' into a string, 30 | # for error messages and the like 31 | 32 | return " ".join(shlex.quote(word) for word in cmd) 33 | 34 | 35 | def annotate(severity, file, title, message, line=None, col=None): 36 | """ 37 | https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#about-workflow-commands 38 | """ 39 | notice = f'::{severity} file={file}' + \ 40 | (f',line={line}' if line else '') + \ 41 | (f',col={col}' if col else '') + \ 42 | f',title={title}::{message}' 43 | print(notice) 44 | 45 | 46 | def failure(msg, file='CODEOWNERS', line=None): 47 | global failures 48 | failures += 1 49 | annotate('error', file=file, title="CODEOWNERS", message=msg, 50 | line=line) 51 | 52 | 53 | def git(*args, cwd=None): 54 | # Helper for running a Git command. Returns the rstrip()ed stdout output. 55 | # Called like git("diff"). Exits with SystemError (raised by sys.exit()) on 56 | # errors. 'cwd' is the working directory to use (default: current 57 | # directory). 58 | 59 | git_cmd = ("git",) + args 60 | try: 61 | cp = subprocess.run(git_cmd, capture_output=True, cwd=cwd) 62 | except OSError as e: 63 | err(f"failed to run '{cmd2str(git_cmd)}': {e}") 64 | 65 | if cp.returncode or cp.stderr: 66 | err(f"'{cmd2str(git_cmd)}' exited with status {cp.returncode} and/or " 67 | f"wrote to stderr.\n" 68 | f"==stdout==\n" 69 | f"{cp.stdout.decode('utf-8')}\n" 70 | f"==stderr==\n" 71 | f"{cp.stderr.decode('utf-8')}\n") 72 | 73 | return cp.stdout.decode("utf-8").rstrip() 74 | 75 | 76 | def get_files(filter=None, paths=None): 77 | filter_arg = (f'--diff-filter={filter}',) if filter else () 78 | paths_arg = ('--', *paths) if paths else () 79 | return git('diff', '--name-only', *filter_arg, COMMIT_RANGE, *paths_arg) 80 | 81 | 82 | def ls_owned_files(codeowners): 83 | """Returns an OrderedDict mapping git patterns from the CODEOWNERS file 84 | to the corresponding list of files found on the filesystem. It 85 | unfortunately does not seem possible to invoke git and re-use 86 | how 'git ignore' and/or 'git attributes' already implement this, 87 | we must re-invent it. 88 | """ 89 | 90 | # TODO: filter out files not in "git ls-files" (e.g., 91 | # twister-out) _if_ the overhead isn't too high for a clean tree. 92 | # 93 | # pathlib.match() doesn't support **, so it looks like we can't 94 | # recursively glob the output of ls-files directly, only real 95 | # files :-( 96 | 97 | pattern2files = collections.OrderedDict() 98 | top_path = Path(GIT_TOP) 99 | 100 | with open(codeowners, "r") as codeo: 101 | for lineno, line in enumerate(codeo, start=1): 102 | 103 | if line.startswith("#") or not line.strip(): 104 | continue 105 | 106 | match = re.match(r"^([^\s,]+)\s+[^\s]+", line) 107 | if not match: 108 | failure(f"Invalid CODEOWNERS line {lineno}\n\t{line}", 109 | file='CODEOWNERS', line=lineno) 110 | continue 111 | 112 | git_patrn = match.group(1) 113 | glob = git_pattern_to_glob(git_patrn) 114 | files = [] 115 | for abs_path in top_path.glob(glob): 116 | # comparing strings is much faster later 117 | files.append(str(abs_path.relative_to(top_path))) 118 | 119 | if not files: 120 | failure(f"Path '{git_patrn}' not found in the tree" 121 | f"but is listed in CODEOWNERS") 122 | 123 | pattern2files[git_patrn] = files 124 | 125 | return pattern2files 126 | 127 | 128 | def git_pattern_to_glob(git_pattern): 129 | """Appends and prepends '**[/*]' when needed. Result has neither a 130 | leading nor a trailing slash. 131 | """ 132 | 133 | if git_pattern.startswith("/"): 134 | ret = git_pattern[1:] 135 | else: 136 | ret = "**/" + git_pattern 137 | 138 | if git_pattern.endswith("/"): 139 | ret = ret + "**/*" 140 | elif os.path.isdir(os.path.join(GIT_TOP, ret)): 141 | failure("Expected '/' after directory '{}' " 142 | "in CODEOWNERS".format(ret)) 143 | 144 | return ret 145 | 146 | 147 | def codeowners(): 148 | codeowners = os.path.join(GIT_TOP, "CODEOWNERS") 149 | if not os.path.exists(codeowners): 150 | err("CODEOWNERS not available in this repo") 151 | 152 | name_changes = get_files(filter="ARCD") 153 | owners_changes = get_files(paths=(codeowners,)) 154 | 155 | if not name_changes and not owners_changes: 156 | # TODO: 1. decouple basic and cheap CODEOWNERS syntax 157 | # validation from the expensive ls_owned_files() scanning of 158 | # the entire tree. 2. run the former always. 159 | return 160 | 161 | logger.info("If this takes too long then cleanup and try again") 162 | patrn2files = ls_owned_files(codeowners) 163 | 164 | # The way git finds Renames and Copies is not "exact science", 165 | # however if one is missed then it will always be reported as an 166 | # Addition instead. 167 | new_files = get_files(filter="ARC").splitlines() 168 | logger.debug(f"New files {new_files}") 169 | 170 | # Convert to pathlib.Path string representation (e.g., 171 | # backslashes 'dir1\dir2\' on Windows) to be consistent 172 | # with ls_owned_files() 173 | new_files = [str(Path(f)) for f in new_files] 174 | 175 | new_not_owned = [] 176 | for newf in new_files: 177 | f_is_owned = False 178 | 179 | for git_pat, owned in patrn2files.items(): 180 | logger.debug(f"Scanning {git_pat} for {newf}") 181 | 182 | if newf in owned: 183 | logger.info(f"{git_pat} matches new file {newf}") 184 | f_is_owned = True 185 | # Unlike github, we don't care about finding any 186 | # more specific owner. 187 | break 188 | 189 | if not f_is_owned: 190 | new_not_owned.append(newf) 191 | 192 | if new_not_owned: 193 | failure("New files added that are not covered in " 194 | "CODEOWNERS:\n\n" + "\n".join(new_not_owned) + 195 | "\n\nPlease add one or more entries in the " 196 | "CODEOWNERS file to cover those files") 197 | 198 | 199 | def init_logs(cli_arg): 200 | # Initializes logging 201 | 202 | global logger 203 | 204 | level = os.environ.get('LOG_LEVEL', "WARN") 205 | 206 | console = logging.StreamHandler() 207 | console.setFormatter(logging.Formatter('%(levelname)-8s: %(message)s')) 208 | 209 | logger = logging.getLogger('') 210 | logger.addHandler(console) 211 | logger.setLevel(cli_arg or level) 212 | 213 | logger.info("Log init completed, level=%s", 214 | logging.getLevelName(logger.getEffectiveLevel())) 215 | 216 | 217 | def parse_args(): 218 | default_range = 'HEAD~1..HEAD' 219 | parser = argparse.ArgumentParser( 220 | allow_abbrev=False, 221 | description="Check for CODEOWNERS file ownership.") 222 | parser.add_argument('-c', '--commits', default=default_range, 223 | help=f'''Commit range in the form: a..[b], default is 224 | {default_range}''') 225 | parser.add_argument("-v", "--loglevel", choices=['DEBUG', 'INFO', 'WARNING', 226 | 'ERROR', 'CRITICAL'], 227 | help="python logging level") 228 | 229 | return parser.parse_args() 230 | 231 | 232 | def main(): 233 | args = parse_args() 234 | 235 | # The absolute path of the top-level git directory. Initialize it here so 236 | # that issues running Git can be reported to GitHub. 237 | global GIT_TOP 238 | GIT_TOP = git("rev-parse", "--show-toplevel") 239 | 240 | # The commit range passed in --commit, e.g. "HEAD~3" 241 | global COMMIT_RANGE 242 | COMMIT_RANGE = args.commits 243 | 244 | init_logs(args.loglevel) 245 | logger.info(f'Running tests on commit range {COMMIT_RANGE}') 246 | 247 | codeowners() 248 | 249 | sys.exit(failures) 250 | 251 | 252 | if __name__ == "__main__": 253 | main() 254 | -------------------------------------------------------------------------------- /scripts/requirements-fixed.txt: -------------------------------------------------------------------------------- 1 | ########################################################### 2 | ##### Fixed Python Requirements ##### 3 | ########################################################### 4 | 5 | Babel==2.9.1 6 | Jinja2==2.11.3 7 | MarkupSafe==1.1.1 8 | Pillow==9.0.1 9 | PyYAML==5.4.1 10 | Pygments==2.7.4 11 | Sphinx==3.4.3 12 | aenum==3.0.0 13 | alabaster==0.7.12 14 | anytree==2.8.0 15 | appdirs==1.4.4 16 | arrow==0.17.0 17 | astroid==2.15.0 18 | attrs==20.3.0 19 | bitarray==2.7.3 20 | breathe==4.26.1 21 | canopen==1.2.0 22 | cbor2==5.4.3 23 | cbor==1.0.0 24 | certifi==2020.12.5 25 | cffi==1.14.4 26 | chardet==4.0.0 27 | click==7.1.2 28 | cmsis-pack-manager==0.2.10 29 | colorama==0.4.6 30 | commonmark==0.9.1 31 | coverage==5.4 32 | cryptography==3.4.8 33 | docopt==0.6.2 34 | docutils==0.16 35 | ecdsa==0.16.1 36 | future==0.18.2 37 | gcovr==4.2 38 | gitlint==0.15.0 39 | grpcio-tools==1.51.1 40 | idna==2.10 41 | imagesize==1.2.0 42 | imgtool==1.7.0 43 | importlib-metadata==3.4.0 44 | iniconfig==1.1.1 45 | intelhex==2.3.0 46 | intervaltree==3.1.0 47 | isort==5.7.0 48 | jsonschema==4.4.0 49 | junit2html==30.0.4 50 | junitparser==2.8.0 51 | lazy-object-proxy==1.4.3 52 | lpc-checksum==2.2.0 53 | lxml==4.9.1 54 | mccabe==0.6.1 55 | milksnake==0.1.5 56 | mock==4.0.3 57 | mypy-extensions==0.4.3 58 | mypy==0.921 59 | naturalsort==1.5.1 60 | packaging==20.8 61 | pluggy==0.13.1 62 | ply==3.11 63 | prettytable==2.0.0 64 | progress==1.5 65 | psutil==5.8.0 66 | py==1.10.0 67 | pycparser==2.20 68 | pyelftools==0.27 69 | pygit2==1.10.0 70 | pykwalify==1.8.0 71 | pylink-square==0.8.1 72 | pylint==2.16.4 73 | pyocd==0.29.0 74 | pyparsing==2.4.7 75 | pyserial==3.5 76 | pytest==6.2.2 77 | python-can==3.3.4 78 | python-dateutil==2.8.1 79 | python-magic==0.4.18 80 | python-stdnum==1.18 81 | pytz==2020.5 82 | pyusb==1.2.0 83 | qrcode==7.3.1 84 | recommonmark==0.6.0 85 | regex==2022.3.15 86 | requests==2.25.1 87 | ruamel.yaml.clib==0.2.6 88 | ruamel.yaml==0.17.21 89 | sh==1.14.1 90 | six==1.15.0 91 | snowballstemmer==2.1.0 92 | sortedcontainers==2.3.0 93 | sphinx-rtd-theme==0.5.1 94 | sphinx-tabs==2.0.0 95 | sphinxcontrib-applehelp==1.0.2 96 | sphinxcontrib-devhelp==1.0.2 97 | sphinxcontrib-htmlhelp==1.0.3 98 | sphinxcontrib-jsmath==1.0.1 99 | sphinxcontrib-mscgen==0.5 100 | sphinxcontrib-qthelp==1.0.3 101 | sphinxcontrib-serializinghtml==1.1.4 102 | sphinxcontrib-svg2pdfconverter==1.1.1 103 | tabulate==0.8.7 104 | toml==0.10.2 105 | tomli==2.0.1 106 | typed-ast==1.5.4 107 | typing-extensions==4.4.0 108 | urllib3==1.26.4 109 | wcwidth==0.2.5 110 | west==1.0.0 111 | wget==3.2 112 | wrapt==1.12.1 113 | yamllint==1.30.0 114 | zcbor==0.5.1 115 | zipp==3.4.0 116 | -------------------------------------------------------------------------------- /src/debugfs/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "fmac_api.h" 12 | #include "fmac_dbgfs_if.h" 13 | 14 | extern struct nrf_wifi_drv_priv_lnx rpu_drv_priv; 15 | struct nrf_wifi_ctx_lnx *ctx; 16 | 17 | static __always_inline unsigned char 18 | param_get_val(unsigned char *buf, unsigned char *str, unsigned long *val) 19 | { 20 | unsigned char *temp = NULL; 21 | 22 | if (strstr(buf, str)) { 23 | temp = strstr(buf, "=") + 1; 24 | 25 | if (!kstrtoul(temp, 0, val)) { 26 | return 1; 27 | } else { 28 | return 0; 29 | } 30 | } else { 31 | return 0; 32 | } 33 | } 34 | 35 | static __always_inline unsigned char 36 | param_get_sval(unsigned char *buf, unsigned char *str, long *sval) 37 | { 38 | unsigned char *temp = NULL; 39 | 40 | if (strstr(buf, str)) { 41 | temp = strstr(buf, "=") + 1; 42 | 43 | if (!kstrtol(temp, 0, sval)) { 44 | return 1; 45 | } else { 46 | return 0; 47 | } 48 | } else { 49 | return 0; 50 | } 51 | } 52 | 53 | static __always_inline unsigned char param_get_match(unsigned char *buf, 54 | unsigned char *str) 55 | { 56 | if (strstr(buf, str)) 57 | return 1; 58 | else 59 | return 0; 60 | } 61 | 62 | static int nrf_wifi_wlan_fmac_conf_disp(struct seq_file *m, void *v) 63 | { 64 | struct rpu_conf_params *conf_params = NULL; 65 | 66 | conf_params = &ctx->conf_params; 67 | 68 | seq_puts(m, "************* Configured Parameters ***********\n"); 69 | 70 | seq_printf(m, "uapsd_queue = %d\n", conf_params->uapsd_queue); 71 | seq_printf(m, "power_save = %s\n", 72 | conf_params->power_save ? "ON" : "OFF"); 73 | seq_printf(m, "he_gi = %d\n", conf_params->he_gi); 74 | seq_printf(m, "rts_threshold = %d\n", conf_params->rts_threshold); 75 | 76 | return 0; 77 | } 78 | 79 | static ssize_t nrf_wifi_wlan_fmac_conf_write(struct file *file, 80 | const char __user *in_buf, 81 | size_t count, loff_t *ppos) 82 | { 83 | char *conf_buf = NULL; 84 | unsigned long val = 0; 85 | char err_str[MAX_ERR_STR_SIZE]; 86 | ssize_t err_val = count; 87 | struct nrf_wifi_ctx_lnx *ctx = NULL; 88 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 89 | 90 | ctx = (struct nrf_wifi_ctx_lnx *)file->f_inode->i_private; 91 | 92 | if (count >= MAX_CONF_BUF_SIZE) { 93 | snprintf(err_str, MAX_ERR_STR_SIZE, 94 | "Size of input buffer cannot be more than %d chars\n", 95 | MAX_CONF_BUF_SIZE); 96 | 97 | err_val = -EFAULT; 98 | goto error; 99 | } 100 | 101 | conf_buf = kzalloc(MAX_CONF_BUF_SIZE, GFP_KERNEL); 102 | 103 | if (!conf_buf) { 104 | snprintf(err_str, MAX_ERR_STR_SIZE, 105 | "Not enough memory available\n"); 106 | 107 | err_val = -EFAULT; 108 | goto error; 109 | } 110 | 111 | if (copy_from_user(conf_buf, in_buf, count)) { 112 | snprintf(err_str, MAX_ERR_STR_SIZE, 113 | "Copy from input buffer failed\n"); 114 | 115 | err_val = -EFAULT; 116 | goto error; 117 | } 118 | 119 | conf_buf[count - 1] = '\0'; 120 | 121 | if (param_get_val(conf_buf, "uapsd_queue=", &val)) { 122 | if ((val < 0) || (val > 15)) { 123 | snprintf(err_str, MAX_ERR_STR_SIZE, 124 | "Invalid value %lu\n", val); 125 | err_val = -EINVAL; 126 | goto error; 127 | } 128 | 129 | if (ctx->conf_params.uapsd_queue == val) 130 | goto out; 131 | 132 | status = nrf_wifi_fmac_set_uapsd_queue(ctx->rpu_ctx, 0, val); 133 | 134 | if (status != NRF_WIFI_STATUS_SUCCESS) { 135 | snprintf(err_str, MAX_ERR_STR_SIZE, 136 | "Programming uapsd queue failed\n"); 137 | goto error; 138 | } 139 | ctx->conf_params.uapsd_queue = val; 140 | goto error; 141 | } else if (param_get_val(conf_buf, "power_save=", &val)) { 142 | if ((val != 0) && (val != 1)) { 143 | snprintf(err_str, MAX_ERR_STR_SIZE, 144 | "Invalid value %lu\n", val); 145 | err_val = -EINVAL; 146 | goto error; 147 | } 148 | 149 | if (ctx->conf_params.power_save == val) 150 | goto out; 151 | 152 | status = nrf_wifi_fmac_set_power_save(ctx->rpu_ctx, 0, val); 153 | 154 | if (status != NRF_WIFI_STATUS_SUCCESS) { 155 | snprintf(err_str, MAX_ERR_STR_SIZE, 156 | "Programming power save failed\n"); 157 | goto error; 158 | } 159 | ctx->conf_params.power_save = val; 160 | } else if (param_get_val(conf_buf, "he_gi=", &val)) { 161 | if ((val < 0) || (val > 2)) { 162 | snprintf(err_str, MAX_ERR_STR_SIZE, 163 | "Invalid value %lu\n", val); 164 | err_val = -EINVAL; 165 | goto error; 166 | } 167 | 168 | if (ctx->conf_params.he_gi == val) 169 | goto out; 170 | ctx->conf_params.he_gi = val; 171 | } else if (param_get_val(conf_buf, "rts_threshold=", &val)) { 172 | struct nrf_wifi_umac_set_wiphy_info *wiphy_info = NULL; 173 | 174 | if (val <= 0) { 175 | snprintf(err_str, MAX_ERR_STR_SIZE, 176 | "Invalid value %lu\n", val); 177 | err_val = -EINVAL; 178 | goto error; 179 | } 180 | 181 | if (ctx->conf_params.rts_threshold == val) 182 | goto out; 183 | 184 | wiphy_info = kzalloc(sizeof(*wiphy_info), GFP_KERNEL); 185 | 186 | if (!wiphy_info) { 187 | snprintf(err_str, MAX_ERR_STR_SIZE, 188 | "Unable to allocate memory\n"); 189 | goto error; 190 | } 191 | wiphy_info->rts_threshold = val; 192 | 193 | status = nrf_wifi_fmac_set_wiphy_params(ctx->rpu_ctx, 0, 194 | wiphy_info); 195 | 196 | if (status != NRF_WIFI_STATUS_SUCCESS) { 197 | snprintf(err_str, MAX_ERR_STR_SIZE, 198 | "Programming rts_threshold failed\n"); 199 | goto error; 200 | } 201 | if (wiphy_info) 202 | kfree(wiphy_info); 203 | 204 | ctx->conf_params.rts_threshold = val; 205 | } else { 206 | snprintf(err_str, MAX_ERR_STR_SIZE, 207 | "Invalid parameter name: %s\n", conf_buf); 208 | err_val = -EFAULT; 209 | goto error; 210 | } 211 | 212 | goto out; 213 | 214 | error: 215 | pr_err("Error condition: %s\n", err_str); 216 | out: 217 | kfree(conf_buf); 218 | 219 | return err_val; 220 | } 221 | 222 | static int nrf_wifi_wlan_fmac_conf_open(struct inode *inode, struct file *file) 223 | { 224 | ctx = (struct nrf_wifi_ctx_lnx *)inode->i_private; 225 | 226 | return single_open(file, nrf_wifi_wlan_fmac_conf_disp, ctx); 227 | } 228 | 229 | static const struct file_operations fops_wlan_conf = { 230 | .open = nrf_wifi_wlan_fmac_conf_open, 231 | .read = seq_read, 232 | .llseek = seq_lseek, 233 | .write = nrf_wifi_wlan_fmac_conf_write, 234 | .release = single_release 235 | }; 236 | 237 | void nrf_wifi_wlan_fmac_dbgfs_conf_deinit(struct nrf_wifi_ctx_lnx *ctx) 238 | { 239 | if (ctx->dbgfs_wlan_conf_root) 240 | debugfs_remove(ctx->dbgfs_wlan_conf_root); 241 | 242 | ctx->dbgfs_wlan_conf_root = NULL; 243 | } 244 | 245 | int nrf_wifi_wlan_fmac_dbgfs_conf_init(struct dentry *root, 246 | struct nrf_wifi_ctx_lnx *ctx) 247 | { 248 | int ret = 0; 249 | 250 | if ((!root) || (!ctx)) { 251 | pr_err("%s: Invalid parameters\n", __func__); 252 | ret = -EINVAL; 253 | goto fail; 254 | } 255 | 256 | ctx->dbgfs_wlan_conf_root = 257 | debugfs_create_file("conf", 0644, root, ctx, &fops_wlan_conf); 258 | 259 | if (!ctx->dbgfs_wlan_conf_root) { 260 | pr_err("%s: Failed to create debugfs entry\n", __func__); 261 | ret = -ENOMEM; 262 | goto fail; 263 | } 264 | 265 | goto out; 266 | 267 | fail: 268 | nrf_wifi_wlan_fmac_dbgfs_conf_deinit(ctx); 269 | out: 270 | return ret; 271 | } 272 | 273 | int nrf_wifi_wlan_fmac_dbgfs_init(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx) 274 | { 275 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 276 | 277 | rpu_ctx_lnx->dbgfs_wlan_root = 278 | debugfs_create_dir("wifi", rpu_drv_priv.dbgfs_root); 279 | 280 | if (!rpu_ctx_lnx->dbgfs_wlan_root) 281 | goto out; 282 | 283 | status = nrf_wifi_wlan_fmac_dbgfs_conf_init( 284 | rpu_ctx_lnx->dbgfs_wlan_root, rpu_ctx_lnx); 285 | 286 | if (status != NRF_WIFI_STATUS_SUCCESS) 287 | goto out; 288 | 289 | status = nrf_wifi_wlan_fmac_dbgfs_twt_init(rpu_ctx_lnx->dbgfs_wlan_root, 290 | rpu_ctx_lnx); 291 | 292 | if (status != NRF_WIFI_STATUS_SUCCESS) 293 | goto out; 294 | 295 | status = nrf_wifi_wlan_fmac_dbgfs_stats_init( 296 | rpu_ctx_lnx->dbgfs_wlan_root, rpu_ctx_lnx); 297 | 298 | if (status != NRF_WIFI_STATUS_SUCCESS) 299 | goto out; 300 | 301 | status = nrf_wifi_wlan_fmac_dbgfs_ver_init(rpu_ctx_lnx->dbgfs_wlan_root, 302 | rpu_ctx_lnx); 303 | 304 | if (status != NRF_WIFI_STATUS_SUCCESS) 305 | goto out; 306 | 307 | out: 308 | if (status != NRF_WIFI_STATUS_SUCCESS) 309 | nrf_wifi_wlan_fmac_dbgfs_deinit(rpu_ctx_lnx); 310 | 311 | return status; 312 | } 313 | 314 | void nrf_wifi_wlan_fmac_dbgfs_deinit(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx) 315 | { 316 | if (rpu_ctx_lnx->dbgfs_wlan_root) 317 | debugfs_remove_recursive(rpu_ctx_lnx->dbgfs_wlan_root); 318 | 319 | rpu_ctx_lnx->dbgfs_wlan_root = NULL; 320 | } 321 | -------------------------------------------------------------------------------- /src/debugfs/stats.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #include 8 | 9 | #include "fmac_api.h" 10 | #include "fmac_dbgfs_if.h" 11 | 12 | #ifndef CONFIG_NRF700X_RADIO_TEST 13 | static void nrf_wifi_wlan_fmac_dbgfs_stats_show_host( 14 | struct seq_file *m, struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx, 15 | struct rpu_host_stats *stats) 16 | { 17 | #ifdef DEBUG_MODE_SUPPORT 18 | int i = 0; 19 | unsigned int cnt = 0; 20 | #endif /* DEBUG_MODE_SUPPORT */ 21 | 22 | seq_puts(m, "************* HOST STATS ***********\n"); 23 | seq_printf(m, "total_tx_pkts =%llu\n", stats->total_tx_pkts); 24 | seq_printf(m, "total_tx_done_pkts = %llu\n", stats->total_tx_done_pkts); 25 | seq_printf(m, "total_rx_pkts = %llu\n", stats->total_rx_pkts); 26 | #ifdef DEBUG_MODE_SUPPORT 27 | 28 | for (i = 0; i < fmac_dev_ctx->fpriv->data_config.max_tx_aggregation; 29 | i++) { 30 | cnt = stats->tx_coalesce_frames[i]; 31 | if (cnt != 0) 32 | seq_printf(m, "tx_coalesece_frames[%d] = %d\n", (i + 1), 33 | cnt); 34 | } 35 | 36 | seq_puts(m, "\n\n"); 37 | 38 | for (i = 0; i < fmac_dev_ctx->fpriv->data_config.max_tx_aggregation; 39 | i++) { 40 | cnt = stats->tx_done_coalesce_frames[i]; 41 | if (cnt != 0) 42 | seq_printf(m, "tx_done_coalesece_frames[%d] = %d\n", 43 | (i + 1), cnt); 44 | } 45 | seq_printf(m, "total_isr_cnts = %u\n", stats->num_isrs); 46 | seq_printf(m, "total_event_pop_cnt = %u\n", stats->num_events); 47 | seq_printf(m, "total_event_resubmit_cnt_true = %u\n", 48 | stats->num_events_resubmit); 49 | seq_printf(m, "total_event_resubmit_cnt_false = %u\n", 50 | (stats->num_events - stats->num_events_resubmit)); 51 | 52 | #endif /* DEBUG_MODE_SUPPORT */ 53 | } 54 | 55 | static void 56 | nrf_wifi_wlan_fmac_dbgfs_stats_show_umac(struct seq_file *m, 57 | struct rpu_umac_stats *stats) 58 | { 59 | seq_puts(m, "**************** UMAC STATS ****************\n"); 60 | seq_printf(m, "tx_cmd = %d\n", stats->tx_dbg_params.tx_cmd); 61 | 62 | seq_printf(m, "tx_non_coalesce_pkts_rcvd_from_host = %d\n", 63 | stats->tx_dbg_params.tx_non_coalesce_pkts_rcvd_from_host); 64 | 65 | seq_printf(m, "tx_coalesce_pkts_rcvd_from_host = %d\n", 66 | stats->tx_dbg_params.tx_coalesce_pkts_rcvd_from_host); 67 | 68 | seq_printf(m, "tx_coalesce_pkts_rcvd_from_host = %d\n", 69 | stats->tx_dbg_params.tx_max_coalesce_pkts_rcvd_from_host); 70 | 71 | seq_printf(m, "tx_cmds_max_used = %d\n", 72 | stats->tx_dbg_params.tx_cmds_max_used); 73 | 74 | seq_printf(m, "tx_cmds_currently_in_use = %d\n", 75 | stats->tx_dbg_params.tx_cmds_currently_in_use); 76 | 77 | seq_printf(m, "tx_done_events_send_to_host = %d\n", 78 | stats->tx_dbg_params.tx_done_events_send_to_host); 79 | 80 | seq_printf(m, "tx_done_success_pkts_to_host = %d\n", 81 | stats->tx_dbg_params.tx_done_success_pkts_to_host); 82 | 83 | seq_printf(m, "tx_done_failure_pkts_to_host = %d\n", 84 | stats->tx_dbg_params.tx_done_failure_pkts_to_host); 85 | 86 | seq_printf( 87 | m, "tx_cmds_with_crypto_pkts_rcvd_from_host = %d\n", 88 | stats->tx_dbg_params.tx_cmds_with_crypto_pkts_rcvd_from_host); 89 | 90 | seq_printf(m, "tx_cmds_with_non_cryptot_pkts_rcvd_from_host = %d\n", 91 | stats->tx_dbg_params 92 | .tx_cmds_with_non_crypto_pkts_rcvd_from_host); 93 | 94 | seq_printf( 95 | m, "tx_cmds_with_broadcast_pkts_rcvd_from_host = %d\n", 96 | stats->tx_dbg_params.tx_cmds_with_broadcast_pkts_rcvd_from_host); 97 | 98 | seq_printf( 99 | m, "tx_cmds_with_multicast_pkts_rcvd_from_host = %d\n", 100 | stats->tx_dbg_params.tx_cmds_with_multicast_pkts_rcvd_from_host); 101 | 102 | seq_printf( 103 | m, "tx_cmds_with_unicast_pkts_rcvd_from_host = %d\n", 104 | stats->tx_dbg_params.tx_cmds_with_unicast_pkts_rcvd_from_host); 105 | 106 | seq_printf(m, "xmit = %d\n", stats->tx_dbg_params.xmit); 107 | 108 | seq_printf(m, "send_addba_req = %d\n", 109 | stats->tx_dbg_params.send_addba_req); 110 | 111 | seq_printf(m, "addba_resp = %d\n", stats->tx_dbg_params.addba_resp); 112 | 113 | seq_printf(m, "softmac_tx = %d\n", stats->tx_dbg_params.softmac_tx); 114 | 115 | seq_printf(m, "internal_pkts = %d\n", 116 | stats->tx_dbg_params.internal_pkts); 117 | 118 | seq_printf(m, "external_pkts = %d\n", 119 | stats->tx_dbg_params.external_pkts); 120 | 121 | seq_printf(m, "tx_cmds_to_lmac = %d\n", 122 | stats->tx_dbg_params.tx_cmds_to_lmac); 123 | 124 | seq_printf(m, "tx_dones_from_lmac = %d\n", 125 | stats->tx_dbg_params.tx_dones_from_lmac); 126 | 127 | seq_printf(m, "total_cmds_to_lmac = %d\n", 128 | stats->tx_dbg_params.total_cmds_to_lmac); 129 | 130 | seq_printf(m, "tx_packet_data_count = %d\n", 131 | stats->tx_dbg_params.tx_packet_data_count); 132 | 133 | seq_printf(m, "tx_packet_mgmt_count = %d\n", 134 | stats->tx_dbg_params.tx_packet_mgmt_count); 135 | 136 | seq_printf(m, "tx_packet_beacon_count = %d\n", 137 | stats->tx_dbg_params.tx_packet_beacon_count); 138 | 139 | seq_printf(m, "tx_packet_probe_req_count = %d\n", 140 | stats->tx_dbg_params.tx_packet_probe_req_count); 141 | 142 | seq_printf(m, "tx_packet_auth_count = %d\n", 143 | stats->tx_dbg_params.tx_packet_auth_count); 144 | 145 | seq_printf(m, "tx_packet_deauth_count = %d\n", 146 | stats->tx_dbg_params.tx_packet_deauth_count); 147 | 148 | seq_printf(m, "tx_packet_assoc_req_count = %d\n", 149 | stats->tx_dbg_params.tx_packet_assoc_req_count); 150 | 151 | seq_printf(m, "tx_packet_disassoc_count = %d\n", 152 | stats->tx_dbg_params.tx_packet_disassoc_count); 153 | 154 | seq_printf(m, "tx_packet_action_count = %d\n", 155 | stats->tx_dbg_params.tx_packet_action_count); 156 | 157 | seq_printf(m, "tx_packet_other_mgmt_count = %d\n", 158 | stats->tx_dbg_params.tx_packet_other_mgmt_count); 159 | 160 | seq_printf(m, "tx_packet_non_mgmt_data_count = %d\n", 161 | stats->tx_dbg_params.tx_packet_non_mgmt_data_count); 162 | 163 | seq_printf(m, "lmac_events = %d\n", stats->rx_dbg_params.lmac_events); 164 | 165 | seq_printf(m, "rx_events = %d\n", stats->rx_dbg_params.rx_events); 166 | 167 | seq_printf(m, "rx_coalised_events = %d\n", 168 | stats->rx_dbg_params.rx_coalesce_events); 169 | 170 | seq_printf(m, "total_rx_pkts_from_lmac = %d\n", 171 | stats->rx_dbg_params.total_rx_pkts_from_lmac); 172 | 173 | seq_printf(m, "max_refill_gap = %d\n", 174 | stats->rx_dbg_params.max_refill_gap); 175 | 176 | seq_printf(m, "current_refill_gap = %d\n", 177 | stats->rx_dbg_params.current_refill_gap); 178 | 179 | seq_printf(m, "out_oforedr_mpdus = %d\n", 180 | stats->rx_dbg_params.out_of_order_mpdus); 181 | 182 | seq_printf(m, "reoredr_free_mpdus = %d\n", 183 | stats->rx_dbg_params.reorder_free_mpdus); 184 | 185 | seq_printf(m, "umac_consumed_pkts = %d\n", 186 | stats->rx_dbg_params.umac_consumed_pkts); 187 | 188 | seq_printf(m, "host_consumed_pkts = %d\n", 189 | stats->rx_dbg_params.host_consumed_pkts); 190 | 191 | seq_printf(m, "rx_mbox_post = %d\n", stats->rx_dbg_params.rx_mbox_post); 192 | 193 | seq_printf(m, "rx_mbox_receive = %d\n", 194 | stats->rx_dbg_params.rx_mbox_receive); 195 | 196 | seq_printf(m, "reordering_ampdu = %d\n", 197 | stats->rx_dbg_params.reordering_ampdu); 198 | 199 | seq_printf(m, "timer_mbox_post = %d\n", 200 | stats->rx_dbg_params.timer_mbox_post); 201 | 202 | seq_printf(m, "timer_mbox_rcv = %d\n", 203 | stats->rx_dbg_params.timer_mbox_rcv); 204 | 205 | seq_printf(m, "work_mbox_post = %d\n", 206 | stats->rx_dbg_params.work_mbox_post); 207 | 208 | seq_printf(m, "work_mbox_rcv = %d\n", 209 | stats->rx_dbg_params.work_mbox_rcv); 210 | 211 | seq_printf(m, "tasklet_mbox_post = %d\n", 212 | stats->rx_dbg_params.tasklet_mbox_post); 213 | 214 | seq_printf(m, "tasklet_mbox_rcv = %d\n", 215 | stats->rx_dbg_params.tasklet_mbox_rcv); 216 | 217 | seq_printf(m, "userspace_offload_frames = %d\n", 218 | stats->rx_dbg_params.userspace_offload_frames); 219 | 220 | seq_printf(m, "alloc_buf_fail = %d\n", 221 | stats->rx_dbg_params.alloc_buf_fail); 222 | 223 | seq_printf(m, "rx_packet_total_count = %d\n", 224 | stats->rx_dbg_params.rx_packet_total_count); 225 | 226 | seq_printf(m, "rx_packet_data_count = %d\n", 227 | stats->rx_dbg_params.rx_packet_data_count); 228 | 229 | seq_printf(m, "rx_packet_qos_data_count = %d\n", 230 | stats->rx_dbg_params.rx_packet_qos_data_count); 231 | 232 | seq_printf(m, "rx_packet_protected_data_count = %d\n", 233 | stats->rx_dbg_params.rx_packet_protected_data_count); 234 | 235 | seq_printf(m, "rx_packet_mgmt_count = %d\n", 236 | stats->rx_dbg_params.rx_packet_mgmt_count); 237 | 238 | seq_printf(m, "rx_packet_beacon_count = %d\n", 239 | stats->rx_dbg_params.rx_packet_beacon_count); 240 | 241 | seq_printf(m, "rx_packet_probe_resp_count = %d\n", 242 | stats->rx_dbg_params.rx_packet_probe_resp_count); 243 | 244 | seq_printf(m, "rx_packet_auth_count = %d\n", 245 | stats->rx_dbg_params.rx_packet_auth_count); 246 | 247 | seq_printf(m, "rx_packet_deauth_count = %d\n", 248 | stats->rx_dbg_params.rx_packet_deauth_count); 249 | 250 | seq_printf(m, "rx_packet_assoc_resp_count = %d\n", 251 | stats->rx_dbg_params.rx_packet_assoc_resp_count); 252 | 253 | seq_printf(m, "rx_packet_disassoc_count = %d\n", 254 | stats->rx_dbg_params.rx_packet_disassoc_count); 255 | 256 | seq_printf(m, "rx_packet_action_count = %d\n", 257 | stats->rx_dbg_params.rx_packet_action_count); 258 | 259 | seq_printf(m, "rx_packet_probe_req_count = %d\n", 260 | stats->rx_dbg_params.rx_packet_probe_req_count); 261 | 262 | seq_printf(m, "rx_packet_other_mgmt_count = %d\n", 263 | stats->rx_dbg_params.rx_packet_other_mgmt_count); 264 | 265 | seq_printf(m, "max_coalised_pkts = %d\n", 266 | stats->rx_dbg_params.max_coalesce_pkts); 267 | 268 | seq_printf(m, "null_skb_pointer_from_lmac = %d\n", 269 | stats->rx_dbg_params.null_skb_pointer_from_lmac); 270 | 271 | seq_printf(m, "unexpected_mgmt_pk = %d\n", 272 | stats->rx_dbg_params.unexpected_mgmt_pkt); 273 | 274 | seq_printf(m, "cmd_init = %d\n", stats->cmd_evnt_dbg_params.cmd_init); 275 | 276 | seq_printf(m, "event_init_done = %d\n", 277 | stats->cmd_evnt_dbg_params.event_init_done); 278 | 279 | seq_printf(m, "cmd_get_stats = %d\n", 280 | stats->cmd_evnt_dbg_params.cmd_get_stats); 281 | 282 | seq_printf(m, "event_ps_state = %d\n", 283 | stats->cmd_evnt_dbg_params.event_ps_state); 284 | 285 | seq_printf(m, "cmd_trigger_scan = %d\n", 286 | stats->cmd_evnt_dbg_params.cmd_trigger_scan); 287 | 288 | seq_printf(m, "event_scan_done = %d\n", 289 | stats->cmd_evnt_dbg_params.event_scan_done); 290 | 291 | seq_printf(m, "cmd_get_scan = %d\n", 292 | stats->cmd_evnt_dbg_params.cmd_get_scan); 293 | 294 | seq_printf(m, "cmd_auth = %d\n", stats->cmd_evnt_dbg_params.cmd_auth); 295 | 296 | seq_printf(m, "cmd_assoc = %d\n", stats->cmd_evnt_dbg_params.cmd_assoc); 297 | 298 | seq_printf(m, "cmd_connect = %d\n", 299 | stats->cmd_evnt_dbg_params.cmd_connect); 300 | 301 | seq_printf(m, "cmd_deauth = %d\n", 302 | stats->cmd_evnt_dbg_params.cmd_deauth); 303 | 304 | seq_printf(m, "cmd_register_frame = %d\n", 305 | stats->cmd_evnt_dbg_params.cmd_register_frame); 306 | 307 | seq_printf(m, "cmd_frame = %d\n", stats->cmd_evnt_dbg_params.cmd_frame); 308 | 309 | seq_printf(m, "cmd_del_key = %d\n", 310 | stats->cmd_evnt_dbg_params.cmd_del_key); 311 | 312 | seq_printf(m, "cmd_new_key = %d\n", 313 | stats->cmd_evnt_dbg_params.cmd_new_key); 314 | 315 | seq_printf(m, "cmd_set_key = %d\n", 316 | stats->cmd_evnt_dbg_params.cmd_set_key); 317 | 318 | seq_printf(m, "cmd_set_station = %d\n", 319 | stats->cmd_evnt_dbg_params.cmd_set_station); 320 | 321 | seq_printf(m, "cmd_del_station = %d\n", 322 | stats->cmd_evnt_dbg_params.cmd_del_station); 323 | 324 | seq_printf(m, "cmd_new_interface = %d\n", 325 | stats->cmd_evnt_dbg_params.cmd_new_interface); 326 | 327 | seq_printf(m, "cmd_set_interface = %d\n", 328 | stats->cmd_evnt_dbg_params.cmd_set_interface); 329 | 330 | seq_printf(m, "cmd_set_ifflags = %d\n", 331 | stats->cmd_evnt_dbg_params.cmd_set_ifflags); 332 | 333 | seq_printf(m, "cmd_set_ifflags_done = %d\n", 334 | stats->cmd_evnt_dbg_params.cmd_set_ifflags_done); 335 | 336 | seq_printf(m, "cmd_set_bss = %d\n", 337 | stats->cmd_evnt_dbg_params.cmd_set_bss); 338 | 339 | seq_printf(m, "cmd_set_wiphy = %d\n", 340 | stats->cmd_evnt_dbg_params.cmd_set_wiphy); 341 | 342 | seq_printf(m, "cmd_start_ap = %d\n", 343 | stats->cmd_evnt_dbg_params.cmd_start_ap); 344 | 345 | seq_printf(m, "cmd_rf_test = %d\n", 346 | stats->cmd_evnt_dbg_params.cmd_rf_test); 347 | 348 | seq_printf(m, "LMAC_CMD_PS = %d\n", 349 | stats->cmd_evnt_dbg_params.LMAC_CMD_PS); 350 | 351 | seq_printf(m, "CURR_STATE = %d\n", 352 | stats->cmd_evnt_dbg_params.CURR_STATE); 353 | 354 | seq_printf(m, "tx_unicast_pkt_count = %d\n", 355 | stats->interface_data_stats.tx_unicast_pkt_count); 356 | 357 | seq_printf(m, "tx_multicast_pkt_count = %d\n", 358 | stats->interface_data_stats.tx_multicast_pkt_count); 359 | 360 | seq_printf(m, "tx_broadcast_pkt_count = %d\n", 361 | stats->interface_data_stats.tx_broadcast_pkt_count); 362 | 363 | seq_printf(m, "tx_bytes = %d\n", stats->interface_data_stats.tx_bytes); 364 | 365 | seq_printf(m, "rx_unicast_pkt_count = %d\n", 366 | stats->interface_data_stats.rx_unicast_pkt_count); 367 | 368 | seq_printf(m, "rx_multicast_pkt_count = %d\n", 369 | stats->interface_data_stats.rx_multicast_pkt_count); 370 | 371 | seq_printf(m, "tx_multicast_pkt_count = %d\n", 372 | stats->interface_data_stats.tx_multicast_pkt_count); 373 | 374 | seq_printf(m, "rx_broadcast_pkt_count = %d\n", 375 | stats->interface_data_stats.rx_broadcast_pkt_count); 376 | 377 | seq_printf(m, "rx_beacon_success_count = %d\n", 378 | stats->interface_data_stats.rx_beacon_success_count); 379 | 380 | seq_printf(m, "rx_beacon_miss_count = %d\n", 381 | stats->interface_data_stats.rx_beacon_miss_count); 382 | 383 | seq_printf(m, "rx_bytes = %d\n", stats->interface_data_stats.rx_bytes); 384 | 385 | seq_printf(m, "rx_checksum_error_count = %d\n", 386 | stats->interface_data_stats.rx_checksum_error_count); 387 | 388 | seq_printf(m, "replay_attack_drop_cnt = %d\n", 389 | stats->interface_data_stats.replay_attack_drop_cnt); 390 | } 391 | 392 | static void 393 | nrf_wifi_wlan_fmac_dbgfs_stats_show_lmac(struct seq_file *m, 394 | struct rpu_lmac_stats *stats) 395 | { 396 | seq_puts(m, "************* LMAC STATS ***********\n"); 397 | 398 | seq_printf(m, "resetCmdCnt =%d\n", stats->reset_cmd_cnt); 399 | 400 | seq_printf(m, "resetCompleteEventCnt =%d\n", 401 | stats->reset_complete_event_cnt); 402 | 403 | seq_printf(m, "unableGenEvent =%d\n", stats->unable_gen_event); 404 | 405 | seq_printf(m, "chProgCmdCnt =%d\n", stats->ch_prog_cmd_cnt); 406 | 407 | seq_printf(m, "channelProgDone =%d\n", stats->channel_prog_done); 408 | 409 | seq_printf(m, "txPktCnt =%d\n", stats->tx_pkt_cnt); 410 | 411 | seq_printf(m, "txPktDoneCnt =%d\n", stats->tx_pkt_done_cnt); 412 | 413 | seq_printf(m, "scanPktCnt =%d\n", stats->scan_pkt_cnt); 414 | 415 | seq_printf(m, "internalPktCnt =%d\n", stats->internal_pkt_cnt); 416 | 417 | seq_printf(m, "internalPktDoneCnt =%d\n", stats->internal_pkt_done_cnt); 418 | 419 | seq_printf(m, "ackRespCnt =%d\n", stats->ack_resp_cnt); 420 | 421 | seq_printf(m, "txTimeout =%d\n", stats->tx_timeout); 422 | 423 | seq_printf(m, "deaggIsr =%d\n", stats->deagg_isr); 424 | 425 | seq_printf(m, "deaggInptrDescEmpty =%d\n", 426 | stats->deagg_inptr_desc_empty); 427 | 428 | seq_printf(m, "deaggCircularBufferFull =%d\n", 429 | stats->deagg_circular_buffer_full); 430 | 431 | seq_printf(m, "lmacRxisrCnt =%d\n", stats->lmac_rxisr_cnt); 432 | 433 | seq_printf(m, "rxDecryptcnt =%d\n", stats->rx_decryptcnt); 434 | 435 | seq_printf(m, "processDecryptFail =%d\n", stats->process_decrypt_fail); 436 | 437 | seq_printf(m, "prepaRxEventFail =%d\n", stats->prepa_rx_event_fail); 438 | 439 | seq_printf(m, "rxCorePoolFullCnt =%d\n", stats->rx_core_pool_full_cnt); 440 | 441 | seq_printf(m, "rxMpduCrcSuccessCnt =%d\n", 442 | stats->rx_mpdu_crc_success_cnt); 443 | 444 | seq_printf(m, "rxMpduCrcFailCnt =%d\n", stats->rx_mpdu_crc_fail_cnt); 445 | 446 | seq_printf(m, "rxOfdmCrcSuccessCnt =%d\n", 447 | stats->rx_ofdm_crc_success_cnt); 448 | 449 | seq_printf(m, "rxOfdmCrcFailCnt =%d\n", stats->rx_ofdm_crc_fail_cnt); 450 | 451 | seq_printf(m, "rxDSSSCrcSuccessCnt =%d\n", stats->rxDSSSCrcSuccessCnt); 452 | 453 | seq_printf(m, "rxDSSSCrcFailCnt =%d\n", stats->rxDSSSCrcFailCnt); 454 | 455 | seq_printf(m, "rxCryptoStartCnt =%d\n", stats->rx_crypto_start_cnt); 456 | 457 | seq_printf(m, "rxCryptoDoneCnt =%d\n", stats->rx_crypto_done_cnt); 458 | 459 | seq_printf(m, "rxEventBufFull =%d\n", stats->rx_event_buf_full); 460 | 461 | seq_printf(m, "rxExtramBufFull =%d\n", stats->rx_extram_buf_full); 462 | 463 | seq_printf(m, "scanReq =%d\n", stats->scan_req); 464 | 465 | seq_printf(m, "scanComplete =%d\n", stats->scan_complete); 466 | 467 | seq_printf(m, "scanAbortReq =%d\n", stats->scan_abort_req); 468 | 469 | seq_printf(m, "scanAbortComplete =%d\n", stats->scan_abort_complete); 470 | 471 | seq_printf(m, "internalBufPoolNull =%d\n", 472 | stats->internal_buf_pool_null); 473 | 474 | #ifdef DEBUG_MODE_SUPPORT 475 | #endif /* DEBUG_MODE_SUPPORT */ 476 | } 477 | #endif /* !CONFIG_NRF700X_RADIO_TEST */ 478 | 479 | static void nrf_wifi_wlan_fmac_dbgfs_stats_show_phy(struct seq_file *m, 480 | #ifdef CONFIG_NRF700X_RADIO_TEST 481 | int op_mode, 482 | #endif /* CONFIG_NRF700X_RADIO_TEST */ 483 | struct rpu_phy_stats *stats) 484 | { 485 | seq_puts(m, "************* PHY STATS ***********\n"); 486 | 487 | seq_printf(m, "rssi_avg = %d dBm\n", stats->rssi_avg); 488 | 489 | #ifdef CONFIG_NRF700X_RADIO_TEST 490 | if (op_mode == RPU_OP_MODE_FCM) 491 | seq_printf(m, "pdout_val = %d\n", stats->pdout_val); 492 | #endif /* CONFIG_NRF700X_RADIO_TEST */ 493 | 494 | seq_printf(m, "ofdm_crc32_pass_cnt=%d\n", stats->ofdm_crc32_pass_cnt); 495 | 496 | seq_printf(m, "ofdm_crc32_fail_cnt=%d\n", stats->ofdm_crc32_fail_cnt); 497 | 498 | seq_printf(m, "dsss_crc32_pass_cnt=%d\n", stats->dsss_crc32_pass_cnt); 499 | 500 | seq_printf(m, "dsss_crc32_fail_cnt=%d\n", stats->dsss_crc32_fail_cnt); 501 | } 502 | 503 | static int nrf_wifi_wlan_fmac_dbgfs_stats_show(struct seq_file *m, void *v) 504 | { 505 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 506 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 507 | #ifdef DEBUG_MODE_SUPPORT 508 | int stats_type = RPU_STATS_TYPE_ALL; 509 | #endif /* DEBUG_MODE_SUPPORT */ 510 | int op_mode = RPU_OP_MODE_MAX; 511 | struct rpu_op_stats *stats = NULL; 512 | #ifdef CONFIG_NRF700X_RADIO_TEST 513 | unsigned int i = 0; 514 | #endif 515 | rpu_ctx_lnx = (struct nrf_wifi_ctx_lnx *)m->private; 516 | #ifdef CONFIG_NRF700X_RADIO_TEST 517 | op_mode = rpu_ctx_lnx->conf_params.op_mode, 518 | #endif 519 | 520 | stats = kzalloc(sizeof(*stats), GFP_KERNEL); 521 | 522 | status = nrf_wifi_fmac_stats_get(rpu_ctx_lnx->rpu_ctx, 523 | #ifdef DEBUG_MODE_SUPPORT 524 | stats_type, 525 | #endif /* DEBUG_MODE_SUPPORT */ 526 | op_mode, stats); 527 | 528 | if (status != NRF_WIFI_STATUS_SUCCESS) { 529 | pr_err("%s: nrf_wifi_fmac_stats_get failed\n", __func__); 530 | goto out; 531 | } 532 | 533 | #ifndef CONFIG_NRF700X_RADIO_TEST 534 | #ifdef DEBUG_MODE_SUPPORT 535 | if ((stats_type == RPU_STATS_TYPE_ALL) || 536 | (stats_type == RPU_STATS_TYPE_HOST)) 537 | #endif /* DEBUG_MODE_SUPPORT */ 538 | nrf_wifi_wlan_fmac_dbgfs_stats_show_host( 539 | m, rpu_ctx_lnx->rpu_ctx, &stats->host); 540 | 541 | #ifdef DEBUG_MODE_SUPPORT 542 | if ((stats_type == RPU_STATS_TYPE_ALL) || 543 | (stats_type == RPU_STATS_TYPE_UMAC)) 544 | #endif /* DEBUG_MODE_SUPPORT */ 545 | nrf_wifi_wlan_fmac_dbgfs_stats_show_umac(m, &stats->fw.umac); 546 | 547 | #ifdef DEBUG_MODE_SUPPORT 548 | if ((stats_type == RPU_STATS_TYPE_ALL) || 549 | (stats_type == RPU_STATS_TYPE_LMAC)) 550 | #endif /* DEBUG_MODE_SUPPORT */ 551 | nrf_wifi_wlan_fmac_dbgfs_stats_show_lmac(m, &stats->fw.lmac); 552 | 553 | #endif 554 | #ifdef DEBUG_MODE_SUPPORT 555 | if ((stats_type == RPU_STATS_TYPE_ALL) || 556 | (stats_type == RPU_STATS_TYPE_PHY)) 557 | #endif /* DEBUG_MODE_SUPPORT */ 558 | nrf_wifi_wlan_fmac_dbgfs_stats_show_phy(m, 559 | #ifdef CONFIG_NRF700X_RADIO_TEST 560 | op_mode, 561 | #endif /* CONFIG_NRF700X_RADIO_TEST */ 562 | &stats->fw.phy); 563 | #ifndef CONFIG_NRF700X_RADIO_TEST 564 | switch (rpu_ctx_lnx->twt_params.status) { 565 | case 0: 566 | seq_printf(m, "sta_status = DISCONNECTED\n"); 567 | break; 568 | case 1: 569 | seq_printf(m, "sta_status = CONNECTED\n"); 570 | break; 571 | default: 572 | break; 573 | } 574 | 575 | seq_puts(m, "************* TWT CMD INFO ***********\n"); 576 | seq_printf(m, "twt_flow_id = %d\n", 577 | rpu_ctx_lnx->twt_params.twt_cmd.twt_flow_id); 578 | seq_printf(m, "neg_type = %d\n", 579 | rpu_ctx_lnx->twt_params.twt_cmd.neg_type); 580 | seq_printf(m, "setup_cmd = %d\n", 581 | rpu_ctx_lnx->twt_params.twt_cmd.setup_cmd); 582 | seq_printf(m, "ap_trigger_frame = %d\n", 583 | rpu_ctx_lnx->twt_params.twt_cmd.ap_trigger_frame); 584 | seq_printf(m, "is_implicit = %d\n", 585 | rpu_ctx_lnx->twt_params.twt_cmd.is_implicit); 586 | seq_printf(m, "setup_cmd = %d\n", 587 | rpu_ctx_lnx->twt_params.twt_cmd.setup_cmd); 588 | seq_printf(m, "twt_flow_type = %d\n", 589 | rpu_ctx_lnx->twt_params.twt_cmd.twt_flow_type); 590 | seq_printf(m, "twt_target_wake_interval_exponent = %d\n", 591 | rpu_ctx_lnx->twt_params.twt_cmd 592 | .twt_target_wake_interval_exponent); 593 | seq_printf(m, "twt_target_wake_interval_mantissa = %d\n", 594 | rpu_ctx_lnx->twt_params.twt_cmd 595 | .twt_target_wake_interval_mantissa); 596 | seq_printf( 597 | m, "twt_nominal_min_twt_wake_duration = %d\n", 598 | rpu_ctx_lnx->twt_params.twt_cmd.nominal_min_twt_wake_duration); 599 | seq_printf(m, "target_wake_time = %llu\n", 600 | rpu_ctx_lnx->twt_params.twt_cmd.target_wake_time); 601 | 602 | seq_puts(m, "\n************* TWT RESPONSE EVENT INFO ***********\n"); 603 | if (rpu_ctx_lnx->twt_params.twt_event_info_avail) { 604 | seq_printf(m, "twt_flow_id = %d\n", 605 | rpu_ctx_lnx->twt_params.twt_event.twt_flow_id); 606 | seq_printf(m, "neg_type = %d\n", 607 | rpu_ctx_lnx->twt_params.twt_event.neg_type); 608 | seq_printf(m, "setup_cmd = %d\n", 609 | rpu_ctx_lnx->twt_params.twt_event.setup_cmd); 610 | seq_printf(m, "ap_trigger_frame = %d\n", 611 | rpu_ctx_lnx->twt_params.twt_event.ap_trigger_frame); 612 | seq_printf(m, "is_implicit = %d\n", 613 | rpu_ctx_lnx->twt_params.twt_event.is_implicit); 614 | seq_printf(m, "setup_cmd = %d\n", 615 | rpu_ctx_lnx->twt_params.twt_event.setup_cmd); 616 | seq_printf(m, "twt_flow_type = %d\n", 617 | rpu_ctx_lnx->twt_params.twt_event.twt_flow_type); 618 | seq_printf(m, "twt_target_wake_interval_exponent = %d\n", 619 | rpu_ctx_lnx->twt_params.twt_event 620 | .twt_target_wake_interval_exponent); 621 | seq_printf(m, "twt_target_wake_interval_mantissa = %d\n", 622 | rpu_ctx_lnx->twt_params.twt_event 623 | .twt_target_wake_interval_mantissa); 624 | seq_printf(m, "twt_nominal_min_twt_wake_duration = %d\n", 625 | rpu_ctx_lnx->twt_params.twt_event 626 | .nominal_min_twt_wake_duration); 627 | seq_printf(m, "target_wake_time = %llu\n", 628 | rpu_ctx_lnx->twt_params.twt_event.target_wake_time); 629 | } 630 | seq_puts(m, "\n************* TWT TEAR DOWN EVENT INFO ***********\n"); 631 | switch (rpu_ctx_lnx->twt_params.teardown_reason) { 632 | case 0: 633 | seq_printf(m, "twt_teardown_reason = INVALID_TSF\n"); 634 | break; 635 | case 1: 636 | seq_printf(m, "twt_teardown_reason = OUT_OF_SYNC\n"); 637 | break; 638 | case 2: 639 | seq_printf( 640 | m, 641 | "twt_teardown_reason = DELAY_IN_TWT_UMAC_SLEEP_RESPONSE\n"); 642 | break; 643 | case 3: 644 | seq_printf( 645 | m, 646 | "twt_teardown_reason = INVALID_TWT_WAKE_INTERVAL\n"); 647 | break; 648 | default: 649 | break; 650 | } 651 | seq_printf(m, "teardown_event_cnt = %d\n", 652 | rpu_ctx_lnx->twt_params.teardown_event_cnt); 653 | #endif 654 | 655 | #ifdef CONFIG_NRF700X_RADIO_TEST 656 | if (rpu_ctx_lnx->rx_cap_buf) { 657 | seq_puts(m, "\n************* RX capture data ***********\n"); 658 | 659 | for (i = 0; i < (rpu_ctx_lnx->conf_params.capture_length); 660 | i++) { 661 | seq_printf(m, "%02X%02X%02X\n", 662 | rpu_ctx_lnx->rx_cap_buf[i * 3 + 2], 663 | rpu_ctx_lnx->rx_cap_buf[i * 3 + 1], 664 | rpu_ctx_lnx->rx_cap_buf[i * 3 + 0]); 665 | } 666 | kfree(rpu_ctx_lnx->rx_cap_buf); 667 | rpu_ctx_lnx->rx_cap_buf = NULL; 668 | } 669 | #endif 670 | out: 671 | return status; 672 | } 673 | 674 | static int open_stats(struct inode *inode, struct file *file) 675 | { 676 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = 677 | (struct nrf_wifi_ctx_lnx *)inode->i_private; 678 | 679 | return single_open(file, nrf_wifi_wlan_fmac_dbgfs_stats_show, 680 | rpu_ctx_lnx); 681 | } 682 | 683 | static const struct file_operations fops_wlan_fmac_stats = { 684 | .open = open_stats, 685 | .read = seq_read, 686 | .llseek = seq_lseek, 687 | .write = NULL, 688 | .release = single_release 689 | }; 690 | 691 | int nrf_wifi_wlan_fmac_dbgfs_stats_init(struct dentry *root, 692 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx) 693 | { 694 | int ret = 0; 695 | 696 | if ((!root) || (!rpu_ctx_lnx)) { 697 | pr_err("%s: Invalid parameters\n", __func__); 698 | ret = -EINVAL; 699 | goto fail; 700 | } 701 | 702 | rpu_ctx_lnx->dbgfs_wlan_stats_root = debugfs_create_file( 703 | "stats", 0444, root, rpu_ctx_lnx, &fops_wlan_fmac_stats); 704 | 705 | if (!rpu_ctx_lnx->dbgfs_wlan_stats_root) { 706 | pr_err("%s: Failed to create debugfs entry\n", __func__); 707 | ret = -ENOMEM; 708 | goto fail; 709 | } 710 | 711 | goto out; 712 | 713 | fail: 714 | nrf_wifi_wlan_fmac_dbgfs_stats_deinit(rpu_ctx_lnx); 715 | 716 | out: 717 | return ret; 718 | } 719 | 720 | void nrf_wifi_wlan_fmac_dbgfs_stats_deinit(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx) 721 | { 722 | if (rpu_ctx_lnx->dbgfs_wlan_stats_root) 723 | debugfs_remove(rpu_ctx_lnx->dbgfs_wlan_stats_root); 724 | 725 | rpu_ctx_lnx->dbgfs_wlan_stats_root = NULL; 726 | } 727 | -------------------------------------------------------------------------------- /src/debugfs/wlan_fmac_twt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "fmac_api.h" 12 | #include "fmac_dbgfs_if.h" 13 | #include "net_stack.h" 14 | #include "osal_ops.h" 15 | #include "util.h" 16 | 17 | int twt_setup_event; 18 | 19 | void nrf_wifi_wlan_fmac_twt_init(struct rpu_twt_params *twt_params) 20 | { 21 | memset(twt_params, 0, sizeof(*twt_params)); 22 | twt_params->teardown_reason = -1; 23 | /* Initialize values which are other than 0 */ 24 | } 25 | 26 | static __always_inline unsigned char 27 | param_get_val(unsigned char *buf, unsigned char *str, unsigned long *val) 28 | { 29 | unsigned char *temp = NULL; 30 | 31 | if (strstr(buf, str)) { 32 | temp = strstr(buf, "=") + 1; 33 | if (!kstrtoul(temp, 0, val)) { 34 | return 1; 35 | } else { 36 | return 0; 37 | } 38 | } else { 39 | return 0; 40 | } 41 | } 42 | 43 | static __always_inline unsigned char param_get_match(unsigned char *buf, 44 | unsigned char *str) 45 | { 46 | if (strstr(buf, str)) 47 | return 1; 48 | else 49 | return 0; 50 | } 51 | 52 | static ssize_t nrf_wifi_wlan_twt_write(struct file *file, 53 | const char __user *in_buf, size_t count, 54 | loff_t *ppos) 55 | { 56 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 57 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 58 | struct nrf_wifi_fmac_dev_ctx *fmac_ctx = NULL; 59 | struct nrf_wifi_umac_cmd_config_twt *twt_setup_cmd = NULL; 60 | struct nrf_wifi_umac_cmd_teardown_twt *twt_teardown_cmd = NULL; 61 | const struct nrf_wifi_osal_ops *osal_ops = NULL; 62 | char *conf_buf = NULL; 63 | char err_str[MAX_ERR_STR_SIZE]; 64 | size_t ret_val = count; 65 | unsigned long val = 0; 66 | unsigned long start_time_us = 0; 67 | int twt_retry_attempt = 0; 68 | char *tok_s = NULL; 69 | 70 | rpu_ctx_lnx = (struct nrf_wifi_ctx_lnx *)file->f_inode->i_private; 71 | fmac_ctx = (struct nrf_wifi_fmac_dev_ctx *)(rpu_ctx_lnx->rpu_ctx); 72 | osal_ops = fmac_ctx->fpriv->opriv->ops; 73 | 74 | if (count >= MAX_CONF_BUF_SIZE) { 75 | snprintf(err_str, MAX_ERR_STR_SIZE, 76 | "Size of input buffer cannot be more than %d chars\n", 77 | MAX_CONF_BUF_SIZE); 78 | 79 | ret_val = -EFAULT; 80 | goto error; 81 | } 82 | 83 | conf_buf = kzalloc(MAX_CONF_BUF_SIZE, GFP_KERNEL); 84 | 85 | if (!conf_buf) { 86 | snprintf(err_str, MAX_ERR_STR_SIZE, 87 | "Not enough memory available\n"); 88 | 89 | ret_val = -EFAULT; 90 | goto error; 91 | } 92 | 93 | if (copy_from_user(conf_buf, in_buf, count)) { 94 | snprintf(err_str, MAX_ERR_STR_SIZE, 95 | "Copy from input buffer failed\n"); 96 | 97 | ret_val = -EFAULT; 98 | goto error; 99 | } 100 | 101 | conf_buf[count - 1] = '\0'; 102 | 103 | tok_s = strstr(conf_buf, "twt_setup "); 104 | 105 | if (tok_s) { 106 | memcpy(rpu_ctx_lnx->twt_params.twt_setup_cmd, conf_buf, 200); 107 | 108 | tok_s = strstr(conf_buf, " negotiation="); 109 | if (tok_s) { 110 | sscanf(tok_s + strlen(" negotiation="), "%lu", &val); 111 | rpu_ctx_lnx->twt_params.twt_cmd.neg_type = val; 112 | } 113 | 114 | tok_s = strstr(conf_buf, " exponent="); 115 | if (tok_s) { 116 | sscanf(tok_s + strlen(" exponent="), "%lu", &val); 117 | rpu_ctx_lnx->twt_params.twt_cmd 118 | .twt_target_wake_interval_exponent = val; 119 | } 120 | 121 | tok_s = strstr(conf_buf, " mantissa="); 122 | if (tok_s) { 123 | sscanf(tok_s + strlen(" mantissa="), "%lu", &val); 124 | rpu_ctx_lnx->twt_params.twt_cmd 125 | .twt_target_wake_interval_mantissa = val; 126 | } 127 | 128 | tok_s = strstr(conf_buf, " min_twt="); 129 | if (tok_s) { 130 | sscanf(tok_s + strlen(" min_twt="), "%lu", &val); 131 | rpu_ctx_lnx->twt_params.twt_cmd 132 | .nominal_min_twt_wake_duration = val; 133 | } 134 | 135 | tok_s = strstr(conf_buf, " setup_cmd="); 136 | if (tok_s) { 137 | sscanf(tok_s + strlen(" setup_cmd="), "%lu", &val); 138 | rpu_ctx_lnx->twt_params.twt_cmd.setup_cmd = val; 139 | } 140 | 141 | tok_s = strstr(conf_buf, " twt="); 142 | if (tok_s) { 143 | unsigned long long twt = 0; 144 | sscanf(tok_s + strlen(" twt="), "%llu", &twt); 145 | rpu_ctx_lnx->twt_params.twt_cmd.target_wake_time = twt; 146 | } 147 | 148 | tok_s = strstr(conf_buf, " trigger="); 149 | if (tok_s) { 150 | sscanf(tok_s + strlen(" trigger="), "%lu", &val); 151 | rpu_ctx_lnx->twt_params.twt_cmd.ap_trigger_frame = val; 152 | } 153 | 154 | tok_s = strstr(conf_buf, " implicit="); 155 | if (tok_s) { 156 | sscanf(tok_s + strlen(" implicit="), "%lu", &val); 157 | rpu_ctx_lnx->twt_params.twt_cmd.is_implicit = val; 158 | } 159 | 160 | tok_s = strstr(conf_buf, " flow_type="); 161 | if (tok_s) { 162 | sscanf(tok_s + strlen(" flow_type="), "%lu", &val); 163 | rpu_ctx_lnx->twt_params.twt_cmd.twt_flow_type = val; 164 | } 165 | 166 | tok_s = strstr(conf_buf, " flow_id="); 167 | if (tok_s) { 168 | sscanf(tok_s + strlen(" flow_id="), "%lu", &val); 169 | rpu_ctx_lnx->twt_params.twt_cmd.twt_flow_id = val; 170 | } 171 | 172 | twt_setup_cmd = kzalloc(sizeof(*twt_setup_cmd), GFP_KERNEL); 173 | 174 | if (!twt_setup_cmd) { 175 | pr_err("%s: Unable to allocate memory\n", __func__); 176 | goto out; 177 | } 178 | twt_setup_cmd->umac_hdr.cmd_evnt = NRF_WIFI_UMAC_CMD_CONFIG_TWT; 179 | twt_setup_cmd->umac_hdr.ids.wdev_id = 0; 180 | twt_setup_cmd->umac_hdr.ids.valid_fields |= 181 | NRF_WIFI_INDEX_IDS_WDEV_ID_VALID; 182 | 183 | twt_setup_cmd->info.twt_flow_id = 184 | rpu_ctx_lnx->twt_params.twt_cmd.twt_flow_id; 185 | twt_setup_cmd->info.neg_type = 186 | rpu_ctx_lnx->twt_params.twt_cmd.neg_type; 187 | twt_setup_cmd->info.setup_cmd = 188 | rpu_ctx_lnx->twt_params.twt_cmd.setup_cmd; 189 | twt_setup_cmd->info.ap_trigger_frame = 190 | rpu_ctx_lnx->twt_params.twt_cmd.ap_trigger_frame; 191 | twt_setup_cmd->info.is_implicit = 192 | rpu_ctx_lnx->twt_params.twt_cmd.is_implicit; 193 | twt_setup_cmd->info.twt_flow_type = 194 | rpu_ctx_lnx->twt_params.twt_cmd.twt_flow_type; 195 | twt_setup_cmd->info.twt_target_wake_interval_exponent = 196 | rpu_ctx_lnx->twt_params.twt_cmd 197 | .twt_target_wake_interval_exponent; 198 | twt_setup_cmd->info.twt_target_wake_interval_mantissa = 199 | rpu_ctx_lnx->twt_params.twt_cmd 200 | .twt_target_wake_interval_mantissa; 201 | twt_setup_cmd->info.target_wake_time = 202 | rpu_ctx_lnx->twt_params.twt_cmd.target_wake_time; 203 | twt_setup_cmd->info.nominal_min_twt_wake_duration = 204 | rpu_ctx_lnx->twt_params.twt_cmd 205 | .nominal_min_twt_wake_duration; 206 | retry_twt: 207 | twt_setup_event = 0; 208 | status = umac_cmd_cfg(fmac_ctx, twt_setup_cmd, 209 | sizeof(*twt_setup_cmd)); 210 | 211 | if (status != NRF_WIFI_STATUS_SUCCESS) { 212 | pr_err("TWT SETUP_CMD failed\n"); 213 | goto out; 214 | } 215 | 216 | start_time_us = osal_ops->time_get_curr_us(); 217 | 218 | while (!twt_setup_event) { 219 | #define MAX_TWT_WAIT (1 * 1000 * 1000) 220 | if (osal_ops->time_elapsed_us(start_time_us) >= 221 | MAX_TWT_WAIT) 222 | break; 223 | } 224 | 225 | if (!twt_setup_event) { 226 | // osal_ops->log_err("%s: TWT SETUP timed out attempt=%d\n", 227 | // __func__, twt_retry_attempt); 228 | if (++twt_retry_attempt != 2) 229 | goto retry_twt; 230 | // else 231 | // osal_ops->log_err("%s: TWT SETUP timed out\n", __func__); 232 | } 233 | if (twt_setup_cmd) 234 | kfree(twt_setup_cmd); 235 | 236 | goto out; 237 | } 238 | 239 | tok_s = strstr(conf_buf, "twt_teardown"); 240 | if (tok_s) { 241 | tok_s = strstr(conf_buf, " flow_id="); 242 | if (tok_s) { 243 | param_get_val(tok_s, "flow_id=", &val); 244 | if (val == 245 | rpu_ctx_lnx->twt_params.twt_cmd.twt_flow_id) { 246 | twt_teardown_cmd = kzalloc( 247 | sizeof(*twt_teardown_cmd), GFP_KERNEL); 248 | if (!twt_teardown_cmd) { 249 | pr_err("%s: Unable to allocate memory\n", 250 | __func__); 251 | goto out; 252 | } 253 | twt_teardown_cmd->umac_hdr.cmd_evnt = 254 | NRF_WIFI_UMAC_CMD_TEARDOWN_TWT; 255 | twt_teardown_cmd->umac_hdr.ids.wdev_id = 0; 256 | twt_teardown_cmd->umac_hdr.ids.valid_fields |= 257 | NRF_WIFI_INDEX_IDS_WDEV_ID_VALID; 258 | 259 | status = 260 | umac_cmd_cfg(fmac_ctx, twt_teardown_cmd, 261 | sizeof(*twt_teardown_cmd)); 262 | if (twt_teardown_cmd) 263 | kfree(twt_teardown_cmd); 264 | 265 | goto out; 266 | } 267 | } 268 | } 269 | error: 270 | pr_err("Error condition: %s\n", err_str); 271 | 272 | out: 273 | if (conf_buf) 274 | kfree(conf_buf); 275 | 276 | return ret_val; 277 | } 278 | 279 | static int nrf_wifi_wlan_fmac_dbgfs_twt_show(struct seq_file *m, void *v) 280 | { 281 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 282 | 283 | rpu_ctx_lnx = (struct nrf_wifi_ctx_lnx *)m->private; 284 | 285 | return 0; 286 | } 287 | 288 | static int nrf_wifi_wlan_twt_open(struct inode *inode, struct file *file) 289 | { 290 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = 291 | (struct nrf_wifi_ctx_lnx *)inode->i_private; 292 | 293 | return single_open(file, nrf_wifi_wlan_fmac_dbgfs_twt_show, 294 | rpu_ctx_lnx); 295 | } 296 | 297 | static const struct file_operations fops_wlan_twt = { 298 | .open = nrf_wifi_wlan_twt_open, 299 | .read = seq_read, 300 | .llseek = seq_lseek, 301 | .write = nrf_wifi_wlan_twt_write, 302 | .release = single_release 303 | }; 304 | 305 | int nrf_wifi_wlan_fmac_dbgfs_twt_init(struct dentry *root, 306 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx) 307 | { 308 | int ret = 0; 309 | 310 | nrf_wifi_wlan_fmac_twt_init(&rpu_ctx_lnx->twt_params); 311 | 312 | if ((!root) || (!rpu_ctx_lnx)) { 313 | pr_err("%s: Invalid parameters\n", __func__); 314 | ret = -EINVAL; 315 | goto fail; 316 | } 317 | 318 | rpu_ctx_lnx->dbgfs_nrf_wifi_twt_root = debugfs_create_file( 319 | "twt", 0644, root, rpu_ctx_lnx, &fops_wlan_twt); 320 | 321 | if (!rpu_ctx_lnx->dbgfs_nrf_wifi_twt_root) { 322 | pr_err("%s: Failed to create debugfs entry\n", __func__); 323 | ret = -ENOMEM; 324 | goto fail; 325 | } 326 | 327 | goto out; 328 | 329 | fail: 330 | nrf_wifi_wlan_fmac_dbgfs_twt_deinit(rpu_ctx_lnx); 331 | out: 332 | return ret; 333 | } 334 | 335 | void nrf_wifi_wlan_fmac_dbgfs_twt_deinit(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx) 336 | { 337 | if (rpu_ctx_lnx->dbgfs_nrf_wifi_twt_root) 338 | debugfs_remove(rpu_ctx_lnx->dbgfs_nrf_wifi_twt_root); 339 | 340 | rpu_ctx_lnx->dbgfs_nrf_wifi_twt_root = NULL; 341 | } 342 | -------------------------------------------------------------------------------- /src/debugfs/wlan_fmac_ver.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #include 8 | 9 | #include "fmac_api.h" 10 | #include "fmac_dbgfs_if.h" 11 | 12 | extern struct nrf_wifi_drv_priv_lnx rpu_drv_priv; 13 | 14 | static int nrf_wifi_wlan_fmac_dbgfs_ver_show(struct seq_file *m, void *v) 15 | { 16 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 17 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 18 | struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; 19 | unsigned int fw_ver; 20 | 21 | rpu_ctx_lnx = (struct nrf_wifi_ctx_lnx *)m->private; 22 | 23 | fmac_dev_ctx = rpu_ctx_lnx->rpu_ctx; 24 | 25 | status = nrf_wifi_fmac_ver_get(fmac_dev_ctx, &fw_ver); 26 | 27 | seq_printf(m, "Driver : %s\n", NRF_WIFI_FMAC_DRV_VER); 28 | 29 | seq_printf(m, "UMAC : %d.%d.%d.%d\n", NRF_WIFI_UMAC_VER(fw_ver), 30 | NRF_WIFI_UMAC_VER_MAJ(fw_ver), NRF_WIFI_UMAC_VER_MIN(fw_ver), 31 | NRF_WIFI_UMAC_VER_EXTRA(fw_ver)); 32 | return NRF_WIFI_STATUS_SUCCESS; 33 | } 34 | 35 | static int open_ver(struct inode *inode, struct file *file) 36 | { 37 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = 38 | (struct nrf_wifi_ctx_lnx *)inode->i_private; 39 | 40 | return single_open(file, nrf_wifi_wlan_fmac_dbgfs_ver_show, 41 | rpu_ctx_lnx); 42 | } 43 | 44 | static const struct file_operations fops_ver = { .open = open_ver, 45 | .read = seq_read, 46 | .llseek = seq_lseek, 47 | .write = NULL, 48 | .release = single_release }; 49 | 50 | int nrf_wifi_wlan_fmac_dbgfs_ver_init(struct dentry *root, 51 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx) 52 | { 53 | int ret = 0; 54 | 55 | if ((!root) || (!rpu_ctx_lnx)) { 56 | pr_err("%s: Invalid parameters\n", __func__); 57 | ret = -EINVAL; 58 | goto fail; 59 | } 60 | 61 | rpu_drv_priv.dbgfs_ver_root = debugfs_create_file( 62 | "version", 0444, root, rpu_ctx_lnx, &fops_ver); 63 | 64 | if (!rpu_drv_priv.dbgfs_ver_root) { 65 | pr_err("%s: Failed to create debugfs entry\n", __func__); 66 | ret = -ENOMEM; 67 | goto fail; 68 | } 69 | 70 | goto out; 71 | 72 | fail: 73 | nrf_wifi_wlan_fmac_dbgfs_ver_deinit(); 74 | 75 | out: 76 | return ret; 77 | } 78 | 79 | void nrf_wifi_wlan_fmac_dbgfs_ver_deinit(void) 80 | { 81 | if (rpu_drv_priv.dbgfs_ver_root) 82 | debugfs_remove(rpu_drv_priv.dbgfs_ver_root); 83 | 84 | rpu_drv_priv.dbgfs_ver_root = NULL; 85 | } 86 | -------------------------------------------------------------------------------- /src/linux_util.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | int hex_str_to_val(unsigned char *hex_arr, unsigned int hex_arr_sz, 11 | unsigned char *str) 12 | { 13 | int i = 0; 14 | int j = 0; 15 | unsigned char ch = 0; 16 | unsigned char val = 0; 17 | int len = 0; 18 | 19 | len = strlen(str); 20 | 21 | if (len / 2 > hex_arr_sz) { 22 | pr_err("%s: String length (%d) greater than array size (%d)\n", 23 | __func__, len, hex_arr_sz); 24 | return -1; 25 | } 26 | 27 | if (len % 2) { 28 | pr_err("%s:String length = %d, is not the multiple of 2\n", 29 | __func__, len); 30 | return -1; 31 | } 32 | 33 | for (i = 0; i < len; i++) { 34 | /* Convert to lower case */ 35 | ch = ((str[i] >= 'A' && str[i] <= 'Z') ? str[i] + 32 : str[i]); 36 | 37 | if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f')) { 38 | pr_err("%s: Invalid hex character in string %d\n", 39 | __func__, ch); 40 | return -1; 41 | } 42 | 43 | if (ch >= '0' && ch <= '9') 44 | ch = ch - '0'; 45 | else 46 | ch = ch - 'a' + 10; 47 | 48 | val += ch; 49 | 50 | if (!(i % 2)) 51 | val <<= 4; 52 | else { 53 | hex_arr[j] = val; 54 | j++; 55 | val = 0; 56 | } 57 | } 58 | 59 | return j; 60 | } 61 | -------------------------------------------------------------------------------- /src/netdev.c: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_NRF700X_RADIO_TEST 2 | /* 3 | * Copyright (c) 2023 Nordic Semiconductor ASA 4 | * 5 | * SPDX-License-Identifier: GPL-2.0 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "host_rpu_umac_if.h" 13 | #include "main.h" 14 | #include "fmac_main.h" 15 | #include "fmac_api.h" 16 | #include "fmac_util.h" 17 | #include "queue.h" 18 | 19 | #ifdef CONFIG_NRF700X_DATA_TX 20 | 21 | static void nrf_cfg80211_data_tx_routine(struct work_struct *w) 22 | { 23 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = 24 | container_of(w, struct nrf_wifi_fmac_vif_ctx_lnx, ws_data_tx); 25 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 26 | struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; 27 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 28 | void *netbuf = NULL; 29 | 30 | rpu_ctx_lnx = vif_ctx_lnx->rpu_ctx; 31 | fmac_dev_ctx = rpu_ctx_lnx->rpu_ctx; 32 | 33 | netbuf = nrf_wifi_utils_q_dequeue(fmac_dev_ctx->fpriv->opriv, 34 | vif_ctx_lnx->data_txq); 35 | if (netbuf == NULL) { 36 | pr_err("%s: fail to get tx data from queue\n", __func__); 37 | return; 38 | } 39 | 40 | status = nrf_wifi_fmac_start_xmit(rpu_ctx_lnx->rpu_ctx, 41 | vif_ctx_lnx->if_idx, netbuf); 42 | if (status != NRF_WIFI_STATUS_SUCCESS) { 43 | pr_err("%s: nrf_wifi_fmac_start_xmit failed\n", __func__); 44 | } 45 | 46 | if (nrf_wifi_utils_q_len(fmac_dev_ctx->fpriv->opriv, 47 | vif_ctx_lnx->data_txq) > 0) { 48 | schedule_work(&vif_ctx_lnx->ws_data_tx); 49 | } 50 | } 51 | 52 | static void nrf_cfg80211_queue_monitor_routine(struct work_struct *w) 53 | { 54 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = container_of( 55 | w, struct nrf_wifi_fmac_vif_ctx_lnx, ws_queue_monitor); 56 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 57 | struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; 58 | struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; 59 | struct rpu_host_stats *host_stats = NULL; 60 | 61 | rpu_ctx_lnx = vif_ctx_lnx->rpu_ctx; 62 | fmac_dev_ctx = rpu_ctx_lnx->rpu_ctx; 63 | def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); 64 | host_stats = &def_dev_ctx->host_stats; 65 | 66 | if (vif_ctx_lnx->num_tx_pkt - host_stats->total_tx_pkts <= 67 | CONFIG_NRF700X_MAX_TX_PENDING_QLEN / 2) { 68 | if (netif_queue_stopped(vif_ctx_lnx->netdev)) { 69 | netif_wake_queue(vif_ctx_lnx->netdev); 70 | } 71 | } else { 72 | schedule_work(&vif_ctx_lnx->ws_queue_monitor); 73 | } 74 | } 75 | 76 | netdev_tx_t nrf_wifi_netdev_start_xmit(struct sk_buff *skb, 77 | struct net_device *netdev) 78 | { 79 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 80 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = NULL; 81 | struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; 82 | struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL; 83 | struct rpu_host_stats *host_stats = NULL; 84 | int status = -1; 85 | int ret = NETDEV_TX_OK; 86 | 87 | vif_ctx_lnx = netdev_priv(netdev); 88 | rpu_ctx_lnx = vif_ctx_lnx->rpu_ctx; 89 | 90 | fmac_dev_ctx = rpu_ctx_lnx->rpu_ctx; 91 | 92 | def_dev_ctx = wifi_dev_priv(fmac_dev_ctx); 93 | host_stats = &def_dev_ctx->host_stats; 94 | 95 | if (skb->dev != netdev) { 96 | pr_err("%s: wrong net dev\n", __func__); 97 | goto out; 98 | } 99 | 100 | if ((vif_ctx_lnx->num_tx_pkt - host_stats->total_tx_pkts) >= 101 | CONFIG_NRF700X_MAX_TX_PENDING_QLEN) { 102 | if (!netif_queue_stopped(netdev)) { 103 | netif_stop_queue(netdev); 104 | } 105 | schedule_work(&vif_ctx_lnx->ws_queue_monitor); 106 | } 107 | 108 | status = nrf_wifi_utils_q_enqueue(fmac_dev_ctx->fpriv->opriv, 109 | vif_ctx_lnx->data_txq, skb); 110 | 111 | if (status != NRF_WIFI_STATUS_SUCCESS) { 112 | pr_err("%s: nrf_wifi_utils_q_enqueue failed\n", __func__); 113 | ret = NETDEV_TX_BUSY; 114 | return ret; 115 | } 116 | 117 | vif_ctx_lnx->num_tx_pkt++; 118 | schedule_work(&vif_ctx_lnx->ws_data_tx); 119 | 120 | out: 121 | return ret; 122 | } 123 | #endif 124 | 125 | int nrf_wifi_netdev_open(struct net_device *netdev) 126 | { 127 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 128 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = NULL; 129 | struct nrf_wifi_umac_chg_vif_state_info *vif_info = NULL; 130 | int status = -1; 131 | 132 | vif_ctx_lnx = netdev_priv(netdev); 133 | rpu_ctx_lnx = vif_ctx_lnx->rpu_ctx; 134 | 135 | vif_info = kzalloc(sizeof(*vif_info), GFP_KERNEL); 136 | 137 | if (!vif_info) { 138 | pr_err("%s: Unable to allocate memory\n", __func__); 139 | goto out; 140 | } 141 | 142 | vif_info->state = 1; 143 | 144 | vif_info->if_index = vif_ctx_lnx->if_idx; 145 | 146 | status = nrf_wifi_fmac_chg_vif_state(rpu_ctx_lnx->rpu_ctx, 147 | vif_ctx_lnx->if_idx, vif_info); 148 | 149 | if (status == NRF_WIFI_STATUS_FAIL) { 150 | pr_err("%s: nrf_wifi_fmac_chg_vif_state failed\n", __func__); 151 | goto out; 152 | } 153 | 154 | out: 155 | if (vif_info) 156 | kfree(vif_info); 157 | 158 | return status; 159 | } 160 | 161 | int nrf_wifi_netdev_close(struct net_device *netdev) 162 | { 163 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 164 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = NULL; 165 | struct nrf_wifi_umac_chg_vif_state_info *vif_info = NULL; 166 | int status = -1; 167 | 168 | vif_ctx_lnx = netdev_priv(netdev); 169 | rpu_ctx_lnx = vif_ctx_lnx->rpu_ctx; 170 | 171 | vif_info = kzalloc(sizeof(*vif_info), GFP_KERNEL); 172 | 173 | if (!vif_info) { 174 | pr_err("%s: Unable to allocate memory\n", __func__); 175 | goto out; 176 | } 177 | 178 | vif_info->state = 0; 179 | 180 | vif_info->if_index = vif_ctx_lnx->if_idx; 181 | 182 | status = nrf_wifi_fmac_chg_vif_state(rpu_ctx_lnx->rpu_ctx, 183 | vif_ctx_lnx->if_idx, vif_info); 184 | 185 | if (status == NRF_WIFI_STATUS_FAIL) { 186 | pr_err("%s: nrf_wifi_fmac_chg_vif_state failed\n", __func__); 187 | goto out; 188 | } 189 | flush_work(&vif_ctx_lnx->ws_data_tx); 190 | flush_work(&vif_ctx_lnx->ws_queue_monitor); 191 | 192 | netif_carrier_off(netdev); 193 | out: 194 | if (vif_info) 195 | kfree(vif_info); 196 | 197 | return status; 198 | } 199 | 200 | void nrf_wifi_netdev_set_multicast_list(struct net_device *netdev) 201 | { 202 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 203 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = NULL; 204 | struct nrf_wifi_umac_mcast_cfg *mcast_info = NULL; 205 | int status = -1; 206 | struct netdev_hw_addr *ha = NULL; 207 | int indx = 0, count = 0; 208 | 209 | vif_ctx_lnx = netdev_priv(netdev); 210 | rpu_ctx_lnx = vif_ctx_lnx->rpu_ctx; 211 | 212 | count = netdev_mc_count(netdev); 213 | mcast_info = 214 | kzalloc((sizeof(*mcast_info) + (count * NRF_WIFI_ETH_ADDR_LEN)), 215 | GFP_KERNEL); 216 | 217 | if (!mcast_info) { 218 | pr_err("%s: Unable to allocate memory\n", __func__); 219 | goto out; 220 | } 221 | 222 | netdev_for_each_mc_addr(ha, netdev) { 223 | memcpy(((char *)(mcast_info->mac_addr) + 224 | (indx * NRF_WIFI_ETH_ADDR_LEN)), 225 | ha->addr, NRF_WIFI_ETH_ADDR_LEN); 226 | indx++; 227 | } 228 | status = nrf_wifi_fmac_set_mcast_addr(rpu_ctx_lnx->rpu_ctx, 229 | vif_ctx_lnx->if_idx, mcast_info); 230 | 231 | if (status == NRF_WIFI_STATUS_FAIL) { 232 | pr_err("%s: nrf_wifi_fmac_chg_vif_state failed\n", __func__); 233 | goto out; 234 | } 235 | 236 | out: 237 | if (mcast_info) 238 | kfree(mcast_info); 239 | } 240 | 241 | void nrf_wifi_netdev_frame_rx_callbk_fn(void *os_vif_ctx, void *frm) 242 | { 243 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = NULL; 244 | struct sk_buff *skb = frm; 245 | struct net_device *netdev = NULL; 246 | 247 | vif_ctx_lnx = os_vif_ctx; 248 | netdev = vif_ctx_lnx->netdev; 249 | 250 | skb->dev = netdev; 251 | skb->protocol = eth_type_trans(skb, skb->dev); 252 | skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */ 253 | 254 | netif_rx(skb); 255 | } 256 | 257 | enum nrf_wifi_status nrf_wifi_netdev_if_state_chg_callbk_fn( 258 | void *vif_ctx, enum nrf_wifi_fmac_if_carr_state if_state) 259 | { 260 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 261 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = NULL; 262 | struct net_device *netdev = NULL; 263 | 264 | if (!vif_ctx) { 265 | pr_err("%s: Invalid parameters\n", __func__); 266 | goto out; 267 | } 268 | 269 | vif_ctx_lnx = (struct nrf_wifi_fmac_vif_ctx_lnx *)vif_ctx; 270 | netdev = vif_ctx_lnx->netdev; 271 | 272 | if (if_state == NRF_WIFI_FMAC_IF_CARR_STATE_ON) 273 | netif_carrier_on(netdev); 274 | else if (if_state == NRF_WIFI_FMAC_IF_CARR_STATE_OFF) 275 | netif_carrier_off(netdev); 276 | else { 277 | pr_err("%s: Invalid interface state %d\n", __func__, if_state); 278 | goto out; 279 | } 280 | 281 | status = NRF_WIFI_STATUS_SUCCESS; 282 | out: 283 | return status; 284 | } 285 | 286 | const struct net_device_ops nrf_wifi_netdev_ops = { 287 | .ndo_open = nrf_wifi_netdev_open, 288 | .ndo_stop = nrf_wifi_netdev_close, 289 | #ifdef CONFIG_NRF700X_DATA_TX 290 | .ndo_start_xmit = nrf_wifi_netdev_start_xmit, 291 | #endif /* CONFIG_NRF700X_DATA_TX */ 292 | }; 293 | 294 | struct nrf_wifi_fmac_vif_ctx_lnx * 295 | nrf_wifi_netdev_add_vif(struct nrf_wifi_ctx_lnx *rpu_ctx_lnx, 296 | const char *if_name, struct wireless_dev *wdev, 297 | char *mac_addr) 298 | { 299 | struct net_device *netdev = NULL; 300 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = NULL; 301 | struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; 302 | int ret = 0; 303 | 304 | ASSERT_RTNL(); 305 | 306 | netdev = alloc_etherdev(sizeof(struct nrf_wifi_fmac_vif_ctx_lnx)); 307 | 308 | if (!netdev) { 309 | pr_err("%s: Unable to allocate memory for a new netdev\n", 310 | __func__); 311 | goto out; 312 | } 313 | 314 | vif_ctx_lnx = netdev_priv(netdev); 315 | vif_ctx_lnx->rpu_ctx = rpu_ctx_lnx; 316 | vif_ctx_lnx->netdev = netdev; 317 | fmac_dev_ctx = rpu_ctx_lnx->rpu_ctx; 318 | 319 | netdev->netdev_ops = &nrf_wifi_netdev_ops; 320 | 321 | strncpy(netdev->name, if_name, sizeof(netdev->name) - 1); 322 | 323 | ether_addr_copy(netdev->dev_addr, mac_addr); 324 | 325 | netdev->ieee80211_ptr = wdev; 326 | 327 | netdev->needed_headroom = TX_BUF_HEADROOM; 328 | 329 | netdev->priv_destructor = free_netdev; 330 | #ifdef CONFIG_NRF700X_DATA_TX 331 | vif_ctx_lnx->data_txq = 332 | nrf_wifi_utils_q_alloc(fmac_dev_ctx->fpriv->opriv); 333 | if (vif_ctx_lnx->data_txq == NULL) { 334 | goto err_reg_netdev; 335 | } 336 | INIT_WORK(&vif_ctx_lnx->ws_data_tx, nrf_cfg80211_data_tx_routine); 337 | INIT_WORK(&vif_ctx_lnx->ws_queue_monitor, 338 | nrf_cfg80211_queue_monitor_routine); 339 | #endif 340 | ret = register_netdevice(netdev); 341 | 342 | if (ret) { 343 | pr_err("%s: Unable to register netdev, ret=%d\n", __func__, 344 | ret); 345 | goto err_reg_netdev; 346 | } 347 | 348 | err_reg_netdev: 349 | if (ret) { 350 | free_netdev(netdev); 351 | netdev = NULL; 352 | vif_ctx_lnx = NULL; 353 | } 354 | out: 355 | return vif_ctx_lnx; 356 | } 357 | 358 | void nrf_wifi_netdev_del_vif(struct net_device *netdev) 359 | { 360 | struct nrf_wifi_fmac_vif_ctx_lnx *vif_ctx_lnx = NULL; 361 | struct nrf_wifi_ctx_lnx *rpu_ctx_lnx = NULL; 362 | struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; 363 | 364 | vif_ctx_lnx = netdev_priv(netdev); 365 | rpu_ctx_lnx = vif_ctx_lnx->rpu_ctx; 366 | fmac_dev_ctx = rpu_ctx_lnx->rpu_ctx; 367 | 368 | nrf_wifi_utils_q_free(fmac_dev_ctx->fpriv->opriv, 369 | vif_ctx_lnx->data_txq); 370 | 371 | unregister_netdevice(netdev); 372 | netdev->ieee80211_ptr = NULL; 373 | } 374 | #endif /* !CONFIG_NRF700X_RADIO_TEST */ 375 | -------------------------------------------------------------------------------- /src/shim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | /** 8 | * @brief Header containing OS specific definitions for the 9 | * Linux OS layer of the Wi-Fi driver. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "osal_api.h" 30 | #include "osal_ops.h" 31 | #include "fmac_api.h" 32 | #include "main.h" 33 | #include "shim.h" 34 | #include "pal.h" 35 | #include "rpu_hw_if.h" 36 | #include "spi_if.h" 37 | 38 | #define NRF_WIFI_SPI_DRV_NAME "nrf_wifi_spi" 39 | #define NRF_WIFI_SPI_DEV_NAME "nrf70-spi" 40 | 41 | struct of_device_id nrf7002_driver_ids[] = { { 42 | .compatible = 43 | "nordic,nrf70-spi", 44 | }, 45 | { /* sentinel */ } }; 46 | 47 | struct spi_device_id nrf7002[] = { 48 | { "nrf70-spi", 0 }, 49 | {}, 50 | }; 51 | 52 | static void *shim_mem_alloc(size_t size) 53 | { 54 | return kmalloc(size, GFP_ATOMIC); 55 | } 56 | 57 | static void *shim_mem_zalloc(size_t size) 58 | { 59 | return kzalloc(size, GFP_ATOMIC); 60 | } 61 | 62 | static void shim_mem_free(void *addr) 63 | { 64 | kfree((const void *)addr); 65 | } 66 | 67 | static void *shim_mem_cpy(void *dest, const void *src, size_t count) 68 | { 69 | return memcpy(dest, src, count); 70 | } 71 | 72 | static void *shim_mem_set(void *start, int val, size_t size) 73 | { 74 | return memset(start, val, size); 75 | } 76 | 77 | static void *shim_iomem_mmap(unsigned long addr, unsigned long size) 78 | { 79 | return ioremap(addr, size); 80 | } 81 | 82 | static void shim_iomem_unmap(volatile void *addr) 83 | { 84 | iounmap(addr); 85 | } 86 | 87 | static unsigned int shim_iomem_read_reg32(const volatile void *addr) 88 | { 89 | return readl(addr); 90 | } 91 | 92 | static void shim_iomem_write_reg32(volatile void *addr, unsigned int val) 93 | { 94 | writel(val, addr); 95 | } 96 | 97 | static void shim_iomem_cpy_from(void *dest, const volatile void *src, 98 | size_t count) 99 | { 100 | memcpy_fromio(dest, src, count); 101 | } 102 | 103 | static void shim_iomem_cpy_to(volatile void *dest, const void *src, 104 | size_t count) 105 | { 106 | memcpy_toio(dest, src, count); 107 | } 108 | 109 | static unsigned int shim_spi_read_reg32(void *dev_ctx, unsigned long addr) 110 | { 111 | unsigned int val; 112 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = dev_ctx; 113 | struct shim_bus_spi_priv *lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 114 | struct spdev *dev = lnx_spi_priv->spdev; 115 | 116 | if (addr < 0x0C0000) { 117 | dev->hl_read(addr, &val, 4); 118 | } else { 119 | dev->read(addr, &val, 4); 120 | } 121 | 122 | return val; 123 | } 124 | 125 | static void shim_spi_write_reg32(void *dev_ctx, unsigned long addr, 126 | unsigned int val) 127 | { 128 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = dev_ctx; 129 | struct shim_bus_spi_priv *lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 130 | struct spdev *dev = lnx_spi_priv->spdev; 131 | 132 | dev->write(addr, val, 4); 133 | } 134 | 135 | static void shim_spi_cpy_from(void *dev_ctx, void *dest, unsigned long addr, 136 | size_t count) 137 | { 138 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = dev_ctx; 139 | struct shim_bus_spi_priv *lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 140 | struct spdev *dev = lnx_spi_priv->spdev; 141 | 142 | if (count % 4 != 0) { 143 | count = (count + 4) & 0xFFFFFFFC; 144 | } 145 | 146 | dev->cp_from(dest, addr, count); 147 | } 148 | 149 | static void shim_spi_cpy_to(void *dev_ctx, unsigned long addr, const void *src, 150 | size_t count) 151 | { 152 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = dev_ctx; 153 | struct shim_bus_spi_priv *lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 154 | struct spdev *dev = lnx_spi_priv->spdev; 155 | 156 | if (count % 4 != 0) { 157 | count = (count + 4) & 0xFFFFFFFC; 158 | } 159 | 160 | dev->cp_to(addr, src, count); 161 | } 162 | 163 | static void *shim_spinlock_alloc(void) 164 | { 165 | struct mutex *lock; 166 | 167 | lock = kmalloc(sizeof(*lock), GFP_KERNEL); 168 | 169 | if (!lock) 170 | pr_err("%s: Unable to allocate memory for spinlock\n", 171 | __func__); 172 | 173 | return lock; 174 | } 175 | 176 | static void shim_spinlock_free(void *lock) 177 | { 178 | kfree(lock); 179 | } 180 | 181 | static void shim_spinlock_init(void *lock) 182 | { 183 | mutex_init(lock); 184 | } 185 | 186 | static void shim_spinlock_take(void *lock) 187 | { 188 | mutex_lock(lock); 189 | } 190 | 191 | static void shim_spinlock_rel(void *lock) 192 | { 193 | mutex_unlock(lock); 194 | } 195 | 196 | static void shim_spinlock_irq_take(void *lock, unsigned long *flags) 197 | { 198 | mutex_lock(lock); 199 | } 200 | 201 | static void shim_spinlock_irq_rel(void *lock, unsigned long *flags) 202 | { 203 | mutex_unlock(lock); 204 | } 205 | 206 | static int shim_pr_dbg(const char *fmt, va_list args) 207 | { 208 | char *mod_fmt = NULL; 209 | int ret = -1; 210 | 211 | mod_fmt = kmalloc(strlen(fmt) + strlen(KERN_DEBUG), GFP_ATOMIC); 212 | 213 | if (!mod_fmt) { 214 | pr_err("%s: Unable to allocate memory for mod_fmt\n", __func__); 215 | return -1; 216 | } 217 | 218 | strcpy(mod_fmt, KERN_DEBUG); 219 | strcat(mod_fmt, fmt); 220 | 221 | ret = vprintk(mod_fmt, args); 222 | 223 | kfree(mod_fmt); 224 | 225 | return ret; 226 | } 227 | 228 | static int shim_pr_info(const char *fmt, va_list args) 229 | { 230 | char *mod_fmt = NULL; 231 | int ret = -1; 232 | 233 | mod_fmt = kmalloc(strlen(fmt) + strlen(KERN_INFO), GFP_ATOMIC); 234 | 235 | if (!mod_fmt) { 236 | pr_err("%s: Unable to allocate memory for mod_fmt\n", __func__); 237 | return -1; 238 | } 239 | 240 | strcpy(mod_fmt, KERN_INFO); 241 | strcat(mod_fmt, fmt); 242 | 243 | ret = vprintk(mod_fmt, args); 244 | 245 | kfree(mod_fmt); 246 | 247 | return ret; 248 | } 249 | 250 | static int shim_pr_err(const char *fmt, va_list args) 251 | { 252 | char *mod_fmt = NULL; 253 | int ret = -1; 254 | 255 | mod_fmt = kmalloc(strlen(fmt) + strlen(KERN_ERR), GFP_ATOMIC); 256 | 257 | if (!mod_fmt) { 258 | pr_err("%s: Unable to allocate memory for mod_fmt\n", __func__); 259 | return -1; 260 | } 261 | 262 | strcpy(mod_fmt, KERN_ERR); 263 | strcat(mod_fmt, fmt); 264 | 265 | ret = vprintk(mod_fmt, args); 266 | 267 | kfree(mod_fmt); 268 | 269 | return ret; 270 | } 271 | 272 | static void *shim_nbuf_alloc(unsigned int size) 273 | { 274 | struct sk_buff *nbuf = NULL; 275 | 276 | nbuf = alloc_skb(size, GFP_ATOMIC); 277 | 278 | if (!nbuf) 279 | pr_err("%s: Unable to allocate memory for network buffer\n", 280 | __func__); 281 | 282 | return nbuf; 283 | } 284 | 285 | static void shim_nbuf_free(void *nbuf) 286 | { 287 | kfree_skb(nbuf); 288 | } 289 | 290 | static void shim_nbuf_headroom_res(void *nbuf, unsigned int size) 291 | { 292 | skb_reserve(nbuf, size); 293 | } 294 | 295 | static unsigned int shim_nbuf_headroom_get(void *nbuf) 296 | { 297 | struct sk_buff *skb = (struct sk_buff *)nbuf; 298 | 299 | return (skb->data - skb->head); 300 | } 301 | 302 | static unsigned int shim_nbuf_data_size(void *nbuf) 303 | { 304 | struct sk_buff *skb = (struct sk_buff *)nbuf; 305 | 306 | return skb->len; 307 | } 308 | 309 | static void *shim_nbuf_data_get(void *nbuf) 310 | { 311 | struct sk_buff *skb = (struct sk_buff *)nbuf; 312 | 313 | return skb->data; 314 | } 315 | 316 | static void *shim_nbuf_data_put(void *nbuf, unsigned int size) 317 | { 318 | return skb_put(nbuf, size); 319 | } 320 | 321 | static void *shim_nbuf_data_push(void *nbuf, unsigned int size) 322 | { 323 | return skb_push(nbuf, size); 324 | } 325 | 326 | static void *shim_nbuf_data_pull(void *nbuf, unsigned int size) 327 | { 328 | return skb_pull(nbuf, size); 329 | } 330 | 331 | static unsigned char shim_nbuf_get_priority(void *nbuf) 332 | { 333 | struct sk_buff *skb = (struct sk_buff *)nbuf; 334 | 335 | /* Note: Linux supports u32 but OSAL supports u8 */ 336 | return skb->priority; 337 | } 338 | 339 | static unsigned char shim_nbuf_get_chksum_done(void *nbuf) 340 | { 341 | struct sk_buff *skb = (struct sk_buff *)nbuf; 342 | __wsum csum; 343 | __sum16 sum; 344 | 345 | if (!skb) { 346 | pr_err("%s: Unable to get checksum\n", __func__); 347 | return -1; 348 | } 349 | 350 | csum = skb_checksum(skb, 0, skb->len, 0); 351 | sum = csum_fold(csum_add(skb->csum, csum)); 352 | 353 | skb->ip_summed = CHECKSUM_COMPLETE; 354 | skb->csum_complete_sw = 1; 355 | skb->csum_valid = !sum; 356 | skb->csum = csum; 357 | 358 | return skb->csum_complete_sw; 359 | } 360 | 361 | static void shim_nbuf_set_chksum_done(void *nbuf, unsigned char chksum_done) 362 | { 363 | struct sk_buff *skb = (struct sk_buff *)nbuf; 364 | 365 | if (!skb) { 366 | pr_err("%s: Unable to set checksum\n", __func__); 367 | return; 368 | } 369 | 370 | skb->csum_complete_sw = (bool)chksum_done; 371 | } 372 | 373 | static void *shim_llist_node_alloc(void) 374 | { 375 | struct shim_llist_node *llist_node = NULL; 376 | 377 | llist_node = kzalloc(sizeof(*llist_node), GFP_ATOMIC); 378 | 379 | if (!llist_node) 380 | pr_err("%s: Unable to allocate memory for linked list node\n", 381 | __func__); 382 | 383 | return llist_node; 384 | } 385 | 386 | static void shim_llist_node_free(void *llist_node) 387 | { 388 | kfree(llist_node); 389 | } 390 | 391 | static void *shim_llist_node_data_get(void *llist_node) 392 | { 393 | struct shim_llist_node *shim_llist_node = NULL; 394 | 395 | shim_llist_node = (struct shim_llist_node *)llist_node; 396 | 397 | return shim_llist_node->data; 398 | } 399 | 400 | static void shim_llist_node_data_set(void *llist_node, void *data) 401 | { 402 | struct shim_llist_node *shim_llist_node = NULL; 403 | 404 | shim_llist_node = (struct shim_llist_node *)llist_node; 405 | 406 | shim_llist_node->data = data; 407 | } 408 | 409 | static void *shim_llist_alloc(void) 410 | { 411 | struct shim_llist *llist = NULL; 412 | 413 | llist = kzalloc(sizeof(*llist), GFP_ATOMIC); 414 | 415 | if (!llist) 416 | pr_err("%s: Unable to allocate memory for linked list\n", 417 | __func__); 418 | 419 | return llist; 420 | } 421 | 422 | static void shim_llist_free(void *llist) 423 | { 424 | kfree(llist); 425 | } 426 | 427 | static void shim_llist_init(void *llist) 428 | { 429 | struct shim_llist *shim_llist = NULL; 430 | 431 | shim_llist = (struct shim_llist *)llist; 432 | 433 | INIT_LIST_HEAD(&shim_llist->head); 434 | } 435 | 436 | static void shim_llist_add_node_tail(void *llist, void *llist_node) 437 | { 438 | struct shim_llist *shim_llist = NULL; 439 | 440 | shim_llist = (struct shim_llist *)llist; 441 | 442 | list_add_tail(llist_node, &shim_llist->head); 443 | 444 | shim_llist->len += 1; 445 | } 446 | 447 | static void *shim_llist_get_node_head(void *llist) 448 | { 449 | struct shim_llist_node *head_node = NULL; 450 | struct shim_llist *shim_llist = NULL; 451 | 452 | shim_llist = (struct shim_llist *)llist; 453 | 454 | if (!shim_llist->len) 455 | return NULL; 456 | 457 | head_node = list_first_entry(&shim_llist->head, struct shim_llist_node, 458 | head); 459 | 460 | return head_node; 461 | } 462 | 463 | static void *shim_llist_get_node_nxt(void *llist, void *llist_node) 464 | { 465 | struct shim_llist_node *node = NULL; 466 | struct shim_llist_node *nxt_node = NULL; 467 | struct shim_llist *shim_llist = NULL; 468 | 469 | shim_llist = (struct shim_llist *)llist; 470 | node = (struct shim_llist_node *)llist_node; 471 | 472 | if (node->head.next == &shim_llist->head) 473 | return NULL; 474 | 475 | nxt_node = list_next_entry(node, head); 476 | 477 | return nxt_node; 478 | } 479 | 480 | static void shim_llist_del_node(void *llist, void *llist_node) 481 | { 482 | struct shim_llist_node *node = NULL; 483 | struct shim_llist *shim_llist = NULL; 484 | 485 | shim_llist = (struct shim_llist *)llist; 486 | node = (struct shim_llist_node *)llist_node; 487 | 488 | list_del(&node->head); 489 | 490 | shim_llist->len -= 1; 491 | } 492 | 493 | static unsigned int shim_llist_len(void *llist) 494 | { 495 | struct shim_llist *shim_llist = NULL; 496 | 497 | shim_llist = (struct shim_llist *)llist; 498 | 499 | return shim_llist->len; 500 | } 501 | 502 | static void *shim_tasklet_alloc(int type) 503 | { 504 | struct work_item *item = NULL; 505 | 506 | item = kcalloc(sizeof(*item), sizeof(char), GFP_KERNEL); 507 | 508 | if (!item) { 509 | pr_err("%s: Unable to allocate memory for work\n", __func__); 510 | goto out; 511 | } 512 | out: 513 | return item; 514 | } 515 | 516 | static void shim_tasklet_free(void *tasklet) 517 | { 518 | kfree(tasklet); 519 | } 520 | 521 | static void fn_worker(struct work_struct *worker) 522 | { 523 | struct work_item *item_ctx; 524 | 525 | item_ctx = container_of(worker, struct work_item, work); 526 | item_ctx->callback(item_ctx->data); 527 | } 528 | 529 | static void shim_tasklet_init(void *tasklet, void (*callback)(unsigned long), 530 | unsigned long data) 531 | { 532 | struct work_item *item_ctx; 533 | 534 | item_ctx = tasklet; 535 | item_ctx->data = data; 536 | item_ctx->callback = callback; 537 | 538 | INIT_WORK(&item_ctx->work, fn_worker); 539 | } 540 | 541 | static void shim_tasklet_schedule(void *tasklet) 542 | { 543 | struct work_item *item_ctx = NULL; 544 | 545 | item_ctx = tasklet; 546 | schedule_work(&item_ctx->work); 547 | } 548 | 549 | static void shim_tasklet_kill(void *tasklet) 550 | { 551 | struct work_item *item_ctx = NULL; 552 | 553 | item_ctx = tasklet; 554 | cancel_work_sync(&item_ctx->work); 555 | } 556 | 557 | static int shim_msleep(int msecs) 558 | { 559 | msleep((unsigned int)msecs); 560 | 561 | return 0; 562 | } 563 | 564 | static int shim_udelay(int usecs) 565 | { 566 | udelay((unsigned long)usecs); 567 | 568 | return 0; 569 | } 570 | 571 | static unsigned long shim_time_get_curr_us(void) 572 | { 573 | return div_u64(ktime_get_real_ns(), NSEC_PER_USEC); 574 | } 575 | 576 | static unsigned int shim_time_elapsed_us(unsigned long start_time_us) 577 | { 578 | return (unsigned int)(div_u64(ktime_get_real_ns(), NSEC_PER_USEC) - 579 | start_time_us); 580 | } 581 | 582 | #ifdef CONFIG_NRF_WIFI_LOW_POWER 583 | 584 | struct shim_timer_data { 585 | struct timer_list timer; 586 | void (*callback)(unsigned long); 587 | unsigned long data; 588 | struct work_struct work; 589 | }; 590 | 591 | static void shim_timer_callback(struct timer_list *t) 592 | { 593 | struct shim_timer_data *timer = from_timer(timer, t, timer); 594 | 595 | schedule_work(&timer->work); 596 | } 597 | 598 | static void shim_timer_invoke_callback(struct work_struct *work) 599 | { 600 | struct shim_timer_data *timer = 601 | container_of(work, struct shim_timer_data, work); 602 | 603 | timer->callback(timer->data); 604 | } 605 | 606 | static void *shim_timer_alloc(void) 607 | { 608 | struct shim_timer_data *timer = NULL; 609 | 610 | timer = kmalloc(sizeof(*timer), GFP_ATOMIC); 611 | 612 | if (!timer) 613 | pr_err("%s: Unable to allocate memory for tasklet\n", __func__); 614 | 615 | INIT_WORK(&timer->work, shim_timer_invoke_callback); 616 | 617 | return timer; 618 | } 619 | 620 | static void shim_timer_init(void *timer, void (*callback)(unsigned long), 621 | unsigned long data) 622 | { 623 | struct shim_timer_data *timer_data = timer; 624 | 625 | timer_data->callback = callback; 626 | timer_data->data = data; 627 | timer_setup(&timer_data->timer, shim_timer_callback, 0); 628 | } 629 | 630 | static void shim_timer_free(void *timer) 631 | { 632 | kfree(timer); 633 | } 634 | 635 | static void shim_timer_schedule(void *timer, unsigned long duration) 636 | { 637 | struct shim_timer_data *timer_data = timer; 638 | 639 | mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(duration)); 640 | } 641 | 642 | static void shim_timer_kill(void *timer) 643 | { 644 | struct shim_timer_data *timer_data = timer; 645 | 646 | del_timer_sync(&timer_data->timer); 647 | } 648 | 649 | static int shim_bus_qspi_ps_sleep(void *os_qspi_priv) 650 | { 651 | (void)os_qspi_priv; 652 | 653 | rpu_sleep(); 654 | 655 | return 0; 656 | } 657 | 658 | static int shim_bus_qspi_ps_wake(void *os_qspi_priv) 659 | { 660 | (void)os_qspi_priv; 661 | 662 | rpu_wakeup(); 663 | 664 | return 0; 665 | } 666 | 667 | static int shim_bus_qspi_ps_status(void *os_qspi_priv) 668 | { 669 | (void)os_qspi_priv; 670 | 671 | return rpu_sleep_status(); 672 | } 673 | #endif 674 | 675 | static void shim_assert(int test_val, int val, enum nrf_wifi_assert_op_type op, 676 | char *msg) 677 | { 678 | switch (op) { 679 | case NRF_WIFI_ASSERT_EQUAL_TO: 680 | WARN(test_val != val, "%s", msg); 681 | break; 682 | case NRF_WIFI_ASSERT_NOT_EQUAL_TO: 683 | WARN(test_val == val, "%s", msg); 684 | break; 685 | case NRF_WIFI_ASSERT_LESS_THAN: 686 | WARN(test_val >= val, "%s", msg); 687 | break; 688 | case NRF_WIFI_ASSERT_LESS_THAN_EQUAL_TO: 689 | WARN(test_val > val, "%s", msg); 690 | break; 691 | case NRF_WIFI_ASSERT_GREATER_THAN: 692 | WARN(test_val <= val, "%s", msg); 693 | break; 694 | case NRF_WIFI_ASSERT_GREATER_THAN_EQUAL_TO: 695 | WARN(test_val < val, "%s", msg); 696 | break; 697 | default: 698 | pr_err("%s: Invalid assertion operation\n", __func__); 699 | } 700 | } 701 | 702 | static int shim_mem_cmp(const void *addr1, const void *addr2, size_t size) 703 | { 704 | return memcmp(addr1, addr2, size); 705 | } 706 | 707 | static unsigned int shim_strlen(const void *str) 708 | { 709 | return strlen(str); 710 | } 711 | 712 | static void shim_bus_spi_reg_drv(struct work_struct *drv_reg_work) 713 | { 714 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 715 | 716 | lnx_spi_priv = 717 | container_of(drv_reg_work, struct shim_bus_spi_priv, drv_reg); 718 | 719 | if (spi_register_driver(lnx_spi_priv->spi_drv)) { 720 | pr_err("%s: Registration of RPI SPI driver failed\n", __func__); 721 | kfree(lnx_spi_priv->spi_dev_id); 722 | kfree(lnx_spi_priv->spi_drv); 723 | kfree(lnx_spi_priv); 724 | } 725 | } 726 | 727 | static enum nrf_wifi_status shim_bus_spi_dev_init(void *os_spi_dev_ctx) 728 | { 729 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 730 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = NULL; 731 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 732 | 733 | lnx_spi_dev_ctx = os_spi_dev_ctx; 734 | lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 735 | 736 | lnx_spi_priv->dev_init = true; 737 | 738 | status = NRF_WIFI_STATUS_SUCCESS; 739 | 740 | return status; 741 | } 742 | 743 | static void shim_bus_spi_dev_deinit(void *os_spi_dev_ctx) 744 | { 745 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = NULL; 746 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 747 | struct spdev *dev = NULL; 748 | 749 | lnx_spi_dev_ctx = os_spi_dev_ctx; 750 | lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 751 | dev = lnx_spi_priv->spdev; 752 | 753 | dev->deinit(); 754 | } 755 | 756 | static void *shim_bus_spi_dev_add(void *os_spi_priv, void *osal_spi_dev_ctx) 757 | { 758 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 759 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = NULL; 760 | 761 | lnx_spi_dev_ctx = kzalloc(sizeof(*lnx_spi_dev_ctx), GFP_ATOMIC); 762 | if (!lnx_spi_dev_ctx) { 763 | pr_err("%s: Unable to allocate memory for lnx_spi_dev_ctx\n", 764 | __func__); 765 | goto out; 766 | } 767 | 768 | lnx_spi_priv = os_spi_priv; 769 | 770 | rpu_enable(lnx_spi_priv->spi_dev); 771 | 772 | lnx_spi_priv->spdev = sp_dev(); 773 | 774 | lnx_spi_dev_ctx->lnx_spi_priv = lnx_spi_priv; 775 | lnx_spi_dev_ctx->osal_spi_dev_ctx = osal_spi_dev_ctx; 776 | 777 | spi_set_drvdata(lnx_spi_priv->spi_dev, lnx_spi_dev_ctx); 778 | 779 | lnx_spi_priv->dev_added = true; 780 | 781 | out: 782 | return lnx_spi_dev_ctx; 783 | } 784 | 785 | static void shim_bus_spi_dev_rem(void *os_spi_dev_ctx) 786 | { 787 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 788 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = NULL; 789 | 790 | lnx_spi_dev_ctx = os_spi_dev_ctx; 791 | lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 792 | 793 | rpu_disable(lnx_spi_priv->spdev); 794 | 795 | if (lnx_spi_priv->wq) { 796 | destroy_workqueue(lnx_spi_priv->wq); 797 | } 798 | 799 | spi_set_drvdata(lnx_spi_priv->spi_dev, NULL); 800 | kfree(lnx_spi_dev_ctx); 801 | } 802 | 803 | static int shim_bus_spi_probe(struct spi_device *spi_dev) 804 | { 805 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 806 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 807 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = NULL; 808 | struct nrf_wifi_ctx_lnx *lnx_rpu_ctx = NULL; 809 | int ret = -1; 810 | const struct spi_device_id *id = spi_get_device_id(spi_dev); 811 | 812 | lnx_spi_priv = (struct shim_bus_spi_priv *)id->driver_data; 813 | 814 | if (lnx_spi_priv->spi_dev) { 815 | pr_err("%s: Previous detected device still not added\n", 816 | __func__); 817 | goto out; 818 | } 819 | 820 | lnx_spi_priv->spi_dev = spi_dev; 821 | 822 | lnx_rpu_ctx = nrf_wifi_fmac_dev_add_lnx(); 823 | 824 | if (!lnx_rpu_ctx) { 825 | pr_err("%s: nrf_wifi_fmac_dev_add_lnx failed\n", __func__); 826 | goto out; 827 | } 828 | 829 | lnx_spi_dev_ctx = spi_get_drvdata(spi_dev); 830 | 831 | lnx_spi_dev_ctx->lnx_rpu_ctx = lnx_rpu_ctx; 832 | 833 | status = nrf_wifi_fmac_dev_init_lnx(lnx_rpu_ctx); 834 | 835 | if (status != NRF_WIFI_STATUS_SUCCESS) { 836 | pr_err("%s: nrf_wifi_fmac_dev_init_lnx failed\n", __func__); 837 | goto out; 838 | } 839 | 840 | lnx_spi_priv->spi_dev = NULL; 841 | 842 | ret = 0; 843 | out: 844 | return ret; 845 | } 846 | 847 | static int shim_bus_spi_remove(struct spi_device *spi_dev) 848 | { 849 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = NULL; 850 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 851 | 852 | lnx_spi_dev_ctx = spi_get_drvdata(spi_dev); 853 | lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 854 | 855 | if (lnx_spi_priv->dev_init) { 856 | nrf_wifi_fmac_dev_deinit_lnx(lnx_spi_dev_ctx->lnx_rpu_ctx); 857 | } 858 | if (lnx_spi_priv->dev_added) { 859 | nrf_wifi_fmac_dev_rem_lnx(lnx_spi_dev_ctx->lnx_rpu_ctx); 860 | } 861 | return 0; 862 | } 863 | 864 | static void irq_work_handler(struct work_struct *work) 865 | { 866 | struct shim_intr_priv *intr_priv = NULL; 867 | int ret = 0; 868 | 869 | intr_priv = (struct shim_intr_priv *)container_of( 870 | work, struct shim_intr_priv, work); 871 | 872 | if (!intr_priv) { 873 | pr_err("fail to get back intr priv\n"); 874 | } 875 | 876 | ret = intr_priv->intr_callbk_fn(intr_priv->intr_callbk_data); 877 | if (ret) { 878 | pr_err("%s: Interrupt callback failed\n", __func__); 879 | } 880 | } 881 | 882 | static irqreturn_t shim_spi_irq_handler(int irq, void *p) 883 | { 884 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 885 | 886 | lnx_spi_priv = (struct shim_bus_spi_priv *)p; 887 | 888 | queue_work(lnx_spi_priv->wq, &lnx_spi_priv->intr_priv.work); 889 | 890 | return IRQ_HANDLED; 891 | } 892 | 893 | static enum nrf_wifi_status 894 | shim_bus_spi_intr_reg(void *os_spi_dev_ctx, void *callbk_data, 895 | int (*callbk_fn)(void *callbk_data)) 896 | { 897 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = NULL; 898 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 899 | enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; 900 | unsigned int irq_flags = IRQ_TYPE_EDGE_RISING; 901 | int ret = -1; 902 | int irq_number; 903 | struct gpio_desc *host_irq; 904 | 905 | lnx_spi_dev_ctx = os_spi_dev_ctx; 906 | lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 907 | 908 | lnx_spi_dev_ctx = os_spi_dev_ctx; 909 | 910 | lnx_spi_priv->wq = alloc_workqueue("nRF7002 WQ", WQ_HIGHPRI, 0); 911 | 912 | if (lnx_spi_priv->wq == NULL) { 913 | pr_err("Cannot allocate nRF7002 WQ\n"); 914 | goto out; 915 | } 916 | 917 | lnx_spi_priv->intr_priv.intr_callbk_data = callbk_data; 918 | lnx_spi_priv->intr_priv.intr_callbk_fn = callbk_fn; 919 | 920 | host_irq = devm_gpiod_get(&lnx_spi_priv->spi_dev->dev, "irq", 0); 921 | 922 | if (IS_ERR(host_irq)) { 923 | goto out; 924 | } 925 | 926 | ret = gpiod_direction_input(host_irq); 927 | if (ret < 0) { 928 | pr_err("Cannot set irq gpio direction\n"); 929 | goto out; 930 | } else { 931 | pr_debug("Set irq direction in\n"); 932 | } 933 | 934 | lnx_spi_priv->host_irq = host_irq; 935 | 936 | irq_number = gpiod_to_irq(lnx_spi_priv->host_irq); 937 | 938 | if (irq_number) { 939 | ret = request_irq(irq_number, shim_spi_irq_handler, irq_flags, 940 | "NRF7002 IRQ", lnx_spi_priv); 941 | if (ret < 0) { 942 | pr_err("Cannot request irq\n"); 943 | free_irq(irq_number, NULL); 944 | lnx_spi_priv->irq_enabled = false; 945 | goto out; 946 | } else { 947 | pr_debug("IRQ requested\n"); 948 | lnx_spi_priv->irq_enabled = true; 949 | } 950 | } 951 | 952 | INIT_WORK(&lnx_spi_priv->intr_priv.work, irq_work_handler); 953 | status = NRF_WIFI_STATUS_SUCCESS; 954 | out: 955 | return status; 956 | } 957 | 958 | static void shim_bus_spi_intr_unreg(void *os_spi_dev_ctx) 959 | { 960 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 961 | struct shim_bus_spi_dev_ctx *lnx_spi_dev_ctx = NULL; 962 | 963 | lnx_spi_dev_ctx = os_spi_dev_ctx; 964 | lnx_spi_priv = lnx_spi_dev_ctx->lnx_spi_priv; 965 | 966 | free_irq(gpiod_to_irq(lnx_spi_priv->host_irq), lnx_spi_priv); 967 | 968 | lnx_spi_priv->irq_enabled = false; 969 | } 970 | 971 | static void 972 | shim_bus_spi_dev_host_map_get(void *os_spi_dev_ctx, 973 | struct nrf_wifi_osal_host_map *host_map) 974 | { 975 | if (!os_spi_dev_ctx || !host_map) { 976 | pr_err("%s: Invalid parameters\n", __func__); 977 | return; 978 | } 979 | 980 | host_map->addr = 0; 981 | } 982 | 983 | static void *shim_bus_spi_init(void) 984 | { 985 | struct spi_driver *lnx_spi_drv = NULL; 986 | struct spi_device_id *lnx_spi_dev_id = NULL; 987 | 988 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 989 | 990 | lnx_spi_priv = kzalloc(sizeof(*lnx_spi_priv), sizeof(char)); 991 | 992 | if (!lnx_spi_priv) { 993 | pr_err("%s: Unable to allocate memory for spi_priv\n", 994 | __func__); 995 | goto out; 996 | } 997 | 998 | lnx_spi_drv = kzalloc(sizeof(*lnx_spi_drv), GFP_ATOMIC); 999 | 1000 | if (!lnx_spi_drv) { 1001 | pr_err("%s: Unable to allocate memory for pcie_drv\n", 1002 | __func__); 1003 | kfree(lnx_spi_drv); 1004 | lnx_spi_drv = NULL; 1005 | goto out; 1006 | } 1007 | 1008 | lnx_spi_dev_id = kzalloc(sizeof(*lnx_spi_dev_id), GFP_ATOMIC); 1009 | 1010 | if (!lnx_spi_dev_id) { 1011 | pr_err("%s: Unable to allocate memory for pdev_id\n", __func__); 1012 | kfree(lnx_spi_drv); 1013 | lnx_spi_drv = NULL; 1014 | kfree(lnx_spi_priv); 1015 | lnx_spi_priv = NULL; 1016 | goto out; 1017 | } 1018 | 1019 | lnx_spi_priv->spi_drv = lnx_spi_drv; 1020 | lnx_spi_priv->spi_dev_id = lnx_spi_dev_id; 1021 | 1022 | lnx_spi_dev_id = &nrf7002[0]; 1023 | memcpy(lnx_spi_dev_id->name, NRF_WIFI_SPI_DEV_NAME, 1024 | sizeof(NRF_WIFI_SPI_DEV_NAME)); 1025 | lnx_spi_dev_id->driver_data = (kernel_ulong_t)lnx_spi_priv; 1026 | 1027 | lnx_spi_drv->driver.name = NRF_WIFI_SPI_DRV_NAME; 1028 | lnx_spi_drv->driver.of_match_table = of_match_ptr(nrf7002_driver_ids); 1029 | lnx_spi_drv->id_table = lnx_spi_dev_id; 1030 | lnx_spi_drv->probe = shim_bus_spi_probe; 1031 | lnx_spi_drv->remove = shim_bus_spi_remove; 1032 | 1033 | INIT_WORK(&lnx_spi_priv->drv_reg, shim_bus_spi_reg_drv); 1034 | 1035 | schedule_work(&lnx_spi_priv->drv_reg); 1036 | 1037 | lnx_spi_priv->dev_init = true; 1038 | 1039 | out: 1040 | return lnx_spi_priv; 1041 | } 1042 | 1043 | static void shim_bus_spi_deinit(void *os_spi_priv) 1044 | { 1045 | struct shim_bus_spi_priv *lnx_spi_priv = NULL; 1046 | 1047 | lnx_spi_priv = os_spi_priv; 1048 | 1049 | spi_unregister_driver(lnx_spi_priv->spi_drv); 1050 | 1051 | kfree(lnx_spi_priv->spi_drv); 1052 | lnx_spi_priv->spi_drv = NULL; 1053 | 1054 | kfree(lnx_spi_priv->spi_dev_id); 1055 | lnx_spi_priv->spi_dev_id = NULL; 1056 | 1057 | kfree(lnx_spi_priv); 1058 | } 1059 | 1060 | const struct nrf_wifi_osal_ops nrf_wifi_os_ops = { 1061 | .mem_alloc = shim_mem_alloc, 1062 | .mem_zalloc = shim_mem_zalloc, 1063 | .mem_free = shim_mem_free, 1064 | .mem_cpy = shim_mem_cpy, 1065 | .mem_set = shim_mem_set, 1066 | .mem_cmp = shim_mem_cmp, 1067 | 1068 | .iomem_mmap = shim_iomem_mmap, 1069 | .iomem_unmap = shim_iomem_unmap, 1070 | .iomem_read_reg32 = shim_iomem_read_reg32, 1071 | .iomem_write_reg32 = shim_iomem_write_reg32, 1072 | .iomem_cpy_from = shim_iomem_cpy_from, 1073 | .iomem_cpy_to = shim_iomem_cpy_to, 1074 | 1075 | .spi_read_reg32 = shim_spi_read_reg32, 1076 | .spi_write_reg32 = shim_spi_write_reg32, 1077 | .spi_cpy_from = shim_spi_cpy_from, 1078 | .spi_cpy_to = shim_spi_cpy_to, 1079 | 1080 | .spinlock_alloc = shim_spinlock_alloc, 1081 | .spinlock_free = shim_spinlock_free, 1082 | .spinlock_init = shim_spinlock_init, 1083 | .spinlock_take = shim_spinlock_take, 1084 | .spinlock_rel = shim_spinlock_rel, 1085 | 1086 | .spinlock_irq_take = shim_spinlock_irq_take, 1087 | .spinlock_irq_rel = shim_spinlock_irq_rel, 1088 | 1089 | .log_dbg = shim_pr_dbg, 1090 | .log_info = shim_pr_info, 1091 | .log_err = shim_pr_err, 1092 | 1093 | .llist_node_alloc = shim_llist_node_alloc, 1094 | .llist_node_free = shim_llist_node_free, 1095 | .llist_node_data_get = shim_llist_node_data_get, 1096 | .llist_node_data_set = shim_llist_node_data_set, 1097 | 1098 | .llist_alloc = shim_llist_alloc, 1099 | .llist_free = shim_llist_free, 1100 | .llist_init = shim_llist_init, 1101 | .llist_add_node_tail = shim_llist_add_node_tail, 1102 | .llist_get_node_head = shim_llist_get_node_head, 1103 | .llist_get_node_nxt = shim_llist_get_node_nxt, 1104 | .llist_del_node = shim_llist_del_node, 1105 | .llist_len = shim_llist_len, 1106 | 1107 | .nbuf_alloc = shim_nbuf_alloc, 1108 | .nbuf_free = shim_nbuf_free, 1109 | .nbuf_headroom_res = shim_nbuf_headroom_res, 1110 | .nbuf_headroom_get = shim_nbuf_headroom_get, 1111 | .nbuf_data_size = shim_nbuf_data_size, 1112 | .nbuf_data_get = shim_nbuf_data_get, 1113 | .nbuf_data_put = shim_nbuf_data_put, 1114 | .nbuf_data_push = shim_nbuf_data_push, 1115 | .nbuf_data_pull = shim_nbuf_data_pull, 1116 | .nbuf_get_priority = shim_nbuf_get_priority, 1117 | .nbuf_get_chksum_done = shim_nbuf_get_chksum_done, 1118 | .nbuf_set_chksum_done = shim_nbuf_set_chksum_done, 1119 | 1120 | .tasklet_alloc = shim_tasklet_alloc, 1121 | .tasklet_free = shim_tasklet_free, 1122 | .tasklet_init = shim_tasklet_init, 1123 | .tasklet_schedule = shim_tasklet_schedule, 1124 | .tasklet_kill = shim_tasklet_kill, 1125 | 1126 | .sleep_ms = shim_msleep, 1127 | .delay_us = shim_udelay, 1128 | .time_get_curr_us = shim_time_get_curr_us, 1129 | .time_elapsed_us = shim_time_elapsed_us, 1130 | 1131 | .bus_spi_init = shim_bus_spi_init, 1132 | .bus_spi_deinit = shim_bus_spi_deinit, 1133 | .bus_spi_dev_add = shim_bus_spi_dev_add, 1134 | .bus_spi_dev_rem = shim_bus_spi_dev_rem, 1135 | .bus_spi_dev_init = shim_bus_spi_dev_init, 1136 | .bus_spi_dev_deinit = shim_bus_spi_dev_deinit, 1137 | .bus_spi_dev_intr_reg = shim_bus_spi_intr_reg, 1138 | .bus_spi_dev_intr_unreg = shim_bus_spi_intr_unreg, 1139 | .bus_spi_dev_host_map_get = shim_bus_spi_dev_host_map_get, 1140 | 1141 | #ifdef CONFIG_NRF_WIFI_LOW_POWER 1142 | .timer_alloc = shim_timer_alloc, 1143 | .timer_init = shim_timer_init, 1144 | .timer_free = shim_timer_free, 1145 | .timer_schedule = shim_timer_schedule, 1146 | .timer_kill = shim_timer_kill, 1147 | 1148 | .bus_qspi_ps_sleep = shim_bus_qspi_ps_sleep, 1149 | .bus_qspi_ps_wake = shim_bus_qspi_ps_wake, 1150 | .bus_qspi_ps_status = shim_bus_qspi_ps_status, 1151 | #endif 1152 | .assert = shim_assert, 1153 | .strlen = shim_strlen, 1154 | }; 1155 | 1156 | const struct nrf_wifi_osal_ops *get_os_ops(void) 1157 | { 1158 | return &nrf_wifi_os_ops; 1159 | } 1160 | -------------------------------------------------------------------------------- /src/spi/inc/rpu_hw_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | /** 8 | * @brief Header containing common functions for RPU hardware interaction 9 | * using SPI that can be invoked by the driver. 10 | */ 11 | 12 | #ifndef __RPU_HW_IF_H_ 13 | #define __RPU_HW_IF_H_ 14 | 15 | #include 16 | 17 | enum { 18 | SYSBUS = 0, 19 | EXT_SYS_BUS, 20 | PBUS, 21 | PKTRAM, 22 | GRAM, 23 | LMAC_ROM, 24 | LMAC_RET_RAM, 25 | LMAC_SRC_RAM, 26 | UMAC_ROM, 27 | UMAC_RET_RAM, 28 | UMAC_SRC_RAM, 29 | NUM_MEM_BLOCKS 30 | }; 31 | 32 | extern char blk_name[][15]; 33 | extern uint32_t rpu_7002_memmap[][3]; 34 | 35 | int rpu_read(unsigned int addr, void *data, int len); 36 | int rpu_write(unsigned int addr, const void *data, int len); 37 | 38 | int rpu_sleep_status(void); 39 | int rpu_sleep(void); 40 | int rpu_wakeup(void); 41 | int rpu_gpio_config(void *dev); 42 | int rpu_wrsr2(uint8_t data); 43 | int rpu_rdsr2(void); 44 | int rpu_rdsr1(void); 45 | int rpu_clks_on(void *dev); 46 | int rpu_enable(void *dev); 47 | int rpu_disable(void *dev); 48 | 49 | #endif /* __RPU_HW_IF_H_ */ 50 | -------------------------------------------------------------------------------- /src/spi/inc/spi_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | /** 8 | * @brief Header containing SPI device interface specific declarations for the 9 | * Linux OS layer of the Wi-Fi driver. 10 | */ 11 | 12 | #ifndef __SPI_IF_H__ 13 | #define __SPI_IF_H__ 14 | 15 | #include 16 | #include 17 | 18 | #define RPU_WAKEUP_NOW BIT(0) /* WAKEUP RPU - RW */ 19 | #define RPU_AWAKE_BIT BIT(1) /* RPU AWAKE FROM SLEEP - RO */ 20 | #define RPU_READY_BIT BIT(2) /* RPU IS READY - RO*/ 21 | 22 | struct spdev_config { 23 | struct mutex lock; 24 | unsigned int addrmask; 25 | unsigned char spi_slave_latency; 26 | void *dev; 27 | }; 28 | 29 | struct spdev { 30 | int (*deinit)(void); 31 | void *config; 32 | void *dev; 33 | int (*init)(struct spdev_config *config); 34 | int (*write)(unsigned long addr, unsigned int data, int len); 35 | int (*read)(unsigned long addr, void *data, int len); 36 | int (*hl_read)(unsigned long addr, void *data, int len); 37 | int (*cp_to)(unsigned long addr, const void *src, int count); 38 | int (*cp_from)(void *dst, unsigned long addr, int count); 39 | void (*hard_reset)(void); 40 | }; 41 | 42 | int spdev_init(struct spdev_config *config); 43 | 44 | int spdev_write(unsigned long addr, unsigned int data, int len); 45 | 46 | int spdev_read(unsigned long addr, void *data, int len); 47 | 48 | int spdev_hl_read(unsigned long addr, void *data, int len); 49 | 50 | int spdev_cp_to(unsigned long addr, const void *src, int count); 51 | 52 | int spdev_cp_from(void *dst, unsigned long addr, int count); 53 | 54 | int spdev_deinit(void); 55 | 56 | struct spdev_config *spdev_defconfig(void); 57 | 58 | struct spdev *sp_dev(void); 59 | 60 | int spdev_cmd_sleep_rpu(void); 61 | 62 | void hard_reset(void); 63 | void get_sleep_stats(uint32_t addr, uint32_t *buff, uint32_t wrd_len); 64 | 65 | extern struct device spi_perip; 66 | 67 | int spdev_validate_rpu_wake_writecmd(void); 68 | int spdev_cmd_wakeup_rpu(uint32_t data); 69 | int spdev_wait_while_rpu_awake(void); 70 | 71 | int spdev_RDSR1(uint8_t *rdsr1); 72 | int spdev_RDSR2(uint8_t *rdsr2); 73 | int spdev_WRSR2(const uint8_t wrsr2); 74 | 75 | #ifdef CONFIG_NRF_WIFI_LOW_POWER 76 | int func_rpu_sleep(void); 77 | int func_rpu_wake(void); 78 | int func_rpu_sleep_status(void); 79 | #endif /* CONFIG_NRF_WIFI_LOW_POWER */ 80 | 81 | int spdev_enable_encryption(uint8_t *key); 82 | 83 | #endif /* __SPI_IF_H__ */ 84 | -------------------------------------------------------------------------------- /src/spi/src/device.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | /** 8 | * @brief File containing QSPI device specific definitions for the 9 | * Zephyr OS layer of the Wi-Fi driver. 10 | */ 11 | 12 | #include "spi_if.h" 13 | 14 | static struct spdev_config config; 15 | 16 | static struct spdev dev = { .init = spdev_init, 17 | .read = spdev_read, 18 | .write = spdev_write, 19 | .hl_read = spdev_hl_read, 20 | .cp_to = spdev_cp_to, 21 | .cp_from = spdev_cp_from }; 22 | 23 | struct spdev_config *spdev_defconfig(void) 24 | { 25 | memset(&config, 0, sizeof(struct spdev_config)); 26 | 27 | config.addrmask = 0x000000; 28 | 29 | config.spi_slave_latency = 3; 30 | 31 | return &config; 32 | } 33 | 34 | struct spdev *sp_dev(void) 35 | { 36 | return &dev; 37 | } 38 | -------------------------------------------------------------------------------- /src/spi/src/rpu_hw_if.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | /** 8 | * @brief File containing common functions for RPU hardware interaction 9 | * using QSPI and SPI that can be invoked by shell or the driver. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "rpu_hw_if.h" 18 | #include "spi_if.h" 19 | 20 | struct gpio_desc *iovdd; 21 | struct gpio_desc *bucken; 22 | struct gpio_desc *host_irq; 23 | struct workqueue_struct *wq; 24 | bool irq_enabled; 25 | 26 | static const struct spdev *spi_dev; 27 | static struct spdev_config *cfg; 28 | 29 | int rpu_gpio_config(void *dev) 30 | { 31 | int ret; 32 | struct spi_device *spi_dev = dev; 33 | 34 | /* IOVDD */ 35 | if (!device_property_present(&spi_dev->dev, "iovdd-gpio")) { 36 | pr_err("dt_gpio - Error! Device property 'iovdd-gpio' not found!\n"); 37 | return -ENODEV; 38 | } 39 | 40 | iovdd = devm_gpiod_get(&spi_dev->dev, "iovdd", 0); 41 | if (IS_ERR(iovdd)) { 42 | pr_err("Cannot get iovdd gpio handle\n"); 43 | return -ENODEV; 44 | } 45 | 46 | ret = gpiod_direction_output(iovdd, 0); 47 | if (ret < 0) { 48 | pr_err("Cannot set iovdd gpio direction\n"); 49 | return ret; 50 | } 51 | pr_debug("Set iovdd direction out\n"); 52 | 53 | /* Bucken */ 54 | if (!device_property_present(&spi_dev->dev, "bucken-gpio")) { 55 | pr_err("dt_gpio - Error! Device property 'bucken' not found!\n"); 56 | return -ENODEV; 57 | } 58 | 59 | bucken = devm_gpiod_get(&spi_dev->dev, "bucken", 0); 60 | if (IS_ERR(bucken)) { 61 | pr_err("Cannot get bucken gpio handle\n"); 62 | return -ENODEV; 63 | } 64 | 65 | ret = gpiod_direction_output(bucken, 0); 66 | if (ret < 0) { 67 | pr_err("Cannot set bucken gpio direction\n"); 68 | return ret; 69 | } 70 | 71 | pr_debug("Set bucken direction out\n"); 72 | 73 | return 0; 74 | } 75 | 76 | int rpu_pwron(void) 77 | { 78 | int ret = -1; 79 | 80 | if (bucken) { 81 | gpiod_set_value(bucken, 0); 82 | } else { 83 | pr_err("BUCKEN GPIO set failed...\n"); 84 | return ret; 85 | } 86 | 87 | if (iovdd) { 88 | gpiod_set_value(iovdd, 0); 89 | } else { 90 | pr_err("IOVDD GPIO set failed...\n"); 91 | return ret; 92 | } 93 | 94 | msleep(1); 95 | 96 | if (bucken) { 97 | gpiod_set_value(bucken, 1); 98 | } else { 99 | pr_err("BUCKEN GPIO set failed...\n"); 100 | return ret; 101 | } 102 | 103 | msleep(1); 104 | 105 | if (iovdd) { 106 | gpiod_set_value(iovdd, 1); 107 | } else { 108 | pr_err("IOVDD GPIO set failed...\n"); 109 | return ret; 110 | } 111 | 112 | msleep(1); 113 | 114 | return 0; 115 | } 116 | 117 | int rpu_spi_init(void *dev) 118 | { 119 | spi_dev = sp_dev(); 120 | 121 | cfg = spdev_defconfig(); 122 | cfg->dev = dev; 123 | spi_dev->init(cfg); 124 | 125 | return 0; 126 | } 127 | 128 | int rpu_sleep(void) 129 | { 130 | return spdev_cmd_sleep_rpu(); 131 | } 132 | 133 | int rpu_wakeup(void) 134 | { 135 | rpu_wrsr2(1); 136 | rpu_rdsr2(); 137 | rpu_rdsr1(); 138 | 139 | return 0; 140 | } 141 | 142 | int rpu_sleep_status(void) 143 | { 144 | return rpu_rdsr1(); 145 | } 146 | 147 | int rpu_wrsr2(uint8_t data) 148 | { 149 | spdev_cmd_wakeup_rpu(data); 150 | return 0; 151 | } 152 | 153 | int rpu_rdsr2(void) 154 | { 155 | return spdev_validate_rpu_wake_writecmd(); 156 | } 157 | 158 | int rpu_rdsr1(void) 159 | { 160 | return spdev_wait_while_rpu_awake(); 161 | } 162 | 163 | int rpu_clks_on(void *dev) 164 | { 165 | struct spi_device *spi_dev = dev; 166 | int err; 167 | uint8_t tx_buffer[] = { 0x02, 0x84, 0x8C, 0x20, 0x00, 0x01, 0x00, 0x00 }; 168 | struct spi_transfer tr = { .tx_buf = tx_buffer, 169 | .len = sizeof(tx_buffer) }; 170 | struct spi_message m; 171 | 172 | spi_message_init(&m); 173 | spi_message_add_tail(&tr, &m); 174 | 175 | err = spi_sync(spi_dev, &m); 176 | if (err) { 177 | pr_err("%s: SPI error: %d\n", __func__, err); 178 | return err; 179 | } 180 | 181 | pr_debug("RPU Clocks ON...\n"); 182 | 183 | return 0; 184 | } 185 | 186 | int rpu_enable(void *dev) 187 | { 188 | rpu_gpio_config(dev); 189 | rpu_pwron(); 190 | rpu_spi_init(dev); 191 | rpu_wakeup(); 192 | rpu_clks_on(dev); 193 | 194 | return 0; 195 | } 196 | 197 | int rpu_disable(void *dev) 198 | { 199 | int err = -1; 200 | 201 | if (bucken) { 202 | gpiod_set_value(bucken, 0); 203 | } else { 204 | pr_err("BUCKEN GPIO set failed...\n"); 205 | return err; 206 | } 207 | 208 | if (iovdd) { 209 | gpiod_set_value(iovdd, 0); 210 | } else { 211 | pr_err("IOVDD GPIO set failed...\n"); 212 | return err; 213 | } 214 | 215 | return 0; 216 | } 217 | -------------------------------------------------------------------------------- /src/spi/src/spi_if.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | /** 8 | * @brief File containing SPI device interface specific definitions for the 9 | * Linux OS layer of the Wi-Fi driver. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "spi_if.h" 17 | 18 | static struct spdev_config *config; 19 | 20 | #define SPI_SPEED_FROM_DTS 0 21 | 22 | static void set_spi_speed(unsigned int speed) 23 | { 24 | struct spi_device *spi_dev = config->dev; 25 | struct device_node *np = spi_dev->dev.of_node; 26 | 27 | if (speed == SPI_SPEED_FROM_DTS) { 28 | const unsigned int *max_speed_hz; 29 | 30 | max_speed_hz = of_get_property(np, "spi-max-frequency", NULL); 31 | if (!max_speed_hz) { 32 | pr_err("%s: spi-max-frequency property not found\n", 33 | __func__); 34 | return; 35 | } 36 | 37 | spi_dev->max_speed_hz = *max_speed_hz; 38 | } else { 39 | spi_dev->max_speed_hz = speed; 40 | } 41 | spi_setup(spi_dev); 42 | } 43 | 44 | static int spdev_read_reg32_hl(unsigned int addr, void *data, unsigned int len, 45 | unsigned int discard_bytes) 46 | { 47 | int err; 48 | struct spi_device *spi_dev = config->dev; 49 | 50 | uint8_t hdr[] = { 51 | 0x0b, /* FASTREAD opcode */ 52 | (addr >> 16) & 0xFF, (addr >> 8) & 0xFF, addr & 0xFF, 53 | 0 /* dummy byte */ 54 | }; 55 | 56 | struct spi_transfer tr = { .tx_buf = hdr, 57 | .len = sizeof(hdr) + discard_bytes }; 58 | struct spi_transfer tr_payload = { .rx_buf = data, .len = len }; 59 | struct spi_message m; 60 | 61 | spi_message_init(&m); 62 | spi_message_add_tail(&tr, &m); 63 | spi_message_add_tail(&tr_payload, &m); 64 | 65 | err = spi_sync(spi_dev, &m); 66 | if (err) { 67 | pr_err("%s: SPI error: %d\n", __func__, err); 68 | return err; 69 | } 70 | 71 | return 0; 72 | } 73 | 74 | int spdev_cp_to(unsigned long addr, const void *src, int count) 75 | { 76 | int err; 77 | struct spi_device *spi_dev = config->dev; 78 | uint8_t hdr[4] = { 0x02, /* PP opcode */ 79 | (((addr >> 16) & 0xFF) | 0x80), (addr >> 8) & 0xFF, 80 | (addr & 0xFF) }; 81 | struct spi_transfer tr = { .tx_buf = hdr, .len = sizeof(hdr) }; 82 | struct spi_transfer tr_payload = { .tx_buf = src, .len = count }; 83 | struct spi_message m; 84 | 85 | spi_message_init(&m); 86 | spi_message_add_tail(&tr, &m); 87 | spi_message_add_tail(&tr_payload, &m); 88 | 89 | err = spi_sync(spi_dev, &m); 90 | if (err < 0) { 91 | pr_err("%s: SPI error: %d\n", __func__, err); 92 | } 93 | return err; 94 | } 95 | 96 | int spdev_cp_from(void *dest, unsigned long addr, int count) 97 | { 98 | int err; 99 | struct spi_device *spi_dev = config->dev; 100 | uint8_t hdr[] = { 101 | 0x0b, /* FASTREAD opcode */ 102 | ((addr >> 16) & 0xFF) | 0x80, (addr >> 8) & 0xFF, addr & 0xFF, 103 | 0 /* dummy byte */ 104 | }; 105 | struct spi_transfer tr_hdr = { .tx_buf = hdr, .len = sizeof(hdr) }; 106 | struct spi_transfer tr_payload = { .rx_buf = dest, .len = count }; 107 | struct spi_message m; 108 | 109 | if (addr < 0x0C0000) { 110 | int offset = 0; 111 | while (count > 0) { 112 | spdev_read_reg32_hl(addr + offset, dest + offset, 4, 113 | 4 * config->spi_slave_latency); 114 | offset += 4; 115 | count -= 4; 116 | } 117 | return 0; 118 | } 119 | 120 | spi_message_init(&m); 121 | spi_message_add_tail(&tr_hdr, &m); 122 | spi_message_add_tail(&tr_payload, &m); 123 | 124 | err = spi_sync(spi_dev, &m); 125 | if (err) { 126 | pr_err("%s: SPI error: %d\n", __func__, err); 127 | return err; 128 | } 129 | 130 | return 0; 131 | } 132 | 133 | int spdev_read_reg(uint32_t reg_addr, uint8_t *reg_value) 134 | { 135 | int err; 136 | uint8_t tx_buffer[6] = { reg_addr }; 137 | uint8_t sr[6]; 138 | struct spi_device *spi_dev = config->dev; 139 | struct spi_message m; 140 | struct spi_transfer tr = { .tx_buf = tx_buffer, 141 | .rx_buf = sr, 142 | .len = sizeof(tx_buffer) }; 143 | 144 | spi_message_init(&m); 145 | spi_message_add_tail(&tr, &m); 146 | 147 | err = spi_sync(spi_dev, &m); 148 | 149 | if (err) { 150 | pr_err("%s: SPI error: %d\n", __func__, err); 151 | return err; 152 | } 153 | 154 | if (err == 0) 155 | *reg_value = sr[1]; 156 | 157 | return err; 158 | } 159 | 160 | int spdev_write_reg(uint32_t reg_addr, const uint8_t reg_value) 161 | { 162 | int err; 163 | uint8_t tx_buffer[] = { reg_addr, reg_value }; 164 | struct spi_device *spi_dev = config->dev; 165 | struct spi_message m; 166 | struct spi_transfer tr = { .tx_buf = tx_buffer, 167 | .len = sizeof(tx_buffer) }; 168 | 169 | spi_message_init(&m); 170 | spi_message_add_tail(&tr, &m); 171 | 172 | err = spi_sync(spi_dev, &m); 173 | 174 | if (err) { 175 | pr_err("%s: SPI error: %d\n", __func__, err); 176 | } 177 | 178 | return err; 179 | } 180 | 181 | int spdev_RDSR1(uint8_t *rdsr1) 182 | { 183 | uint8_t val = 0; 184 | 185 | return spdev_read_reg(0x1F, &val); 186 | } 187 | 188 | int spdev_RDSR2(uint8_t *rdsr2) 189 | { 190 | uint8_t val = 0; 191 | 192 | return spdev_read_reg(0x2F, &val); 193 | } 194 | 195 | int spdev_WRSR2(const uint8_t wrsr2) 196 | { 197 | return spdev_write_reg(0x3F, wrsr2); 198 | } 199 | 200 | int _spdev_wait_while_rpu_awake(void) 201 | { 202 | int ret; 203 | uint8_t val = 0; 204 | int ii = 0; 205 | 206 | for (ii = 0; ii < 10; ii++) { 207 | ret = spdev_read_reg(0x1F, &val); 208 | 209 | if (!ret && (val & RPU_AWAKE_BIT)) { 210 | break; 211 | } 212 | 213 | msleep(10); 214 | } 215 | 216 | return val; 217 | } 218 | 219 | /* Wait until RDSR2 confirms RPU_WAKEUP_NOW write is successful */ 220 | int spdev_wait_while_rpu_wake_write(void) 221 | { 222 | int ret; 223 | uint8_t val = 0; 224 | int ii = 0; 225 | 226 | for (ii = 0; ii < 10; ii++) { 227 | ret = spdev_read_reg(0x2F, &val); 228 | 229 | if (!ret && (val & RPU_WAKEUP_NOW)) { 230 | set_spi_speed(SPI_SPEED_FROM_DTS); 231 | break; 232 | } 233 | 234 | msleep(10); 235 | } 236 | 237 | return ret; 238 | } 239 | 240 | #define RPU_SPI_WAKEUP_FREQ_MHZ 8 * 1000 * 1000 241 | int _spdev_cmd_wakeup_rpu(uint32_t data) 242 | { 243 | /* Always use 8MHz to wake up RPU */ 244 | set_spi_speed(RPU_SPI_WAKEUP_FREQ_MHZ); 245 | 246 | return spdev_write_reg(0x3F, data); 247 | } 248 | 249 | unsigned int _spdev_cmd_sleep_rpu(void) 250 | { 251 | int err; 252 | uint8_t tx_buffer[] = { 0x3f, 0x0 }; 253 | struct spi_device *spi_dev = config->dev; 254 | struct spi_message m; 255 | struct spi_transfer tr = { .tx_buf = tx_buffer, 256 | .len = sizeof(tx_buffer) }; 257 | 258 | spi_message_init(&m); 259 | spi_message_add_tail(&tr, &m); 260 | 261 | err = spi_sync(spi_dev, &m); 262 | 263 | if (err) { 264 | pr_err("%s: SPI error: %d\n", __func__, err); 265 | return err; 266 | } 267 | 268 | return 0; 269 | } 270 | 271 | int spdev_init(struct spdev_config *dev_config) 272 | { 273 | config = dev_config; 274 | config->spi_slave_latency = 3; 275 | mutex_init(&config->lock); 276 | 277 | set_spi_speed(SPI_SPEED_FROM_DTS); 278 | return 0; 279 | } 280 | 281 | static void spdev_addr_check(unsigned int addr, const void *data, 282 | unsigned int len) 283 | { 284 | /* Unused for now */ 285 | } 286 | 287 | static int _spdev_write(unsigned long addr, unsigned int val, unsigned int len) 288 | { 289 | int err; 290 | struct spi_device *spi_dev = config->dev; 291 | uint8_t hdr[8] = { 292 | 0x02, /* PP opcode */ 293 | (((addr >> 16) & 0xFF) | 0x80), 294 | (addr >> 8) & 0xFF, 295 | (addr & 0xFF), 296 | (val & 0xFF), 297 | ((val >> 8) & 0xFF), 298 | ((val >> 16) & 0xFF), 299 | ((val >> 24) & 0xFF), 300 | }; 301 | struct spi_transfer tr = { .tx_buf = hdr, .len = sizeof(hdr) }; 302 | struct spi_message m; 303 | 304 | spi_message_init(&m); 305 | spi_message_add_tail(&tr, &m); 306 | 307 | err = spi_sync(spi_dev, &m); 308 | if (err < 0) { 309 | pr_err("%s: SPI error: %d\n", __func__, err); 310 | } 311 | 312 | return err; 313 | } 314 | 315 | int spdev_write(unsigned long addr, unsigned int data, int len) 316 | { 317 | int status = -1; 318 | 319 | spdev_addr_check(addr, &data, len); 320 | 321 | addr |= config->addrmask; 322 | 323 | status = _spdev_write(addr, data, len); 324 | 325 | return status; 326 | } 327 | 328 | static int _spdev_read(unsigned long addr, void *data, unsigned int len, 329 | unsigned int discard_bytes) 330 | { 331 | int err; 332 | struct spi_device *spi_dev = config->dev; 333 | uint8_t hdr[] = { 334 | 0x0b, /* FASTREAD opcode */ 335 | (addr >> 16) & 0xFF, (addr >> 8) & 0xFF, addr & 0xFF, 336 | 0 /* dummy byte */ 337 | }; 338 | struct spi_transfer tr = { .tx_buf = hdr, 339 | .len = sizeof(hdr) + discard_bytes }; 340 | struct spi_transfer tr_payload = { .rx_buf = data, .len = len }; 341 | struct spi_message m; 342 | 343 | spi_message_init(&m); 344 | spi_message_add_tail(&tr, &m); 345 | spi_message_add_tail(&tr_payload, &m); 346 | 347 | err = spi_sync(spi_dev, &m); 348 | if (err) { 349 | pr_err("%s: SPI error: %d\n", __func__, err); 350 | return err; 351 | } 352 | 353 | return 0; 354 | } 355 | 356 | int spdev_read(unsigned long addr, void *data, int len) 357 | { 358 | int status; 359 | 360 | spdev_addr_check(addr, data, len); 361 | 362 | addr |= config->addrmask; 363 | 364 | status = _spdev_read(addr, data, len, 0); 365 | 366 | return status; 367 | } 368 | 369 | static int spdev_hl_readw(unsigned long addr, void *data) 370 | { 371 | int status = -1; 372 | 373 | status = spdev_read_reg32_hl(addr, data, 4, 374 | 4 * config->spi_slave_latency); 375 | 376 | return status; 377 | } 378 | 379 | int spdev_hl_read(unsigned long addr, void *data, int len) 380 | { 381 | int count = 0; 382 | 383 | spdev_addr_check(addr, data, len); 384 | 385 | while (count < (len / 4)) { 386 | spdev_hl_readw(addr + (4 * count), (char *)data + (4 * count)); 387 | count++; 388 | } 389 | 390 | return 0; 391 | } 392 | 393 | /* ------------------------------added for wifi utils -------------------------------- */ 394 | 395 | int spdev_cmd_wakeup_rpu(uint32_t data) 396 | { 397 | return _spdev_cmd_wakeup_rpu(data); 398 | } 399 | 400 | int spdev_cmd_sleep_rpu(void) 401 | { 402 | return _spdev_cmd_sleep_rpu(); 403 | } 404 | 405 | int spdev_wait_while_rpu_awake(void) 406 | { 407 | return _spdev_wait_while_rpu_awake(); 408 | } 409 | 410 | int spdev_validate_rpu_wake_writecmd(void) 411 | { 412 | return spdev_wait_while_rpu_wake_write(); 413 | } 414 | -------------------------------------------------------------------------------- /src/wiphy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Nordic Semiconductor ASA 3 | * 4 | * SPDX-License-Identifier: GPL-2.0 5 | */ 6 | 7 | #include 8 | 9 | #define CHAN5G(_freq, _idx, _flags) \ 10 | { \ 11 | .band = NL80211_BAND_5GHZ, .center_freq = (_freq), \ 12 | .hw_value = (_idx), .max_power = 20, .flags = (_flags), \ 13 | } 14 | 15 | #define CHAN2G(_freq, _idx) \ 16 | { \ 17 | .band = NL80211_BAND_2GHZ, .center_freq = (_freq), \ 18 | .hw_value = (_idx), .max_power = 20, \ 19 | } 20 | 21 | /* There isn't a lot of sense in it, but you can transmit anything you like */ 22 | const struct ieee80211_txrx_stypes 23 | ieee80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = { 24 | [NL80211_IFTYPE_ADHOC] = { 25 | .tx = 0xffff, 26 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | 27 | BIT(IEEE80211_STYPE_AUTH >> 4) | 28 | BIT(IEEE80211_STYPE_DEAUTH >> 4) | 29 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4), 30 | }, 31 | [NL80211_IFTYPE_STATION] = { 32 | .tx = 0xffff, 33 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | 34 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4), 35 | }, 36 | [NL80211_IFTYPE_AP] = { 37 | .tx = 0xffff, 38 | .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | 39 | BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | 40 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | 41 | BIT(IEEE80211_STYPE_DISASSOC >> 4) | 42 | BIT(IEEE80211_STYPE_AUTH >> 4) | 43 | BIT(IEEE80211_STYPE_DEAUTH >> 4) | 44 | BIT(IEEE80211_STYPE_ACTION >> 4), 45 | }, 46 | [NL80211_IFTYPE_AP_VLAN] = { 47 | /* copy AP */ 48 | .tx = 0xffff, 49 | .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | 50 | BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | 51 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | 52 | BIT(IEEE80211_STYPE_DISASSOC >> 4) | 53 | BIT(IEEE80211_STYPE_AUTH >> 4) | 54 | BIT(IEEE80211_STYPE_DEAUTH >> 4) | 55 | BIT(IEEE80211_STYPE_ACTION >> 4), 56 | }, 57 | [NL80211_IFTYPE_P2P_CLIENT] = { 58 | .tx = 0xffff, 59 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | 60 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4), 61 | }, 62 | [NL80211_IFTYPE_P2P_GO] = { 63 | .tx = 0xffff, 64 | .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | 65 | BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | 66 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | 67 | BIT(IEEE80211_STYPE_DISASSOC >> 4) | 68 | BIT(IEEE80211_STYPE_AUTH >> 4) | 69 | BIT(IEEE80211_STYPE_DEAUTH >> 4) | 70 | BIT(IEEE80211_STYPE_ACTION >> 4), 71 | }, 72 | [NL80211_IFTYPE_MESH_POINT] = { 73 | .tx = 0xffff, 74 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | 75 | BIT(IEEE80211_STYPE_AUTH >> 4) | 76 | BIT(IEEE80211_STYPE_DEAUTH >> 4), 77 | }, 78 | [NL80211_IFTYPE_P2P_DEVICE] = { 79 | .tx = 0xffff, 80 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | 81 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4), 82 | }, 83 | }; 84 | 85 | struct ieee80211_channel ofdm_chantable[] = { 86 | CHAN5G(5180, 14, 0), /* Channel 36 */ 87 | CHAN5G(5200, 15, 0), /* Channel 40 */ 88 | CHAN5G(5220, 16, 0), /* Channel 44 */ 89 | CHAN5G(5240, 17, 0), /* Channel 48 */ 90 | CHAN5G(5260, 18, IEEE80211_CHAN_RADAR), /* Channel 52 */ 91 | CHAN5G(5280, 19, IEEE80211_CHAN_RADAR), /* Channel 56 */ 92 | CHAN5G(5300, 20, IEEE80211_CHAN_RADAR), /* Channel 60 */ 93 | CHAN5G(5320, 21, IEEE80211_CHAN_RADAR), /* Channel 64 */ 94 | CHAN5G(5500, 22, IEEE80211_CHAN_RADAR), /* Channel 100 */ 95 | CHAN5G(5520, 23, IEEE80211_CHAN_RADAR), /* Channel 104 */ 96 | CHAN5G(5540, 24, IEEE80211_CHAN_RADAR), /* Channel 108 */ 97 | CHAN5G(5560, 25, IEEE80211_CHAN_RADAR), /* Channel 112 */ 98 | CHAN5G(5580, 26, IEEE80211_CHAN_RADAR), /* Channel 116 */ 99 | CHAN5G(5600, 27, IEEE80211_CHAN_RADAR), /* Channel 120 */ 100 | CHAN5G(5620, 28, IEEE80211_CHAN_RADAR), /* Channel 124 */ 101 | CHAN5G(5640, 29, IEEE80211_CHAN_RADAR), /* Channel 128 */ 102 | CHAN5G(5660, 30, IEEE80211_CHAN_RADAR), /* Channel 132 */ 103 | CHAN5G(5680, 31, IEEE80211_CHAN_RADAR), /* Channel 136 */ 104 | CHAN5G(5700, 32, IEEE80211_CHAN_RADAR), /* Channel 140 */ 105 | CHAN5G(5720, 33, IEEE80211_CHAN_RADAR), /* Channel 144 */ 106 | CHAN5G(5745, 34, 0), /* Channel 149 */ 107 | CHAN5G(5765, 35, 0), /* Channel 153 */ 108 | CHAN5G(5785, 36, 0), /* Channel 157 */ 109 | CHAN5G(5805, 37, 0), /* Channel 161 */ 110 | CHAN5G(5825, 38, 0), /* Channel 165 */ 111 | CHAN5G(5845, 39, 0), /* Channel 169 */ 112 | CHAN5G(5865, 40, 0), /* Channel 173 */ 113 | CHAN5G(5885, 41, 0), /* Channel 177 */ 114 | }; 115 | 116 | struct ieee80211_channel dsss_chantable[] = { 117 | CHAN2G(2412, 0), /* Channel 1 */ 118 | CHAN2G(2417, 1), /* Channel 2 */ 119 | CHAN2G(2422, 2), /* Channel 3 */ 120 | CHAN2G(2427, 3), /* Channel 4 */ 121 | CHAN2G(2432, 4), /* Channel 5 */ 122 | CHAN2G(2437, 5), /* Channel 6 */ 123 | CHAN2G(2442, 6), /* Channel 7 */ 124 | CHAN2G(2447, 7), /* Channel 8 */ 125 | CHAN2G(2452, 8), /* Channel 9 */ 126 | CHAN2G(2457, 9), /* Channel 10 */ 127 | CHAN2G(2462, 10), /* Channel 11 */ 128 | CHAN2G(2467, 11), /* Channel 12 */ 129 | CHAN2G(2472, 12), /* Channel 13 */ 130 | CHAN2G(2484, 13), /* Channel 14 */ 131 | }; 132 | 133 | struct ieee80211_rate dsss_rates[] = { 134 | { .bitrate = 10, .hw_value = 2 }, 135 | { .bitrate = 20, .hw_value = 4, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 136 | { .bitrate = 55, 137 | .hw_value = 11, 138 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 139 | { .bitrate = 110, 140 | .hw_value = 22, 141 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 142 | { .bitrate = 60, .hw_value = 12 }, 143 | { .bitrate = 90, .hw_value = 18 }, 144 | { .bitrate = 120, .hw_value = 24 }, 145 | { .bitrate = 180, .hw_value = 36 }, 146 | { .bitrate = 240, .hw_value = 48 }, 147 | { .bitrate = 360, .hw_value = 72 }, 148 | { .bitrate = 480, .hw_value = 96 }, 149 | { .bitrate = 540, .hw_value = 108 } 150 | }; 151 | 152 | static struct ieee80211_rate ofdm_rates[] = { 153 | { .bitrate = 60, .hw_value = 12 }, { .bitrate = 90, .hw_value = 18 }, 154 | { .bitrate = 120, .hw_value = 24 }, { .bitrate = 180, .hw_value = 36 }, 155 | { .bitrate = 240, .hw_value = 48 }, { .bitrate = 360, .hw_value = 72 }, 156 | { .bitrate = 480, .hw_value = 96 }, { .bitrate = 540, .hw_value = 108 } 157 | }; 158 | 159 | struct ieee80211_supported_band band_5ghz = { 160 | .channels = ofdm_chantable, 161 | .n_channels = ARRAY_SIZE(ofdm_chantable), 162 | .band = NL80211_BAND_5GHZ, 163 | .bitrates = ofdm_rates, 164 | .n_bitrates = ARRAY_SIZE(ofdm_rates), 165 | }; 166 | struct ieee80211_supported_band band_2ghz = { 167 | .channels = dsss_chantable, 168 | .n_channels = ARRAY_SIZE(dsss_chantable), 169 | .band = NL80211_BAND_2GHZ, 170 | .bitrates = dsss_rates, 171 | .n_bitrates = ARRAY_SIZE(dsss_rates), 172 | .ht_cap.ht_supported = 1, 173 | /*.vht_cap.vht_supported = 1,*/ 174 | }; 175 | -------------------------------------------------------------------------------- /west.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 Nordic Semiconductor ASA 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | manifest: 5 | remotes: 6 | - name: ncs 7 | url-base: https://github.com/nrfconnect 8 | 9 | projects: 10 | # TODO: Once west supports sparse checkout, we should use it here. 11 | - name: nrfxlib 12 | remote: ncs 13 | repo-path: sdk-nrfxlib 14 | revision: 2fe3e8248e16a52cf530358815d19617cb96c1d1 15 | --------------------------------------------------------------------------------