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
db8c2a05
Commit
db8c2a05
authored
Oct 23, 2016
by
Raymond Knopp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update of ETHERNET interfaces (removal of global variables).
parent
5affbe38
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
133 deletions
+134
-133
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
+38
-41
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
+48
-56
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
+34
-34
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
+14
-2
No files found.
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
View file @
db8c2a05
This diff is collapsed.
Click to expand it.
targets/ARCH/ETHERNET/USERSPACE/LIB/eth_udp.c
View file @
db8c2a05
This diff is collapsed.
Click to expand it.
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
View file @
db8c2a05
...
@@ -52,9 +52,9 @@
...
@@ -52,9 +52,9 @@
#include "common_lib.h"
#include "common_lib.h"
#include "ethernet_lib.h"
#include "ethernet_lib.h"
int
num_devices_eth
=
0
;
//
int num_devices_eth = 0;
struct
sockaddr_in
dest_addr
[
MAX_INST
];
//
struct sockaddr_in dest_addr[MAX_INST];
int
dest_addr_len
[
MAX_INST
];
//
int dest_addr_len[MAX_INST];
int
trx_eth_start
(
openair0_device
*
device
)
{
int
trx_eth_start
(
openair0_device
*
device
)
{
...
@@ -119,13 +119,12 @@ int trx_eth_start(openair0_device *device) {
...
@@ -119,13 +119,12 @@ int trx_eth_start(openair0_device *device) {
void
trx_eth_end
(
openair0_device
*
device
)
{
void
trx_eth_end
(
openair0_device
*
device
)
{
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
/* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */
/* destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */
if
(
close
(
eth
->
sockfd
[
Mod_id
]
)
<
0
)
{
if
(
close
(
eth
->
sockfd
)
<
0
)
{
perror
(
"ETHERNET: Failed to close socket"
);
perror
(
"ETHERNET: Failed to close socket"
);
exit
(
0
);
exit
(
0
);
}
else
{
}
else
{
printf
(
"[%s] socket
for mod_id %d has been successfully closed.
\n
"
,(
device
->
host_type
==
BBU_HOST
)
?
"BBU"
:
"RRH"
,
Mod_id
);
printf
(
"[%s] socket
has been successfully closed.
\n
"
,(
device
->
host_type
==
BBU_HOST
)
?
"BBU"
:
"RRH"
);
}
}
}
}
...
@@ -133,15 +132,15 @@ void trx_eth_end(openair0_device *device) {
...
@@ -133,15 +132,15 @@ void trx_eth_end(openair0_device *device) {
int
trx_eth_request
(
openair0_device
*
device
,
void
*
msg
,
ssize_t
msg_len
)
{
int
trx_eth_request
(
openair0_device
*
device
,
void
*
msg
,
ssize_t
msg_len
)
{
int
Mod_id
=
device
->
Mod_id
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
/* BBU sends a message to RRH */
/* BBU sends a message to RRH */
if
(
sendto
(
eth
->
sockfd
[
Mod_id
],
msg
,
msg_len
,
0
,(
struct
sockaddr
*
)
&
dest_addr
[
Mod_id
],
dest_addr_len
[
Mod_id
])
==-
1
)
{
if
(
sendto
(
eth
->
sockfd
,
msg
,
msg_len
,
0
,(
struct
sockaddr
*
)
&
eth
->
dest_addr
,
eth
->
addr_len
)
==-
1
)
{
perror
(
"ETHERNET: "
);
perror
(
"ETHERNET: "
);
exit
(
0
);
exit
(
0
);
}
}
return
0
;
return
0
;
}
}
...
@@ -149,19 +148,21 @@ int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) {
...
@@ -149,19 +148,21 @@ int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) {
int
trx_eth_reply
(
openair0_device
*
device
,
void
*
msg
,
ssize_t
msg_len
)
{
int
trx_eth_reply
(
openair0_device
*
device
,
void
*
msg
,
ssize_t
msg_len
)
{
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
/* RRH receives from BBU a message */
/* RRH receives from BBU a message */
if
(
recvfrom
(
eth
->
sockfd
[
Mod_id
],
if
(
recvfrom
(
eth
->
sockfd
,
msg
,
msg
,
msg_len
,
msg_len
,
0
,
0
,
(
struct
sockaddr
*
)
&
dest_addr
[
Mod_id
],
(
struct
sockaddr
*
)
&
eth
->
dest_addr
,
(
socklen_t
*
)
&
dest_addr_len
[
Mod_id
])
==-
1
)
{
(
socklen_t
*
)
&
eth
->
addr_len
)
==-
1
)
{
perror
(
"ETHERNET: "
);
perror
(
"ETHERNET: recv_from in trx_eth_reply "
);
exit
(
0
);
exit
(
0
);
}
}
return
0
;
return
0
;
}
}
...
@@ -191,7 +192,6 @@ int trx_eth_reset_stats(openair0_device* device) {
...
@@ -191,7 +192,6 @@ int trx_eth_reset_stats(openair0_device* device) {
int
ethernet_tune
(
openair0_device
*
device
,
unsigned
int
option
,
int
value
)
{
int
ethernet_tune
(
openair0_device
*
device
,
unsigned
int
option
,
int
value
)
{
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
eth_state_t
*
eth
=
(
eth_state_t
*
)
device
->
priv
;
int
Mod_id
=
device
->
Mod_id
;
struct
timeval
timeout
;
struct
timeval
timeout
;
struct
ifreq
ifr
;
struct
ifreq
ifr
;
char
system_cmd
[
256
];
char
system_cmd
[
256
];
...
@@ -204,7 +204,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
...
@@ -204,7 +204,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
/****************** socket level options ************************/
/****************** socket level options ************************/
switch
(
option
)
{
switch
(
option
)
{
case
SND_BUF_SIZE
:
/* transmit socket buffer size */
case
SND_BUF_SIZE
:
/* transmit socket buffer size */
if
(
setsockopt
(
eth
->
sockfd
[
Mod_id
]
,
if
(
setsockopt
(
eth
->
sockfd
,
SOL_SOCKET
,
SOL_SOCKET
,
SO_SNDBUF
,
SO_SNDBUF
,
&
value
,
sizeof
(
value
)))
{
&
value
,
sizeof
(
value
)))
{
...
@@ -215,7 +215,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
...
@@ -215,7 +215,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
break
;
break
;
case
RCV_BUF_SIZE
:
/* receive socket buffer size */
case
RCV_BUF_SIZE
:
/* receive socket buffer size */
if
(
setsockopt
(
eth
->
sockfd
[
Mod_id
]
,
if
(
setsockopt
(
eth
->
sockfd
,
SOL_SOCKET
,
SOL_SOCKET
,
SO_RCVBUF
,
SO_RCVBUF
,
&
value
,
sizeof
(
value
)))
{
&
value
,
sizeof
(
value
)))
{
...
@@ -228,7 +228,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
...
@@ -228,7 +228,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
case
RCV_TIMEOUT
:
case
RCV_TIMEOUT
:
timeout
.
tv_sec
=
value
/
1000000
;
timeout
.
tv_sec
=
value
/
1000000
;
timeout
.
tv_usec
=
value
%
1000000
;
//less than rt_period?
timeout
.
tv_usec
=
value
%
1000000
;
//less than rt_period?
if
(
setsockopt
(
eth
->
sockfd
[
Mod_id
]
,
if
(
setsockopt
(
eth
->
sockfd
,
SOL_SOCKET
,
SOL_SOCKET
,
SO_RCVTIMEO
,
SO_RCVTIMEO
,
(
char
*
)
&
timeout
,
sizeof
(
timeout
)))
{
(
char
*
)
&
timeout
,
sizeof
(
timeout
)))
{
...
@@ -241,7 +241,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
...
@@ -241,7 +241,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
case
SND_TIMEOUT
:
case
SND_TIMEOUT
:
timeout
.
tv_sec
=
value
/
1000000000
;
timeout
.
tv_sec
=
value
/
1000000000
;
timeout
.
tv_usec
=
value
%
1000000000
;
//less than rt_period?
timeout
.
tv_usec
=
value
%
1000000000
;
//less than rt_period?
if
(
setsockopt
(
eth
->
sockfd
[
Mod_id
]
,
if
(
setsockopt
(
eth
->
sockfd
,
SOL_SOCKET
,
SOL_SOCKET
,
SO_SNDTIMEO
,
SO_SNDTIMEO
,
(
char
*
)
&
timeout
,
sizeof
(
timeout
)))
{
(
char
*
)
&
timeout
,
sizeof
(
timeout
)))
{
...
@@ -255,27 +255,27 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
...
@@ -255,27 +255,27 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
/******************* interface level options *************************/
/******************* interface level options *************************/
case
MTU_SIZE
:
/* change MTU of the eth interface */
case
MTU_SIZE
:
/* change MTU of the eth interface */
ifr
.
ifr_addr
.
sa_family
=
AF_INET
;
ifr
.
ifr_addr
.
sa_family
=
AF_INET
;
strncpy
(
ifr
.
ifr_name
,
eth
->
if_name
[
Mod_id
]
,
sizeof
(
ifr
.
ifr_name
));
strncpy
(
ifr
.
ifr_name
,
eth
->
if_name
,
sizeof
(
ifr
.
ifr_name
));
ifr
.
ifr_mtu
=
value
;
ifr
.
ifr_mtu
=
value
;
if
(
ioctl
(
eth
->
sockfd
[
Mod_id
]
,
SIOCSIFMTU
,(
caddr_t
)
&
ifr
)
<
0
)
if
(
ioctl
(
eth
->
sockfd
,
SIOCSIFMTU
,(
caddr_t
)
&
ifr
)
<
0
)
perror
(
"[ETHERNET] Can't set the MTU"
);
perror
(
"[ETHERNET] Can't set the MTU"
);
else
else
printf
(
"[ETHERNET] %s MTU size has changed to %d
\n
"
,
eth
->
if_name
[
Mod_id
]
,
ifr
.
ifr_mtu
);
printf
(
"[ETHERNET] %s MTU size has changed to %d
\n
"
,
eth
->
if_name
,
ifr
.
ifr_mtu
);
break
;
break
;
case
TX_Q_LEN
:
/* change TX queue length of eth interface */
case
TX_Q_LEN
:
/* change TX queue length of eth interface */
ifr
.
ifr_addr
.
sa_family
=
AF_INET
;
ifr
.
ifr_addr
.
sa_family
=
AF_INET
;
strncpy
(
ifr
.
ifr_name
,
eth
->
if_name
[
Mod_id
]
,
sizeof
(
ifr
.
ifr_name
));
strncpy
(
ifr
.
ifr_name
,
eth
->
if_name
,
sizeof
(
ifr
.
ifr_name
));
ifr
.
ifr_qlen
=
value
;
ifr
.
ifr_qlen
=
value
;
if
(
ioctl
(
eth
->
sockfd
[
Mod_id
]
,
SIOCSIFTXQLEN
,(
caddr_t
)
&
ifr
)
<
0
)
if
(
ioctl
(
eth
->
sockfd
,
SIOCSIFTXQLEN
,(
caddr_t
)
&
ifr
)
<
0
)
perror
(
"[ETHERNET] Can't set the txqueuelen"
);
perror
(
"[ETHERNET] Can't set the txqueuelen"
);
else
else
printf
(
"[ETHERNET] %s txqueuelen size has changed to %d
\n
"
,
eth
->
if_name
[
Mod_id
]
,
ifr
.
ifr_qlen
);
printf
(
"[ETHERNET] %s txqueuelen size has changed to %d
\n
"
,
eth
->
if_name
,
ifr
.
ifr_qlen
);
break
;
break
;
/******************* device level options *************************/
/******************* device level options *************************/
case
COALESCE_PAR
:
case
COALESCE_PAR
:
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -C %s rx-usecs %d"
,
eth
->
if_name
[
Mod_id
]
,
value
);
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -C %s rx-usecs %d"
,
eth
->
if_name
,
value
);
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
ret
=
system
(
system_cmd
);
ret
=
system
(
system_cmd
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
...
@@ -290,8 +290,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
...
@@ -290,8 +290,8 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
break
;
break
;
case
PAUSE_PAR
:
case
PAUSE_PAR
:
if
(
value
==
1
)
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -A %s autoneg off rx off tx off"
,
eth
->
if_name
[
Mod_id
]
);
if
(
value
==
1
)
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -A %s autoneg off rx off tx off"
,
eth
->
if_name
);
else
if
(
value
==
0
)
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -A %s autoneg on rx on tx on"
,
eth
->
if_name
[
Mod_id
]
);
else
if
(
value
==
0
)
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -A %s autoneg on rx on tx on"
,
eth
->
if_name
);
else
break
;
else
break
;
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
ret
=
system
(
system_cmd
);
ret
=
system
(
system_cmd
);
...
@@ -307,7 +307,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
...
@@ -307,7 +307,7 @@ int ethernet_tune(openair0_device *device, unsigned int option, int value) {
break
;
break
;
case
RING_PAR
:
case
RING_PAR
:
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -G %s val %d"
,
eth
->
if_name
[
Mod_id
]
,
value
);
ret
=
snprintf
(
system_cmd
,
sizeof
(
system_cmd
),
"ethtool -G %s val %d"
,
eth
->
if_name
,
value
);
if
(
ret
>
0
)
{
if
(
ret
>
0
)
{
ret
=
system
(
system_cmd
);
ret
=
system
(
system_cmd
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
...
@@ -351,7 +351,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
...
@@ -351,7 +351,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
}
}
printf
(
"[ETHERNET]: Initializing openair0_device for %s ...
\n
"
,
((
device
->
host_type
==
BBU_HOST
)
?
"BBU"
:
"RRH"
));
printf
(
"[ETHERNET]: Initializing openair0_device for %s ...
\n
"
,
((
device
->
host_type
==
BBU_HOST
)
?
"BBU"
:
"RRH"
));
device
->
Mod_id
=
num_devices_eth
++
;
device
->
Mod_id
=
0
;
//
num_devices_eth++;
device
->
transp_type
=
ETHERNET_TP
;
device
->
transp_type
=
ETHERNET_TP
;
device
->
trx_start_func
=
trx_eth_start
;
device
->
trx_start_func
=
trx_eth_start
;
device
->
trx_request_func
=
trx_eth_request
;
device
->
trx_request_func
=
trx_eth_request
;
...
@@ -383,7 +383,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
...
@@ -383,7 +383,7 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
//device->trx_read_func = trx_eth_read_udp_IF4p5;
//device->trx_read_func = trx_eth_read_udp_IF4p5;
}
}
eth
->
if_name
[
device
->
Mod_id
]
=
eth_params
->
local_if_name
;
eth
->
if_name
=
eth_params
->
local_if_name
;
device
->
priv
=
eth
;
device
->
priv
=
eth
;
/* device specific */
/* device specific */
...
...
targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h
View file @
db8c2a05
...
@@ -62,11 +62,23 @@
...
@@ -62,11 +62,23 @@
typedef
struct
{
typedef
struct
{
/*!\brief socket file desc */
/*!\brief socket file desc */
int
sockfd
[
MAX_INST
]
;
int
sockfd
;
/*!\brief interface name */
/*!\brief interface name */
char
*
if_name
[
MAX_INST
]
;
char
*
if_name
;
/*!\brief buffer size */
/*!\brief buffer size */
unsigned
int
buffer_size
;
unsigned
int
buffer_size
;
/*!\brief destination address for UDP socket*/
struct
sockaddr_in
dest_addr
;
/*!\brief local address for UDP socket*/
struct
sockaddr_in
local_addr
;
/*!\brief address length for both UDP and RAW socket*/
int
addr_len
;
/*!\brief destination address for RAW socket*/
struct
sockaddr_ll
dest_addr_ll
;
/*!\brief local address for RAW socket*/
struct
sockaddr_ll
local_addr_ll
;
/*!\brief inteface index for RAW socket*/
struct
ifreq
if_index
;
/*!\brief timeout ms */
/*!\brief timeout ms */
unsigned
int
rx_timeout_ms
;
unsigned
int
rx_timeout_ms
;
/*!\brief timeout ms */
/*!\brief timeout ms */
...
...
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