Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
b2a6951d
Commit
b2a6951d
authored
Feb 15, 2021
by
Antoine Kaufmann
Browse files
lib/nicif: refactor identifier names for google style
parent
e5622be2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
70 deletions
+75
-70
lib/simbricks/nicbm/nicbm.cc
lib/simbricks/nicbm/nicbm.cc
+15
-15
lib/simbricks/nicbm/nicbm.h
lib/simbricks/nicbm/nicbm.h
+1
-1
lib/simbricks/nicif/nicsim.c
lib/simbricks/nicif/nicsim.c
+23
-20
lib/simbricks/nicif/nicsim.h
lib/simbricks/nicif/nicsim.h
+22
-20
sims/nic/corundum/corundum_verilator.cc
sims/nic/corundum/corundum_verilator.cc
+14
-14
No files found.
lib/simbricks/nicbm/nicbm.cc
View file @
b2a6951d
...
@@ -59,7 +59,7 @@ static void sigusr1_handler(int dummy) {
...
@@ -59,7 +59,7 @@ static void sigusr1_handler(int dummy) {
volatile
union
SimbricksProtoPcieD2H
*
Runner
::
d2h_alloc
(
void
)
{
volatile
union
SimbricksProtoPcieD2H
*
Runner
::
d2h_alloc
(
void
)
{
volatile
union
SimbricksProtoPcieD2H
*
msg
;
volatile
union
SimbricksProtoPcieD2H
*
msg
;
while
((
msg
=
nicsim_d2h_a
lloc
(
&
nsparams
,
main_time
))
==
NULL
)
{
while
((
msg
=
SimbricksNicIfD2HA
lloc
(
&
nsparams
,
main_time
))
==
NULL
)
{
fprintf
(
stderr
,
"d2h_alloc: no entry available
\n
"
);
fprintf
(
stderr
,
"d2h_alloc: no entry available
\n
"
);
}
}
return
msg
;
return
msg
;
...
@@ -67,7 +67,7 @@ volatile union SimbricksProtoPcieD2H *Runner::d2h_alloc(void) {
...
@@ -67,7 +67,7 @@ volatile union SimbricksProtoPcieD2H *Runner::d2h_alloc(void) {
volatile
union
SimbricksProtoNetD2N
*
Runner
::
d2n_alloc
(
void
)
{
volatile
union
SimbricksProtoNetD2N
*
Runner
::
d2n_alloc
(
void
)
{
volatile
union
SimbricksProtoNetD2N
*
msg
;
volatile
union
SimbricksProtoNetD2N
*
msg
;
while
((
msg
=
nicsim_d2n_a
lloc
(
&
nsparams
,
main_time
))
==
NULL
)
{
while
((
msg
=
SimbricksNicIfD2NA
lloc
(
&
nsparams
,
main_time
))
==
NULL
)
{
fprintf
(
stderr
,
"d2n_alloc: no entry available
\n
"
);
fprintf
(
stderr
,
"d2n_alloc: no entry available
\n
"
);
}
}
return
msg
;
return
msg
;
...
@@ -285,7 +285,7 @@ void Runner::eth_send(const void *data, size_t len) {
...
@@ -285,7 +285,7 @@ void Runner::eth_send(const void *data, size_t len) {
void
Runner
::
poll_h2d
()
{
void
Runner
::
poll_h2d
()
{
volatile
union
SimbricksProtoPcieH2D
*
msg
=
volatile
union
SimbricksProtoPcieH2D
*
msg
=
nicif_h2d_p
oll
(
&
nsparams
,
main_time
);
SimbricksNicIfH2DP
oll
(
&
nsparams
,
main_time
);
uint8_t
type
;
uint8_t
type
;
if
(
msg
==
NULL
)
if
(
msg
==
NULL
)
...
@@ -320,13 +320,13 @@ void Runner::poll_h2d() {
...
@@ -320,13 +320,13 @@ void Runner::poll_h2d() {
fprintf
(
stderr
,
"poll_h2d: unsupported type=%u
\n
"
,
type
);
fprintf
(
stderr
,
"poll_h2d: unsupported type=%u
\n
"
,
type
);
}
}
nicif_h2d_d
one
(
msg
);
SimbricksNicIfH2DD
one
(
msg
);
nicif_h2d_n
ext
();
SimbricksNicIfH2DN
ext
();
}
}
void
Runner
::
poll_n2d
()
{
void
Runner
::
poll_n2d
()
{
volatile
union
SimbricksProtoNetN2D
*
msg
=
volatile
union
SimbricksProtoNetN2D
*
msg
=
nicif_n2d_p
oll
(
&
nsparams
,
main_time
);
SimbricksNicIfN2DP
oll
(
&
nsparams
,
main_time
);
uint8_t
t
;
uint8_t
t
;
if
(
msg
==
NULL
)
if
(
msg
==
NULL
)
...
@@ -345,8 +345,8 @@ void Runner::poll_n2d() {
...
@@ -345,8 +345,8 @@ void Runner::poll_n2d() {
fprintf
(
stderr
,
"poll_n2d: unsupported type=%u"
,
t
);
fprintf
(
stderr
,
"poll_n2d: unsupported type=%u"
,
t
);
}
}
nicif_n2d_d
one
(
msg
);
SimbricksNicIfN2DD
one
(
msg
);
nicif_n2d_n
ext
();
SimbricksNicIfN2DN
ext
();
}
}
uint64_t
Runner
::
time_ps
()
const
{
uint64_t
Runner
::
time_ps
()
const
{
...
@@ -436,7 +436,7 @@ int Runner::runMain(int argc, char *argv[]) {
...
@@ -436,7 +436,7 @@ int Runner::runMain(int argc, char *argv[]) {
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
nsparams
.
sync_mode
=
sync_mode
;
nsparams
.
sync_mode
=
sync_mode
;
if
(
nicsim_i
nit
(
&
nsparams
,
&
dintro
))
{
if
(
SimbricksNicIfI
nit
(
&
nsparams
,
&
dintro
))
{
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
fprintf
(
stderr
,
"sync_pci=%d sync_eth=%d
\n
"
,
nsparams
.
sync_pci
,
fprintf
(
stderr
,
"sync_pci=%d sync_eth=%d
\n
"
,
nsparams
.
sync_pci
,
...
@@ -445,10 +445,10 @@ int Runner::runMain(int argc, char *argv[]) {
...
@@ -445,10 +445,10 @@ int Runner::runMain(int argc, char *argv[]) {
bool
is_sync
=
nsparams
.
sync_pci
||
nsparams
.
sync_eth
;
bool
is_sync
=
nsparams
.
sync_pci
||
nsparams
.
sync_eth
;
while
(
!
exiting
)
{
while
(
!
exiting
)
{
while
(
nicsim_s
ync
(
&
nsparams
,
main_time
))
{
while
(
SimbricksNicIfS
ync
(
&
nsparams
,
main_time
))
{
fprintf
(
stderr
,
"warn:
nicsim_s
ync failed (t=%lu)
\n
"
,
main_time
);
fprintf
(
stderr
,
"warn:
SimbricksNicIfS
ync failed (t=%lu)
\n
"
,
main_time
);
}
}
nicsim_a
dvance
_e
poch
(
&
nsparams
,
main_time
);
SimbricksNicIfA
dvance
E
poch
(
&
nsparams
,
main_time
);
do
{
do
{
poll_h2d
();
poll_h2d
();
...
@@ -456,7 +456,7 @@ int Runner::runMain(int argc, char *argv[]) {
...
@@ -456,7 +456,7 @@ int Runner::runMain(int argc, char *argv[]) {
event_trigger
();
event_trigger
();
if
(
is_sync
)
{
if
(
is_sync
)
{
next_ts
=
nicsim_n
ext
_t
imestamp
(
&
nsparams
);
next_ts
=
SimbricksNicIfN
ext
T
imestamp
(
&
nsparams
);
if
(
next_ts
>
main_time
+
max_step
)
if
(
next_ts
>
main_time
+
max_step
)
next_ts
=
main_time
+
max_step
;
next_ts
=
main_time
+
max_step
;
}
else
{
}
else
{
...
@@ -467,11 +467,11 @@ int Runner::runMain(int argc, char *argv[]) {
...
@@ -467,11 +467,11 @@ int Runner::runMain(int argc, char *argv[]) {
if
(
event_next
(
ev_ts
)
&&
ev_ts
<
next_ts
)
if
(
event_next
(
ev_ts
)
&&
ev_ts
<
next_ts
)
next_ts
=
ev_ts
;
next_ts
=
ev_ts
;
}
while
(
next_ts
<=
main_time
&&
!
exiting
);
}
while
(
next_ts
<=
main_time
&&
!
exiting
);
main_time
=
nicsim_a
dvance
_t
ime
(
&
nsparams
,
next_ts
);
main_time
=
SimbricksNicIfA
dvance
T
ime
(
&
nsparams
,
next_ts
);
}
}
fprintf
(
stderr
,
"exit main_time: %lu
\n
"
,
main_time
);
fprintf
(
stderr
,
"exit main_time: %lu
\n
"
,
main_time
);
nicsim_c
leanup
();
SimbricksNicIfC
leanup
();
return
0
;
return
0
;
}
}
...
...
lib/simbricks/nicbm/nicbm.h
View file @
b2a6951d
...
@@ -124,7 +124,7 @@ class Runner {
...
@@ -124,7 +124,7 @@ class Runner {
std
::
deque
<
DMAOp
*>
dma_queue
;
std
::
deque
<
DMAOp
*>
dma_queue
;
size_t
dma_pending
;
size_t
dma_pending
;
uint64_t
mac_addr
;
uint64_t
mac_addr
;
struct
nicsim_p
arams
nsparams
;
struct
SimbricksNicIfP
arams
nsparams
;
struct
SimbricksProtoPcieDevIntro
dintro
;
struct
SimbricksProtoPcieDevIntro
dintro
;
volatile
union
SimbricksProtoPcieD2H
*
d2h_alloc
(
void
);
volatile
union
SimbricksProtoPcieD2H
*
d2h_alloc
(
void
);
...
...
lib/simbricks/nicif/nicsim.c
View file @
b2a6951d
...
@@ -177,7 +177,7 @@ static int accept_conns(struct SimbricksProtoPcieDevIntro *di, int pci_lfd,
...
@@ -177,7 +177,7 @@ static int accept_conns(struct SimbricksProtoPcieDevIntro *di, int pci_lfd,
return
0
;
return
0
;
}
}
int
nicsim_init
(
struct
nicsim_p
arams
*
params
,
int
SimbricksNicIfInit
(
struct
SimbricksNicIfP
arams
*
params
,
struct
SimbricksProtoPcieDevIntro
*
di
)
{
struct
SimbricksProtoPcieDevIntro
*
di
)
{
int
pci_lfd
=
-
1
,
eth_lfd
=
-
1
;
int
pci_lfd
=
-
1
,
eth_lfd
=
-
1
;
void
*
shmptr
;
void
*
shmptr
;
...
@@ -243,7 +243,7 @@ int nicsim_init(struct nicsim_params *params,
...
@@ -243,7 +243,7 @@ int nicsim_init(struct nicsim_params *params,
return
0
;
return
0
;
}
}
void
nicsim_c
leanup
(
void
)
{
void
SimbricksNicIfC
leanup
(
void
)
{
close
(
pci_cfd
);
close
(
pci_cfd
);
close
(
eth_cfd
);
close
(
eth_cfd
);
}
}
...
@@ -251,7 +251,8 @@ void nicsim_cleanup(void) {
...
@@ -251,7 +251,8 @@ void nicsim_cleanup(void) {
/******************************************************************************/
/******************************************************************************/
/* Sync */
/* Sync */
int
nicsim_sync
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
int
SimbricksNicIfSync
(
struct
SimbricksNicIfParams
*
params
,
uint64_t
timestamp
)
{
int
ret
=
0
;
int
ret
=
0
;
volatile
union
SimbricksProtoPcieD2H
*
d2h
;
volatile
union
SimbricksProtoPcieD2H
*
d2h
;
volatile
union
SimbricksProtoNetD2N
*
d2n
;
volatile
union
SimbricksProtoNetD2N
*
d2n
;
...
@@ -274,7 +275,7 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
...
@@ -274,7 +275,7 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
}
}
if
(
sync
)
{
if
(
sync
)
{
d2h
=
nicsim_d2h_a
lloc
(
params
,
timestamp
);
d2h
=
SimbricksNicIfD2HA
lloc
(
params
,
timestamp
);
if
(
d2h
==
NULL
)
{
if
(
d2h
==
NULL
)
{
ret
=
-
1
;
ret
=
-
1
;
}
else
{
}
else
{
...
@@ -303,7 +304,7 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
...
@@ -303,7 +304,7 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
}
}
if
(
sync
)
{
if
(
sync
)
{
d2n
=
nicsim_d2n_a
lloc
(
params
,
timestamp
);
d2n
=
SimbricksNicIfD2NA
lloc
(
params
,
timestamp
);
if
(
d2n
==
NULL
)
{
if
(
d2n
==
NULL
)
{
ret
=
-
1
;
ret
=
-
1
;
}
else
{
}
else
{
...
@@ -316,7 +317,8 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
...
@@ -316,7 +317,8 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
return
ret
;
return
ret
;
}
}
void
nicsim_advance_epoch
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
void
SimbricksNicIfAdvanceEpoch
(
struct
SimbricksNicIfParams
*
params
,
uint64_t
timestamp
)
{
if
(
params
->
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
)
{
if
(
params
->
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
)
{
if
((
params
->
sync_pci
||
params
->
sync_eth
)
&&
if
((
params
->
sync_pci
||
params
->
sync_eth
)
&&
timestamp
-
current_epoch
>=
params
->
sync_delay
)
{
timestamp
-
current_epoch
>=
params
->
sync_delay
)
{
...
@@ -325,7 +327,8 @@ void nicsim_advance_epoch(struct nicsim_params *params, uint64_t timestamp) {
...
@@ -325,7 +327,8 @@ void nicsim_advance_epoch(struct nicsim_params *params, uint64_t timestamp) {
}
}
}
}
uint64_t
nicsim_advance_time
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
uint64_t
SimbricksNicIfAdvanceTime
(
struct
SimbricksNicIfParams
*
params
,
uint64_t
timestamp
)
{
switch
(
params
->
sync_mode
)
{
switch
(
params
->
sync_mode
)
{
case
SIMBRICKS_PROTO_SYNC_SIMBRICKS
:
case
SIMBRICKS_PROTO_SYNC_SIMBRICKS
:
return
timestamp
;
return
timestamp
;
...
@@ -339,7 +342,7 @@ uint64_t nicsim_advance_time(struct nicsim_params *params, uint64_t timestamp) {
...
@@ -339,7 +342,7 @@ uint64_t nicsim_advance_time(struct nicsim_params *params, uint64_t timestamp) {
}
}
}
}
uint64_t
nicsim_n
ext
_t
imestamp
(
struct
nicsim_p
arams
*
params
)
{
uint64_t
SimbricksNicIfN
ext
T
imestamp
(
struct
SimbricksNicIfP
arams
*
params
)
{
if
(
params
->
sync_pci
&&
params
->
sync_eth
)
{
if
(
params
->
sync_pci
&&
params
->
sync_eth
)
{
return
(
pci_last_rx_time
<=
eth_last_rx_time
?
pci_last_rx_time
return
(
pci_last_rx_time
<=
eth_last_rx_time
?
pci_last_rx_time
:
eth_last_rx_time
);
:
eth_last_rx_time
);
...
@@ -355,8 +358,8 @@ uint64_t nicsim_next_timestamp(struct nicsim_params *params) {
...
@@ -355,8 +358,8 @@ uint64_t nicsim_next_timestamp(struct nicsim_params *params) {
/******************************************************************************/
/******************************************************************************/
/* PCI */
/* PCI */
volatile
union
SimbricksProtoPcieH2D
*
nicif_h2d_p
oll
(
volatile
union
SimbricksProtoPcieH2D
*
SimbricksNicIfH2DP
oll
(
struct
nicsim_p
arams
*
params
,
uint64_t
timestamp
)
{
struct
SimbricksNicIfP
arams
*
params
,
uint64_t
timestamp
)
{
volatile
union
SimbricksProtoPcieH2D
*
msg
=
volatile
union
SimbricksProtoPcieH2D
*
msg
=
(
volatile
union
SimbricksProtoPcieH2D
*
)(
h2d_queue
+
h2d_pos
*
H2D_ELEN
);
(
volatile
union
SimbricksProtoPcieH2D
*
)(
h2d_queue
+
h2d_pos
*
H2D_ELEN
);
...
@@ -373,18 +376,18 @@ volatile union SimbricksProtoPcieH2D *nicif_h2d_poll(
...
@@ -373,18 +376,18 @@ volatile union SimbricksProtoPcieH2D *nicif_h2d_poll(
return
msg
;
return
msg
;
}
}
void
nicif_h2d_d
one
(
volatile
union
SimbricksProtoPcieH2D
*
msg
)
{
void
SimbricksNicIfH2DD
one
(
volatile
union
SimbricksProtoPcieH2D
*
msg
)
{
msg
->
dummy
.
own_type
=
msg
->
dummy
.
own_type
=
(
msg
->
dummy
.
own_type
&
SIMBRICKS_PROTO_PCIE_H2D_MSG_MASK
)
|
(
msg
->
dummy
.
own_type
&
SIMBRICKS_PROTO_PCIE_H2D_MSG_MASK
)
|
SIMBRICKS_PROTO_PCIE_H2D_OWN_HOST
;
SIMBRICKS_PROTO_PCIE_H2D_OWN_HOST
;
}
}
void
nicif_h2d_n
ext
(
void
)
{
void
SimbricksNicIfH2DN
ext
(
void
)
{
h2d_pos
=
(
h2d_pos
+
1
)
%
H2D_ENUM
;
h2d_pos
=
(
h2d_pos
+
1
)
%
H2D_ENUM
;
}
}
volatile
union
SimbricksProtoPcieD2H
*
nicsim_d2h_a
lloc
(
volatile
union
SimbricksProtoPcieD2H
*
SimbricksNicIfD2HA
lloc
(
struct
nicsim_p
arams
*
params
,
uint64_t
timestamp
)
{
struct
SimbricksNicIfP
arams
*
params
,
uint64_t
timestamp
)
{
volatile
union
SimbricksProtoPcieD2H
*
msg
=
volatile
union
SimbricksProtoPcieD2H
*
msg
=
(
volatile
union
SimbricksProtoPcieD2H
*
)(
d2h_queue
+
d2h_pos
*
D2H_ELEN
);
(
volatile
union
SimbricksProtoPcieD2H
*
)(
d2h_queue
+
d2h_pos
*
D2H_ELEN
);
...
@@ -403,8 +406,8 @@ volatile union SimbricksProtoPcieD2H *nicsim_d2h_alloc(
...
@@ -403,8 +406,8 @@ volatile union SimbricksProtoPcieD2H *nicsim_d2h_alloc(
/******************************************************************************/
/******************************************************************************/
/* Ethernet */
/* Ethernet */
volatile
union
SimbricksProtoNetN2D
*
nicif_n2d_p
oll
(
volatile
union
SimbricksProtoNetN2D
*
SimbricksNicIfN2DP
oll
(
struct
nicsim_p
arams
*
params
,
uint64_t
timestamp
)
{
struct
SimbricksNicIfP
arams
*
params
,
uint64_t
timestamp
)
{
volatile
union
SimbricksProtoNetN2D
*
msg
=
volatile
union
SimbricksProtoNetN2D
*
msg
=
(
volatile
union
SimbricksProtoNetN2D
*
)(
n2d_queue
+
n2d_pos
*
N2D_ELEN
);
(
volatile
union
SimbricksProtoNetN2D
*
)(
n2d_queue
+
n2d_pos
*
N2D_ELEN
);
...
@@ -421,18 +424,18 @@ volatile union SimbricksProtoNetN2D *nicif_n2d_poll(
...
@@ -421,18 +424,18 @@ volatile union SimbricksProtoNetN2D *nicif_n2d_poll(
return
msg
;
return
msg
;
}
}
void
nicif_n2d_d
one
(
volatile
union
SimbricksProtoNetN2D
*
msg
)
{
void
SimbricksNicIfN2DD
one
(
volatile
union
SimbricksProtoNetN2D
*
msg
)
{
msg
->
dummy
.
own_type
=
msg
->
dummy
.
own_type
=
(
msg
->
dummy
.
own_type
&
SIMBRICKS_PROTO_NET_N2D_MSG_MASK
)
|
(
msg
->
dummy
.
own_type
&
SIMBRICKS_PROTO_NET_N2D_MSG_MASK
)
|
SIMBRICKS_PROTO_NET_N2D_OWN_NET
;
SIMBRICKS_PROTO_NET_N2D_OWN_NET
;
}
}
void
nicif_n2d_n
ext
(
void
)
{
void
SimbricksNicIfN2DN
ext
(
void
)
{
n2d_pos
=
(
n2d_pos
+
1
)
%
N2D_ENUM
;
n2d_pos
=
(
n2d_pos
+
1
)
%
N2D_ENUM
;
}
}
volatile
union
SimbricksProtoNetD2N
*
nicsim_d2n_a
lloc
(
volatile
union
SimbricksProtoNetD2N
*
SimbricksNicIfD2NA
lloc
(
struct
nicsim_p
arams
*
params
,
uint64_t
timestamp
)
{
struct
SimbricksNicIfP
arams
*
params
,
uint64_t
timestamp
)
{
volatile
union
SimbricksProtoNetD2N
*
msg
=
volatile
union
SimbricksProtoNetD2N
*
msg
=
(
volatile
union
SimbricksProtoNetD2N
*
)(
d2n_queue
+
d2n_pos
*
D2N_ELEN
);
(
volatile
union
SimbricksProtoNetD2N
*
)(
d2n_queue
+
d2n_pos
*
D2N_ELEN
);
...
...
lib/simbricks/nicif/nicsim.h
View file @
b2a6951d
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#include <simbricks/proto/network.h>
#include <simbricks/proto/network.h>
#include <simbricks/proto/pcie.h>
#include <simbricks/proto/pcie.h>
struct
nicsim_p
arams
{
struct
SimbricksNicIfP
arams
{
const
char
*
pci_socket_path
;
const
char
*
pci_socket_path
;
const
char
*
eth_socket_path
;
const
char
*
eth_socket_path
;
const
char
*
shm_path
;
const
char
*
shm_path
;
...
@@ -42,29 +42,31 @@ struct nicsim_params {
...
@@ -42,29 +42,31 @@ struct nicsim_params {
int
sync_mode
;
int
sync_mode
;
};
};
int
nicsim_init
(
struct
nicsim_p
arams
*
params
,
int
SimbricksNicIfInit
(
struct
SimbricksNicIfP
arams
*
params
,
struct
SimbricksProtoPcieDevIntro
*
di
);
struct
SimbricksProtoPcieDevIntro
*
di
);
void
nicsim_c
leanup
(
void
);
void
SimbricksNicIfC
leanup
(
void
);
int
nicsim_sync
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
int
SimbricksNicIfSync
(
struct
SimbricksNicIfParams
*
params
,
uint64_t
timestamp
);
void
nicsim_advance_epoch
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
void
SimbricksNicIfAdvanceEpoch
(
struct
SimbricksNicIfParams
*
params
,
uint64_t
nicsim_advance_time
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
uint64_t
timestamp
);
uint64_t
nicsim_next_timestamp
(
struct
nicsim_params
*
params
);
uint64_t
SimbricksNicIfAdvanceTime
(
struct
SimbricksNicIfParams
*
params
,
uint64_t
timestamp
);
uint64_t
SimbricksNicIfNextTimestamp
(
struct
SimbricksNicIfParams
*
params
);
volatile
union
SimbricksProtoPcieH2D
*
nicif_h2d_p
oll
(
volatile
union
SimbricksProtoPcieH2D
*
SimbricksNicIfH2DP
oll
(
struct
nicsim_p
arams
*
params
,
uint64_t
timestamp
);
struct
SimbricksNicIfP
arams
*
params
,
uint64_t
timestamp
);
void
nicif_h2d_d
one
(
volatile
union
SimbricksProtoPcieH2D
*
msg
);
void
SimbricksNicIfH2DD
one
(
volatile
union
SimbricksProtoPcieH2D
*
msg
);
void
nicif_h2d_n
ext
(
void
);
void
SimbricksNicIfH2DN
ext
(
void
);
volatile
union
SimbricksProtoPcieD2H
*
nicsim_d2h_a
lloc
(
volatile
union
SimbricksProtoPcieD2H
*
SimbricksNicIfD2HA
lloc
(
struct
nicsim_p
arams
*
params
,
uint64_t
timestamp
);
struct
SimbricksNicIfP
arams
*
params
,
uint64_t
timestamp
);
volatile
union
SimbricksProtoNetN2D
*
nicif_n2d_p
oll
(
volatile
union
SimbricksProtoNetN2D
*
SimbricksNicIfN2DP
oll
(
struct
nicsim_p
arams
*
params
,
uint64_t
timestamp
);
struct
SimbricksNicIfP
arams
*
params
,
uint64_t
timestamp
);
void
nicif_n2d_d
one
(
volatile
union
SimbricksProtoNetN2D
*
msg
);
void
SimbricksNicIfN2DD
one
(
volatile
union
SimbricksProtoNetN2D
*
msg
);
void
nicif_n2d_n
ext
(
void
);
void
SimbricksNicIfN2DN
ext
(
void
);
volatile
union
SimbricksProtoNetD2N
*
nicsim_d2n_a
lloc
(
volatile
union
SimbricksProtoNetD2N
*
SimbricksNicIfD2NA
lloc
(
struct
nicsim_p
arams
*
params
,
uint64_t
timestamp
);
struct
SimbricksNicIfP
arams
*
params
,
uint64_t
timestamp
);
#endif // SIMBRICKS_NICIF_NICSIM_H_
#endif // SIMBRICKS_NICIF_NICSIM_H_
sims/nic/corundum/corundum_verilator.cc
View file @
b2a6951d
...
@@ -54,7 +54,7 @@ static uint64_t eth_latency = 500 * 1000ULL; // 500ns
...
@@ -54,7 +54,7 @@ static uint64_t eth_latency = 500 * 1000ULL; // 500ns
static
volatile
int
exiting
=
0
;
static
volatile
int
exiting
=
0
;
uint64_t
main_time
=
0
;
uint64_t
main_time
=
0
;
static
struct
nicsim_p
arams
nsparams
;
static
struct
SimbricksNicIfP
arams
nsparams
;
#ifdef TRACE_ENABLED
#ifdef TRACE_ENABLED
static
VerilatedVcdC
*
trace
;
static
VerilatedVcdC
*
trace
;
#endif
#endif
...
@@ -540,7 +540,7 @@ static void h2d_write(MMIOInterface &mmio,
...
@@ -540,7 +540,7 @@ static void h2d_write(MMIOInterface &mmio,
static
void
poll_h2d
(
MMIOInterface
&
mmio
)
{
static
void
poll_h2d
(
MMIOInterface
&
mmio
)
{
volatile
union
SimbricksProtoPcieH2D
*
msg
=
volatile
union
SimbricksProtoPcieH2D
*
msg
=
nicif_h2d_p
oll
(
&
nsparams
,
main_time
);
SimbricksNicIfH2DP
oll
(
&
nsparams
,
main_time
);
uint8_t
t
;
uint8_t
t
;
if
(
msg
==
NULL
)
if
(
msg
==
NULL
)
...
@@ -576,12 +576,12 @@ static void poll_h2d(MMIOInterface &mmio) {
...
@@ -576,12 +576,12 @@ static void poll_h2d(MMIOInterface &mmio) {
std
::
cerr
<<
"poll_h2d: unsupported type="
<<
t
<<
std
::
endl
;
std
::
cerr
<<
"poll_h2d: unsupported type="
<<
t
<<
std
::
endl
;
}
}
nicif_h2d_d
one
(
msg
);
SimbricksNicIfH2DD
one
(
msg
);
nicif_h2d_n
ext
();
SimbricksNicIfH2DN
ext
();
}
}
static
volatile
union
SimbricksProtoPcieD2H
*
d2h_alloc
(
void
)
{
static
volatile
union
SimbricksProtoPcieD2H
*
d2h_alloc
(
void
)
{
return
nicsim_d2h_a
lloc
(
&
nsparams
,
main_time
);
return
SimbricksNicIfD2HA
lloc
(
&
nsparams
,
main_time
);
}
}
class
EthernetTx
{
class
EthernetTx
{
...
@@ -596,7 +596,7 @@ class EthernetTx {
...
@@ -596,7 +596,7 @@ class EthernetTx {
void
packet_done
()
{
void
packet_done
()
{
volatile
union
SimbricksProtoNetD2N
*
msg
=
volatile
union
SimbricksProtoNetD2N
*
msg
=
nicsim_d2n_a
lloc
(
&
nsparams
,
main_time
);
SimbricksNicIfD2NA
lloc
(
&
nsparams
,
main_time
);
volatile
struct
SimbricksProtoNetD2NSend
*
send
;
volatile
struct
SimbricksProtoNetD2NSend
*
send
;
if
(
!
msg
)
if
(
!
msg
)
...
@@ -734,7 +734,7 @@ static void n2d_recv(EthernetRx &rx,
...
@@ -734,7 +734,7 @@ static void n2d_recv(EthernetRx &rx,
static
void
poll_n2d
(
EthernetRx
&
rx
)
{
static
void
poll_n2d
(
EthernetRx
&
rx
)
{
volatile
union
SimbricksProtoNetN2D
*
msg
=
volatile
union
SimbricksProtoNetN2D
*
msg
=
nicif_n2d_p
oll
(
&
nsparams
,
main_time
);
SimbricksNicIfN2DP
oll
(
&
nsparams
,
main_time
);
uint8_t
t
;
uint8_t
t
;
if
(
msg
==
NULL
)
if
(
msg
==
NULL
)
...
@@ -754,8 +754,8 @@ static void poll_n2d(EthernetRx &rx) {
...
@@ -754,8 +754,8 @@ static void poll_n2d(EthernetRx &rx) {
std
::
cerr
<<
"poll_n2d: unsupported type="
<<
t
<<
std
::
endl
;
std
::
cerr
<<
"poll_n2d: unsupported type="
<<
t
<<
std
::
endl
;
}
}
nicif_n2d_d
one
(
msg
);
SimbricksNicIfN2DD
one
(
msg
);
nicif_n2d_n
ext
();
SimbricksNicIfN2DN
ext
();
}
}
void
pci_msi_issue
(
uint8_t
vec
)
{
void
pci_msi_issue
(
uint8_t
vec
)
{
...
@@ -845,7 +845,7 @@ int main(int argc, char *argv[]) {
...
@@ -845,7 +845,7 @@ int main(int argc, char *argv[]) {
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
sync_mode
==
SIMBRICKS_PROTO_SYNC_BARRIER
);
nsparams
.
sync_mode
=
sync_mode
;
nsparams
.
sync_mode
=
sync_mode
;
if
(
nicsim_i
nit
(
&
nsparams
,
&
di
))
{
if
(
SimbricksNicIfI
nit
(
&
nsparams
,
&
di
))
{
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
std
::
cout
<<
"sync_pci="
<<
nsparams
.
sync_pci
std
::
cout
<<
"sync_pci="
<<
nsparams
.
sync_pci
...
@@ -954,17 +954,17 @@ int main(int argc, char *argv[]) {
...
@@ -954,17 +954,17 @@ int main(int argc, char *argv[]) {
top
->
rst
=
0
;
top
->
rst
=
0
;
while
(
!
exiting
)
{
while
(
!
exiting
)
{
while
(
nicsim_s
ync
(
&
nsparams
,
main_time
))
{
while
(
SimbricksNicIfS
ync
(
&
nsparams
,
main_time
))
{
std
::
cerr
<<
"warn:
nicsim_s
ync failed (t="
<<
main_time
<<
")"
std
::
cerr
<<
"warn:
SimbricksNicIfS
ync failed (t="
<<
main_time
<<
")"
<<
std
::
endl
;
<<
std
::
endl
;
}
}
nicsim_a
dvance
_e
poch
(
&
nsparams
,
main_time
);
SimbricksNicIfA
dvance
E
poch
(
&
nsparams
,
main_time
);
do
{
do
{
poll_h2d
(
mmio
);
poll_h2d
(
mmio
);
poll_n2d
(
rx
);
poll_n2d
(
rx
);
}
while
((
nsparams
.
sync_pci
||
nsparams
.
sync_eth
)
&&
}
while
((
nsparams
.
sync_pci
||
nsparams
.
sync_eth
)
&&
nicsim_n
ext
_t
imestamp
(
&
nsparams
)
<=
main_time
&&
!
exiting
);
SimbricksNicIfN
ext
T
imestamp
(
&
nsparams
)
<=
main_time
&&
!
exiting
);
/* falling edge */
/* falling edge */
top
->
clk
=
!
top
->
clk
;
top
->
clk
=
!
top
->
clk
;
...
...
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