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
27e6198c
Commit
27e6198c
authored
Jul 25, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:fw:ep style improvement
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
c6aa871a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
70 deletions
+72
-70
mockturtle-rt-common.c
software/firmware/lib/mockturtle-rt-common.c
+59
-61
mockturtle-rt.h
software/firmware/lib/mockturtle-rt.h
+13
-9
No files found.
software/firmware/lib/mockturtle-rt-common.c
View file @
27e6198c
...
...
@@ -72,84 +72,82 @@ void pr_message(struct trtl_fw_msg *msg)
pp_printf
(
"%s: data[%d] = 0x%"
PRIx32
"
\n\r
"
,
__func__
,
i
,
d
[
i
]);
}
static
inline
void
rmq_ep_out_writel
(
int
slot
,
uint32_t
data
,
uint32_t
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
)
);
mq_writel
(
TRTL_RMQ
,
data
,
addr
+
TRTL_MQ_SLOT_ENDPOINT_CONFIG_START
+
TRTL_MQ_SLOT_OUT
(
slot
)
);
}
static
inline
void
rmq_ep_in_writel
(
int
slot
,
uint32_t
data
,
uint32_t
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
)
);
mq_writel
(
TRTL_RMQ
,
data
,
addr
+
TRTL_MQ_SLOT_ENDPOINT_CONFIG_START
+
TRTL_MQ_SLOT_IN
(
slot
)
);
}
static
void
rmq_ep_bind_in
(
int
slot
,
struct
trtl_ep_address
*
addr
)
static
void
rmq_ep_bind_in
(
int
slot
,
struct
trtl_ep_eth_address
*
addr
)
{
uint32_t
cfg
=
0
;
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
;
case
TRTL_EP_FRAME_RAW
:
cfg
|=
TRTL_EP_FILTER_RAW
;
break
;
}
cfg
|=
addr
->
filter
;
uint32_t
tmp
;
rmq_ep_in_writel
(
slot
,
cfg
,
TRTL_EP_IN_CONFIG
);
tmp
=
(
(
uint32_t
)
addr
->
dst_mac
[
0
]
<<
8
)
|
addr
->
dst_mac
[
1
];
rmq_ep_in_writel
(
slot
,
tmp
,
TRTL_EP_IN_DST_MAC_HI
);
tmp
=
(
(
uint32_t
)
addr
->
dst_mac
[
2
]
<<
24
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
3
]
<<
16
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
4
]
<<
8
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
5
]
<<
0
);
rmq_ep_in_writel
(
slot
,
tmp
,
TRTL_EP_IN_DST_MAC_LO
);
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
);
uint32_t
cfg
=
0
;
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
;
case
TRTL_EP_FRAME_RAW
:
cfg
|=
TRTL_EP_FILTER_RAW
;
break
;
}
cfg
|=
addr
->
filter
;
uint32_t
tmp
;
rmq_ep_in_writel
(
slot
,
cfg
,
TRTL_EP_IN_CONFIG
);
tmp
=
(
(
uint32_t
)
addr
->
dst_mac
[
0
]
<<
8
)
|
addr
->
dst_mac
[
1
];
rmq_ep_in_writel
(
slot
,
tmp
,
TRTL_EP_IN_DST_MAC_HI
);
tmp
=
(
(
uint32_t
)
addr
->
dst_mac
[
2
]
<<
24
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
3
]
<<
16
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
4
]
<<
8
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
5
]
<<
0
);
rmq_ep_in_writel
(
slot
,
tmp
,
TRTL_EP_IN_DST_MAC_LO
);
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
);
}
static
void
rmq_ep_bind_out
(
int
slot
,
struct
trtl_ep_address
*
addr
)
{
uint32_t
tmp
;
uint32_t
tmp
;
rmq_ep_out_writel
(
slot
,
addr
->
type
==
TRTL_EP_FRAME_UDP
?
1
:
0
,
TRTL_EP_OUT_CONFIG
);
rmq_ep_out_writel
(
slot
,
addr
->
type
==
TRTL_EP_FRAME_UDP
?
1
:
0
,
TRTL_EP_OUT_CONFIG
);
tmp
=
(
(
uint32_t
)
addr
->
dst_mac
[
0
]
<<
8
)
|
addr
->
dst_mac
[
1
];
rmq_ep_out_writel
(
slot
,
tmp
,
TRTL_EP_OUT_MAC_HI
);
tmp
=
(
(
uint32_t
)
addr
->
dst_mac
[
2
]
<<
24
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
3
]
<<
16
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
4
]
<<
8
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
5
]
<<
0
);
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
);
tmp
=
(
(
uint32_t
)
addr
->
dst_mac
[
0
]
<<
8
)
|
addr
->
dst_mac
[
1
];
rmq_ep_out_writel
(
slot
,
tmp
,
TRTL_EP_OUT_MAC_HI
);
tmp
=
(
(
uint32_t
)
addr
->
dst_mac
[
2
]
<<
24
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
3
]
<<
16
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
4
]
<<
8
)
|
(
(
uint32_t
)
addr
->
dst_mac
[
5
]
<<
0
);
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
);
}
void
mq_bind
(
enum
trtl_mq_type
type
,
int
slot
,
int
is_out
,
struct
trtl_ep_address
*
addr
)
{
if
(
type
!=
TRTL_RMQ
)
{
pr_error
(
"mq_bind() not supported on HMQ slots
\n\r
"
);
return
;
}
if
(
is_out
)
rmq_ep_bind_out
(
slot
,
addr
);
else
rmq_ep_bind_in
(
slot
,
addr
);
if
(
type
!=
TRTL_RMQ
)
{
pr_error
(
"mq_bind() not supported on HMQ slots
\n\r
"
);
return
;
}
if
(
is_out
)
rmq_ep_bind_out
(
slot
,
addr
);
else
rmq_ep_bind_in
(
slot
,
addr
);
}
software/firmware/lib/mockturtle-rt.h
View file @
27e6198c
...
...
@@ -11,6 +11,7 @@
#ifndef __MOCKTURTLE_RT_H
#define __MOCKTURTLE_RT_H
#include <errno.h>
#include <stdint.h>
#include <stdarg.h>
#include <generated/autoconf.h>
...
...
@@ -450,17 +451,18 @@ static inline void *mq_map_in_header(enum trtl_mq_type type, int slot)
* @copydoc TRTL_MQ_CMD_CLAIM
* @param[in] type MQ type to use
* @param[in] slot slot number
* @return
1 on success, 0
if queue busy/full
* @return
0 on success, -EBUSY
if queue busy/full
*/
static
inline
int
mq_claim
(
enum
trtl_mq_type
type
,
int
slot
)
{
uint32_t
status
=
mq_readl
(
type
,
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_STATUS
);
if
(
status
&
TRTL_MQ_SLOT_STATUS_FULL
)
return
0
;
uint32_t
status
=
mq_readl
(
type
,
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_STATUS
);
mq_writel
(
type
,
TRTL_MQ_CMD_CLAIM
,
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_COMMAND
);
return
1
;
if
(
status
&
TRTL_MQ_SLOT_STATUS_FULL
)
return
-
EBUSY
;
mq_writel
(
type
,
TRTL_MQ_CMD_CLAIM
,
TRTL_MQ_SLOT_OUT
(
slot
)
+
TRTL_MQ_SLOT_COMMAND
);
return
0
;
}
/**
...
...
@@ -487,13 +489,15 @@ 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.
* Binds an RMQ slot to a particular IP configuration. Used when the Ethernet/UDP
* endpoint is enabled.
* @param[in] type MQ type to use
* @param[in] slot slot number
* @param[in] is_out non-zero if we're configuring an output slot
* @param[in] addr bind address
*/
void
mq_bind
(
enum
trtl_mq_type
type
,
int
slot
,
int
is_out
,
struct
trtl_ep_address
*
addr
);
void
mq_bind
(
enum
trtl_mq_type
type
,
int
slot
,
int
is_out
,
struct
trtl_ep_address
*
addr
);
/**
...
...
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