FAPI TM, WLS_LIB and ODULOW documentation
[o-du/phy.git] / wls_lib / syslib.h
1 /******************************************************************************
2 *
3 *   Copyright (c) 2019 Intel.
4 *
5 *   Licensed under the Apache License, Version 2.0 (the "License");
6 *   you may not use this file except in compliance with the License.
7 *   You may obtain a copy of the License at
8 *
9 *       http://www.apache.org/licenses/LICENSE-2.0
10 *
11 *   Unless required by applicable law or agreed to in writing, software
12 *   distributed under the License is distributed on an "AS IS" BASIS,
13 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 *   See the License for the specific language governing permissions and
15 *   limitations under the License.
16 *
17 *******************************************************************************/
18
19 #ifndef __SYSLIB_H__
20 #define __SYSLIB_H__
21
22 typedef unsigned char  U8;      /* unsigned 8-bit  integer */
23 typedef unsigned short U16;     /* unsigned 16-bit integer */
24 typedef unsigned int   U32;     /* unsigned 32-bit integer */
25 #ifdef __x86_64__
26 typedef unsigned long  U64;     /* unsigned 64-bit integer */
27 #else
28 typedef unsigned long long  U64;     /* unsigned 64-bit integer */
29 #endif
30
31 typedef volatile unsigned char  V8;
32 typedef volatile unsigned short V16;
33 typedef volatile unsigned int   V32;
34 typedef volatile unsigned long  V4;
35
36 typedef signed char  S8;         /* 8-bit  signed integer */
37 typedef signed short S16;       /* 16-bit signed integer */
38 typedef signed int   S32;        /* 32-bit signed integer */
39
40 #ifdef __x86_64__
41 typedef signed long  S64;          /* unsigned 64-bit integer */
42 #else
43 typedef signed long long  S64;     /* unsigned 64-bit integer */
44 #endif
45
46 #ifndef _PVOID_
47 #define _PVOID_
48 typedef void *PVOID;
49 #endif
50
51 typedef U64 (*wls_us_addr_conv)(void*, U64);
52
53
54 #define K                       1024
55 #define M                       (K*K)
56 #define KHZ         1000
57 #define MHZ         (KHZ * KHZ)
58
59 #ifndef TRUE
60 #define TRUE (1)
61 #endif
62
63 #ifndef FALSE
64 #define FALSE (0)
65 #endif
66
67 #ifndef NULL
68 #define NULL ((PVOID)(0))
69 #endif
70 #define HANDLE  PVOID
71
72 #ifdef __KERNEL__
73 #define DSB()  smp_mb()
74 #define DMB()  smp_wmb()
75 #else
76 #define DSB()  __asm__ __volatile__("mfence": : :"memory")
77 #define DMB()  __asm__ __volatile__("sfence": : :"memory")
78 #endif
79
80 typedef struct tagWLS_MSG_HANDLE
81 {
82     U64   pIaPaMsg;
83     U32   pWlsPaMsg;
84     U32   MsgSize;
85     U16   TypeID;         // used to identify destination
86     U16   flags;
87     U32   res1;
88 } WLS_MSG_HANDLE, *PWLS_MSG_HANDLE; /* 4 x QW */
89
90 typedef struct tagFASTQUEUE {
91     U64 pStorage;
92         U32 BlockSize;
93         U32 sema;
94         V32 get;
95         V32 put;
96         U32 size;
97     U32 res;
98 } FASTQUEUE, *PFASTQUEUE;
99
100 typedef struct tagWLS_MSG_QUEUE {
101     U64 pStorage;
102         U32 sema;
103         V32 get;
104         V32 put;
105         U32 size;
106 } WLS_MSG_QUEUE, *PWLS_MSG_QUEUE;
107
108 #define COUNT(some_array) ( sizeof(some_array)/sizeof((some_array)[0]) )
109
110 void SFL_DefQueue(PFASTQUEUE pq, void *pStorage, int StorageSize);
111 int     SFL_WlsEnqueue(PFASTQUEUE pq, U64 pData, wls_us_addr_conv change_addr, void* hWls);
112 int     SFL_Enqueue_NoSync(PFASTQUEUE pq, PVOID pData);
113 U64 SFL_WlsDequeue(PFASTQUEUE pq, wls_us_addr_conv change_addr, void *hWls);
114
115 PVOID SFL_Dequeue_NoSync(PFASTQUEUE pq);
116 U32 SFL_Queue_BatchRead( PFASTQUEUE pq, unsigned long *pDestArr, U32 Count);
117 U32 SFL_Queue_BatchWrite( PFASTQUEUE pq, unsigned long *pSrcArr, U32 Count);
118
119 void WLS_MsgDefineQueue(PWLS_MSG_QUEUE pq, PWLS_MSG_HANDLE pStorage, U32 size, U32 sema);
120 U32 WLS_MsgEnqueue(PWLS_MSG_QUEUE pq, U64  pIaPaMsg, U32 MsgSize, U16 TypeID, U16   flags, wls_us_addr_conv change_addr, void* h);
121 int WLS_MsgDequeue(PWLS_MSG_QUEUE pq, PWLS_MSG_HANDLE pDestItem, wls_us_addr_conv change_addr, void *hWls);
122 U32 WLS_GetNumItemsInTheQueue(PWLS_MSG_QUEUE fpq);
123 U32 SFL_GetNumItemsInTheQueue(FASTQUEUE *fpq);
124
125
126
127
128
129 #endif // __SYSLIB_H__
130
131