nRF WiFi
Loading...
Searching...
No Matches
osal_api.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
12#ifndef __OSAL_API_H__
13#define __OSAL_API_H__
14
15#include "osal_structs.h"
16
17/* Have to match zephyr/include/zephyr/logging/log_core.h */
18#define NRF_WIFI_LOG_LEVEL_ERR 1U
19#define NRF_WIFI_LOG_LEVEL_INF 3U
20#define NRF_WIFI_LOG_LEVEL_DBG 4U
21
22#ifndef NRF70_LOG_VERBOSE
23#define __func__ "<snipped>"
24#endif /* NRF70_LOG_VERBOSE */
25
33void nrf_wifi_osal_init(const struct nrf_wifi_osal_ops *ops);
34
42
52void *nrf_wifi_osal_mem_alloc(size_t size);
53
63void *nrf_wifi_osal_mem_zalloc(size_t size);
64
76
84void nrf_wifi_osal_mem_free(void *buf);
85
96
110 const void *src,
111 size_t count);
112
124void *nrf_wifi_osal_mem_set(void *start,
125 int val,
126 size_t size);
127
128
138void *nrf_wifi_osal_iomem_mmap(unsigned long addr,
139 unsigned long size);
140
147void nrf_wifi_osal_iomem_unmap(volatile void *addr);
148
155unsigned int nrf_wifi_osal_iomem_read_reg32(const volatile void *addr);
156
166 unsigned int val);
167
178 const volatile void *src,
179 size_t count);
180
191 const void *src,
192 size_t count);
193
194
203
211
212
220
221
229
230
238
239
249 unsigned long *flags);
250
251
261 unsigned long *flags);
262
263
264#if WIFI_NRF70_LOG_LEVEL >= NRF_WIFI_LOG_LEVEL_DBG
274int nrf_wifi_osal_log_dbg(const char *fmt, ...);
275#else
276#define nrf_wifi_osal_log_dbg(fmt, ...)
277#endif
278
279#if WIFI_NRF70_LOG_LEVEL >= NRF_WIFI_LOG_LEVEL_INF
289int nrf_wifi_osal_log_info(const char *fmt, ...);
290#else
291#define nrf_wifi_osal_log_info(fmt, ...)
292#endif
293
294#if WIFI_NRF70_LOG_LEVEL >= NRF_WIFI_LOG_LEVEL_ERR
304int nrf_wifi_osal_log_err(const char *fmt, ...);
305#else
306#define nrf_wifi_osal_log_err(fmt, ...)
307#endif
308
318
328
336
344
355
356
365 void *data);
366
367
376
383void nrf_wifi_osal_llist_free(void *llist);
384
393
401
408void nrf_wifi_osal_llist_init(void *llist);
409
410
420 void *llist_node);
421
422
432 void *llist_node);
443
444
456 void *llist_node);
457
458
468 void *llist_node);
469
470
479unsigned int nrf_wifi_osal_llist_len(void *llist);
480
481
490void *nrf_wifi_osal_nbuf_alloc(unsigned int size);
491
492
500void nrf_wifi_osal_nbuf_free(void *nbuf);
501
502
512 unsigned int size);
513
514
515
525unsigned int nrf_wifi_osal_nbuf_headroom_get(void *nbuf);
526
535unsigned int nrf_wifi_osal_nbuf_data_size(void *nbuf);
536
537
547
548
561 unsigned int size);
562
563
576 unsigned int size);
577
578
591 unsigned int size);
592
593
602unsigned char nrf_wifi_osal_nbuf_get_priority(void *nbuf);
603
612unsigned char nrf_wifi_osal_nbuf_get_chksum_done(void *nbuf);
613
622 unsigned char chksum_done);
623
624#if defined(CONFIG_NRF70_RAW_DATA_TX) || defined(__DOXYGEN__)
635 unsigned short raw_hdr_len);
636
646
656#endif /* CONFIG_NRF70_RAW_DATA_TX || __DOXYGEN__ */
657
667
675void nrf_wifi_osal_tasklet_free(void *tasklet);
676
677
686void nrf_wifi_osal_tasklet_init(void *tasklet,
687 void (*callbk_fn)(unsigned long),
688 unsigned long data);
689
690
700
701
709void nrf_wifi_osal_tasklet_kill(void *tasklet);
710
711
718void nrf_wifi_osal_sleep_ms(unsigned int msecs);
719
720
729void nrf_wifi_osal_delay_us(unsigned long usecs);
730
731
740
749unsigned int nrf_wifi_osal_time_elapsed_us(unsigned long start_time_us);
750
759
770unsigned int nrf_wifi_osal_time_elapsed_ms(unsigned long start_time_ms);
771
784void *nrf_wifi_osal_bus_pcie_init(const char *dev_name,
785 unsigned int vendor_id,
786 unsigned int sub_vendor_id,
787 unsigned int device_id,
788 unsigned int sub_device_id);
789
790
798void nrf_wifi_osal_bus_pcie_deinit(void *os_pcie_priv);
799
800
806void *nrf_wifi_osal_bus_pcie_dev_add(void *os_pcie_priv,
807 void *osal_pcie_dev_ctx);
808
809
817void nrf_wifi_osal_bus_pcie_dev_rem(void *os_pcie_dev_ctx);
818
819
830
831
839void nrf_wifi_osal_bus_pcie_dev_deinit(void *os_pcie_dev_ctx);
840
841
854 void *callbk_data,
855 int (*callbk_fn)(void *callbk_data));
856
857
864void nrf_wifi_osal_bus_pcie_dev_intr_unreg(void *os_pcie_dev_ctx);
865
866
882void *nrf_wifi_osal_bus_pcie_dev_dma_map(void *os_pcie_dev_ctx,
883 void *virt_addr,
884 size_t size,
885 enum nrf_wifi_osal_dma_dir dir);
886
887
897void nrf_wifi_osal_bus_pcie_dev_dma_unmap(void *os_pcie_dev_ctx,
898 void *dma_addr,
899 size_t size,
900 enum nrf_wifi_osal_dma_dir dir);
901
902
911 struct nrf_wifi_osal_host_map *host_map);
912
913
914
915
924
932void nrf_wifi_osal_bus_qspi_deinit(void *os_qspi_priv);
933
934
945void *nrf_wifi_osal_bus_qspi_dev_add(void *os_qspi_priv,
946 void *osal_qspi_dev_ctx);
947
948
956void nrf_wifi_osal_bus_qspi_dev_rem(void *os_qspi_dev_ctx);
957
958
971
972
980void nrf_wifi_osal_bus_qspi_dev_deinit(void *os_qspi_dev_ctx);
981
982
995 void *callbk_data,
996 int (*callbk_fn)(void *callbk_data));
997
998
1006void nrf_wifi_osal_bus_qspi_dev_intr_unreg(void *os_qspi_dev_ctx);
1007
1008
1017 struct nrf_wifi_osal_host_map *host_map);
1018
1026unsigned int nrf_wifi_osal_qspi_read_reg32(void *priv,
1027 unsigned long addr);
1028
1036 unsigned long addr,
1037 unsigned int val);
1038
1047 void *dest,
1048 unsigned long addr,
1049 size_t count);
1050
1059 unsigned long addr,
1060 const void *src,
1061 size_t count);
1062
1071
1079void nrf_wifi_osal_bus_spi_deinit(void *os_spi_priv);
1080
1081
1092void *nrf_wifi_osal_bus_spi_dev_add(void *os_spi_priv,
1093 void *osal_spi_dev_ctx);
1094
1095
1103void nrf_wifi_osal_bus_spi_dev_rem(void *os_spi_dev_ctx);
1104
1105
1118
1119
1127void nrf_wifi_osal_bus_spi_dev_deinit(void *os_spi_dev_ctx);
1128
1129
1144 void *callbk_data,
1145 int (*callbk_fn)(void *callbk_data));
1146
1147
1155void nrf_wifi_osal_bus_spi_dev_intr_unreg(void *os_spi_dev_ctx);
1156
1157
1166 struct nrf_wifi_osal_host_map *host_map);
1167
1175unsigned int nrf_wifi_osal_spi_read_reg32(void *priv,
1176 unsigned long addr);
1177
1185 unsigned long addr,
1186 unsigned int val);
1187
1196 void *dest,
1197 unsigned long addr,
1198 size_t count);
1199
1208 unsigned long addr,
1209 const void *src,
1210 size_t count);
1211
1212
1213#if defined(NRF_WIFI_LOW_POWER) || defined(__DOXYGEN__)
1222
1230
1231
1243 void (*callbk_fn)(unsigned long),
1244 unsigned long data);
1245
1246
1256 unsigned long duration);
1257
1258
1264
1271int nrf_wifi_osal_bus_qspi_ps_sleep(void *os_qspi_priv);
1272
1279int nrf_wifi_osal_bus_qspi_ps_wake(void *os_qspi_priv);
1280
1289int nrf_wifi_osal_bus_qspi_ps_status(void *os_qspi_priv);
1290#endif /* NRF_WIFI_LOW_POWER */
1291
1302 int val,
1304 char *msg);
1305
1314unsigned int nrf_wifi_osal_strlen(const void *str);
1315
1327int nrf_wifi_osal_mem_cmp(const void *addr1,
1328 const void *addr2,
1329 size_t count);
1330
1339unsigned char nrf_wifi_osal_rand8_get(void);
1340
1341
1342#endif /* __OSAL_API_H__ */
unsigned char src[6]
Definition fmac_util.h:1
unsigned char dest[6]
Definition host_rpu_data_if.h:5
unsigned int type
Definition host_rpu_umac_if.h:1
unsigned int nrf_wifi_osal_llist_len(void *llist)
Get length of a linked list.
void nrf_wifi_osal_spi_cpy_to(void *priv, unsigned long addr, const void *src, size_t count)
Copies data from a source buffer to a SPI slave device.
void nrf_wifi_osal_llist_add_node_tail(void *llist, void *llist_node)
Add a node to the tail of a linked list.
void nrf_wifi_osal_tasklet_init(void *tasklet, void(*callbk_fn)(unsigned long), unsigned long data)
Initialize a tasklet.
void nrf_wifi_osal_deinit(void)
Deinitialize the OSAL layer.
void nrf_wifi_osal_assert(int test, int val, enum nrf_wifi_assert_op_type op, char *msg)
nrf_wifi_osal_assert() - Assert a condition with a value.
unsigned char nrf_wifi_osal_nbuf_get_priority(void *nbuf)
Get the priority of a network buffer.
void nrf_wifi_osal_iomem_cpy_to(volatile void *dest, const void *src, size_t count)
Copy data to the memory of a memory mapped IO device from host memory.
void nrf_wifi_osal_qspi_cpy_from(void *priv, void *dest, unsigned long addr, size_t count)
Copies data from a QSPI slave device to a destination buffer.
void nrf_wifi_osal_tasklet_kill(void *tasklet)
Terminate a tasklet.
void * nrf_wifi_osal_llist_alloc(void)
Allocate a linked list.
void nrf_wifi_osal_bus_pcie_dev_intr_unreg(void *os_pcie_dev_ctx)
Unregister an interrupt handler for a PCIe device.
#define nrf_wifi_osal_log_info(fmt,...)
Definition osal_api.h:291
void nrf_wifi_osal_bus_pcie_deinit(void *os_pcie_priv)
Deinitialize a PCIe device driver.
void nrf_wifi_osal_spinlock_init(void *lock)
Initialize a busy lock.
void nrf_wifi_osal_bus_pcie_dev_rem(void *os_pcie_dev_ctx)
Remove a PCIe device instance.
int nrf_wifi_osal_bus_qspi_ps_wake(void *os_qspi_priv)
Wakes up the QSPI interface from sleep.
enum nrf_wifi_status nrf_wifi_osal_bus_qspi_dev_init(void *os_qspi_dev_ctx)
Initialize a qspi device instance.
enum nrf_wifi_status nrf_wifi_osal_bus_qspi_dev_intr_reg(void *os_qspi_dev_ctx, void *callbk_data, int(*callbk_fn)(void *callbk_data))
void * nrf_wifi_osal_bus_qspi_dev_add(void *os_qspi_priv, void *osal_qspi_dev_ctx)
void * nrf_wifi_osal_llist_node_alloc(void)
Allocate a linked list node.
void nrf_wifi_osal_spinlock_irq_rel(void *lock, unsigned long *flags)
Release a busy lock and enable interrupts.
void * nrf_wifi_osal_mem_set(void *start, int val, size_t size)
Fill a block of memory with a particular value.
void nrf_wifi_osal_timer_schedule(void *timer, unsigned long duration)
Schedule a timer.
void nrf_wifi_osal_spi_cpy_from(void *priv, void *dest, unsigned long addr, size_t count)
Copies data from a SPI slave device to a destination buffer.
void * nrf_wifi_osal_ctrl_llist_node_alloc(void)
Allocate a linked list node from control pool.
void nrf_wifi_osal_bus_pcie_dev_dma_unmap(void *os_pcie_dev_ctx, void *dma_addr, size_t size, enum nrf_wifi_osal_dma_dir dir)
Unmap DMA mapped host memory.
void nrf_wifi_osal_spinlock_free(void *lock)
Free a busy lock.
void * nrf_wifi_osal_llist_node_data_get(void *node)
Get data stored in a linked list node.
#define nrf_wifi_osal_log_err(fmt,...)
Definition osal_api.h:306
void nrf_wifi_osal_data_mem_free(void *buf)
Free previously allocated memory for data.
void nrf_wifi_osal_tasklet_free(void *tasklet)
Free a tasklet.
void nrf_wifi_osal_timer_free(void *timer)
Free a timer.
enum nrf_wifi_status nrf_wifi_osal_bus_spi_dev_init(void *os_spi_dev_ctx)
Initialize a spi device instance.
unsigned int nrf_wifi_osal_spi_read_reg32(void *priv, unsigned long addr)
Read value from a 32 bit register on a SPI slave device.
bool nrf_wifi_osal_nbuf_is_raw_tx(void *nbuf)
Check if a network buffer is a raw Tx buffer.
void nrf_wifi_osal_init(const struct nrf_wifi_osal_ops *ops)
Initialize the OSAL layer.
int nrf_wifi_osal_bus_qspi_ps_status(void *os_qspi_priv)
Get the power status of a QSPI interface.
void * nrf_wifi_osal_llist_get_node_nxt(void *llist, void *llist_node)
Get the next node in a linked list.
void nrf_wifi_osal_llist_node_free(void *node)
Free a linked list node.
unsigned int nrf_wifi_osal_time_elapsed_us(unsigned long start_time_us)
Get elapsed time in microseconds.
void * nrf_wifi_osal_ctrl_llist_alloc(void)
Allocate a linked list.
void nrf_wifi_osal_llist_node_data_set(void *node, void *data)
Set data in a linked list node.
#define nrf_wifi_osal_log_dbg(fmt,...)
Definition osal_api.h:276
unsigned int nrf_wifi_osal_nbuf_data_size(void *nbuf)
Get the size of data in a network buffer.
void * nrf_wifi_osal_nbuf_data_push(void *nbuf, unsigned int size)
Extend the head portion of the data in a network buffer.
unsigned int nrf_wifi_osal_time_elapsed_ms(unsigned long start_time_ms)
void nrf_wifi_osal_iomem_unmap(volatile void *addr)
Unmap previously mapped IO memory from CPU space.
void nrf_wifi_osal_tasklet_schedule(void *tasklet)
Schedule a tasklet.
void nrf_wifi_osal_spinlock_irq_take(void *lock, unsigned long *flags)
Acquire a busy lock and disable interrupts.
void nrf_wifi_osal_bus_qspi_deinit(void *os_qspi_priv)
Deinitialize a qspi device driver.
void nrf_wifi_osal_bus_qspi_dev_rem(void *os_qspi_dev_ctx)
unsigned int nrf_wifi_osal_nbuf_headroom_get(void *nbuf)
Get the size of the headroom in a network buffer.
void * nrf_wifi_osal_bus_qspi_init(void)
Initialize a qspi driver.
unsigned int nrf_wifi_osal_strlen(const void *str)
Gives the length of the string str.
unsigned int nrf_wifi_osal_qspi_read_reg32(void *priv, unsigned long addr)
Read value from a 32 bit register on a QSPI slave device.
void nrf_wifi_osal_bus_spi_dev_host_map_get(void *os_spi_dev_ctx, struct nrf_wifi_osal_host_map *host_map)
Get host mapped address for a spi device.
void nrf_wifi_osal_qspi_write_reg32(void *priv, unsigned long addr, unsigned int val)
Writes a 32 bit value to a 32 bit device register on a QSPI slave device.
unsigned char nrf_wifi_osal_rand8_get(void)
void * nrf_wifi_osal_spinlock_alloc(void)
Allocate a busy lock.
void * nrf_wifi_osal_nbuf_set_raw_tx_hdr(void *nbuf, unsigned short raw_hdr_len)
Set the raw Tx header in a network buffer.
void nrf_wifi_osal_timer_init(void *timer, void(*callbk_fn)(unsigned long), unsigned long data)
Initialize a timer.
void nrf_wifi_osal_bus_spi_deinit(void *os_spi_priv)
Deinitialize a spi device driver.
void * nrf_wifi_osal_bus_pcie_dev_dma_map(void *os_pcie_dev_ctx, void *virt_addr, size_t size, enum nrf_wifi_osal_dma_dir dir)
Map host memory for DMA access.
void nrf_wifi_osal_spinlock_take(void *lock)
Acquire a busy lock.
void * nrf_wifi_osal_bus_spi_init(void)
Initialize a spi driver.
void nrf_wifi_osal_qspi_cpy_to(void *priv, unsigned long addr, const void *src, size_t count)
Copies data from a source buffer to a QSPI slave device.
void * nrf_wifi_osal_llist_get_node_head(void *llist)
Get the head of a linked list.
void nrf_wifi_osal_nbuf_headroom_res(void *nbuf, unsigned int size)
Reserve headroom space in a network buffer.
void nrf_wifi_osal_llist_free(void *llist)
Free a linked list.
void nrf_wifi_osal_bus_qspi_dev_intr_unreg(void *os_qspi_dev_ctx)
void nrf_wifi_osal_llist_add_node_head(void *llist, void *llist_node)
Add a node to the head of a linked list.
unsigned int nrf_wifi_osal_iomem_read_reg32(const volatile void *addr)
Read value from a 32 bit IO memory mapped register.
int nrf_wifi_osal_mem_cmp(const void *addr1, const void *addr2, size_t count)
Compare contents from one memory location to another.
void nrf_wifi_osal_llist_init(void *llist)
Initialize a linked list.
void nrf_wifi_osal_delay_us(unsigned long usecs)
Delay for a specified duration in microseconds.
void * nrf_wifi_osal_mem_zalloc(size_t size)
Allocated zero-initialized memory for control path requests.
void * nrf_wifi_osal_timer_alloc(void)
Allocate a timer.
void * nrf_wifi_osal_iomem_mmap(unsigned long addr, unsigned long size)
Memory map IO memory into CPU space.
void * nrf_wifi_osal_mem_alloc(size_t size)
Allocate memory for control path requests.
void * nrf_wifi_osal_nbuf_alloc(unsigned int size)
Allocate a network buffer.
void * nrf_wifi_osal_nbuf_data_pull(void *nbuf, unsigned int size)
Reduce the head portion of the data in a network buffer.
void nrf_wifi_osal_iomem_cpy_from(void *dest, const volatile void *src, size_t count)
Copy data from the memory of a memory mapped IO device to host memory.
void nrf_wifi_osal_bus_spi_dev_intr_unreg(void *os_spi_dev_ctx)
Unregister an interrupt handler for a spi device.
int nrf_wifi_osal_bus_qspi_ps_sleep(void *os_qspi_priv)
Puts the QSPI interface to sleep.
void * nrf_wifi_osal_data_mem_zalloc(size_t size)
Allocated zero-initialized memory for data.
void nrf_wifi_osal_spinlock_rel(void *lock)
Releases a busy lock.
void * nrf_wifi_osal_nbuf_data_get(void *nbuf)
Get a handle to the data in a network buffer.
unsigned char nrf_wifi_osal_nbuf_get_chksum_done(void *nbuf)
Get the checksum status of a network buffer.
void * nrf_wifi_osal_nbuf_get_raw_tx_hdr(void *nbuf)
Get the raw Tx header from a network buffer.
void * nrf_wifi_osal_nbuf_data_put(void *nbuf, unsigned int size)
Extend the tail portion of the data in a network buffer.
void nrf_wifi_osal_bus_spi_dev_rem(void *os_spi_dev_ctx)
Remove a spi device instance.
void nrf_wifi_osal_mem_free(void *buf)
Free previously allocated memory for control path requests.
void nrf_wifi_osal_bus_pcie_dev_host_map_get(void *os_pcie_dev_ctx, struct nrf_wifi_osal_host_map *host_map)
Get host mapped address for a PCIe device.
void nrf_wifi_osal_bus_qspi_dev_host_map_get(void *os_qspi_dev_ctx, struct nrf_wifi_osal_host_map *host_map)
Get host mapped address for a qspi device.
void nrf_wifi_osal_llist_del_node(void *llist, void *llist_node)
Delete node from a linked list.
void nrf_wifi_osal_ctrl_llist_free(void *llist)
Free a linked list.
void nrf_wifi_osal_nbuf_free(void *nbuf)
Free a network buffer.
void nrf_wifi_osal_iomem_write_reg32(volatile void *addr, unsigned int val)
Write a 32 bit value to a IO memory mapped register.
unsigned long nrf_wifi_osal_time_get_curr_us(void)
Get current system uptime in microseconds.
void nrf_wifi_osal_bus_qspi_dev_deinit(void *os_qspi_dev_ctx)
enum nrf_wifi_status nrf_wifi_osal_bus_pcie_dev_intr_reg(void *os_pcie_dev_ctx, void *callbk_data, int(*callbk_fn)(void *callbk_data))
Register an interrupt handler for a PCIe device.
void * nrf_wifi_osal_bus_pcie_init(const char *dev_name, unsigned int vendor_id, unsigned int sub_vendor_id, unsigned int device_id, unsigned int sub_device_id)
Initialize a PCIe driver.
void nrf_wifi_osal_bus_pcie_dev_deinit(void *os_pcie_dev_ctx)
Deinitialize a PCIe device instance.
void * nrf_wifi_osal_bus_pcie_dev_add(void *os_pcie_priv, void *osal_pcie_dev_ctx)
void * nrf_wifi_osal_tasklet_alloc(int type)
Allocate a tasklet.
void * nrf_wifi_osal_bus_spi_dev_add(void *os_spi_priv, void *osal_spi_dev_ctx)
void nrf_wifi_osal_ctrl_llist_node_free(void *node)
Free a linked list node in control pool.
void * nrf_wifi_osal_mem_cpy(void *dest, const void *src, size_t count)
Copy contents from one memory location to another.
enum nrf_wifi_status nrf_wifi_osal_bus_pcie_dev_init(void *os_pcie_dev_ctx)
Initialize a PCIe device instance.
void nrf_wifi_osal_timer_kill(void *timer)
Kills a timer.
void nrf_wifi_osal_nbuf_set_chksum_done(void *nbuf, unsigned char chksum_done)
Set the checksum status of a network buffer.
void nrf_wifi_osal_bus_spi_dev_deinit(void *os_spi_dev_ctx)
Deinitialize a spi device instance.
unsigned long nrf_wifi_osal_time_get_curr_ms(void)
enum nrf_wifi_status nrf_wifi_osal_bus_spi_dev_intr_reg(void *os_spi_dev_ctx, void *callbk_data, int(*callbk_fn)(void *callbk_data))
Register a interrupt handler for a spi device.
void nrf_wifi_osal_spi_write_reg32(void *priv, unsigned long addr, unsigned int val)
Writes a 32 bit value to a 32 bit device register on a SPI slave device.
void nrf_wifi_osal_sleep_ms(unsigned int msecs)
Sleep for a specified duration in milliseconds.
nrf_wifi_assert_op_type
The type of assertion operation to be performed.
Definition osal_structs.h:101
nrf_wifi_status
The status of an operation performed by the RPU driver.
Definition osal_structs.h:39
nrf_wifi_osal_dma_dir
DMA direction for a DMA operation.
Definition osal_structs.h:49
Structure declarations for the OSAL Layer of the Wi-Fi driver.
unsigned int addr
Definition rpu_if.h:1
Structure representing a host map.
Definition osal_structs.h:83
File containing OPs declarations for the OSAL Layer of the Wi-Fi driver.
Definition osal_ops.h:27