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
canghaiwuhen
OpenXG-RAN
Commits
d43b8a30
Commit
d43b8a30
authored
Jun 21, 2016
by
Sandeep Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handling low level eth function for read
parent
12385fbd
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
44 deletions
+66
-44
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
+53
-35
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
+6
-5
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
+2
-2
targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
+5
-2
No files found.
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
View file @
d43b8a30
...
...
@@ -52,6 +52,7 @@
#include "common_lib.h"
#include "ethernet_lib.h"
#include "if_defs.h"
#include "openair1/PHY/LTE_TRANSPORT/if4_tools.h"
#define DEBUG 0
...
...
@@ -214,7 +215,7 @@ int trx_eth_write_raw_IF4(openair0_device *device, openair0_timestamp timestamp,
}
else
if
(
flags
==
IF4_PULFFT
)
{
packet_size
=
RAW_IF4_PULFFT_SIZE_BYTES
(
nblocks
);
}
else
{
packet_size
=
RAW_IF4_PRACH_SIZE_BYTES
(
nblocks
)
;
packet_size
=
RAW_IF4_PRACH_SIZE_BYTES
;
}
eth
->
tx_nsamps
=
nblocks
;
...
...
@@ -302,49 +303,66 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi
int
trx_eth_read_raw_IF4
(
openair0_device
*
device
,
openair0_timestamp
*
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
)
{
int
nblocks
=
nsamps
;
int
bytes_received
=
0
;
int
i
=
0
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
int
rcvfrom_flag
=
0
;
eth
->
rx_nsamps
=
nsamps
;
ssize_t
packet_size
=
MAC_HEADER_SIZE_BYTES
+
sizeof_IF4_dl_header_t
;
/* buff[i] points to the position in rx buffer where the payload to be received will be placed
buff2 points to the position in rx buffer where the packet header will be placed */
void
*
buff2
=
(
void
*
)(
buff
[
i
]
-
APP_HEADER_SIZE_BYTES
-
MAC_HEADER_SIZE_BYTES
);
void
*
test_buffer
=
(
void
*
)
malloc
(
packet_size
);
void
*
rx_buffer
=
NULL
;
IF4_dl_header_t
*
test_header
=
(
IF4_dl_header_t
*
)(
test_buffer
+
MAC_HEADER_SIZE_BYTES
);
/* we don't want to ovewrite with the header info the previous rx buffer data so we store it*/
struct
ether_header
temp
=
*
(
struct
ether_header
*
)
buff2
;
int32_t
temp0
=
*
(
int32_t
*
)(
buff2
+
MAC_HEADER_SIZE_BYTES
);
openair0_timestamp
temp1
=
*
(
openair0_timestamp
*
)(
buff2
+
MAC_HEADER_SIZE_BYTES
+
sizeof
(
int32_t
));
bytes_received
=
recv
(
eth
->
sockfd
[
Mod_id
],
test_buffer
,
packet_size
,
0
);
if
(
bytes_received
==-
1
)
{
eth
->
num_rx_errors
++
;
perror
(
"ETHERNET READ: "
);
exit
(
-
1
);
}
bytes_received
=
0
;
*
timestamp
=
test_header
->
sub_type
;
while
(
bytes_received
<
RAW_PACKET_SIZE_BYTES
(
nsamps
))
{
bytes_received
+=
recv
(
eth
->
sockfd
[
Mod_id
],
buff2
,
RAW_PACKET_SIZE_BYTES
(
nsamps
),
rcvfrom_flag
);
if
(
test_header
->
sub_type
==
IF4_PDLFFT
)
{
buff
[
0
]
=
(
void
*
)
malloc
(
RAW_IF4_PDLFFT_SIZE_BYTES
(
nblocks
)
-
MAC_HEADER_SIZE_BYTES
);
packet_size
=
RAW_IF4_PDLFFT_SIZE_BYTES
(
nblocks
)
-
packet_size
;
}
else
if
(
test_header
->
sub_type
==
IF4_PULFFT
)
{
buff
[
0
]
=
(
void
*
)
malloc
(
RAW_IF4_PULFFT_SIZE_BYTES
(
nblocks
)
-
MAC_HEADER_SIZE_BYTES
);
packet_size
=
RAW_IF4_PULFFT_SIZE_BYTES
(
nblocks
)
-
packet_size
;
}
else
{
buff
[
0
]
=
(
void
*
)
malloc
(
RAW_IF4_PRACH_SIZE_BYTES
-
MAC_HEADER_SIZE_BYTES
);
packet_size
=
RAW_IF4_PRACH_SIZE_BYTES
-
packet_size
;
}
memcpy
(
buff
[
0
],
test_header
,
sizeof_IF4_dl_header_t
);
rx_buffer
=
(
void
*
)(
buff
[
0
]
+
sizeof_IF4_dl_header_t
);
bytes_received
=
0
;
while
(
bytes_received
<
packet_size
)
{
bytes_received
+=
recv
(
eth
->
sockfd
[
Mod_id
],
rx_buffer
,
packet_size
-
bytes_received
,
0
);
if
(
bytes_received
==-
1
)
{
eth
->
num_rx_errors
++
;
perror
(
"ETHERNET READ: "
);
exit
(
-
1
);
}
else
{
/* store the timestamp value from packet's header */
*
timestamp
=
*
(
openair0_timestamp
*
)(
buff2
+
MAC_HEADER_SIZE_BYTES
+
sizeof
(
int32_t
));
eth
->
rx_actual_nsamps
=
bytes_received
>>
2
;
eth
->
rx_actual_nsamps
=
bytes_received
>>
1
;
eth
->
rx_count
++
;
}
}
/* tx buffer values restored */
*
(
struct
ether_header
*
)
buff2
=
temp
;
*
(
int32_t
*
)(
buff2
+
MAC_HEADER_SIZE_BYTES
)
=
temp0
;
*
(
openair0_timestamp
*
)(
buff2
+
MAC_HEADER_SIZE_BYTES
+
sizeof
(
int32_t
))
=
temp1
;
eth
->
rx_nsamps
=
nsamps
;
return
(
bytes_received
-
APP_HEADER_SIZE_BYTES
-
MAC_HEADER_SIZE_BYTES
)
>>
2
;
free
(
test_buffer
);
return
(
bytes_received
-
MAC_HEADER_SIZE_BYTES
)
>>
1
;
}
...
...
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
View file @
d43b8a30
...
...
@@ -320,7 +320,8 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
}
else
if
(
eth_params
->
transp_preference
==
2
)
{
eth
->
flags
=
ETH_UDP_IF4_MODE
;
}
else
{
AssertFatal
(
0
==
4
,
"transport_init: Unknown transport preference %d"
,
eth_params
->
transp_preference
);
printf
(
"transport_init: Unknown transport preference %d - default to RAW"
,
eth_params
->
transp_preference
);
eth
->
flags
=
ETH_RAW_MODE
;
}
printf
(
"[ETHERNET]: Initializing openair0_device for %s ...
\n
"
,
((
device
->
host_type
==
BBU_HOST
)
?
"BBU"
:
"RRH"
));
...
...
@@ -346,16 +347,16 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
device
->
trx_write_func
=
trx_eth_write_raw_IF4
;
device
->
trx_read_func
=
trx_eth_read_raw_IF4
;
}
else
{
device
->
trx_write_func
=
trx_eth_write_udp_IF4
;
device
->
trx_read_func
=
trx_eth_read_udp_IF4
;
//
device->trx_write_func = trx_eth_write_udp_IF4;
//
device->trx_read_func = trx_eth_read_udp_IF4;
}
eth
->
if_name
[
device
->
Mod_id
]
=
eth_params
->
local_if_name
;
device
->
priv
=
eth
;
/* device specific */
openair0_cfg
[
0
].
txlaunch_wait
=
0
;
//manage when TX processing is triggered
openair0_cfg
[
0
].
txlaunch_wait_slotcount
=
0
;
//manage when TX processing is triggered
//
openair0_cfg[0].txlaunch_wait = 0;//manage when TX processing is triggered
//
openair0_cfg[0].txlaunch_wait_slotcount = 0; //manage when TX processing is triggered
openair0_cfg
[
0
].
iq_rxrescale
=
15
;
//rescale iqs
openair0_cfg
[
0
].
iq_txshift
=
eth_params
->
iq_txshift
;
// shift
openair0_cfg
[
0
].
tx_sample_advance
=
eth_params
->
tx_sample_advance
;
...
...
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
View file @
d43b8a30
...
...
@@ -222,8 +222,8 @@ int eth_set_dev_conf_udp(openair0_device *device);
int
eth_socket_init_raw
(
openair0_device
*
device
);
int
trx_eth_write_raw
(
openair0_device
*
device
,
openair0_timestamp
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
,
int
flags
);
int
trx_eth_read_raw
(
openair0_device
*
device
,
openair0_timestamp
*
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
);
//
int trx_eth_write_raw_IF4(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags);
//
int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc);
int
trx_eth_write_raw_IF4
(
openair0_device
*
device
,
openair0_timestamp
timestamp
,
void
**
buff
,
int
nsamps
,
int
cc
,
int
flags
);
int
trx_eth_read_raw_IF4
(
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
);
...
...
targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
View file @
d43b8a30
...
...
@@ -39,6 +39,7 @@
*/
#include <netinet/ether.h>
#include <stdint.h>
// ETH transport preference modes
#define ETH_UDP_MODE 0
...
...
@@ -54,7 +55,9 @@
#define RAW_PACKET_SIZE_BYTES(nsamps) (APP_HEADER_SIZE_BYTES + MAC_HEADER_SIZE_BYTES + PAYLOAD_SIZE_BYTES(nsamps))
// Packet sizes for IF4 interface format
#define DATA_BLOCK_SIZE_BYTES(scaled_nblocks) (2*scaled_nblocks)
#define DATA_BLOCK_SIZE_BYTES(scaled_nblocks) (sizeof(int16_t)*scaled_nblocks)
#define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*839) // FIX hard coded prach size
#define RAW_IF4_PDLFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4_dl_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
#define RAW_IF4_PULFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4_ul_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
#define RAW_IF4_PRACH_SIZE_BYTES
(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4_prach_header_t + DATA_BLOCK_SIZE_BYTES(nblocks)
)
#define RAW_IF4_PRACH_SIZE_BYTES
(MAC_HEADER_SIZE_BYTES + sizeof_IF4_prach_header_t + PRACH_BLOCK_SIZE_BYTES
)
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