5f27522768aff4e873275bf39a2927c29b8737d2
[o-du/l2.git] / src / rlog / rl_soc.c
1 /*******************************************************************************
2 ################################################################################
3 #   Copyright (c) [2017-2019] [Radisys]                                        #
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 /********************************************************************20**
20
21      Name:     Radisys Logging Framework
22      Type:     C source file
23      Desc:     This file contains logging framework implementation.
24      File:     rl_soc.c
25
26 *********************************************************************21*/
27 /**********************************************************************
28  @ description: This source file has SOC specific functions required for 
29  logging framework
30 ************************************************************************/
31 #include "envopt.h"
32 #include "envdep.h"
33 #include"stdint.h"
34 #include "rl_interface.h"
35 #include "rl_rlog.h"
36 #include "rl_platform.h"
37
38 #include "gen.h"
39 #include "ssi.h"
40 #include "ss_msg.h"
41 #include "ss_task.h"
42 #include "gen.x"
43 #include "ssi.x"
44 #include "ss_queue.h"
45 #include "ss_queue.x"
46 #include "ss_task.x"
47 #include "ss_msg.x"
48 #include "cm_inet.h"
49 #include "cm_inet.x"
50
51 #include "rl_soc.h"
52
53 //////////////////////////////////////////////////////////////////////////
54 //  @Function    : rlInitL2Log 
55 //  @Description : This will be trigigered from cl init function to
56 //                 allocate buffer from shared memory and to intialize
57 //                 the buffer
58 //  @in          : void
59 //  @out         : void
60 //////////////////////////////////////////////////////////////////////////
61
62 void rlInitL2SocSpecific(void)
63 {
64 #ifndef RLOG_ENABLE_TEXT_LOGGING
65
66    if (SGetStaticBuffer(0,  /* region - value does not matter in this case  */
67                         0,  /* pool   - value does not matter in this case  */  
68                         &g_l2rlogBuf, 
69                         L2LOG_BUFF_BLOCK_SIZE, /* Buffer size to be allocated */
70                         0) != ROK)      /* Memory type is SS_SHARABLE_MEMORY  */
71    {
72       printf("Memory allocation failed for g_l2rlogBuf!!!\n");
73       /* kill binary */
74    }
75    memset(g_l2rlogBuf, 0, L2LOG_BUFF_SIZE); 
76
77    g_l2LogBufBasePtr = g_l2rlogBuf;
78    g_l2LogBufStartPtr     = g_l2rlogBuf + sizeof(g_l2LogBufLen);
79
80 #endif
81    return;
82 }
83
84 //////////////////////////////////////////////////////////////////////////
85 //  @Function    : processL2LogBuff 
86 //  @Description : This function will get triggered after every 10 tti 
87 //                 and this will reset log buffers for L2 and also  sends log
88 //                 buffer to L3 which was collected
89 //  @in          : void
90 //  @out         : void
91 //////////////////////////////////////////////////////////////////////////
92
93 void processL2LogBuff(void)
94 {
95 #ifndef RLOG_ENABLE_TEXT_LOGGING
96    if(g_l2LogBufLen > 0)
97    {
98       Data *l2rlogBuf_post;
99
100       /* Log buffer position in flat buffer. If position is last wrap to first buffer */
101       if (g_l2logBuffPos++ >=4)
102       {
103          g_l2logBuffPos = 0;
104       }
105
106       g_writeCirBuf = 1; /* This will avoid contention while switching log buffers */
107
108       l2rlogBuf_post = g_l2LogBufBasePtr;   /* copy logBufferPointer for later use */
109       /* Set L2 Log Buffer length in first 4 bytes of flat buffer */
110       *((uint32_t*) g_l2LogBufBasePtr) = g_l2LogBufLen; /* Set L2 Log Buffer length in 
111                                                first 4 bytes of flat buffer */
112
113       /* Re-setting pointer so that L2 will use this to write logs */
114       g_l2LogBufBasePtr = g_l2rlogBuf + (g_l2logBuffPos * L2LOG_BUFF_BLOCK_SIZE) ; 
115       g_l2LogBufStartPtr     = g_l2LogBufBasePtr + sizeof(g_l2LogBufLen); 
116
117       g_l2LogBufLen = 0;
118
119       g_writeCirBuf = 0; /* This will avoid contention while switching log buffers */
120
121    }
122 #endif   
123    return; 
124 }
125
126 //////////////////////////////////////////////////////////////////////////
127 //  @Function    : rlGetL2LogBufPtr 
128 //  @Description : This function reads LogBufPointer and Length of log Buffer 
129 //                 and stores pointer and length variable so that these 
130 //                 values can be used while reading L2 Log Buffer 
131 //  @in          : mBuf     - Log Buffer
132 //  @out         : logLen   - Length of log Buffer
133 //                 logPtr   - Address of log Buffer
134 //////////////////////////////////////////////////////////////////////////
135
136 void rlGetL2LogBufPtr
137 (
138    void *mBuf,
139    uint32_t *logLen,
140    Data **logPtr
141 )
142 {
143    /* Get Buffer pointer and length */
144    *logPtr = ((Data *)mBuf) + sizeof(logLen);
145    *logLen = *((uint32_t *) mBuf);
146 }
147
148 //////////////////////////////////////////////////////////////////////////
149 //  @Function    : rlInvalidateL2LogsInCache 
150 //  @Description : Dummy function which is not used for this SOC. 
151 //                 
152 //  @in          : ptr     - starting address to be invalidated.
153 //                 len     - Length to be invalidated.
154 //  @out         : void
155 //////////////////////////////////////////////////////////////////////////
156
157 void rlInvalidateL2LogsInCache
158 (
159    Data *ptr,
160    uint32_t   len
161 )
162 {
163    return;
164 }
165
166 /**********************************************************************
167          End of file
168 ***********************************************************************/