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
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
hdl-core-lib
mock-turtle
Commits
9b8b187f
Commit
9b8b187f
authored
Jul 25, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:fw:ep: improve code
Readability, and API Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
748944e5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
44 deletions
+75
-44
mockturtle-rt-common.c
software/firmware/lib/mockturtle-rt-common.c
+53
-26
mockturtle-rt.h
software/firmware/lib/mockturtle-rt.h
+13
-6
mockturtle_endpoint.h
software/include/hw/mockturtle_endpoint.h
+7
-10
rmq-udp-send.c
tests/firmware/rmq-udp-send/rmq-udp-send.c
+2
-2
No files found.
software/firmware/lib/mockturtle-rt-common.c
View file @
9b8b187f
...
...
@@ -89,23 +89,24 @@ static inline uint32_t ep_eth_build_mac_lo(struct trtl_ep_eth_address* addr)
static
inline
void
rmq_ep_out_writel
(
int
slot
,
uint32_t
data
,
uint32_t
addr
)
{
mq_writel
(
TRTL_RMQ
,
data
,
addr
+
TRTL_MQ_SLOT_ENDPOINT_CONFIG_START
+
TRTL_MQ_SLOT_OUT
(
slot
)
);
addr
+=
TRTL_MQ_SLOT_ENDPOINT_CONFIG_START
+
TRTL_MQ_SLOT_OUT
(
slot
);
mq_writel
(
TRTL_RMQ
,
data
,
addr
);
}
static
inline
void
rmq_ep_in_writel
(
int
slot
,
uint32_t
data
,
uint32_t
addr
)
{
mq_writel
(
TRTL_RMQ
,
data
,
addr
+
TRTL_MQ_SLOT_ENDPOINT_CONFIG_START
+
TRTL_MQ_SLOT_IN
(
slot
)
);
addr
+=
TRTL_MQ_SLOT_ENDPOINT_CONFIG_START
+
TRTL_MQ_SLOT_IN
(
slot
);
mq_writel
(
TRTL_RMQ
,
data
,
addr
);
}
static
void
rmq_ep_bind_in
(
int
slot
,
struct
trtl_ep_eth_address
*
addr
)
static
int
rmq_ep_eth_bind_in
(
unsigned
int
slot
,
void
*
arg
)
{
struct
trtl_ep_eth_address
*
addr
=
arg
;
uint32_t
cfg
=
0
,
tmp
;
switch
(
addr
->
type
)
{
case
TRTL_EP_FRAME_UDP
:
cfg
|=
TRTL_EP_FILTER_UDP
;
break
;
case
TRTL_EP_FRAME_TLV
:
cfg
|=
TRTL_EP_FILTER_UDP
;
break
;
...
...
@@ -123,37 +124,63 @@ static void rmq_ep_bind_in(int slot, struct trtl_ep_eth_address* addr)
rmq_ep_in_writel
(
slot
,
addr
->
ethertype
,
TRTL_EP_IN_ETHERTYPE
);
rmq_ep_in_writel
(
slot
,
addr
->
dst_ip
,
TRTL_EP_IN_DST_IP
);
rmq_ep_in_writel
(
slot
,
addr
->
dst_port
,
TRTL_EP_IN_DST_PORT
);
return
0
;
}
static
void
rmq_ep_bind_out
(
int
slot
,
struct
trtl_ep_eth_address
*
addr
)
static
int
rmq_ep_eth_bind_out
(
unsigned
int
slot
,
void
*
arg
)
{
struct
trtl_ep_eth_address
*
addr
=
arg
;
uint32_t
tmp
;
rmq_ep_out_writel
(
slot
,
addr
->
type
==
TRTL_EP_FRAME_UDP
?
1
:
0
,
TRTL_EP_OUT_CONFIG
);
tmp
=
addr
->
type
==
TRTL_EP_FRAME_UDP
?
1
:
0
;
rmq_ep_out_writel
(
slot
,
tmp
,
TRTL_EP_OUT_CONFIG
);
tmp
=
ep_eth_build_mac_hi
(
addr
);
rmq_ep_out_writel
(
slot
,
tmp
,
TRTL_EP_OUT_MAC_HI
);
rmq_ep_out_writel
(
slot
,
tmp
,
TRTL_EP_OUT_MAC_HI
);
tmp
=
ep_eth_build_mac_lo
(
addr
);
rmq_ep_out_writel
(
slot
,
tmp
,
TRTL_EP_OUT_MAC_LO
);
rmq_ep_out_writel
(
slot
,
addr
->
ethertype
,
TRTL_EP_OUT_ETHERTYPE
);
rmq_ep_out_writel
(
slot
,
addr
->
src_ip
,
TRTL_EP_OUT_SRC_IP
);
rmq_ep_out_writel
(
slot
,
addr
->
dst_ip
,
TRTL_EP_OUT_DST_IP
);
rmq_ep_out_writel
(
slot
,
addr
->
src_port
,
TRTL_EP_OUT_SRC_PORT
);
rmq_ep_out_writel
(
slot
,
addr
->
dst_port
,
TRTL_EP_OUT_DST_PORT
);
rmq_ep_out_writel
(
slot
,
tmp
,
TRTL_EP_OUT_MAC_LO
);
rmq_ep_out_writel
(
slot
,
addr
->
ethertype
,
TRTL_EP_OUT_ETHERTYPE
);
rmq_ep_out_writel
(
slot
,
addr
->
src_ip
,
TRTL_EP_OUT_SRC_IP
);
rmq_ep_out_writel
(
slot
,
addr
->
dst_ip
,
TRTL_EP_OUT_DST_IP
);
rmq_ep_out_writel
(
slot
,
addr
->
src_port
,
TRTL_EP_OUT_SRC_PORT
);
rmq_ep_out_writel
(
slot
,
addr
->
dst_port
,
TRTL_EP_OUT_DST_PORT
);
return
0
;
}
void
mq_bind
(
enum
trtl_mq_type
type
,
int
slot
,
int
is_out
,
struct
trtl_ep_eth_address
*
addr
)
typedef
int
(
trtl_fw_rmq_bind_t
)
(
unsigned
int
slot
,
void
*
arg
);
/*
* It's true that this is slower to execute, but on the other hand
* we do not expect to use this on cricital paths. This should be
* used during the initialization phase. The advantage is that, when
* we will add more end-point, here we will have a nice summary and
* we will not need any switch case to execute our functions.
*/
#define __TRTL_EP_IN 0
#define __TRTL_EP_OUT 1
static
trtl_fw_rmq_bind_t
*
rmq_ep_bind
[
__TRTL_EP_MAX
][
2
]
=
{
[
TRTL_EP_ETH
]
=
{
[
__TRTL_EP_IN
]
=
rmq_ep_eth_bind_in
,
[
__TRTL_EP_OUT
]
=
rmq_ep_eth_bind_out
,
},
};
int
rmq_bind_in
(
unsigned
int
slot
,
enum
trtl_ep_type
type
,
void
*
addr
)
{
if
(
type
!=
TRTL_RMQ
)
{
pr_error
(
"mq_bind() not supported on HMQ slots
\n\r
"
);
return
;
}
if
(
type
>=
__TRTL_EP_MAX
)
return
-
EINVAL
;
return
rmq_ep_bind
[
type
][
__TRTL_EP_IN
](
slot
,
addr
);
}
int
rmq_bind_out
(
unsigned
int
slot
,
enum
trtl_ep_type
type
,
void
*
addr
)
{
if
(
type
>=
__TRTL_EP_MAX
)
return
-
EINVAL
;
if
(
is_out
)
rmq_ep_bind_out
(
slot
,
addr
);
else
rmq_ep_bind_in
(
slot
,
addr
);
return
rmq_ep_bind
[
type
][
__TRTL_EP_OUT
](
slot
,
addr
);
}
software/firmware/lib/mockturtle-rt.h
View file @
9b8b187f
...
...
@@ -489,15 +489,22 @@ static inline void mq_send(enum trtl_mq_type type, int slot)
}
/**
* Binds an RMQ slot to a particular IP configuration. Used when the Ethernet/UDP
* endpoint is enabled.
* @param[in] type MQ type to use
* Binds an RMQ slot (input) to a particular IP configuration. Used when
* the Ethernet/UDP endpoint is enabled.
* @param[in] slot slot number
* @param[in] type EP type to use
* @param[in] addr bind address
*/
extern
int
rmq_bind_in
(
unsigned
int
slot
,
enum
trtl_ep_type
type
,
void
*
addr
);
/**
* Binds an RMQ slot (output) to a particular IP configuration. Used when
* the Ethernet/UDP endpoint is enabled.
* @param[in] slot slot number
* @param[in]
is_out non-zero if we're configuring an output slot
* @param[in]
type EP type to use
* @param[in] addr bind address
*/
void
mq_bind
(
enum
trtl_mq_type
type
,
int
slot
,
int
is_out
,
struct
trtl_ep_eth_address
*
addr
);
extern
int
rmq_bind_out
(
unsigned
int
slot
,
enum
trtl_ep_type
type
,
void
*
addr
);
/**
...
...
software/include/hw/mockturtle_endpoint.h
View file @
9b8b187f
/*
* This work is part of the White Rabbit Node Core project.
*
* Copyright (C) 2013-2014 CERN (www.cern.ch)
* Copyright (C) 2018 CERN (www.cern.ch)
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
*
Released according to the GNU GPL, version 2 or any later version.
*
SPDX-License-Identifier: LGPL-3.0-or-later
*/
/*.
* White Rabbit Node Core
*
* rt-mqueue.h: Message Queues definitions and functions
*/
#ifndef __TRTL_ENDPOINT_H
#define __TRTL_ENDPOINT_H
enum
trtl_ep_type
{
TRTL_EP_ETH
=
0
,
__TRTL_EP_MAX
,
};
#define TRTL_EP_OUT_CONFIG 0
#define TRTL_EP_OUT_MAC_HI 4
#define TRTL_EP_OUT_MAC_LO 8
...
...
tests/firmware/rmq-udp-send/rmq-udp-send.c
View file @
9b8b187f
...
...
@@ -78,9 +78,9 @@ int main()
bind_addr
.
filter
|=
TRTL_EP_FILTER_ENABLE
;
// configure outgoing channel
mq_bind
(
TRTL_RMQ
,
rmq
,
1
,
&
bind_addr
);
rmq_bind_out
(
rmq
,
TRTL_EP_ETH
,
&
bind_addr
);
// configure incoming channel
mq_bind
(
TRTL_RMQ
,
rmq
,
0
,
&
bind_addr
);
rmq_bind_in
(
rmq
,
TRTL_EP_ETH
,
&
bind_addr
);
send_pkt
(
0
,
0x123
);
v
=
handle_rx
(
0
);
...
...
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