Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
M
Mock Turtle
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Mock Turtle
Commits
d474c0d0
Commit
d474c0d0
authored
Jun 01, 2016
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrtd:*: remove serializer
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
31595d9d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
20 additions
and
304 deletions
+20
-304
mockturtle-rt-message.h
applications/common/rt/mockturtle-rt-message.h
+0
-26
wrtd-serializers.h
applications/wrtd/include/wrtd-serializers.h
+0
-206
libwrtd-common.c
applications/wrtd/lib/libwrtd-common.c
+0
-1
libwrtd-internal.h
applications/wrtd/lib/libwrtd-internal.h
+5
-0
libwrtd-logging.c
applications/wrtd/lib/libwrtd-logging.c
+8
-38
libwrtd-output.c
applications/wrtd/lib/libwrtd-output.c
+0
-4
wrtd-rt-fd.c
applications/wrtd/rt/fd/wrtd-rt-fd.c
+4
-2
wrtd-rt-tdc.c
applications/wrtd/rt/tdc/wrtd-rt-tdc.c
+2
-1
mockturtle.h
include/mockturtle.h
+0
-13
libmockturtle-rt-msg.c
lib/libmockturtle-rt-msg.c
+0
-2
libmockturtle.c
lib/libmockturtle.c
+1
-11
No files found.
applications/common/rt/mockturtle-rt-message.h
View file @
d474c0d0
...
...
@@ -21,22 +21,12 @@
#ifdef WRNODE_RT
enum
trtl_msg_direction
{
WRNC_MSG_DIR_SEND
=
0
,
WRNC_MSG_DIR_RECEIVE
=
1
};
/**
* White-Rabbit Node-Core message descriptor
*/
struct
trtl_msg
{
uint32_t
datalen
;
/**< payload length*/
volatile
uint32_t
*
data
;
/**< payload */
uint32_t
max_size
;
/**< maximum message size for chosen slot */
uint32_t
offset
;
/**< serialization/deserialization offset */
enum
trtl_msg_direction
direction
;
/**< serialization direction (used by trtl_msg_x functions) */
int
error
;
/** serialization error status */
int
slot
;
/** concerned slot */
};
...
...
@@ -53,11 +43,7 @@ static inline struct trtl_msg rt_mq_claim_out(struct trtl_proto_header *h)
mq_claim
(
remote
,
slot
);
b
.
data
=
mq_map_out_buffer
(
remote
,
slot
);
b
.
direction
=
WRNC_MSG_DIR_SEND
;
b
.
max_size
=
h
->
len
;
b
.
offset
=
0
;
b
.
datalen
=
0
;
b
.
slot
=
slot
;
return
b
;
}
...
...
@@ -85,11 +71,7 @@ static inline struct trtl_msg rt_mq_claim_in(struct trtl_proto_header *h)
int
slot
=
(
h
->
slot_io
>>
4
)
&
0xF
;
b
.
data
=
mq_map_in_buffer
(
0
,
slot
);
b
.
direction
=
WRNC_MSG_DIR_RECEIVE
;
b
.
max_size
=
h
->
len
;
b
.
datalen
=
h
->
len
;
b
.
offset
=
0
;
b
.
slot
=
slot
;
return
b
;
}
...
...
@@ -108,14 +90,6 @@ static inline struct trtl_msg hmq_msg_claim_in(int slot, int max_size)
}
/**
* It enqueue the message in the slot, and it will be sent as soon as possible
*/
static
inline
void
hmq_msg_send
(
struct
trtl_msg
*
buf
)
{
mq_send
(
0
,
buf
->
slot
,
buf
->
datalen
);
}
#endif
#endif
applications/wrtd/include/wrtd-serializers.h
deleted
100644 → 0
View file @
31595d9d
/*
* This work is part of the White Rabbit Node Core project.
*
* Copyright (C) 2013-2014 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
/*.
* White Rabbit Trigge Distribution
*
* wrtd-serializers.h: API for serializing HMQ messages specific for WR Trigger Distribution system.
*/
#ifndef __WRTD_SERIALIZERS_H
#define __WRTD_SERIALIZERS_H
#include "wrtd-common.h"
#ifdef WRNODE_RT
#include "rt-message.h"
#endif
static
inline
int
_trtl_msg_check_buffer
(
struct
trtl_msg
*
buf
,
int
n_words
)
{
#ifndef WRNODE_RT
if
(
buf
->
error
)
return
-
1
;
if
(
buf
->
direction
==
WRNC_MSG_DIR_SEND
&&
buf
->
datalen
+
n_words
>
buf
->
max_size
)
{
#ifdef DEBUG
pp_printf
(
"Error: HMQ buffer send overflow: %d vs %d
\n
"
,
buf
->
datalen
+
n_words
,
buf
->
max_size
);
#endif
buf
->
error
=
1
;
return
-
1
;
}
else
if
(
buf
->
direction
==
WRNC_MSG_DIR_RECEIVE
&&
buf
->
offset
+
n_words
>
buf
->
datalen
)
{
#ifdef DEBUG
pp_printf
(
"Error: HMQ buffer recv overflow: %d vs %d
\n
"
,
buf
->
offset
+
n_words
,
buf
->
datalen
);
#endif
buf
->
error
=
1
;
return
-
1
;
}
#endif
return
0
;
}
static
inline
int
trtl_msg_int32
(
struct
trtl_msg
*
buf
,
int
*
value
)
{
if
(
_trtl_msg_check_buffer
(
buf
,
1
)
<
0
)
return
-
1
;
if
(
buf
->
direction
==
WRNC_MSG_DIR_SEND
)
{
buf
->
data
[
buf
->
datalen
]
=
*
value
;
buf
->
datalen
++
;
}
else
{
*
value
=
buf
->
data
[
buf
->
offset
];
buf
->
offset
++
;
}
return
0
;
}
static
inline
int
trtl_msg_int16
(
struct
trtl_msg
*
buf
,
int16_t
*
value
)
{
if
(
_trtl_msg_check_buffer
(
buf
,
1
)
<
0
)
return
-
1
;
if
(
buf
->
direction
==
WRNC_MSG_DIR_SEND
)
{
buf
->
data
[
buf
->
datalen
]
=
*
value
;
buf
->
datalen
++
;
}
else
{
*
value
=
(
int16_t
)
buf
->
data
[
buf
->
offset
];
buf
->
offset
++
;
}
return
0
;
}
static
inline
int
trtl_msg_uint32
(
struct
trtl_msg
*
buf
,
uint32_t
*
value
)
{
return
trtl_msg_int32
(
buf
,
(
int
*
)
value
);
}
static
inline
int
trtl_msg_uint16
(
struct
trtl_msg
*
buf
,
uint16_t
*
value
)
{
return
trtl_msg_int16
(
buf
,
(
int16_t
*
)
value
);
}
static
inline
int
trtl_msg_header
(
struct
trtl_msg
*
buf
,
uint32_t
*
id
,
uint32_t
*
seq_no
)
{
if
(
_trtl_msg_check_buffer
(
buf
,
2
)
<
0
)
return
-
1
;
if
(
buf
->
direction
==
WRNC_MSG_DIR_SEND
)
{
buf
->
data
[
buf
->
datalen
+
0
]
=
*
id
;
buf
->
data
[
buf
->
datalen
+
1
]
=
*
seq_no
;
buf
->
datalen
+=
2
;
}
else
{
*
id
=
buf
->
data
[
buf
->
offset
+
0
];
*
seq_no
=
buf
->
data
[
buf
->
offset
+
1
];
buf
->
offset
+=
2
;
}
return
0
;
}
static
inline
void
trtl_msg_skip
(
struct
trtl_msg
*
buf
,
int
n_words
)
{
_trtl_msg_check_buffer
(
buf
,
n_words
);
if
(
buf
->
direction
==
WRNC_MSG_DIR_SEND
)
buf
->
datalen
+=
n_words
;
else
buf
->
offset
+=
n_words
;
}
static
inline
void
trtl_msg_seek
(
struct
trtl_msg
*
buf
,
int
pos
)
{
buf
->
offset
=
pos
;
buf
->
datalen
=
pos
;
}
static
inline
int
wrtd_msg_timestamp
(
struct
trtl_msg
*
buf
,
struct
wr_timestamp
*
ts
)
{
if
(
_trtl_msg_check_buffer
(
buf
,
4
)
<
0
)
return
-
1
;
if
(
buf
->
direction
==
WRNC_MSG_DIR_SEND
)
{
buf
->
data
[
buf
->
datalen
+
0
]
=
(
ts
->
seconds
>>
32
)
&
0xFFFFFFFF
;
buf
->
data
[
buf
->
datalen
+
1
]
=
ts
->
seconds
&
0xFFFFFFFF
;
buf
->
data
[
buf
->
datalen
+
2
]
=
ts
->
ticks
;
buf
->
data
[
buf
->
datalen
+
3
]
=
ts
->
frac
;
buf
->
datalen
+=
4
;
}
else
{
ts
->
seconds
=
((
uint64_t
)
buf
->
data
[
buf
->
offset
+
0
])
<<
32
;
ts
->
seconds
|=
buf
->
data
[
buf
->
offset
+
1
];
ts
->
ticks
=
buf
->
data
[
buf
->
offset
+
2
];
ts
->
frac
=
buf
->
data
[
buf
->
offset
+
3
];
buf
->
offset
+=
4
;
}
return
0
;
}
static
inline
int
wrtd_msg_trig_id
(
struct
trtl_msg
*
buf
,
struct
wrtd_trig_id
*
id
)
{
if
(
_trtl_msg_check_buffer
(
buf
,
3
)
<
0
)
return
-
1
;
if
(
buf
->
direction
==
WRNC_MSG_DIR_SEND
)
{
buf
->
data
[
buf
->
datalen
+
0
]
=
id
->
system
;
buf
->
data
[
buf
->
datalen
+
1
]
=
id
->
source_port
;
buf
->
data
[
buf
->
datalen
+
2
]
=
id
->
trigger
;
buf
->
datalen
+=
3
;
}
else
{
id
->
system
=
buf
->
data
[
buf
->
offset
+
0
];
id
->
source_port
=
buf
->
data
[
buf
->
offset
+
1
];
id
->
trigger
=
buf
->
data
[
buf
->
offset
+
2
];
buf
->
offset
+=
3
;
}
return
0
;
}
static
inline
int
wrtd_msg_trigger_entry
(
struct
trtl_msg
*
buf
,
struct
wrtd_trigger_entry
*
ent
)
{
if
(
wrtd_msg_timestamp
(
buf
,
&
ent
->
ts
)
<
0
)
return
-
1
;
if
(
wrtd_msg_trig_id
(
buf
,
&
ent
->
id
)
<
0
)
return
-
1
;
return
trtl_msg_int32
(
buf
,
(
int
*
)
&
ent
->
seq
);
}
static
inline
struct
trtl_msg
trtl_msg_init
(
int
max_size
)
{
struct
trtl_msg
b
;
b
.
direction
=
WRNC_MSG_DIR_SEND
;
b
.
max_size
=
max_size
;
b
.
offset
=
0
;
b
.
datalen
=
0
;
b
.
error
=
0
;
return
b
;
}
static
inline
int
trtl_msg_check_error
(
struct
trtl_msg
*
buf
)
{
return
buf
->
error
;
}
#endif
applications/wrtd/lib/libwrtd-common.c
View file @
d474c0d0
...
...
@@ -10,7 +10,6 @@
#include <errno.h>
#include <libmockturtle.h>
#include <libwrtd-internal.h>
#include <wrtd-serializers.h>
static
const
uint32_t
application_id
[]
=
{
0x115790de
,
...
...
applications/wrtd/lib/libwrtd-internal.h
View file @
d474c0d0
...
...
@@ -29,6 +29,11 @@ struct wrtd_desc {
uint32_t
n_cpu
;
/**< Number of CPUs */
};
#define WRTD_OUT_CHANNEL_PUBLIC_SIZE (sizeof(struct wrtd_out_channel) \
- sizeof(struct wrtd_out_channel_private))
/**
* @file libwrtd-interal.c
*/
...
...
applications/wrtd/lib/libwrtd-logging.c
View file @
d474c0d0
...
...
@@ -11,7 +11,6 @@
#include <poll.h>
#include <libmockturtle.h>
#include <libwrtd-internal.h>
#include <wrtd-serializers.h>
/**
* It returns a human readable string that describe a given log level
...
...
@@ -167,7 +166,6 @@ int wrtd_log_read(struct trtl_hmq *hmq_log, struct wrtd_log_entry *log,
struct
pollfd
p
;
int
remaining
=
count
;
int
n_read
=
0
,
ret
;
uint32_t
id
=
0
,
seq
=
0
;
p
.
fd
=
hmq_log
->
fd
;
p
.
events
=
POLLIN
;
...
...
@@ -177,7 +175,6 @@ int wrtd_log_read(struct trtl_hmq *hmq_log, struct wrtd_log_entry *log,
than expected */
errno
=
0
;
while
(
remaining
)
{
struct
wrtd_trigger_entry
ent
;
ret
=
poll
(
&
p
,
1
,
poll_timeout
);
if
(
ret
<=
0
||
!
(
p
.
revents
&
POLLIN
))
break
;
...
...
@@ -186,41 +183,14 @@ int wrtd_log_read(struct trtl_hmq *hmq_log, struct wrtd_log_entry *log,
if
(
!
msg
)
break
;
if
(
hmq_log
->
index
==
WRTD_OUT_FD_LOGGING
)
{
/* Output */
trtl_msg_header
(
msg
,
&
id
,
&
seq
);
if
(
id
!=
WRTD_REP_LOG_MESSAGE
)
{
free
(
msg
);
errno
=
EWRTD_INVALID_ANSWER_STATE
;
break
;
}
trtl_msg_uint32
(
msg
,
&
cur
->
type
);
trtl_msg_int32
(
msg
,
&
cur
->
channel
);
trtl_msg_uint32
(
msg
,
&
cur
->
miss_reason
);
wrtd_msg_trigger_entry
(
msg
,
&
ent
);
cur
->
ts
=
ent
.
ts
;
cur
->
seq
=
ent
.
seq
;
cur
->
id
=
ent
.
id
;
if
(
trtl_msg_check_error
(
msg
)
)
{
free
(
msg
);
errno
=
EWRTD_INVALID_ANSWER_STATE
;
break
;
}
}
else
{
/* Input */
trtl_message_unpack
(
msg
,
&
hdr
,
cur
);
if
(
hdr
.
msg_id
!=
WRTD_IN_ACTION_LOG
)
{
free
(
msg
);
errno
=
EWRTD_INVALID_ANSWER_STATE
;
break
;
}
wrtd_timestamp_endianess_fix
(
&
cur
->
ts
);
trtl_message_unpack
(
msg
,
&
hdr
,
cur
);
if
(
hdr
.
msg_id
!=
WRTD_IN_ACTION_LOG
&&
hdr
.
msg_id
!=
WRTD_OUT_ACTION_LOG
)
{
free
(
msg
);
errno
=
EWRTD_INVALID_ANSWER_STATE
;
break
;
}
wrtd_timestamp_endianess_fix
(
&
cur
->
ts
);
remaining
--
;
n_read
++
;
...
...
@@ -265,7 +235,7 @@ static int wrtd_log_level_set(struct wrtd_node *dev, unsigned int channel,
}
tlv
.
index
=
OUT_STRUCT_CHAN_0
+
channel
;
tlv
.
size
=
sizeof
(
struct
wrtd_out_channel
)
;
tlv
.
size
=
WRTD_OUT_CHANNEL_PUBLIC_SIZE
;
tlv
.
structure
=
&
ochan
;
hdr
.
slot_io
=
(
WRTD_IN_FD_CONTROL
<<
4
)
|
(
WRTD_OUT_FD_CONTROL
&
0xF
);
...
...
applications/wrtd/lib/libwrtd-output.c
View file @
d474c0d0
...
...
@@ -11,10 +11,6 @@
#include <libmockturtle.h>
#include <libwrtd-internal.h>
#include "wrtd-serializers.h"
#define WRTD_OUT_CHANNEL_PUBLIC_SIZE (sizeof(struct wrtd_out_channel) \
- sizeof(struct wrtd_out_channel_private))
/* Basic header for synchronous messages */
static
const
struct
trtl_proto_header
hdr_base_sync
=
{
...
...
applications/wrtd/rt/fd/wrtd-rt-fd.c
View file @
d474c0d0
...
...
@@ -31,6 +31,7 @@
static
const
uint32_t
version
=
GIT_VERSION
;
static
uint32_t
promiscuous_mode
=
0
;
struct
rt_application
app
;
#define WR_LINK_OFFLINE 1
...
...
@@ -192,11 +193,12 @@ static void ts_adjust_delay(struct wr_timestamp *ts, uint32_t cycles, uint32_t f
/**
* Puts a trigger message in the log buffer
*/
static
void
log_trigger
(
int
type
,
int
miss_reason
,
struct
wrtd_out_channel
*
out
,
static
void
log_trigger
(
int
type
,
int
miss_reason
,
struct
wrtd_out_channel
*
out
,
struct
wrtd_trigger_entry
*
ent
)
{
struct
trtl_proto_header
hdr
=
{
.
rt_app_id
=
0
,
.
rt_app_id
=
app
.
version
.
rt_id
,
.
msg_id
=
WRTD_OUT_ACTION_LOG
,
.
slot_io
=
WRTD_OUT_FD_LOGGING
,
.
seq
=
ent
->
seq
,
...
...
applications/wrtd/rt/tdc/wrtd-rt-tdc.c
View file @
d474c0d0
...
...
@@ -41,6 +41,7 @@ enum wrtd_in_wr_link {
static
struct
wrtd_in
wrtd_in_dev
;
static
struct
wrtd_in_channel
wrtd_in_channels
[
TDC_NUM_CHANNELS
];
struct
rt_application
app
;
uint32_t
seq
=
0
;
/**< global sequence number */
uint32_t
sent_packets
=
0
;
/**< Total number of packets sent */
...
...
@@ -80,7 +81,7 @@ static int wrtd_in_trigger_log(int type, int miss_reason,
struct
trtl_msg
out_buf
;
struct
wrtd_log_entry
*
log
;
struct
trtl_proto_header
hdr
=
{
.
rt_app_id
=
0
,
.
rt_app_id
=
app
.
version
.
rt_id
,
.
msg_id
=
WRTD_IN_ACTION_LOG
,
.
slot_io
=
WRTD_OUT_TDC_LOGGING
,
.
seq
=
seq
,
...
...
include/mockturtle.h
View file @
d474c0d0
...
...
@@ -30,14 +30,6 @@ enum trtl_smem_modifier {
TRTL_SMEM_XOR
,
/**< on write, atomic XOR with memory content */
};
/**
* @enum trtl_msg_direction
* Message direction on the Host Message Queue
*/
enum
trtl_msg_direction
{
WRNC_MSG_DIR_SEND
=
0
,
/**< from Host to RealTime Application */
WRNC_MSG_DIR_RECEIVE
=
1
,
/**< from RealTime application to Host */
};
/**
* Messages descriptor
...
...
@@ -46,11 +38,6 @@ struct trtl_msg {
uint32_t
datalen
;
/**< payload length*/
uint32_t
data
[
TRTL_MAX_PAYLOAD_SIZE
];
/**< payload, free content
(no official protocol) */
uint32_t
max_size
;
/**< maximum message size for chosen slot */
uint32_t
offset
;
/**< serialization/deserialization offset */
enum
trtl_msg_direction
direction
;
/**< serialization direction
(used by trtl_msg_x functions) */
int
error
;
/** serialization error status */
};
/**
...
...
lib/libmockturtle-rt-msg.c
View file @
d474c0d0
...
...
@@ -25,7 +25,6 @@ void trtl_message_header_set(struct trtl_msg *msg,
msg
->
data
[
2
]
=
htobe32
(
hdr32
[
2
]);
msg
->
data
[
3
]
=
hdr32
[
3
];
msg
->
datalen
=
sizeof
(
struct
trtl_proto_header
)
/
4
;
msg
->
max_size
=
msg
->
datalen
;
}
/**
...
...
@@ -68,7 +67,6 @@ void trtl_message_pack(struct trtl_msg *msg,
memcpy
(
data
+
sizeof
(
struct
trtl_proto_header
),
payload
,
hdr
->
len
*
4
);
msg
->
datalen
+=
hdr
->
len
;
msg
->
max_size
=
msg
->
datalen
;
}
...
...
lib/libmockturtle.c
View file @
d474c0d0
...
...
@@ -749,10 +749,6 @@ int trtl_hmq_send_and_receive_sync(struct trtl_hmq *hmq,
if
(
err
)
return
-
1
;
msg
->
error
=
0
;
msg
->
offset
=
0
;
msg
->
direction
=
WRNC_MSG_DIR_RECEIVE
;
if
(
smsg
.
timeout_ms
==
0
)
{
errno
=
ETIME
;
return
-
1
;
...
...
@@ -1083,7 +1079,7 @@ int trtl_cpu_is_enable(struct trtl_dev *trtl, unsigned int index,
int
trtl_hmq_receive_n
(
struct
trtl_hmq
*
hmq
,
struct
trtl_msg
*
msg
,
unsigned
int
n
)
{
int
ret
,
size
,
i
;
int
ret
,
size
;
if
(
!
hmq
||
hmq
->
fd
<
0
)
{
errno
=
ETRTL_HMQ_CLOSE
;
...
...
@@ -1098,12 +1094,6 @@ int trtl_hmq_receive_n(struct trtl_hmq *hmq,
return
-
1
;
}
for
(
i
=
0
;
i
<
n
;
++
i
)
{
msg
[
i
].
error
=
0
;
msg
[
i
].
offset
=
0
;
msg
[
i
].
direction
=
WRNC_MSG_DIR_RECEIVE
;
}
return
(
ret
/
size
);
}
...
...
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