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
wangjie
OpenXG-RAN
Commits
8014a940
Commit
8014a940
authored
Aug 05, 2016
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IF4p5 with UDP.
parent
3608e5bc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
38 deletions
+133
-38
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
+6
-13
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
+100
-3
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
+20
-21
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
+4
-1
targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
+3
-0
No files found.
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
View file @
8014a940
...
...
@@ -65,23 +65,18 @@ int eth_socket_init_raw(openair0_device *device) {
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
const
char
*
local_mac
,
*
remote_mac
;
int
local_port
=
0
,
remote_port
=
0
;
int
sock_dom
=
0
;
int
sock_type
=
0
;
int
sock_proto
=
0
;
if
(
device
->
host_type
==
RRH_HOST
)
{
/* RRH doesn't know remote MAC(will be retrieved from first packet send from BBU) and remote port(don't care) */
local_mac
=
device
->
openair0_cfg
->
my_addr
;
local_port
=
device
->
openair0_cfg
->
my_port
;
remote_mac
=
malloc
(
ETH_ALEN
);
memset
(
remote_mac
,
0
,
ETH_ALEN
);
remote_port
=
0
;
memset
((
void
*
)
remote_mac
,
0
,
ETH_ALEN
);
printf
(
"[%s] local MAC addr %s remote MAC addr %s
\n
"
,
"RRH"
,
local_mac
,
remote_mac
);
}
else
{
local_mac
=
device
->
openair0_cfg
->
my_addr
;
local_port
=
device
->
openair0_cfg
->
my_port
;
remote_mac
=
device
->
openair0_cfg
->
remote_addr
;
remote_port
=
device
->
openair0_cfg
->
remote_port
;
printf
(
"[%s] local MAC addr %s remote MAC addr %s
\n
"
,
"BBU"
,
local_mac
,
remote_mac
);
}
...
...
@@ -425,7 +420,6 @@ int eth_get_dev_conf_raw(openair0_device *device) {
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
char
str
[
INET_ADDRSTRLEN
];
void
*
msg
;
ssize_t
msg_len
;
...
...
@@ -456,7 +450,6 @@ int eth_get_dev_conf_raw_IF4p5(openair0_device *device) {
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
char
str
[
INET_ADDRSTRLEN
];
void
*
msg
;
ssize_t
msg_len
;
...
...
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
View file @
8014a940
...
...
@@ -63,7 +63,7 @@ uint16_t pck_seq_num = 1;
uint16_t
pck_seq_num_cur
=
0
;
uint16_t
pck_seq_num_prev
=
0
;
int
eth_socket_init_udp
(
openair0_device
*
device
)
{
int
eth_socket_init_udp
(
openair0_device
*
device
)
{
int
i
=
0
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
...
...
@@ -138,6 +138,103 @@ uint16_t pck_seq_num_prev=0;
return
0
;
}
int
trx_eth_read_udp_IF4p5
(
openair0_device
*
device
,
openair0_timestamp
*
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
)
{
// Read nblocks info from packet itself
int
nblocks
=
nsamps
;
int
bytes_received
=
0
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
ssize_t
packet_size
=
sizeof_IF4p5_header_t
;
IF4p5_header_t
*
test_header
=
(
IF4p5_header_t
*
)(
buff
[
0
]);
bytes_received
=
recvfrom
(
eth
->
sockfd
[
Mod_id
],
buff
[
0
],
packet_size
,
0
,
(
struct
sockaddr
*
)
&
dest_addr
[
Mod_id
],
(
socklen_t
*
)
&
addr_len
[
Mod_id
]);
if
(
bytes_received
==-
1
)
{
eth
->
num_rx_errors
++
;
perror
(
"ETHERNET IF4p5 READ (header): "
);
exit
(
-
1
);
}
*
timestamp
=
test_header
->
sub_type
;
if
(
test_header
->
sub_type
==
IF4p5_PDLFFT
)
{
packet_size
=
UDP_IF4p5_PDLFFT_SIZE_BYTES
(
nblocks
);
}
else
if
(
test_header
->
sub_type
==
IF4p5_PULFFT
)
{
packet_size
=
UDP_IF4p5_PULFFT_SIZE_BYTES
(
nblocks
);
}
else
{
packet_size
=
UDP_IF4p5_PRACH_SIZE_BYTES
;
}
while
(
bytes_received
<
packet_size
)
{
bytes_received
=
recvfrom
(
eth
->
sockfd
[
Mod_id
],
buff
[
0
],
packet_size
,
0
,
(
struct
sockaddr
*
)
&
dest_addr
[
Mod_id
],
(
socklen_t
*
)
&
addr_len
[
Mod_id
]);
if
(
bytes_received
==-
1
)
{
eth
->
num_rx_errors
++
;
perror
(
"ETHERNET IF4p5 READ (payload): "
);
exit
(
-
1
);
}
else
{
eth
->
rx_actual_nsamps
=
bytes_received
>>
1
;
eth
->
rx_count
++
;
}
}
eth
->
rx_nsamps
=
nsamps
;
return
(
bytes_received
);
}
int
trx_eth_write_udp_IF4p5
(
openair0_device
*
device
,
openair0_timestamp
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
,
int
flags
)
{
int
nblocks
=
nsamps
;
int
bytes_sent
=
0
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
ssize_t
packet_size
;
if
(
flags
==
IF4p5_PDLFFT
)
{
packet_size
=
UDP_IF4p5_PDLFFT_SIZE_BYTES
(
nblocks
);
}
else
if
(
flags
==
IF4p5_PULFFT
)
{
packet_size
=
UDP_IF4p5_PULFFT_SIZE_BYTES
(
nblocks
);
}
else
{
printf
(
"trx_eth_write_udp_IF4p5: unknown flags %d
\n
"
,
flags
);
return
(
-
1
);
}
eth
->
tx_nsamps
=
nblocks
;
bytes_sent
=
sendto
(
eth
->
sockfd
[
Mod_id
],
buff
[
0
],
packet_size
,
0
,
(
struct
sockaddr
*
)
&
dest_addr
[
Mod_id
],
addr_len
[
Mod_id
]);
if
(
bytes_sent
==
-
1
)
{
eth
->
num_tx_errors
++
;
perror
(
"ETHERNET WRITE: "
);
exit
(
-
1
);
}
else
{
eth
->
tx_actual_nsamps
=
bytes_sent
>>
1
;
eth
->
tx_count
++
;
}
return
(
bytes_sent
);
}
int
trx_eth_write_udp
(
openair0_device
*
device
,
openair0_timestamp
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
,
int
flags
)
{
int
bytes_sent
=
0
;
...
...
@@ -216,7 +313,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
int
bytes_received
=
0
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
openair0_timestamp
prev_timestamp
=
-
1
;
//
openair0_timestamp prev_timestamp = -1;
int
Mod_id
=
device
->
Mod_id
;
int
rcvfrom_flag
=
0
;
int
block_cnt
=
0
;
...
...
@@ -298,7 +395,7 @@ int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, voi
pck_seq_num_cur
=
*
(
uint16_t
*
)
buff2
;
//printf("cur=%d prev=%d buff=%d\n",pck_seq_num_cur,pck_seq_num_prev,*(uint16_t *)(buff2));
if
(
(
pck_seq_num_cur
!=
(
pck_seq_num_prev
+
1
)
)
&&
!
((
pck_seq_num_prev
==
75
)
&&
(
pck_seq_num_cur
==
1
))){
printf
(
"out of order packet received1! %d|%d|%d
\n
"
,
pck_seq_num_cur
,
pck_seq_num_prev
,
*
timestamp
);
printf
(
"out of order packet received1! %d|%d|%d
\n
"
,
pck_seq_num_cur
,
pck_seq_num_prev
,
(
int
)
*
timestamp
);
}
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME
(
VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM
,
pck_seq_num_cur
);
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME
(
VCD_SIGNAL_DUMPER_VARIABLES_RX_SEQ_NUM_PRV
,
pck_seq_num_prev
);
...
...
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
View file @
8014a940
...
...
@@ -90,19 +90,15 @@ int trx_eth_start(openair0_device *device) {
if
(
ethernet_tune
(
device
,
RCV_TIMEOUT
,
999999
)
!=
0
)
return
-
1
;
}
else
if
(
eth
->
flags
==
ETH_UDP_IF4p5_MODE
)
{
printf
(
"Setting ETHERNET to UDP_IF4p5_MODE
\n
"
);
if
(
eth_socket_init_udp
(
device
)
!=
0
)
return
-
1
;
if
(
device
->
host_type
==
BBU_HOST
)
{
if
(
eth_set_dev_conf_udp
(
device
)
!=
0
)
return
-
1
;
}
else
{
if
(
eth_get_dev_conf_udp
(
device
)
!=
0
)
return
-
1
;
}
}
else
if
(
eth
->
flags
==
ETH_RAW_IF5_MOBIPASS
)
{
printf
(
"Setting ETHERNET to RAW_IF5_MODE
\n
"
);
if
(
eth_socket_init_raw
(
device
)
!=
0
)
return
-
1
;
/* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/
//if (device->host_type == BBU_HOST) {
//if(eth_set_dev_conf_raw_IF4p5(device)!=0) return -1;
//} else {
//if(eth_get_dev_conf_raw_IF4p5(device)!=0) return -1;
//
/* adjust MTU wrt number of samples per packet */
// if(ethernet_tune (device,MTU_SIZE,RAW_PACKET_SIZE_BYTES(device->openair0_cfg->samples_per_packet))!=0) return -1;
}
else
{
if
(
eth_socket_init_udp
(
device
)
!=
0
)
return
-
1
;
/* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/
...
...
@@ -171,7 +167,7 @@ int trx_eth_reply(openair0_device *device, void *msg, ssize_t msg_len) {
int
trx_eth_stop
(
int
card
)
{
int
trx_eth_stop
(
openair0_device
*
device
)
{
return
(
0
);
}
...
...
@@ -199,11 +195,11 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
struct
timeval
timeout
;
struct
ifreq
ifr
;
char
system_cmd
[
256
];
char
*
if_name
=
DEFAULT_IF
;
struct
in_addr
ia
;
struct
if_nameindex
*
ids
;
//
char* if_name=DEFAULT_IF;
//
struct in_addr ia;
//
struct if_nameindex *ids;
int
ret
=
0
;
int
i
=
0
;
//
int i=0;
/****************** socket level options ************************/
switch
(
option
)
{
...
...
@@ -238,7 +234,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
(
char
*
)
&
timeout
,
sizeof
(
timeout
)))
{
perror
(
"[ETHERNET] setsockopt()"
);
}
else
{
printf
(
"receive timeout= %u usec
\n
"
,
timeout
.
tv_usec
);
printf
(
"receive timeout= %u usec
\n
"
,
(
unsigned
int
)
timeout
.
tv_usec
);
}
break
;
...
...
@@ -251,7 +247,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
(
char
*
)
&
timeout
,
sizeof
(
timeout
)))
{
perror
(
"[ETHERNET] setsockopt()"
);
}
else
{
printf
(
"send timeout= %d,%d sec
\n
"
,
timeout
.
tv_sec
,
timeout
.
tv_usec
);
printf
(
"send timeout= %d,%d sec
\n
"
,
(
int
)
timeout
.
tv_sec
,(
int
)
timeout
.
tv_usec
);
}
break
;
...
...
@@ -311,7 +307,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
break
;
case
RING_PAR
:
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -G %s
rx %d tx
%d"
,
eth
->
if_name
[
Mod_id
],
value
);
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -G %s
val
%d"
,
eth
->
if_name
[
Mod_id
],
value
);
if
(
ret
>
0
)
{
ret
=
system
(
system_cmd
);
if
(
ret
==
-
1
)
{
...
...
@@ -376,6 +372,9 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
}
else
if
(
eth
->
flags
==
ETH_RAW_IF4p5_MODE
)
{
device
->
trx_write_func
=
trx_eth_write_raw_IF4p5
;
device
->
trx_read_func
=
trx_eth_read_raw_IF4p5
;
}
else
if
(
eth
->
flags
==
ETH_UDP_IF4p5_MODE
)
{
device
->
trx_write_func
=
trx_eth_write_udp_IF4p5
;
device
->
trx_read_func
=
trx_eth_read_udp_IF4p5
;
}
else
if
(
eth
->
flags
==
ETH_RAW_IF5_MOBIPASS
)
{
device
->
trx_write_func
=
trx_eth_write_raw_IF4p5
;
device
->
trx_read_func
=
trx_eth_read_raw_IF4p5
;
...
...
@@ -460,7 +459,7 @@ void dump_dev(openair0_device *device) {
device
->
openair0_cfg
->
num_rb_dl
,
device
->
openair0_cfg
->
sample_rate
);
printf
(
" BBU configured for %i tx/%i rx channels)
\n
"
,
device
->
openair0_cfg
->
tx_num_channels
,
device
->
openair0_cfg
->
rx_num_channels
);
printf
(
" Running flags: %s %s
%s
\n
"
,
printf
(
" Running flags: %s %s
(
\n
"
,
((
eth
->
flags
&
ETH_RAW_MODE
)
?
"RAW socket mode - "
:
""
),
((
eth
->
flags
&
ETH_UDP_MODE
)
?
"UDP socket mode - "
:
""
));
printf
(
" Number of iqs dumped when displaying packets: %i
\n\n
"
,
eth
->
iqdumpcnt
);
...
...
@@ -470,14 +469,14 @@ void dump_dev(openair0_device *device) {
void
inline
dump_txcounters
(
openair0_device
*
device
)
{
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
printf
(
" Ethernet device interface %i, tx counters:
\n
"
,
device
->
openair0_cfg
->
Mod_id
);
printf
(
" Sent packets: %llu send errors: %i
\n
"
,
eth
->
tx_count
,
eth
->
num_tx_errors
);
printf
(
" Sent packets: %llu send errors: %i
\n
"
,
(
long
long
unsigned
int
)
eth
->
tx_count
,
eth
->
num_tx_errors
);
}
void
inline
dump_rxcounters
(
openair0_device
*
device
)
{
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
printf
(
" Ethernet device interface %i rx counters:
\n
"
,
device
->
openair0_cfg
->
Mod_id
);
printf
(
" Received packets: %llu missed packets errors: %i
\n
"
,
eth
->
rx_count
,
eth
->
num_underflows
);
printf
(
" Received packets: %llu missed packets errors: %i
\n
"
,
(
long
long
unsigned
int
)
eth
->
rx_count
,
eth
->
num_underflows
);
}
void
inline
dump_buff
(
openair0_device
*
device
,
char
*
buff
,
unsigned
int
tx_rx_flag
,
int
nsamps
)
{
...
...
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
View file @
8014a940
...
...
@@ -176,9 +176,10 @@ typedef struct {
void
dump_packet
(
char
*
title
,
unsigned
char
*
pkt
,
int
bytes
,
unsigned
int
tx_rx_flag
);
unsigned
short
calc_csum
(
unsigned
short
*
buf
,
int
nwords
);
void
dump_dev
(
openair0_device
*
device
);
void
inline
dump_buff
(
openair0_device
*
device
,
char
*
buff
,
unsigned
int
tx_rx_flag
,
int
nsamps
);
/*
void inline dump_buff(openair0_device *device, char *buff,unsigned int tx_rx_flag,int nsamps);
void inline dump_rxcounters(openair0_device *device);
void inline dump_txcounters(openair0_device *device);
*/
void
dump_iqs
(
char
*
buff
,
int
iq_cnt
);
...
...
@@ -224,6 +225,8 @@ int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, voi
int
trx_eth_read_raw
(
openair0_device
*
device
,
openair0_timestamp
*
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
);
int
trx_eth_write_raw_IF4p5
(
openair0_device
*
device
,
openair0_timestamp
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
,
int
flags
);
int
trx_eth_read_raw_IF4p5
(
openair0_device
*
device
,
openair0_timestamp
*
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
);
int
trx_eth_write_udp_IF4p5
(
openair0_device
*
device
,
openair0_timestamp
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
,
int
flags
);
int
trx_eth_read_udp_IF4p5
(
openair0_device
*
device
,
openair0_timestamp
*
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
);
int
eth_get_dev_conf_raw
(
openair0_device
*
device
);
int
eth_set_dev_conf_raw
(
openair0_device
*
device
);
int
eth_get_dev_conf_raw_IF4p5
(
openair0_device
*
device
);
...
...
targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
View file @
8014a940
...
...
@@ -65,6 +65,9 @@
#define RAW_IF4p5_PDLFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
#define RAW_IF4p5_PULFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
#define RAW_IF4p5_PRACH_SIZE_BYTES (MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t + PRACH_BLOCK_SIZE_BYTES)
#define UDP_IF4p5_PDLFFT_SIZE_BYTES(nblocks) (sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
#define UDP_IF4p5_PULFFT_SIZE_BYTES(nblocks) (sizeof_IF4p5_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
#define UDP_IF4p5_PRACH_SIZE_BYTES (sizeof_IF4p5_header_t + PRACH_BLOCK_SIZE_BYTES)
// Mobipass packet sizes
#define RAW_IF5_MOBIPASS_BLOCK_SIZE_BYTES 1280
...
...
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