Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alex037yang
OpenXG-RAN
Commits
7c9a7042
Commit
7c9a7042
authored
Nov 25, 2015
by
Cedric Roux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Setting up the callback mechanism.
parent
705be491
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
211 additions
and
4 deletions
+211
-4
openair2/LAYER2/MAC/defs.h
openair2/LAYER2/MAC/defs.h
+8
-0
openair2/LAYER2/MAC/ff-mac.c
openair2/LAYER2/MAC/ff-mac.c
+151
-2
openair2/LAYER2/MAC/ff-mac.h
openair2/LAYER2/MAC/ff-mac.h
+21
-0
openair2/LAYER2/MAC/main.c
openair2/LAYER2/MAC/main.c
+16
-0
openair2/LAYER2/MAC/minifapi.c
openair2/LAYER2/MAC/minifapi.c
+15
-2
No files found.
openair2/LAYER2/MAC/defs.h
View file @
7c9a7042
...
...
@@ -71,6 +71,10 @@
#include "SCellToAddMod-r10.h"
#endif
#ifdef FAPI
#include "ff-mac.h"
#endif
//#ifdef PHY_EMUL
//#include "SIMULATION/PHY_EMULATION/impl_defs.h"
//#endif
...
...
@@ -910,6 +914,10 @@ typedef struct {
/// processing time of eNB ULSCH reception
time_stats_t
rx_ulsch_sdu
;
// include rlc_data_ind
#ifdef FAPI
/// fapi interface handler
fapi_interface_t
*
fapi
;
#endif
}
eNB_MAC_INST
;
/*
...
...
openair2/LAYER2/MAC/ff-mac.c
View file @
7c9a7042
...
...
@@ -3,60 +3,209 @@
#include "ff-mac-csched-sap.h"
#include "ff-mac-init.h"
#include "log.h"
#include "assertions.h"
#undef LOG_D
#define LOG_D LOG_I
#include <stdlib.h>
#include <pthread.h>
/* number of callbacks */
#define N 9
/* this structure stores required data for OAI to work with FAPI */
/* it is the private version of fapi_interface_t */
struct
fapi
{
fapi_interface_t
fi
;
/* the start of the structure matches fapi_interface_t */
pthread_mutex_t
mutex
[
N
];
pthread_cond_t
cond
[
N
];
volatile
int
req_id
[
N
];
volatile
int
rsp_id
[
N
];
struct
CschedCellConfigCnfParameters
CschedCellConfigCnfParameters
;
};
/* here come the callbacks */
#define LOCK(fi, fn) do { \
LOG_D(MAC, "%s: locking fn %d fi %p mutex %p\n", __FUNCTION__, fn, fi, &fi->mutex[fn]); \
if (pthread_mutex_lock(&fi->mutex[fn])) \
AssertFatal(0, "%s:%d:%s: mutex error\n", __FILE__, __LINE__, __FUNCTION__); \
} while (0)
#define UNLOCK(fi, fn) do { \
LOG_D(MAC, "%s: unlocking fn %d fi %p mutex %p\n", __FUNCTION__, fn, fi, &fi->mutex[fn]); \
if (pthread_mutex_unlock(&fi->mutex[fn])) \
AssertFatal(0, "%s:%d:%s: mutex error\n", __FILE__, __LINE__, __FUNCTION__); \
} while (0)
#define CHECK(fi, fn) do { \
if (fi->req_id[fn] != fi->rsp_id[fn]) \
AssertFatal(0, "%s:%d:%s: check error\n", __FILE__, __LINE__, __FUNCTION__); \
} while (0)
#define WAIT(fi, fn) do { \
LOG_D(MAC, "%s: WAIT fn %d req %d rsp %d\n", __FUNCTION__, fn, fi->req_id[fn], fi->rsp_id[fn]); \
while (fi->req_id[fn] == fi->rsp_id[fn]) \
if (pthread_cond_wait(&fi->cond[fn], &fi->mutex[fn])) \
AssertFatal(0, "%s:%d:%s: cond error\n", __FILE__, __LINE__, __FUNCTION__); \
} while (0)
#define DONE_callback(fi, fn) do { \
fi->req_id[fn]++; \
if (pthread_cond_signal(&fi->cond[fn])) \
AssertFatal(0, "%s:%d:%s: mutex error\n", __FILE__, __LINE__, __FUNCTION__); \
} while (0)
#define DONE_wrapper(fi, fn) do { \
fi->rsp_id[fn]++; \
} while (0)
/* SCHED "wrappers" */
void
SchedDlConfigInd
(
fapi_interface_t
*
_fi
,
struct
SchedDlConfigIndParameters
*
params
)
{
int
fn
=
0
;
}
void
SchedUlConfigInd
(
fapi_interface_t
*
_fi
,
struct
SchedUlConfigIndParameters
*
params
)
{
int
fn
=
1
;
}
/* CSCHED "wrappers" */
void
CschedCellConfigCnf
(
fapi_interface_t
*
_fi
,
struct
CschedCellConfigCnfParameters
*
params
)
{
struct
fapi
*
fi
=
(
struct
fapi
*
)
_fi
;
int
fn
=
2
;
LOG_D
(
MAC
,
"CschedCellConfigCnf enter
\n
"
);
LOCK
(
fi
,
fn
);
WAIT
(
fi
,
fn
);
*
params
=
fi
->
CschedCellConfigCnfParameters
;
DONE_wrapper
(
fi
,
fn
);
UNLOCK
(
fi
,
fn
);
LOG_D
(
MAC
,
"CschedCellConfigCnf leave
\n
"
);
}
void
CschedUeConfigCnf
(
fapi_interface_t
*
_fi
,
struct
CschedUeConfigCnfParameters
*
params
)
{
int
fn
=
3
;
}
void
CschedLcConfigCnf
(
fapi_interface_t
*
_fi
,
struct
CschedLcConfigCnfParameters
*
params
)
{
int
fn
=
4
;
}
void
CschedLcReleaseCnf
(
fapi_interface_t
*
_fi
,
struct
CschedLcReleaseCnfParameters
*
params
)
{
int
fn
=
5
;
}
void
CschedUeReleaseCnf
(
fapi_interface_t
*
_fi
,
struct
CschedUeReleaseCnfParameters
*
params
)
{
int
fn
=
6
;
}
void
CschedUeConfigUpdateInd
(
fapi_interface_t
*
_fi
,
struct
CschedUeConfigUpdateIndParameters
*
params
)
{
int
fn
=
7
;
}
void
CschedCellConfigUpdateInd
(
fapi_interface_t
*
_fi
,
struct
CschedCellConfigUpdateIndParameters
*
params
)
{
int
fn
=
8
;
}
/* SCHED callbacks */
void
SchedDlConfigInd_callback
(
void
*
callback_data
,
const
struct
SchedDlConfigIndParameters
*
params
)
{
int
fn
=
0
;
}
void
SchedUlConfigInd_callback
(
void
*
callback_data
,
const
struct
SchedUlConfigIndParameters
*
params
)
{
int
fn
=
1
;
}
/* CSCHED callbacks */
void
CschedCellConfigCnf_callback
(
void
*
callback_data
,
const
struct
CschedCellConfigCnfParameters
*
params
)
{
struct
fapi
*
fi
=
callback_data
;
int
fn
=
2
;
LOG_D
(
MAC
,
"CschedCellConfigCnf_callback enter
\n
"
);
LOCK
(
fi
,
fn
);
CHECK
(
fi
,
fn
);
fi
->
CschedCellConfigCnfParameters
=
*
params
;
DONE_callback
(
fi
,
fn
);
UNLOCK
(
fi
,
fn
);
LOG_D
(
MAC
,
"CschedCellConfigCnf_callback leave
\n
"
);
}
void
CschedUeConfigCnf_callback
(
void
*
callback_data
,
const
struct
CschedUeConfigCnfParameters
*
params
)
{
int
fn
=
3
;
}
void
CschedLcConfigCnf_callback
(
void
*
callback_data
,
const
struct
CschedLcConfigCnfParameters
*
params
)
{
int
fn
=
4
;
}
void
CschedLcReleaseCnf_callback
(
void
*
callback_data
,
const
struct
CschedLcReleaseCnfParameters
*
params
)
{
int
fn
=
5
;
}
void
CschedUeReleaseCnf_callback
(
void
*
callback_data
,
const
struct
CschedUeReleaseCnfParameters
*
params
)
{
int
fn
=
6
;
}
void
CschedUeConfigUpdateInd_callback
(
void
*
callback_data
,
const
struct
CschedUeConfigUpdateIndParameters
*
params
)
{
int
fn
=
7
;
}
void
CschedCellConfigUpdateInd_callback
(
void
*
callback_data
,
const
struct
CschedCellConfigUpdateIndParameters
*
params
)
{
int
fn
=
8
;
}
fapi_interface_t
*
init_fapi
(
void
)
{
struct
fapi
*
ret
;
int
i
;
LOG_I
(
MAC
,
"FAPI initialization
\n
"
);
ret
=
calloc
(
1
,
sizeof
(
struct
fapi
));
if
(
ret
==
NULL
)
LOG_E
(
MAC
,
"init_fapi: memory allocation error
\n
"
);
if
(
ret
==
NULL
)
{
LOG_E
(
MAC
,
"init_fapi: memory allocation error
\n
"
);
return
NULL
;
}
for
(
i
=
0
;
i
<
N
;
i
++
)
{
if
(
pthread_mutex_init
(
&
ret
->
mutex
[
i
],
NULL
))
{
LOG_E
(
MAC
,
"init_fapi: mutex init error
\n
"
);
exit
(
1
);
}
if
(
pthread_cond_init
(
&
ret
->
cond
[
i
],
NULL
))
{
LOG_E
(
MAC
,
"init_fapi: cond init error
\n
"
);
exit
(
1
);
}
ret
->
req_id
[
i
]
=
0
;
ret
->
rsp_id
[
i
]
=
0
;
}
ret
->
fi
.
sched
=
SchedInit
(
ret
,
SchedDlConfigInd_callback
,
...
...
openair2/LAYER2/MAC/ff-mac.h
View file @
7c9a7042
...
...
@@ -14,4 +14,25 @@ typedef struct {
*/
fapi_interface_t
*
init_fapi
(
void
);
/* the following functions are called by OAI
* they wait for the corresponding callback
* to be called by the FAPI scheduler
*/
#include "ff-mac-sched-sap.h"
#include "ff-mac-csched-sap.h"
/* from SCHED */
void
SchedDlConfigInd
(
fapi_interface_t
*
,
struct
SchedDlConfigIndParameters
*
params
);
void
SchedUlConfigInd
(
fapi_interface_t
*
,
struct
SchedUlConfigIndParameters
*
params
);
/* from CSCHED */
void
CschedCellConfigCnf
(
fapi_interface_t
*
,
struct
CschedCellConfigCnfParameters
*
params
);
void
CschedUeConfigCnf
(
fapi_interface_t
*
,
struct
CschedUeConfigCnfParameters
*
params
);
void
CschedLcConfigCnf
(
fapi_interface_t
*
,
struct
CschedLcConfigCnfParameters
*
params
);
void
CschedLcReleaseCnf
(
fapi_interface_t
*
,
struct
CschedLcReleaseCnfParameters
*
params
);
void
CschedUeReleaseCnf
(
fapi_interface_t
*
,
struct
CschedUeReleaseCnfParameters
*
params
);
void
CschedUeConfigUpdateInd
(
fapi_interface_t
*
,
struct
CschedUeConfigUpdateIndParameters
*
params
);
void
CschedCellConfigUpdateInd
(
fapi_interface_t
*
,
struct
CschedCellConfigUpdateIndParameters
*
params
);
#endif
/* FF_MAC_H */
openair2/LAYER2/MAC/main.c
View file @
7c9a7042
...
...
@@ -352,6 +352,22 @@ int mac_top_init(int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, ui
#endif
//end ALU's algo
#ifdef FAPI
/// setup FAPI interface
for
(
i
=
0
;
i
<
NB_eNB_INST
;
i
++
)
{
eNB_mac_inst
[
i
].
fapi
=
init_fapi
();
AssertFatal
(
eNB_mac_inst
[
i
].
fapi
!=
NULL
,
"error calling init_fapi()
\n
"
);
}
/* test code, to remove */
struct
CschedCellConfigReqParameters
p
;
struct
CschedCellConfigCnfParameters
r
;
CschedCellConfigReq
(
eNB_mac_inst
[
0
].
fapi
->
sched
,
&
p
);
CschedCellConfigCnf
(
eNB_mac_inst
[
0
].
fapi
,
&
r
);
if
(
r
.
result
!=
ff_SUCCESS
)
abort
();
#endif
LOG_I
(
MAC
,
"[MAIN][INIT] Init function finished
\n
"
);
return
(
0
);
...
...
openair2/LAYER2/MAC/minifapi.c
View file @
7c9a7042
...
...
@@ -11,6 +11,8 @@
#include <stdlib.h>
#include <stdio.h>
#define LOG(...) do { printf("minifapi:%s:%d: ", __FUNCTION__, __LINE__); printf(__VA_ARGS__); printf("\n"); } while (0)
struct
scheduler
{
void
*
callback_data
;
SchedDlConfigInd_callback_t
*
SchedDlConfigInd
;
...
...
@@ -38,7 +40,7 @@ void *SchedInit(
{
struct
scheduler
*
ret
;
printf
(
"minifapi:%s:%d: start
\n
"
,
__FUNCTION__
,
__LINE__
);
LOG
(
"enter"
);
ret
=
calloc
(
1
,
sizeof
(
struct
scheduler
));
if
(
ret
==
NULL
)
{
...
...
@@ -57,7 +59,7 @@ void *SchedInit(
ret
->
CschedUeConfigUpdateInd
=
CschedUeConfigUpdateInd
;
ret
->
CschedCellConfigUpdateInd
=
CschedCellConfigUpdateInd
;
printf
(
"minifapi:%s:%d: done
\n
"
,
__FUNCTION__
,
__LINE__
);
LOG
(
"leave"
);
return
ret
;
}
...
...
@@ -112,6 +114,17 @@ void SchedUlCqiInfoReq(void *_sched, const struct SchedUlCqiInfoReqParameters *p
void
CschedCellConfigReq
(
void
*
_sched
,
const
struct
CschedCellConfigReqParameters
*
params
)
{
struct
scheduler
*
sched
=
_sched
;
struct
CschedCellConfigCnfParameters
conf
;
LOG
(
"enter"
);
conf
.
result
=
ff_SUCCESS
;
conf
.
nr_vendorSpecificList
=
0
;
sched
->
CschedCellConfigCnf
(
sched
->
callback_data
,
&
conf
);
LOG
(
"leave"
);
}
void
CschedUeConfigReq
(
void
*
_sched
,
const
struct
CschedUeConfigReqParameters
*
params
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment