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
Michael Black
OpenXG-RAN
Commits
6e721cec
Commit
6e721cec
authored
Jun 13, 2020
by
Michael Cook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move queue_t into it own .h, .c
parent
7c37d6d3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
61 deletions
+112
-61
cmake_targets/CMakeLists.txt
cmake_targets/CMakeLists.txt
+1
-0
openair2/PHY_INTERFACE/phy_stub_UE.c
openair2/PHY_INTERFACE/phy_stub_UE.c
+17
-46
openair2/PHY_INTERFACE/phy_stub_UE.h
openair2/PHY_INTERFACE/phy_stub_UE.h
+1
-15
openair2/PHY_INTERFACE/queue.c
openair2/PHY_INTERFACE/queue.c
+48
-0
openair2/PHY_INTERFACE/queue.h
openair2/PHY_INTERFACE/queue.h
+45
-0
No files found.
cmake_targets/CMakeLists.txt
View file @
6e721cec
...
...
@@ -1805,6 +1805,7 @@ set (MAC_NR_SRC
set
(
MAC_SRC_UE
${
PHY_INTERFACE_DIR
}
/phy_stub_UE.c
${
PHY_INTERFACE_DIR
}
/queue.c
${
MAC_DIR
}
/main_ue.c
${
MAC_DIR
}
/ue_procedures.c
${
MAC_DIR
}
/ra_procedures.c
...
...
openair2/PHY_INTERFACE/phy_stub_UE.c
View file @
6e721cec
...
...
@@ -55,48 +55,6 @@ int frame_sfn = 0;
static
int
ue_sock_descriptor
=
-
1
;
void
init_queue
(
queue_t
*
q
)
{
memset
(
q
,
0
,
sizeof
(
*
q
));
pthread_mutex_init
(
&
q
->
mutex
,
NULL
);
}
void
put_queue
(
queue_t
*
q
,
void
*
item
)
{
if
(
pthread_mutex_lock
(
&
q
->
mutex
)
!=
0
)
{
LOG_E
(
MAC
,
"put_queue mutex_lock failed
\n
"
);
return
;
}
if
(
q
->
num_items
>=
MAX_QUEUE_SIZE
)
{
LOG_E
(
MAC
,
"Queue is full in put_queue
\n
"
);
}
else
{
q
->
items
[
q
->
write_index
]
=
item
;
q
->
write_index
=
(
q
->
write_index
+
1
)
%
MAX_QUEUE_SIZE
;
q
->
num_items
++
;
}
pthread_mutex_unlock
(
&
q
->
mutex
);
}
void
*
get_queue
(
queue_t
*
q
)
{
void
*
item
=
NULL
;
if
(
pthread_mutex_lock
(
&
q
->
mutex
)
!=
0
)
{
LOG_E
(
MAC
,
"get_queue mutex_lock failed
\n
"
);
return
NULL
;
}
if
(
q
->
num_items
>
0
)
{
item
=
q
->
items
[
q
->
read_index
];
q
->
read_index
=
(
q
->
read_index
+
1
)
%
MAX_QUEUE_SIZE
;
q
->
num_items
--
;
}
pthread_mutex_unlock
(
&
q
->
mutex
);
return
item
;
}
extern
nfapi_tx_request_pdu_t
*
tx_request_pdu
[
1023
][
10
][
10
];
extern
int
timer_subframe
;
extern
int
timer_frame
;
...
...
@@ -971,7 +929,9 @@ int memcpy_dl_config_req(L1_rxtx_proc_t *proc,
req
->
dl_config_request_body
.
dl_config_pdu_list
[
i
];
}
put_queue
(
&
dl_config_req_queue
,
p
);
if
(
!
put_queue
(
&
dl_config_req_queue
,
p
))
{
free
(
p
);
}
return
0
;
}
...
...
@@ -998,7 +958,11 @@ int memcpy_ul_config_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, n
req
->
ul_config_request_body
.
ul_config_pdu_list
[
i
];
}
// put_queue(&ul_config_req_queue, (void *)p);
#if 0 // TODO not using queue here yet
if (!put_queue(&ul_config_req_queue, p)) {
free(p);
}
#endif
ul_config_req
=
p
;
return
0
;
}
...
...
@@ -1021,7 +985,9 @@ int memcpy_tx_req(nfapi_pnf_p7_config_t *pnf_p7, nfapi_tx_request_t *req) {
}
}
}
put_queue
(
&
tx_req_pdu_queue
,
p
);
if
(
!
put_queue
(
&
tx_req_pdu_queue
,
p
))
{
free
(
p
);
}
return
0
;
}
...
...
@@ -1058,7 +1024,12 @@ int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc,
// \n",req->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type,
// UE_mac_inst[Mod_id].p->hi_dci0_request_body.hi_dci0_pdu_list[i].pdu_type);
}
// put_queue(&hi_dci0_req_queue, (void *)p);
#if 0 // TODO not using queue here yet
if (!put_queue(&hi_dci0_req_queue, p)) {
free(p);
}
#endif
hi_dci0_req
=
p
;
return
0
;
...
...
openair2/PHY_INTERFACE/phy_stub_UE.h
View file @
6e721cec
...
...
@@ -18,6 +18,7 @@
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
//#include "openair1/PHY/defs.h"
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
#include "queue.h"
// this mutex is used to set multiple UE's UL value in L2 FAPI simulator.
FILL_UL_INFO_MUTEX_t
fill_ul_mutex
;
...
...
@@ -134,26 +135,11 @@ void ue_init_standalone_socket(const char *addr, int port);
// This function is used to read from standalone pnf socket call corresponding memcpy functions
void
*
ue_standalone_pnf_task
(
void
*
context
);
#define MAX_QUEUE_SIZE 512
typedef
struct
queue_t
{
void
*
items
[
MAX_QUEUE_SIZE
];
size_t
read_index
,
write_index
;
size_t
num_items
;
pthread_mutex_t
mutex
;
}
queue_t
;
void
init_queue
(
queue_t
*
q
);
void
put_queue
(
queue_t
*
q
,
void
*
item
);
void
*
get_queue
(
queue_t
*
q
);
extern
queue_t
dl_config_req_queue
;
extern
queue_t
tx_req_pdu_queue
;
extern
queue_t
ul_config_req_queue
;
extern
queue_t
hi_dci0_req_queue
;
extern
nfapi_ul_config_request_t
*
ul_config_req
;
extern
nfapi_hi_dci0_request_t
*
hi_dci0_req
;
...
...
openair2/PHY_INTERFACE/queue.c
0 → 100644
View file @
6e721cec
#include "queue.h"
#include "common/utils/LOG/log.h"
#include <string.h>
void
init_queue
(
queue_t
*
q
)
{
memset
(
q
,
0
,
sizeof
(
*
q
));
pthread_mutex_init
(
&
q
->
mutex
,
NULL
);
}
bool
put_queue
(
queue_t
*
q
,
void
*
item
)
{
if
(
pthread_mutex_lock
(
&
q
->
mutex
)
!=
0
)
{
LOG_E
(
PHY
,
"put_queue mutex_lock failed
\n
"
);
return
false
;
}
bool
queued
;
if
(
q
->
num_items
>=
MAX_QUEUE_SIZE
)
{
LOG_E
(
PHY
,
"Queue is full in put_queue
\n
"
);
queued
=
false
;
}
else
{
q
->
items
[
q
->
write_index
]
=
item
;
q
->
write_index
=
(
q
->
write_index
+
1
)
%
MAX_QUEUE_SIZE
;
q
->
num_items
++
;
queued
=
true
;
}
pthread_mutex_unlock
(
&
q
->
mutex
);
return
queued
;
}
void
*
get_queue
(
queue_t
*
q
)
{
void
*
item
=
NULL
;
if
(
pthread_mutex_lock
(
&
q
->
mutex
)
!=
0
)
{
LOG_E
(
PHY
,
"get_queue mutex_lock failed
\n
"
);
return
NULL
;
}
if
(
q
->
num_items
>
0
)
{
item
=
q
->
items
[
q
->
read_index
];
q
->
read_index
=
(
q
->
read_index
+
1
)
%
MAX_QUEUE_SIZE
;
q
->
num_items
--
;
}
pthread_mutex_unlock
(
&
q
->
mutex
);
return
item
;
}
openair2/PHY_INTERFACE/queue.h
0 → 100644
View file @
6e721cec
/*
queue_t is a basic thread-safe non-blocking fixed-size queue.
put_queue returns false if the queue is full.
get_queue returns NULL if the queue is empty.
Example usage:
// Initialization:
queue_t fooq;
init_queue(&fooq);
// Producer:
foo_t *item = new_foo();
if (!put_queue(&fooq, item))
delete_foo(item);
// Consumer:
foo_t *item = get_queue(&fooq);
if (item)
{
do_something_with_foo(item);
delete_foo(item);
}
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <pthread.h>
#define MAX_QUEUE_SIZE 512
typedef
struct
queue_t
{
void
*
items
[
MAX_QUEUE_SIZE
];
size_t
read_index
,
write_index
;
size_t
num_items
;
pthread_mutex_t
mutex
;
}
queue_t
;
void
init_queue
(
queue_t
*
q
);
bool
put_queue
(
queue_t
*
q
,
void
*
item
);
void
*
get_queue
(
queue_t
*
q
);
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