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
803110a8
Commit
803110a8
authored
Feb 14, 2021
by
Antoine Kaufmann
Browse files
lib/proto/network: rename definitions cosim->simbricks
Also fix identifier case
parent
69f0e0d1
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
134 additions
and
124 deletions
+134
-124
lib/simbricks/netif/netsim.c
lib/simbricks/netif/netsim.c
+22
-20
lib/simbricks/netif/netsim.h
lib/simbricks/netif/netsim.h
+3
-3
lib/simbricks/nicbm/nicbm.cc
lib/simbricks/nicbm/nicbm.cc
+11
-10
lib/simbricks/nicbm/nicbm.h
lib/simbricks/nicbm/nicbm.h
+2
-2
lib/simbricks/nicif/nicsim.c
lib/simbricks/nicif/nicsim.c
+21
-20
lib/simbricks/nicif/nicsim.h
lib/simbricks/nicif/nicsim.h
+4
-4
lib/simbricks/proto/network.h
lib/simbricks/proto/network.h
+32
-32
sims/external/ns-3
sims/external/ns-3
+1
-1
sims/net/switch/net_switch.cc
sims/net/switch/net_switch.cc
+11
-9
sims/net/tap/net_tap.c
sims/net/tap/net_tap.c
+8
-7
sims/net/wire/net_wire.c
sims/net/wire/net_wire.c
+10
-8
sims/nic/corundum/corundum_verilator.cc
sims/nic/corundum/corundum_verilator.cc
+9
-8
No files found.
lib/simbricks/netif/netsim.c
View file @
803110a8
...
...
@@ -37,8 +37,8 @@ static uint64_t current_epoch = 0;
int
netsim_init
(
struct
netsim_interface
*
nsif
,
const
char
*
eth_socket_path
,
int
*
sync_eth
)
{
struct
cosim_eth_proto_dev_i
ntro
di
;
struct
cosim_eth_proto_net_i
ntro
ni
;
struct
SimbricksProtoNetDevI
ntro
di
;
struct
SimbricksProtoNetNetI
ntro
ni
;
int
cfd
,
shm_fd
;
void
*
p
;
...
...
@@ -49,7 +49,7 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path,
memset
(
&
ni
,
0
,
sizeof
(
ni
));
if
(
*
sync_eth
)
ni
.
flags
|=
CO
SIM
_ETH
_PROTO_FLAGS_NI_SYNC
;
ni
.
flags
|=
SIM
BRICKS
_PROTO_
NET_
FLAGS_NI_SYNC
;
if
(
send
(
cfd
,
&
ni
,
sizeof
(
ni
),
0
)
!=
sizeof
(
ni
))
{
perror
(
"sending net intro failed"
);
...
...
@@ -65,7 +65,7 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path,
}
close
(
shm_fd
);
if
((
di
.
flags
&
CO
SIM
_ETH
_PROTO_FLAGS_DI_SYNC
)
==
0
)
{
if
((
di
.
flags
&
SIM
BRICKS
_PROTO_
NET_
FLAGS_DI_SYNC
)
==
0
)
{
*
sync_eth
=
0
;
nsif
->
sync
=
0
;
}
else
{
...
...
@@ -89,15 +89,15 @@ void netsim_cleanup(struct netsim_interface *nsif) {
abort
();
}
volatile
union
cosim_eth_proto_d2n
*
netsim_d2n_poll
(
volatile
union
SimbricksProtoNetD2N
*
netsim_d2n_poll
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
)
{
volatile
union
cosim_eth_proto_d2n
*
msg
=
(
volatile
union
cosim_eth_proto_d2n
*
)(
nsif
->
d2n_queue
+
volatile
union
SimbricksProtoNetD2N
*
msg
=
(
volatile
union
SimbricksProtoNetD2N
*
)(
nsif
->
d2n_queue
+
nsif
->
d2n_pos
*
nsif
->
d2n_elen
);
/* message not ready */
if
((
msg
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_D2N_OWN_MASK
)
!=
CO
SIM
_ETH
_PROTO_D2N_OWN_NET
)
if
((
msg
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
D2N_OWN_MASK
)
!=
SIM
BRICKS
_PROTO_
NET_
D2N_OWN_NET
)
return
NULL
;
/* if in sync mode, wait till message is ready */
...
...
@@ -110,19 +110,20 @@ volatile union cosim_eth_proto_d2n *netsim_d2n_poll(
}
void
netsim_d2n_done
(
struct
netsim_interface
*
nsif
,
volatile
union
cosim_eth_proto_d2n
*
msg
)
{
msg
->
dummy
.
own_type
=
(
msg
->
dummy
.
own_type
&
COSIM_ETH_PROTO_D2N_MSG_MASK
)
|
COSIM_ETH_PROTO_D2N_OWN_DEV
;
volatile
union
SimbricksProtoNetD2N
*
msg
)
{
msg
->
dummy
.
own_type
=
(
msg
->
dummy
.
own_type
&
SIMBRICKS_PROTO_NET_D2N_MSG_MASK
)
|
SIMBRICKS_PROTO_NET_D2N_OWN_DEV
;
}
volatile
union
cosim_eth_proto_n2d
*
netsim_n2d_alloc
(
volatile
union
SimbricksProtoNetN2D
*
netsim_n2d_alloc
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
)
{
volatile
union
cosim_eth_proto_n2d
*
msg
=
(
volatile
union
cosim_eth_proto_n2d
*
)(
nsif
->
n2d_queue
+
volatile
union
SimbricksProtoNetN2D
*
msg
=
(
volatile
union
SimbricksProtoNetN2D
*
)(
nsif
->
n2d_queue
+
nsif
->
n2d_pos
*
nsif
->
n2d_elen
);
if
((
msg
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_N2D_OWN_MASK
)
!=
CO
SIM
_ETH
_PROTO_N2D_OWN_NET
)
{
if
((
msg
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
N2D_OWN_MASK
)
!=
SIM
BRICKS
_PROTO_
NET_
N2D_OWN_NET
)
{
return
NULL
;
}
...
...
@@ -135,8 +136,8 @@ volatile union cosim_eth_proto_n2d *netsim_n2d_alloc(
int
netsim_n2d_sync
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
,
uint64_t
sync_delay
,
int
sync_mode
)
{
volatile
union
cosim_eth_proto_n2d
*
msg
;
volatile
struct
cosim_eth_proto_n2d_s
ync
*
sync
;
volatile
union
SimbricksProtoNetN2D
*
msg
;
volatile
struct
SimbricksProtoNetN2DS
ync
*
sync
;
int
do_sync
;
if
(
!
nsif
->
sync
)
...
...
@@ -165,7 +166,8 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
sync
=
&
msg
->
sync
;
// WMB();
sync
->
own_type
=
COSIM_ETH_PROTO_N2D_MSG_SYNC
|
COSIM_ETH_PROTO_N2D_OWN_DEV
;
sync
->
own_type
=
SIMBRICKS_PROTO_NET_N2D_MSG_SYNC
|
SIMBRICKS_PROTO_NET_N2D_OWN_DEV
;
return
0
;
}
...
...
lib/simbricks/netif/netsim.h
View file @
803110a8
...
...
@@ -53,15 +53,15 @@ int netsim_init(struct netsim_interface *nsif, const char *eth_socket_path,
int
*
sync_eth
);
void
netsim_cleanup
(
struct
netsim_interface
*
nsif
);
volatile
union
cosim_eth_proto_d2n
*
netsim_d2n_poll
(
volatile
union
SimbricksProtoNetD2N
*
netsim_d2n_poll
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
);
void
netsim_d2n_done
(
struct
netsim_interface
*
nsif
,
volatile
union
cosim_eth_proto_d2n
*
msg
);
volatile
union
SimbricksProtoNetD2N
*
msg
);
static
inline
uint64_t
netsim_d2n_timestamp
(
struct
netsim_interface
*
nsif
)
{
return
nsif
->
d2n_timestamp
;
}
volatile
union
cosim_eth_proto_n2d
*
netsim_n2d_alloc
(
volatile
union
SimbricksProtoNetN2D
*
netsim_n2d_alloc
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
);
int
netsim_n2d_sync
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
,
uint64_t
sync_delay
,
int
sync_mode
);
...
...
lib/simbricks/nicbm/nicbm.cc
View file @
803110a8
...
...
@@ -61,8 +61,8 @@ volatile union SimbricksProtoPcieD2H *Runner::d2h_alloc(void) {
return
msg
;
}
volatile
union
cosim_eth_proto_d2n
*
Runner
::
d2n_alloc
(
void
)
{
volatile
union
cosim_eth_proto_d2n
*
msg
;
volatile
union
SimbricksProtoNetD2N
*
Runner
::
d2n_alloc
(
void
)
{
volatile
union
SimbricksProtoNetD2N
*
msg
;
while
((
msg
=
nicsim_d2n_alloc
(
&
nsparams
,
main_time
))
==
NULL
)
{
fprintf
(
stderr
,
"d2n_alloc: no entry available
\n
"
);
}
...
...
@@ -257,7 +257,7 @@ void Runner::h2d_devctrl(volatile struct SimbricksProtoPcieH2DDevctrl *dc) {
dev
.
devctrl_update
(
*
(
struct
SimbricksProtoPcieH2DDevctrl
*
)
dc
);
}
void
Runner
::
eth_recv
(
volatile
struct
cosim_eth_proto_n2d_r
ecv
*
recv
)
{
void
Runner
::
eth_recv
(
volatile
struct
SimbricksProtoNetN2DR
ecv
*
recv
)
{
#ifdef DEBUG_NICBM
printf
(
"nicbm: eth rx: port %u len %u
\n
"
,
recv
->
port
,
recv
->
len
);
#endif
...
...
@@ -270,12 +270,13 @@ void Runner::eth_send(const void *data, size_t len) {
printf
(
"nicbm: eth tx: len %zu
\n
"
,
len
);
#endif
volatile
union
cosim_eth_proto_d2n
*
msg
=
d2n_alloc
();
volatile
struct
cosim_eth_proto_d2n_s
end
*
send
=
&
msg
->
send
;
volatile
union
SimbricksProtoNetD2N
*
msg
=
d2n_alloc
();
volatile
struct
SimbricksProtoNetD2NS
end
*
send
=
&
msg
->
send
;
send
->
port
=
0
;
// single port
send
->
len
=
len
;
memcpy
((
void
*
)
send
->
data
,
data
,
len
);
send
->
own_type
=
COSIM_ETH_PROTO_D2N_MSG_SEND
|
COSIM_ETH_PROTO_D2N_OWN_NET
;
send
->
own_type
=
SIMBRICKS_PROTO_NET_D2N_MSG_SEND
|
SIMBRICKS_PROTO_NET_D2N_OWN_NET
;
}
void
Runner
::
poll_h2d
()
{
...
...
@@ -320,20 +321,20 @@ void Runner::poll_h2d() {
}
void
Runner
::
poll_n2d
()
{
volatile
union
cosim_eth_proto_n2d
*
msg
=
volatile
union
SimbricksProtoNetN2D
*
msg
=
nicif_n2d_poll
(
&
nsparams
,
main_time
);
uint8_t
t
;
if
(
msg
==
NULL
)
return
;
t
=
msg
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_N2D_MSG_MASK
;
t
=
msg
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
N2D_MSG_MASK
;
switch
(
t
)
{
case
CO
SIM
_ETH
_PROTO_N2D_MSG_RECV
:
case
SIM
BRICKS
_PROTO_
NET_
N2D_MSG_RECV
:
eth_recv
(
&
msg
->
recv
);
break
;
case
CO
SIM
_ETH
_PROTO_N2D_MSG_SYNC
:
case
SIM
BRICKS
_PROTO_
NET_
N2D_MSG_SYNC
:
break
;
default:
...
...
lib/simbricks/nicbm/nicbm.h
View file @
803110a8
...
...
@@ -128,7 +128,7 @@ class Runner {
struct
SimbricksProtoPcieDevIntro
dintro
;
volatile
union
SimbricksProtoPcieD2H
*
d2h_alloc
(
void
);
volatile
union
cosim_eth_proto_d2n
*
d2n_alloc
(
void
);
volatile
union
SimbricksProtoNetD2N
*
d2n_alloc
(
void
);
void
h2d_read
(
volatile
struct
SimbricksProtoPcieH2DRead
*
read
);
void
h2d_write
(
volatile
struct
SimbricksProtoPcieH2DWrite
*
write
);
...
...
@@ -137,7 +137,7 @@ class Runner {
void
h2d_devctrl
(
volatile
struct
SimbricksProtoPcieH2DDevctrl
*
dc
);
void
poll_h2d
();
void
eth_recv
(
volatile
struct
cosim_eth_proto_n2d_r
ecv
*
recv
);
void
eth_recv
(
volatile
struct
SimbricksProtoNetN2DR
ecv
*
recv
);
void
poll_n2d
();
bool
event_next
(
uint64_t
&
retval
);
...
...
lib/simbricks/nicif/nicsim.c
View file @
803110a8
...
...
@@ -101,7 +101,7 @@ static int accept_pci(struct SimbricksProtoPcieDevIntro *di, int pci_lfd,
}
static
int
accept_eth
(
int
eth_lfd
,
int
*
sync_eth
)
{
struct
cosim_eth_proto_dev_i
ntro
di
;
struct
SimbricksProtoNetDevI
ntro
di
;
if
((
eth_cfd
=
accept
(
eth_lfd
,
NULL
,
NULL
))
<
0
)
{
return
-
1
;
...
...
@@ -112,7 +112,7 @@ static int accept_eth(int eth_lfd, int *sync_eth) {
memset
(
&
di
,
0
,
sizeof
(
di
));
di
.
flags
=
0
;
if
(
*
sync_eth
)
di
.
flags
|=
CO
SIM
_ETH
_PROTO_FLAGS_DI_SYNC
;
di
.
flags
|=
SIM
BRICKS
_PROTO_
NET_
FLAGS_DI_SYNC
;
di
.
d2n_offset
=
d2n_off
;
di
.
d2n_elen
=
D2N_ELEN
;
...
...
@@ -230,11 +230,11 @@ int nicsim_init(struct nicsim_params *params,
printf
(
"pci host info received
\n
"
);
}
if
(
params
->
eth_socket_path
!=
NULL
)
{
struct
cosim_eth_proto_net_i
ntro
ni
;
struct
SimbricksProtoNetNetI
ntro
ni
;
if
(
recv
(
eth_cfd
,
&
ni
,
sizeof
(
ni
),
0
)
!=
sizeof
(
ni
))
{
return
-
1
;
}
if
((
ni
.
flags
&
CO
SIM
_ETH
_PROTO_FLAGS_NI_SYNC
)
==
0
)
if
((
ni
.
flags
&
SIM
BRICKS
_PROTO_
NET_
FLAGS_NI_SYNC
)
==
0
)
params
->
sync_eth
=
0
;
printf
(
"eth net info received
\n
"
);
}
...
...
@@ -253,7 +253,7 @@ void nicsim_cleanup(void) {
int
nicsim_sync
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
int
ret
=
0
;
volatile
union
SimbricksProtoPcieD2H
*
d2h
;
volatile
union
cosim_eth_proto_d2n
*
d2n
;
volatile
union
SimbricksProtoNetD2N
*
d2n
;
/* sync PCI if necessary */
if
(
params
->
sync_pci
)
{
...
...
@@ -307,7 +307,7 @@ int nicsim_sync(struct nicsim_params *params, uint64_t timestamp) {
ret
=
-
1
;
}
else
{
d2n
->
sync
.
own_type
=
CO
SIM
_ETH
_PROTO_D2N_MSG_SYNC
|
CO
SIM
_ETH
_PROTO_D2N_OWN_NET
;
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_SYNC
|
SIM
BRICKS
_PROTO_
NET_
D2N_OWN_NET
;
}
}
}
...
...
@@ -402,14 +402,14 @@ volatile union SimbricksProtoPcieD2H *nicsim_d2h_alloc(
/******************************************************************************/
/* Ethernet */
volatile
union
cosim_eth_proto_n2d
*
nicif_n2d_poll
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
volatile
union
cosim_eth_proto_n2d
*
msg
=
(
volatile
union
cosim_eth_proto_n2d
*
)(
n2d_queue
+
n2d_pos
*
N2D_ELEN
);
volatile
union
SimbricksProtoNetN2D
*
nicif_n2d_poll
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
volatile
union
SimbricksProtoNetN2D
*
msg
=
(
volatile
union
SimbricksProtoNetN2D
*
)(
n2d_queue
+
n2d_pos
*
N2D_ELEN
);
/* message not ready */
if
((
msg
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_N2D_OWN_MASK
)
!=
CO
SIM
_ETH
_PROTO_N2D_OWN_DEV
)
if
((
msg
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
N2D_OWN_MASK
)
!=
SIM
BRICKS
_PROTO_
NET_
N2D_OWN_DEV
)
return
NULL
;
/* if in sync mode, wait till message is ready */
...
...
@@ -420,22 +420,23 @@ volatile union cosim_eth_proto_n2d *nicif_n2d_poll(struct nicsim_params *params,
return
msg
;
}
void
nicif_n2d_done
(
volatile
union
cosim_eth_proto_n2d
*
msg
)
{
msg
->
dummy
.
own_type
=
(
msg
->
dummy
.
own_type
&
COSIM_ETH_PROTO_N2D_MSG_MASK
)
|
COSIM_ETH_PROTO_N2D_OWN_NET
;
void
nicif_n2d_done
(
volatile
union
SimbricksProtoNetN2D
*
msg
)
{
msg
->
dummy
.
own_type
=
(
msg
->
dummy
.
own_type
&
SIMBRICKS_PROTO_NET_N2D_MSG_MASK
)
|
SIMBRICKS_PROTO_NET_N2D_OWN_NET
;
}
void
nicif_n2d_next
(
void
)
{
n2d_pos
=
(
n2d_pos
+
1
)
%
N2D_ENUM
;
}
volatile
union
cosim_eth_proto_d2n
*
nicsim_d2n_alloc
(
volatile
union
SimbricksProtoNetD2N
*
nicsim_d2n_alloc
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
)
{
volatile
union
cosim_eth_proto_d2n
*
msg
=
(
volatile
union
cosim_eth_proto_d2n
*
)(
d2n_queue
+
d2n_pos
*
D2N_ELEN
);
volatile
union
SimbricksProtoNetD2N
*
msg
=
(
volatile
union
SimbricksProtoNetD2N
*
)(
d2n_queue
+
d2n_pos
*
D2N_ELEN
);
if
((
msg
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_D2N_OWN_MASK
)
!=
CO
SIM
_ETH
_PROTO_D2N_OWN_DEV
)
{
if
((
msg
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
D2N_OWN_MASK
)
!=
SIM
BRICKS
_PROTO_
NET_
D2N_OWN_DEV
)
{
return
NULL
;
}
...
...
lib/simbricks/nicif/nicsim.h
View file @
803110a8
...
...
@@ -62,12 +62,12 @@ void nicif_h2d_next(void);
volatile
union
SimbricksProtoPcieD2H
*
nicsim_d2h_alloc
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
volatile
union
cosim_eth_proto_n2d
*
nicif_n2d_poll
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
void
nicif_n2d_done
(
volatile
union
cosim_eth_proto_n2d
*
msg
);
volatile
union
SimbricksProtoNetN2D
*
nicif_n2d_poll
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
void
nicif_n2d_done
(
volatile
union
SimbricksProtoNetN2D
*
msg
);
void
nicif_n2d_next
(
void
);
volatile
union
cosim_eth_proto_d2n
*
nicsim_d2n_alloc
(
volatile
union
SimbricksProtoNetD2N
*
nicsim_d2n_alloc
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
#endif // SIMBRICKS_NICIF_NICSIM_H_
lib/simbricks/proto/network.h
View file @
803110a8
...
...
@@ -31,14 +31,14 @@
/* Initialization messages on Unix socket */
/** in dev_intro.flags to indicate that sender supports issuing syncs. */
#define
CO
SIM
_ETH
_PROTO_FLAGS_DI_SYNC (1 << 0)
#define SIM
BRICKS
_PROTO_
NET_
FLAGS_DI_SYNC (1 << 0)
/**
* welcome message sent by device to network. This message comes with the shared
* memory file descriptor attached.
*/
struct
cosim_eth_proto_dev_i
ntro
{
/** flags: see
CO
SIM
_ETH
_PROTO_FLAGS_DI_* */
struct
SimbricksProtoNetDevI
ntro
{
/** flags: see SIM
BRICKS
_PROTO_
NET_
FLAGS_DI_* */
uint64_t
flags
;
/** offset of the device-to-network queue in shared memory region */
...
...
@@ -56,11 +56,11 @@ struct cosim_eth_proto_dev_intro {
uint64_t
n2d_nentries
;
}
__attribute__
((
packed
));
#define
CO
SIM
_ETH
_PROTO_FLAGS_NI_SYNC (1 << 0)
#define SIM
BRICKS
_PROTO_
NET_
FLAGS_NI_SYNC (1 << 0)
/** welcome message sent by network to device */
struct
cosim_eth_proto_net_i
ntro
{
/** flags: see
CO
SIM
_ETH
_PROTO_FLAGS_IN_* */
struct
SimbricksProtoNetNetI
ntro
{
/** flags: see SIM
BRICKS
_PROTO_
NET_
FLAGS_IN_* */
uint64_t
flags
;
}
__attribute__
((
packed
));
...
...
@@ -68,32 +68,32 @@ struct cosim_eth_proto_net_intro {
/* Messages on in-memory device to network channel */
/** Mask for ownership bit in own_type field */
#define
CO
SIM
_ETH
_PROTO_D2N_OWN_MASK 0x80
#define SIM
BRICKS
_PROTO_
NET_
D2N_OWN_MASK 0x80
/** Message is owned by device */
#define
CO
SIM
_ETH
_PROTO_D2N_OWN_DEV 0x00
#define SIM
BRICKS
_PROTO_
NET_
D2N_OWN_DEV 0x00
/** Message is owned by network */
#define
CO
SIM
_ETH
_PROTO_D2N_OWN_NET 0x80
#define SIM
BRICKS
_PROTO_
NET_
D2N_OWN_NET 0x80
/** Mask for type value in own_type field */
#define
CO
SIM
_ETH
_PROTO_D2N_MSG_MASK 0x7f
#define
CO
SIM
_ETH
_PROTO_D2N_MSG_SYNC 0x1
#define
CO
SIM
_ETH
_PROTO_D2N_MSG_SEND 0x2
#define SIM
BRICKS
_PROTO_
NET_
D2N_MSG_MASK 0x7f
#define SIM
BRICKS
_PROTO_
NET_
D2N_MSG_SYNC 0x1
#define SIM
BRICKS
_PROTO_
NET_
D2N_MSG_SEND 0x2
struct
cosim_eth_proto_d2n_d
ummy
{
struct
SimbricksProtoNetD2ND
ummy
{
uint8_t
pad
[
48
];
uint64_t
timestamp
;
uint8_t
pad_
[
7
];
uint8_t
own_type
;
}
__attribute__
((
packed
));
struct
cosim_eth_proto_d2n_s
ync
{
struct
SimbricksProtoNetD2NS
ync
{
uint8_t
pad
[
48
];
uint64_t
timestamp
;
uint8_t
pad_
[
7
];
uint8_t
own_type
;
}
__attribute__
((
packed
));
struct
cosim_eth_proto_d2n_s
end
{
struct
SimbricksProtoNetD2NS
end
{
uint16_t
len
;
uint8_t
port
;
uint8_t
pad
[
45
];
...
...
@@ -103,40 +103,40 @@ struct cosim_eth_proto_d2n_send {
uint8_t
data
[];
}
__attribute__
((
packed
));
union
cosim_eth_proto_d2n
{
struct
cosim_eth_proto_d2n_d
ummy
dummy
;
struct
cosim_eth_proto_d2n_s
ync
sync
;
struct
cosim_eth_proto_d2n_s
end
send
;
union
SimbricksProtoNetD2N
{
struct
SimbricksProtoNetD2ND
ummy
dummy
;
struct
SimbricksProtoNetD2NS
ync
sync
;
struct
SimbricksProtoNetD2NS
end
send
;
};
/******************************************************************************/
/* Messages on in-memory network to device channel */
#define
CO
SIM
_ETH
_PROTO_N2D_OWN_MASK 0x80
#define SIM
BRICKS
_PROTO_
NET_
N2D_OWN_MASK 0x80
/** Message is owned by host */
#define
CO
SIM
_ETH
_PROTO_N2D_OWN_NET 0x00
#define SIM
BRICKS
_PROTO_
NET_
N2D_OWN_NET 0x00
/** Message is owned by device */
#define
CO
SIM
_ETH
_PROTO_N2D_OWN_DEV 0x80
#define SIM
BRICKS
_PROTO_
NET_
N2D_OWN_DEV 0x80
#define
CO
SIM
_ETH
_PROTO_N2D_MSG_MASK 0x7f
#define
CO
SIM
_ETH
_PROTO_N2D_MSG_SYNC 0x1
#define
CO
SIM
_ETH
_PROTO_N2D_MSG_RECV 0x2
#define SIM
BRICKS
_PROTO_
NET_
N2D_MSG_MASK 0x7f
#define SIM
BRICKS
_PROTO_
NET_
N2D_MSG_SYNC 0x1
#define SIM
BRICKS
_PROTO_
NET_
N2D_MSG_RECV 0x2
struct
cosim_eth_proto_n2d_d
ummy
{
struct
SimbricksProtoNetN2DD
ummy
{
uint8_t
pad
[
48
];
uint64_t
timestamp
;
uint8_t
pad_
[
7
];
uint8_t
own_type
;
}
__attribute__
((
packed
));
struct
cosim_eth_proto_n2d_s
ync
{
struct
SimbricksProtoNetN2DS
ync
{
uint8_t
pad
[
48
];
uint64_t
timestamp
;
uint8_t
pad_
[
7
];
uint8_t
own_type
;
}
__attribute__
((
packed
));
struct
cosim_eth_proto_n2d_r
ecv
{
struct
SimbricksProtoNetN2DR
ecv
{
uint16_t
len
;
uint8_t
port
;
uint8_t
pad
[
45
];
...
...
@@ -146,10 +146,10 @@ struct cosim_eth_proto_n2d_recv {
uint8_t
data
[];
};
union
cosim_eth_proto_n2d
{
struct
cosim_eth_proto_n2d_d
ummy
dummy
;
struct
cosim_eth_proto_n2d_s
ync
sync
;
struct
cosim_eth_proto_n2d_r
ecv
recv
;
union
SimbricksProtoNetN2D
{
struct
SimbricksProtoNetN2DD
ummy
dummy
;
struct
SimbricksProtoNetN2DS
ync
sync
;
struct
SimbricksProtoNetN2DR
ecv
recv
;
};
#endif // SIMBRICKS_PROTO_NETWORK_H_
ns-3
@
160793a4
Compare
20b07886
...
160793a4
Subproject commit
20b07886c898a232741d93911c70a4d5bb15c2ad
Subproject commit
160793a40cc120da2a3175b62e813bb750683c69
sims/net/switch/net_switch.cc
View file @
803110a8
...
...
@@ -81,33 +81,35 @@ static void sigint_handler(int dummy) {
exiting
=
1
;
}
static
void
forward_pkt
(
volatile
struct
cosim_eth_proto_d2n_s
end
*
tx
,
static
void
forward_pkt
(
volatile
struct
SimbricksProtoNetD2NS
end
*
tx
,
int
port
)
{
volatile
union
cosim_eth_proto_n2d
*
msg_to
;
volatile
union
SimbricksProtoNetN2D
*
msg_to
;
msg_to
=
netsim_n2d_alloc
(
&
nsifs
[
port
],
cur_ts
,
eth_latency
);
if
(
msg_to
!=
NULL
)
{
volatile
struct
cosim_eth_proto_n2d_r
ecv
*
rx
;
volatile
struct
SimbricksProtoNetN2DR
ecv
*
rx
;
rx
=
&
msg_to
->
recv
;
rx
->
len
=
tx
->
len
;
rx
->
port
=
0
;
memcpy
((
void
*
)
rx
->
data
,
(
void
*
)
tx
->
data
,
tx
->
len
);
// WMB();
rx
->
own_type
=
COSIM_ETH_PROTO_N2D_MSG_RECV
|
COSIM_ETH_PROTO_N2D_OWN_DEV
;
rx
->
own_type
=
SIMBRICKS_PROTO_NET_N2D_MSG_RECV
|
SIMBRICKS_PROTO_NET_N2D_OWN_DEV
;
}
else
{
fprintf
(
stderr
,
"forward_pkt: dropping packet
\n
"
);
}
}
static
void
switch_pkt
(
struct
netsim_interface
*
nsif
,
int
iport
)
{
volatile
union
cosim_eth_proto_d2n
*
msg_from
=
netsim_d2n_poll
(
nsif
,
cur_ts
);
volatile
union
SimbricksProtoNetD2N
*
msg_from
=
netsim_d2n_poll
(
nsif
,
cur_ts
);
if
(
msg_from
==
NULL
)
{
return
;
}
uint8_t
type
=
msg_from
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_D2N_MSG_MASK
;
if
(
type
==
CO
SIM
_ETH
_PROTO_D2N_MSG_SEND
)
{
volatile
struct
cosim_eth_proto_d2n_s
end
*
tx
;
uint8_t
type
=
msg_from
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_MASK
;
if
(
type
==
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_SEND
)
{
volatile
struct
SimbricksProtoNetD2NS
end
*
tx
;
tx
=
&
msg_from
->
send
;
// Get MAC addresses
MAC
dst
(
tx
->
data
),
src
(
tx
->
data
+
6
);
...
...
@@ -128,7 +130,7 @@ static void switch_pkt(struct netsim_interface *nsif, int iport) {
}
}
}
}
else
if
(
type
==
CO
SIM
_ETH
_PROTO_D2N_MSG_SYNC
)
{
}
else
if
(
type
==
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_SYNC
)
{
}
else
{
fprintf
(
stderr
,
"switch_pkt: unsupported type=%u
\n
"
,
type
);
abort
();
...
...
sims/net/tap/net_tap.c
View file @
803110a8
...
...
@@ -62,7 +62,7 @@ static int tap_open(const char *name) {
return
fd
;
}
static
void
d2n_send
(
volatile
struct
cosim_eth_proto_d2n_s
end
*
s
)
{
static
void
d2n_send
(
volatile
struct
SimbricksProtoNetD2NS
end
*
s
)
{
#ifdef DEBUG_PKTMETA
printf
(
"sent packet: len=%u
\n
"
,
s
->
len
);
#endif
...
...
@@ -73,16 +73,16 @@ static void d2n_send(volatile struct cosim_eth_proto_d2n_send *s) {
}
static
void
poll_d2n
(
void
)
{
volatile
union
cosim_eth_proto_d2n
*
msg
=
netsim_d2n_poll
(
&
nsif
,
0
);
volatile
union
SimbricksProtoNetD2N
*
msg
=
netsim_d2n_poll
(
&
nsif
,
0
);
uint8_t
type
;
/* message not ready */
if
(
msg
==
NULL
)
return
;
type
=
msg
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_D2N_MSG_MASK
;
type
=
msg
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_MASK
;
switch
(
type
)
{
case
CO
SIM
_ETH
_PROTO_D2N_MSG_SEND
:
case
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_SEND
:
d2n_send
(
&
msg
->
send
);
break
;
...
...
@@ -94,8 +94,8 @@ static void poll_d2n(void) {
}
static
void
*
rx_handler
(
void
*
arg
)
{
volatile
union
cosim_eth_proto_n2d
*
msg
;
volatile
struct
cosim_eth_proto_n2d_r
ecv
*
rx
;
volatile
union
SimbricksProtoNetN2D
*
msg
;
volatile
struct
SimbricksProtoNetN2DR
ecv
*
rx
;
ssize_t
len
;
while
(
1
)
{
...
...
@@ -117,7 +117,8 @@ static void *rx_handler(void *arg) {
#endif
// WMB();
rx
->
own_type
=
COSIM_ETH_PROTO_N2D_MSG_RECV
|
COSIM_ETH_PROTO_N2D_OWN_DEV
;
rx
->
own_type
=
SIMBRICKS_PROTO_NET_N2D_MSG_RECV
|
SIMBRICKS_PROTO_NET_N2D_OWN_DEV
;
}
}
...
...
sims/net/wire/net_wire.c
View file @
803110a8
...
...
@@ -54,18 +54,19 @@ static void sigusr1_handler(int dummy) {
static
void
move_pkt
(
struct
netsim_interface
*
from
,
struct
netsim_interface
*
to
)
{
volatile
union
cosim_eth_proto_d2n
*
msg_from
=
netsim_d2n_poll
(
from
,
cur_ts
);
volatile
union
cosim_eth_proto_n2d
*
msg_to
;
volatile
struct
cosim_eth_proto_d2n_send
*
tx
;
volatile
struct
cosim_eth_proto_n2d_recv
*
rx
;
volatile
union
SimbricksProtoNetD2N
*
msg_from
=
netsim_d2n_poll
(
from
,
cur_ts
);
volatile
union
SimbricksProtoNetN2D
*
msg_to
;
volatile
struct
SimbricksProtoNetD2NSend
*
tx
;
volatile
struct
SimbricksProtoNetN2DRecv
*
rx
;
struct
pcap_pkthdr
ph
;
uint8_t
type
;
if
(
msg_from
==
NULL
)
return
;
type
=
msg_from
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_D2N_MSG_MASK
;
if
(
type
==
CO
SIM
_ETH
_PROTO_D2N_MSG_SEND
)
{
type
=
msg_from
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_MASK
;
if
(
type
==
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_SEND
)
{
tx
=
&
msg_from
->
send
;
// log to pcap file if initialized
...
...
@@ -86,11 +87,12 @@ static void move_pkt(struct netsim_interface *from,
memcpy
((
void
*
)
rx
->
data
,
(
void
*
)
tx
->
data
,
tx
->
len
);
// WMB();
rx
->
own_type
=
COSIM_ETH_PROTO_N2D_MSG_RECV
|
COSIM_ETH_PROTO_N2D_OWN_DEV
;
rx
->
own_type
=
SIMBRICKS_PROTO_NET_N2D_MSG_RECV
|
SIMBRICKS_PROTO_NET_N2D_OWN_DEV
;
}
else
{
fprintf
(
stderr
,
"move_pkt: dropping packet
\n
"
);
}
}
else
if
(
type
==
CO
SIM
_ETH
_PROTO_D2N_MSG_SYNC
)
{
}
else
if
(
type
==
SIM
BRICKS
_PROTO_
NET_
D2N_MSG_SYNC
)
{
}
else
{
fprintf
(
stderr
,
"move_pkt: unsupported type=%u
\n
"
,
type
);
abort
();
...
...
sims/nic/corundum/corundum_verilator.cc
View file @
803110a8
...
...
@@ -594,9 +594,9 @@ class EthernetTx {
}
void
packet_done
()
{
volatile
union
cosim_eth_proto_d2n
*
msg
=
volatile
union
SimbricksProtoNetD2N
*
msg
=
nicsim_d2n_alloc
(
&
nsparams
,
main_time
);
volatile
struct
cosim_eth_proto_d2n_s
end
*
send
;
volatile
struct
SimbricksProtoNetD2NS
end
*
send
;
if
(
!
msg
)
throw
"completion alloc failed"
;
...
...
@@ -607,7 +607,8 @@ class EthernetTx {
send
->
timestamp
=
main_time
+
eth_latency
;
// WMB();
send
->
own_type
=
COSIM_ETH_PROTO_D2N_MSG_SEND
|
COSIM_ETH_PROTO_D2N_OWN_NET
;
send
->
own_type
=
SIMBRICKS_PROTO_NET_D2N_MSG_SEND
|
SIMBRICKS_PROTO_NET_D2N_OWN_NET
;
#ifdef ETH_DEBUG
std
::
cerr
<<
main_time
<<
" EthernetTx: packet len="
<<
std
::
hex
...
...
@@ -726,26 +727,26 @@ class EthernetRx {
};
static
void
n2d_recv
(
EthernetRx
&
rx
,
volatile
struct
cosim_eth_proto_n2d_r
ecv
*
recv
)
{
volatile
struct
SimbricksProtoNetN2DR
ecv
*
recv
)
{
rx
.
packet_received
((
const
void
*
)
recv
->
data
,
recv
->
len
);
}
static
void
poll_n2d
(
EthernetRx
&
rx
)
{
volatile
union
cosim_eth_proto_n2d
*
msg
=
volatile
union
SimbricksProtoNetN2D
*
msg
=
nicif_n2d_poll
(
&
nsparams
,
main_time
);
uint8_t
t
;
if
(
msg
==
NULL
)
return
;
t
=
msg
->
dummy
.
own_type
&
CO
SIM
_ETH
_PROTO_N2D_MSG_MASK
;
t
=
msg
->
dummy
.
own_type
&
SIM
BRICKS
_PROTO_
NET_
N2D_MSG_MASK
;
switch
(
t
)
{
case
CO
SIM
_ETH
_PROTO_N2D_MSG_RECV
:
case
SIM
BRICKS
_PROTO_
NET_
N2D_MSG_RECV
:
n2d_recv
(
rx
,
&
msg
->
recv
);
break
;
case
CO
SIM
_ETH
_PROTO_N2D_MSG_SYNC
:
case
SIM
BRICKS
_PROTO_
NET_
N2D_MSG_SYNC
:
break
;
default:
...
...
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