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
fd8ff102
Commit
fd8ff102
authored
Feb 11, 2021
by
Antoine Kaufmann
Browse files
lib: format changes to make cpplint happier
parent
56775bc1
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
55 additions
and
36 deletions
+55
-36
lib/simbricks/netif/internal.h
lib/simbricks/netif/internal.h
+5
-1
lib/simbricks/netif/netsim.c
lib/simbricks/netif/netsim.c
+5
-3
lib/simbricks/netif/netsim.h
lib/simbricks/netif/netsim.h
+7
-5
lib/simbricks/netif/utils.c
lib/simbricks/netif/utils.c
+1
-1
lib/simbricks/nicbm/nicbm.cc
lib/simbricks/nicbm/nicbm.cc
+9
-8
lib/simbricks/nicbm/nicbm.h
lib/simbricks/nicbm/nicbm.h
+7
-1
lib/simbricks/nicif/internal.h
lib/simbricks/nicif/internal.h
+5
-0
lib/simbricks/nicif/nicsim.c
lib/simbricks/nicif/nicsim.c
+1
-2
lib/simbricks/nicif/nicsim.h
lib/simbricks/nicif/nicsim.h
+5
-5
lib/simbricks/nicif/utils.c
lib/simbricks/nicif/utils.c
+2
-2
lib/simbricks/proto/network.h
lib/simbricks/proto/network.h
+3
-3
lib/simbricks/proto/pcie.h
lib/simbricks/proto/pcie.h
+5
-5
No files found.
lib/simbricks/netif/internal.h
View file @
fd8ff102
...
@@ -22,9 +22,13 @@
...
@@ -22,9 +22,13 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#ifndef SIMBRICKS_NETIF_INTERNAL_H_
#define SIMBRICKS_NETIF_INTERNAL_H_
#include <stddef.h>
#include <stddef.h>
#include <stdio.h>
int
uxsocket_connect
(
const
char
*
path
);
int
uxsocket_connect
(
const
char
*
path
);
int
uxsocket_recv
(
int
fd
,
void
*
data
,
size_t
len
,
int
*
pfd
);
int
uxsocket_recv
(
int
fd
,
void
*
data
,
size_t
len
,
int
*
pfd
);
void
*
shm_map
(
int
shm_fd
);
void
*
shm_map
(
int
shm_fd
);
#endif // SIMBRICKS_NETIF_INTERNAL_H_
lib/simbricks/netif/netsim.c
View file @
fd8ff102
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include <unistd.h>
#include <unistd.h>
#include <simbricks/netif/netsim.h>
#include <simbricks/netif/netsim.h>
#include "internal.h"
#include "
lib/simbricks/netif/
internal.h"
static
uint64_t
current_epoch
=
0
;
static
uint64_t
current_epoch
=
0
;
...
@@ -178,7 +178,8 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
...
@@ -178,7 +178,8 @@ int netsim_n2d_sync(struct netsim_interface *nsif, uint64_t timestamp,
return
0
;
return
0
;
}
}
void
netsim_advance_epoch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
)
void
netsim_advance_epoch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
)
{
{
if
(
sync_mode
==
SYNC_BARRIER
)
{
if
(
sync_mode
==
SYNC_BARRIER
)
{
if
(
timestamp
-
current_epoch
>=
sync_delay
)
{
if
(
timestamp
-
current_epoch
>=
sync_delay
)
{
...
@@ -187,7 +188,8 @@ void netsim_advance_epoch(uint64_t timestamp, uint64_t sync_delay, int sync_mode
...
@@ -187,7 +188,8 @@ void netsim_advance_epoch(uint64_t timestamp, uint64_t sync_delay, int sync_mode
}
}
}
}
uint64_t
netsim_advance_time
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
)
uint64_t
netsim_advance_time
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
)
{
{
switch
(
sync_mode
)
{
switch
(
sync_mode
)
{
case
SYNC_MODES
:
case
SYNC_MODES
:
...
...
lib/simbricks/netif/netsim.h
View file @
fd8ff102
...
@@ -22,8 +22,8 @@
...
@@ -22,8 +22,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#ifndef
CO
SIM_NETSIM_H_
#ifndef SIM
BRICKS_NETIF
_NETSIM_H_
#define
CO
SIM_NETSIM_H_
#define SIM
BRICKS_NETIF
_NETSIM_H_
#include <stddef.h>
#include <stddef.h>
#include <stdint.h>
#include <stdint.h>
...
@@ -66,7 +66,9 @@ volatile union cosim_eth_proto_n2d *netsim_n2d_alloc(
...
@@ -66,7 +66,9 @@ volatile union cosim_eth_proto_n2d *netsim_n2d_alloc(
uint64_t
latency
);
uint64_t
latency
);
int
netsim_n2d_sync
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
int
netsim_n2d_sync
(
struct
netsim_interface
*
nsif
,
uint64_t
timestamp
,
uint64_t
latency
,
uint64_t
sync_delay
,
int
sync_mode
);
uint64_t
latency
,
uint64_t
sync_delay
,
int
sync_mode
);
void
netsim_advance_epoch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
);
void
netsim_advance_epoch
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
uint64_t
netsim_advance_time
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
);
int
sync_mode
);
uint64_t
netsim_advance_time
(
uint64_t
timestamp
,
uint64_t
sync_delay
,
int
sync_mode
);
#endif
/* ndef COSIM
_NETSIM_H_
*/
#endif
// SIMBRICKS_NETIF
_NETSIM_H_
lib/simbricks/netif/utils.c
View file @
fd8ff102
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
#include "internal.h"
#include "
lib/simbricks/netif/
internal.h"
int
uxsocket_connect
(
const
char
*
path
)
int
uxsocket_connect
(
const
char
*
path
)
{
{
...
...
lib/simbricks/nicbm/nicbm.cc
View file @
fd8ff102
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
#include <simbricks/nicbm/nicbm.h>
#include <simbricks/nicbm/nicbm.h>
//#define DEBUG_NICBM 1
//
#define DEBUG_NICBM 1
#define DMA_MAX_PENDING 64
#define DMA_MAX_PENDING 64
...
@@ -204,7 +204,7 @@ void Runner::h2d_read(volatile struct cosim_pcie_proto_h2d_read *read)
...
@@ -204,7 +204,7 @@ void Runner::h2d_read(volatile struct cosim_pcie_proto_h2d_read *read)
read
->
len
,
dbg_val
);
read
->
len
,
dbg_val
);
#endif
#endif
//WMB();
//
WMB();
rc
->
own_type
=
COSIM_PCIE_PROTO_D2H_MSG_READCOMP
|
rc
->
own_type
=
COSIM_PCIE_PROTO_D2H_MSG_READCOMP
|
COSIM_PCIE_PROTO_D2H_OWN_HOST
;
COSIM_PCIE_PROTO_D2H_OWN_HOST
;
}
}
...
@@ -219,14 +219,15 @@ void Runner::h2d_write(volatile struct cosim_pcie_proto_h2d_write *write)
...
@@ -219,14 +219,15 @@ void Runner::h2d_write(volatile struct cosim_pcie_proto_h2d_write *write)
#ifdef DEBUG_NICBM
#ifdef DEBUG_NICBM
uint64_t
dbg_val
=
0
;
uint64_t
dbg_val
=
0
;
memcpy
(
&
dbg_val
,
(
const
void
*
)
write
->
data
,
write
->
len
<=
8
?
write
->
len
:
8
);
memcpy
(
&
dbg_val
,
(
const
void
*
)
write
->
data
,
write
->
len
<=
8
?
write
->
len
:
8
);
printf
(
"nicbm: write(off=0x%lx, len=%u, val=0x%lx)
\n
"
,
write
->
offset
,
printf
(
"nicbm: write(off=0x%lx, len=%u, val=0x%lx)
\n
"
,
write
->
offset
,
write
->
len
,
dbg_val
);
write
->
len
,
dbg_val
);
#endif
#endif
dev
.
reg_write
(
write
->
bar
,
write
->
offset
,
(
void
*
)
write
->
data
,
write
->
len
);
dev
.
reg_write
(
write
->
bar
,
write
->
offset
,
(
void
*
)
write
->
data
,
write
->
len
);
wc
->
req_id
=
write
->
req_id
;
wc
->
req_id
=
write
->
req_id
;
//WMB();
//
WMB();
wc
->
own_type
=
COSIM_PCIE_PROTO_D2H_MSG_WRITECOMP
|
wc
->
own_type
=
COSIM_PCIE_PROTO_D2H_MSG_WRITECOMP
|
COSIM_PCIE_PROTO_D2H_OWN_HOST
;
COSIM_PCIE_PROTO_D2H_OWN_HOST
;
}
}
...
@@ -284,7 +285,7 @@ void Runner::eth_send(const void *data, size_t len)
...
@@ -284,7 +285,7 @@ void Runner::eth_send(const void *data, size_t len)
volatile
union
cosim_eth_proto_d2n
*
msg
=
d2n_alloc
();
volatile
union
cosim_eth_proto_d2n
*
msg
=
d2n_alloc
();
volatile
struct
cosim_eth_proto_d2n_send
*
send
=
&
msg
->
send
;
volatile
struct
cosim_eth_proto_d2n_send
*
send
=
&
msg
->
send
;
send
->
port
=
0
;
// single port
send
->
port
=
0
;
// single port
send
->
len
=
len
;
send
->
len
=
len
;
memcpy
((
void
*
)
send
->
data
,
data
,
len
);
memcpy
((
void
*
)
send
->
data
,
data
,
len
);
send
->
own_type
=
COSIM_ETH_PROTO_D2N_MSG_SEND
|
send
->
own_type
=
COSIM_ETH_PROTO_D2N_MSG_SEND
|
...
@@ -397,7 +398,7 @@ void Runner::event_trigger()
...
@@ -397,7 +398,7 @@ void Runner::event_trigger()
Runner
::
Runner
(
Device
&
dev_
)
Runner
::
Runner
(
Device
&
dev_
)
:
dev
(
dev_
),
events
(
event_cmp
())
:
dev
(
dev_
),
events
(
event_cmp
())
{
{
//mac_addr = lrand48() & ~(3ULL << 46);
//
mac_addr = lrand48() & ~(3ULL << 46);
dma_pending
=
0
;
dma_pending
=
0
;
srand48
(
time
(
NULL
)
^
getpid
());
srand48
(
time
(
NULL
)
^
getpid
());
mac_addr
=
lrand48
();
mac_addr
=
lrand48
();
...
@@ -419,7 +420,8 @@ int Runner::runMain(int argc, char *argv[])
...
@@ -419,7 +420,8 @@ int Runner::runMain(int argc, char *argv[])
if
(
argc
<
4
&&
argc
>
9
)
{
if
(
argc
<
4
&&
argc
>
9
)
{
fprintf
(
stderr
,
"Usage: corundum_bm PCI-SOCKET ETH-SOCKET "
fprintf
(
stderr
,
"Usage: corundum_bm PCI-SOCKET ETH-SOCKET "
"SHM [SYNC-MODE] [START-TICK] [SYNC-PERIOD] [PCI-LATENCY] [ETH-LATENCY]
\n
"
);
"SHM [SYNC-MODE] [START-TICK] [SYNC-PERIOD] [PCI-LATENCY] "
"[ETH-LATENCY]
\n
"
);
return
EXIT_FAILURE
;
return
EXIT_FAILURE
;
}
}
if
(
argc
>=
5
)
if
(
argc
>=
5
)
...
@@ -480,7 +482,6 @@ int Runner::runMain(int argc, char *argv[])
...
@@ -480,7 +482,6 @@ int Runner::runMain(int argc, char *argv[])
uint64_t
ev_ts
;
uint64_t
ev_ts
;
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_advance_time
(
&
nsparams
,
next_ts
);
main_time
=
nicsim_advance_time
(
&
nsparams
,
next_ts
);
}
}
...
...
lib/simbricks/nicbm/nicbm.h
View file @
fd8ff102
...
@@ -22,6 +22,9 @@
...
@@ -22,6 +22,9 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#ifndef SIMBRICKS_NICBM_NICBM_H_
#define SIMBRICKS_NICBM_NICBM_H_
#include <set>
#include <set>
#include <deque>
#include <deque>
extern
"C"
{
extern
"C"
{
...
@@ -145,6 +148,7 @@ class Runner {
...
@@ -145,6 +148,7 @@ class Runner {
void
dma_do
(
DMAOp
&
op
);
void
dma_do
(
DMAOp
&
op
);
void
dma_trigger
();
void
dma_trigger
();
public:
public:
Runner
(
Device
&
dev_
);
Runner
(
Device
&
dev_
);
...
@@ -190,4 +194,6 @@ class SimpleDevice : public Runner::Device {
...
@@ -190,4 +194,6 @@ class SimpleDevice : public Runner::Device {
reg_write
(
bar
,
addr
,
r
);
reg_write
(
bar
,
addr
,
r
);
}
}
};
};
}
}
// namespace nicbm
#endif // SIMBRICKS_NICBM_NICBM_H_
lib/simbricks/nicif/internal.h
View file @
fd8ff102
...
@@ -22,9 +22,14 @@
...
@@ -22,9 +22,14 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#ifndef SIMBRICKS_NICIF_INTERNAL_H_
#define SIMBRICKS_NICIF_INTERNAL_H_
#include <stddef.h>
#include <stddef.h>
#include <stdio.h>
#include <stdio.h>
int
uxsocket_init
(
const
char
*
path
);
int
uxsocket_init
(
const
char
*
path
);
int
uxsocket_send
(
int
connfd
,
void
*
data
,
size_t
len
,
int
fd
);
int
uxsocket_send
(
int
connfd
,
void
*
data
,
size_t
len
,
int
fd
);
int
shm_create
(
const
char
*
path
,
size_t
size
,
void
**
addr
);
int
shm_create
(
const
char
*
path
,
size_t
size
,
void
**
addr
);
#endif // SIMBRICKS_NICIF_INTERNAL_H_
lib/simbricks/nicif/nicsim.c
View file @
fd8ff102
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
#include <simbricks/nicif/nicsim.h>
#include <simbricks/nicif/nicsim.h>
#include "internal.h"
#include "
lib/simbricks/nicif/
internal.h"
#define D2H_ELEN (9024 + 64)
#define D2H_ELEN (9024 + 64)
#define D2H_ENUM 1024
#define D2H_ENUM 1024
...
@@ -195,7 +195,6 @@ int nicsim_init(struct nicsim_params *params,
...
@@ -195,7 +195,6 @@ int nicsim_init(struct nicsim_params *params,
if
((
shm_fd
=
shm_create
(
params
->
shm_path
,
shm_size
,
&
shmptr
))
if
((
shm_fd
=
shm_create
(
params
->
shm_path
,
shm_size
,
&
shmptr
))
<
0
)
<
0
)
{
{
return
-
1
;
return
-
1
;
}
}
...
...
lib/simbricks/nicif/nicsim.h
View file @
fd8ff102
...
@@ -22,14 +22,14 @@
...
@@ -22,14 +22,14 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#ifndef
CO
SIM_NICSIM_H_
#ifndef SIM
BRICKS_NICIF
_NICSIM_H_
#define
CO
SIM_NICSIM_H_
#define SIM
BRICKS_NICIF
_NICSIM_H_
#include <simbricks/proto/pcie.h>
#include <simbricks/proto/pcie.h>
#include <simbricks/proto/network.h>
#include <simbricks/proto/network.h>
#define SYNC_MODES 0 // ModES style synchronization
#define SYNC_MODES 0
// ModES style synchronization
#define SYNC_BARRIER 1 // Global barrier style synchronization
#define SYNC_BARRIER 1
// Global barrier style synchronization
struct
nicsim_params
{
struct
nicsim_params
{
const
char
*
pci_socket_path
;
const
char
*
pci_socket_path
;
...
@@ -71,4 +71,4 @@ void nicif_n2d_next(void);
...
@@ -71,4 +71,4 @@ void nicif_n2d_next(void);
volatile
union
cosim_eth_proto_d2n
*
nicsim_d2n_alloc
(
volatile
union
cosim_eth_proto_d2n
*
nicsim_d2n_alloc
(
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
struct
nicsim_params
*
params
,
uint64_t
timestamp
);
#endif
/* ndef COSIM
_NICSIM_H_
*/
#endif
// SIMBRICKS_NICIF
_NICSIM_H_
lib/simbricks/nicif/utils.c
View file @
fd8ff102
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
#include <sys/mman.h>
#include <sys/mman.h>
#include <unistd.h>
#include <unistd.h>
#include "internal.h"
#include "
lib/simbricks/nicif/
internal.h"
int
uxsocket_init
(
const
char
*
path
)
int
uxsocket_init
(
const
char
*
path
)
{
{
...
@@ -97,7 +97,7 @@ int uxsocket_send(int connfd, void *data, size_t len, int fd)
...
@@ -97,7 +97,7 @@ int uxsocket_send(int connfd, void *data, size_t len, int fd)
*
(
int
*
)
CMSG_DATA
(
cmsg
)
=
fd
;
*
(
int
*
)
CMSG_DATA
(
cmsg
)
=
fd
;
}
}
if
((
tx
=
sendmsg
(
connfd
,
&
msg
,
0
))
!=
(
ssize_t
)
len
)
{
if
((
tx
=
sendmsg
(
connfd
,
&
msg
,
0
))
!=
(
ssize_t
)
len
)
{
fprintf
(
stderr
,
"tx == %zd
\n
"
,
tx
);
fprintf
(
stderr
,
"tx == %zd
\n
"
,
tx
);
return
-
1
;
return
-
1
;
}
}
...
...
lib/simbricks/proto/network.h
View file @
fd8ff102
...
@@ -22,8 +22,8 @@
...
@@ -22,8 +22,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#ifndef
CO
SIM
_ETH_PROTO
_H_
#ifndef SIM
BRICKS_PROTO_NETWORK
_H_
#define
CO
SIM
_ETH_PROTO
_H_
#define SIM
BRICKS_PROTO_NETWORK
_H_
#include <stdint.h>
#include <stdint.h>
...
@@ -155,4 +155,4 @@ union cosim_eth_proto_n2d {
...
@@ -155,4 +155,4 @@ union cosim_eth_proto_n2d {
struct
cosim_eth_proto_n2d_recv
recv
;
struct
cosim_eth_proto_n2d_recv
recv
;
};
};
#endif
/* ndef COSIM_ETH_PROTO_H_ */
#endif
// SIMBRICKS_PROTO_NETWORK_H_
lib/simbricks/proto/pcie.h
View file @
fd8ff102
...
@@ -22,13 +22,13 @@
...
@@ -22,13 +22,13 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
*/
#ifndef
CO
SIM
_PCIE
_PROTO_H_
#ifndef SIM
BRICKS
_PROTO_
PCIE_
H_
#define
CO
SIM
_PCIE
_PROTO_H_
#define SIM
BRICKS
_PROTO_
PCIE_
H_
#include <stdint.h>
#include <stdint.h>
//#define COSIM_PCI_MSG_SZCHECK(s) static_assert(sizeof(s) == 64)
//
#define COSIM_PCI_MSG_SZCHECK(s) static_assert(sizeof(s) == 64)
//#define COSIM_PCI_MSG_SZCHECK(s) _Static_assert(sizeof(s) == 64)
//
#define COSIM_PCI_MSG_SZCHECK(s) _Static_assert(sizeof(s) == 64)
#define COSIM_PCI_MSG_SZCHECK(s)
#define COSIM_PCI_MSG_SZCHECK(s)
/******************************************************************************/
/******************************************************************************/
...
@@ -322,4 +322,4 @@ union cosim_pcie_proto_h2d {
...
@@ -322,4 +322,4 @@ union cosim_pcie_proto_h2d {
}
__attribute__
((
packed
));
}
__attribute__
((
packed
));
COSIM_PCI_MSG_SZCHECK
(
union
cosim_pcie_proto_h2d
);
COSIM_PCI_MSG_SZCHECK
(
union
cosim_pcie_proto_h2d
);
#endif
/* ndef COSIM_PCIE_PROTO_H_ */
#endif
// SIMBRICKS_PROTO_PCIE_H_
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